@synnaxlabs/client 0.17.6 → 0.18.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/client.cjs CHANGED
@@ -1,24 +1,24 @@
1
- "use strict";var rp=Object.defineProperty;var np=(r,e,t)=>e in r?rp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var h=(r,e,t)=>(np(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("zod");var sp=Object.defineProperty,ap=(r,e,t)=>e in r?sp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,N=(r,e,t)=>(ap(r,typeof e!="symbol"?e+"":e,t),t);let ip="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",op=(r=21)=>{let e="",t=r;for(;t--;)e+=ip[Math.random()*64|0];return e};const cp=r=>r!=null&&typeof r=="object"&&"toString"in r,up=(r,e=!1)=>{const t=cp(r)?"stringer":typeof r;let n;switch(t){case"string":n=(s,a)=>s.localeCompare(a);break;case"stringer":n=(s,a)=>s.toString().localeCompare(a.toString());break;case"number":n=(s,a)=>s-a;break;case"bigint":n=(s,a)=>s-a>BigInt(0)?1:-1;break;case"boolean":n=(s,a)=>Number(s)-Number(a);break;default:return console.warn("sortFunc: unknown type"),()=>-1}return e?lp(n):n},lp=r=>(e,t)=>r(t,e);var _e;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(_e||(_e={}));var yo;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(yo||(yo={}));const U=_e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Rr=r=>{switch(typeof r){case"undefined":return U.undefined;case"string":return U.string;case"number":return isNaN(r)?U.nan:U.number;case"boolean":return U.boolean;case"function":return U.function;case"bigint":return U.bigint;case"symbol":return U.symbol;case"object":return Array.isArray(r)?U.array:r===null?U.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?U.promise:typeof Map<"u"&&r instanceof Map?U.map:typeof Set<"u"&&r instanceof Set?U.set:typeof Date<"u"&&r instanceof Date?U.date:U.object;default:return U.unknown}},Z=_e.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),dp=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let Rt=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,_e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Rt.create=r=>new Rt(r);const is=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===U.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,_e.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${_e.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_e.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${_e.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:_e.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Z.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,_e.assertNever(r)}return{message:t}};let Yu=is;function hp(r){Yu=r}function Da(){return Yu}const La=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},pp=[];function B(r,e){const t=La({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Da(),is].filter(n=>!!n)});r.common.issues.push(t)}class ct{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return ie;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return ct.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return ie;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const ie=Object.freeze({status:"aborted"}),Ju=r=>({status:"dirty",value:r}),vt=r=>({status:"valid",value:r}),go=r=>r.status==="aborted",vo=r=>r.status==="dirty",os=r=>r.status==="valid",Ba=r=>typeof Promise<"u"&&r instanceof Promise;var F;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(F||(F={}));let Ht=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const Wc=(r,e)=>{if(os(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Rt(r.common.issues);return this._error=t,this._error}}};function ue(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:s}}class he{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Rr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Rr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ct,ctx:{common:e.parent.common,data:e.data,parsedType:Rr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Ba(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Rr(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Wc(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Rr(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Ba(s)?s:Promise.resolve(s));return Wc(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:Z.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new Lt({schema:this,typeName:H.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Tr.create(this,this._def)}nullable(){return hn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return ln.create(this,this._def)}promise(){return Mn.create(this,this._def)}or(e){return fs.create([this,e],this._def)}and(e){return ms.create(this,e,this._def)}transform(e){return new Lt({...ue(this._def),schema:this,typeName:H.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new bs({...ue(this._def),innerType:this,defaultValue:t,typeName:H.ZodDefault})}brand(){return new rl({typeName:H.ZodBranded,type:this,...ue(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Fa({...ue(this._def),innerType:this,catchValue:t,typeName:H.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Wo.create(this,e)}readonly(){return Ya.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const fp=/^c[^\s-]{8,}$/i,mp=/^[a-z][a-z0-9]*$/,yp=/^[0-9A-HJKMNP-TV-Z]{26}$/,gp=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,vp=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,wp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Fi;const bp=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,_p=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,kp=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Op(r,e){return!!((e==="v4"||!e)&&bp.test(r)||(e==="v6"||!e)&&_p.test(r))}let zn=class Qn extends he{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==U.string){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:U.string,received:s.parsedType}),ie}const t=new ct;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:Z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:Z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?B(n,{code:Z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&B(n,{code:Z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")vp.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"email",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Fi||(Fi=new RegExp(wp,"u")),Fi.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"emoji",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")gp.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"uuid",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")fp.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"cuid",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")mp.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"cuid2",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")yp.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"ulid",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),B(n,{validation:"url",code:Z.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"regex",code:Z.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),B(n,{code:Z.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),B(n,{code:Z.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),B(n,{code:Z.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?kp(s).test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:Z.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?Op(e.data,s.version)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"ip",code:Z.invalid_string,message:s.message}),t.dirty()):_e.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:Z.invalid_string,...F.errToObj(n)})}_addCheck(e){return new Qn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...F.errToObj(e)})}url(e){return this._addCheck({kind:"url",...F.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...F.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...F.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...F.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...F.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...F.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...F.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...F.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...F.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...F.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...F.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...F.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...F.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...F.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...F.errToObj(t)})}nonempty(e){return this.min(1,F.errToObj(e))}trim(){return new Qn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Qn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Qn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};zn.create=r=>{var e;return new zn({checks:[],typeName:H.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ue(r)})};function Tp(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}let cs=class wo extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==U.number){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:U.number,received:s.parsedType}),ie}let t;const n=new ct;for(const s of this._def.checks)s.kind==="int"?_e.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:Z.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?Tp(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:Z.not_finite,message:s.message}),n.dirty()):_e.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,F.toString(t))}gt(e,t){return this.setLimit("min",e,!1,F.toString(t))}lte(e,t){return this.setLimit("max",e,!0,F.toString(t))}lt(e,t){return this.setLimit("max",e,!1,F.toString(t))}setLimit(e,t,n,s){return new wo({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:F.toString(s)}]})}_addCheck(e){return new wo({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:F.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:F.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:F.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:F.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:F.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:F.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:F.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:F.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:F.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&_e.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};cs.create=r=>new cs({checks:[],typeName:H.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ue(r)});let us=class bo extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==U.bigint){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:U.bigint,received:s.parsedType}),ie}let t;const n=new ct;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):_e.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,F.toString(t))}gt(e,t){return this.setLimit("min",e,!1,F.toString(t))}lte(e,t){return this.setLimit("max",e,!0,F.toString(t))}lt(e,t){return this.setLimit("max",e,!1,F.toString(t))}setLimit(e,t,n,s){return new bo({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:F.toString(s)}]})}_addCheck(e){return new bo({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:F.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:F.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:F.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:F.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:F.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};us.create=r=>{var e;return new us({checks:[],typeName:H.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ue(r)})};let ls=class extends he{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==U.boolean){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.boolean,received:t.parsedType}),ie}return vt(e.data)}};ls.create=r=>new ls({typeName:H.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ue(r)});let ds=class Gu extends he{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==U.date){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:U.date,received:s.parsedType}),ie}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_date}),ie}const t=new ct;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:Z.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:Z.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):_e.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Gu({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:F.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:F.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};ds.create=r=>new ds({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:H.ZodDate,...ue(r)});let Va=class extends he{_parse(e){if(this._getType(e)!==U.symbol){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.symbol,received:t.parsedType}),ie}return vt(e.data)}};Va.create=r=>new Va({typeName:H.ZodSymbol,...ue(r)});let hs=class extends he{_parse(e){if(this._getType(e)!==U.undefined){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.undefined,received:t.parsedType}),ie}return vt(e.data)}};hs.create=r=>new hs({typeName:H.ZodUndefined,...ue(r)});let ps=class extends he{_parse(e){if(this._getType(e)!==U.null){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.null,received:t.parsedType}),ie}return vt(e.data)}};ps.create=r=>new ps({typeName:H.ZodNull,...ue(r)});let Pn=class extends he{constructor(){super(...arguments),this._any=!0}_parse(e){return vt(e.data)}};Pn.create=r=>new Pn({typeName:H.ZodAny,...ue(r)});let an=class extends he{constructor(){super(...arguments),this._unknown=!0}_parse(e){return vt(e.data)}};an.create=r=>new an({typeName:H.ZodUnknown,...ue(r)});class Ar extends he{_parse(e){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.never,received:t.parsedType}),ie}}Ar.create=r=>new Ar({typeName:H.ZodNever,...ue(r)});let qa=class extends he{_parse(e){if(this._getType(e)!==U.undefined){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.void,received:t.parsedType}),ie}return vt(e.data)}};qa.create=r=>new qa({typeName:H.ZodVoid,...ue(r)});let ln=class ya extends he{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==U.array)return B(t,{code:Z.invalid_type,expected:U.array,received:t.parsedType}),ie;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(B(t,{code:i?Z.too_big:Z.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(B(t,{code:Z.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(B(t,{code:Z.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new Ht(t,i,t.path,o)))).then(i=>ct.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Ht(t,i,t.path,o)));return ct.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new ya({...this._def,minLength:{value:e,message:F.toString(t)}})}max(e,t){return new ya({...this._def,maxLength:{value:e,message:F.toString(t)}})}length(e,t){return new ya({...this._def,exactLength:{value:e,message:F.toString(t)}})}nonempty(e){return this.min(1,e)}};ln.create=(r,e)=>new ln({type:r,minLength:null,maxLength:null,exactLength:null,typeName:H.ZodArray,...ue(e)});function Sn(r){if(r instanceof Et){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Tr.create(Sn(n))}return new Et({...r._def,shape:()=>e})}else return r instanceof ln?new ln({...r._def,type:Sn(r.element)}):r instanceof Tr?Tr.create(Sn(r.unwrap())):r instanceof hn?hn.create(Sn(r.unwrap())):r instanceof Br?Br.create(r.items.map(e=>Sn(e))):r}let Et=class Zt extends he{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=_e.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==U.object){const c=this._getOrReturnCtx(e);return B(c,{code:Z.invalid_type,expected:U.object,received:c.parsedType}),ie}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Ar&&this._def.unknownKeys==="strip"))for(const c in n.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=s[c],m=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Ht(n,m,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Ar){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(c==="strict")i.length>0&&(B(n,{code:Z.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const m=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Ht(n,m,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const m=await l.key;c.push({key:m,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>ct.mergeObjectSync(t,c)):ct.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return F.errToObj,new Zt({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=F.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Zt({...this._def,unknownKeys:"strip"})}passthrough(){return new Zt({...this._def,unknownKeys:"passthrough"})}extend(e){return new Zt({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Zt({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:H.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Zt({...this._def,catchall:e})}pick(e){const t={};return _e.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Zt({...this._def,shape:()=>t})}omit(e){const t={};return _e.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Zt({...this._def,shape:()=>t})}deepPartial(){return Sn(this)}partial(e){const t={};return _e.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Zt({...this._def,shape:()=>t})}required(e){const t={};return _e.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Tr;)s=s._def.innerType;t[n]=s}}),new Zt({...this._def,shape:()=>t})}keyof(){return tl(_e.objectKeys(this.shape))}};Et.create=(r,e)=>new Et({shape:()=>r,unknownKeys:"strip",catchall:Ar.create(),typeName:H.ZodObject,...ue(e)});Et.strictCreate=(r,e)=>new Et({shape:()=>r,unknownKeys:"strict",catchall:Ar.create(),typeName:H.ZodObject,...ue(e)});Et.lazycreate=(r,e)=>new Et({shape:r,unknownKeys:"strip",catchall:Ar.create(),typeName:H.ZodObject,...ue(e)});let fs=class extends he{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Rt(o.ctx.common.issues));return B(t,{code:Z.invalid_union,unionErrors:i}),ie}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of n){const l={...t,common:{...t.common,issues:[]},parent:null},m=c._parseSync({data:t.data,path:t.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new Rt(c));return B(t,{code:Z.invalid_union,unionErrors:o}),ie}}get options(){return this._def.options}};fs.create=(r,e)=>new fs({options:r,typeName:H.ZodUnion,...ue(e)});const ga=r=>r instanceof gs?ga(r.schema):r instanceof Lt?ga(r.innerType()):r instanceof vs?[r.value]:r instanceof Vr?r.options:r instanceof ws?Object.keys(r.enum):r instanceof bs?ga(r._def.innerType):r instanceof hs?[void 0]:r instanceof ps?[null]:null;let Hu=class Xu extends he{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==U.object)return B(t,{code:Z.invalid_type,expected:U.object,received:t.parsedType}),ie;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(B(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ie)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=ga(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Xu({typeName:H.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ue(n)})}};function _o(r,e){const t=Rr(r),n=Rr(e);if(r===e)return{valid:!0,data:r};if(t===U.object&&n===U.object){const s=_e.objectKeys(e),a=_e.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=_o(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===U.array&&n===U.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=_o(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===U.date&&n===U.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}let ms=class extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(go(a)||go(i))return ie;const o=_o(a.value,i.value);return o.valid?((vo(a)||vo(i))&&t.dirty(),{status:t.value,value:o.data}):(B(n,{code:Z.invalid_intersection_types}),ie)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};ms.create=(r,e,t)=>new ms({left:r,right:e,typeName:H.ZodIntersection,...ue(t)});let Br=class Qu extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==U.array)return B(n,{code:Z.invalid_type,expected:U.array,received:n.parsedType}),ie;if(n.data.length<this._def.items.length)return B(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ie;!this._def.rest&&n.data.length>this._def.items.length&&(B(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new Ht(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>ct.mergeArray(t,a)):ct.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Qu({...this._def,rest:e})}};Br.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Br({items:r,typeName:H.ZodTuple,rest:null,...ue(e)})};class ys extends he{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==U.object)return B(n,{code:Z.invalid_type,expected:U.object,received:n.parsedType}),ie;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Ht(n,o,n.path,o)),value:i._parse(new Ht(n,n.data[o],n.path,o))});return n.common.async?ct.mergeObjectAsync(t,s):ct.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof he?new ys({keyType:e,valueType:t,typeName:H.ZodRecord,...ue(n)}):new ys({keyType:zn.create(),valueType:e,typeName:H.ZodRecord,...ue(t)})}}let Ka=class extends he{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==U.map)return B(n,{code:Z.invalid_type,expected:U.map,received:n.parsedType}),ie;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new Ht(n,o,n.path,[l,"key"])),value:a._parse(new Ht(n,c,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,m=await c.value;if(l.status==="aborted"||m.status==="aborted")return ie;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,m=c.value;if(l.status==="aborted"||m.status==="aborted")return ie;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}}}};Ka.create=(r,e,t)=>new Ka({valueType:e,keyType:r,typeName:H.ZodMap,...ue(t)});class dn extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==U.set)return B(n,{code:Z.invalid_type,expected:U.set,received:n.parsedType}),ie;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(B(n,{code:Z.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(B(n,{code:Z.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const m of c){if(m.status==="aborted")return ie;m.status==="dirty"&&t.dirty(),l.add(m.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Ht(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new dn({...this._def,minSize:{value:e,message:F.toString(t)}})}max(e,t){return new dn({...this._def,maxSize:{value:e,message:F.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}dn.create=(r,e)=>new dn({valueType:r,minSize:null,maxSize:null,typeName:H.ZodSet,...ue(e)});let el=class va extends he{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==U.function)return B(t,{code:Z.invalid_type,expected:U.function,received:t.parsedType}),ie;function n(o,c){return La({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Da(),is].filter(l=>!!l),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return La({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Da(),is].filter(l=>!!l),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Mn){const o=this;return vt(async function(...c){const l=new Rt([]),m=await o._def.args.parseAsync(c,a).catch(J=>{throw l.addIssue(n(c,J)),l}),T=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(T,a).catch(J=>{throw l.addIssue(s(T,J)),l})})}else{const o=this;return vt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Rt([n(c,l.error)]);const m=Reflect.apply(i,this,l.data),T=o._def.returns.safeParse(m,a);if(!T.success)throw new Rt([s(m,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new va({...this._def,args:Br.create(e).rest(an.create())})}returns(e){return new va({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new va({args:e||Br.create([]).rest(an.create()),returns:t||an.create(),typeName:H.ZodFunction,...ue(n)})}},gs=class extends he{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};gs.create=(r,e)=>new gs({getter:r,typeName:H.ZodLazy,...ue(e)});let vs=class extends he{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),ie}return{status:"valid",value:e.data}}get value(){return this._def.value}};vs.create=(r,e)=>new vs({value:r,typeName:H.ZodLiteral,...ue(e)});function tl(r,e){return new Vr({values:r,typeName:H.ZodEnum,...ue(e)})}class Vr extends he{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{expected:_e.joinValues(n),received:t.parsedType,code:Z.invalid_type}),ie}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{received:t.data,code:Z.invalid_enum_value,options:n}),ie}return vt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Vr.create(e)}exclude(e){return Vr.create(this.options.filter(t=>!e.includes(t)))}}Vr.create=tl;let ws=class extends he{_parse(e){const t=_e.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==U.string&&n.parsedType!==U.number){const s=_e.objectValues(t);return B(n,{expected:_e.joinValues(s),received:n.parsedType,code:Z.invalid_type}),ie}if(t.indexOf(e.data)===-1){const s=_e.objectValues(t);return B(n,{received:n.data,code:Z.invalid_enum_value,options:s}),ie}return vt(e.data)}get enum(){return this._def.values}};ws.create=(r,e)=>new ws({values:r,typeName:H.ZodNativeEnum,...ue(e)});let Mn=class extends he{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==U.promise&&t.common.async===!1)return B(t,{code:Z.invalid_type,expected:U.promise,received:t.parsedType}),ie;const n=t.parsedType===U.promise?t.data:Promise.resolve(t.data);return vt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Mn.create=(r,e)=>new Mn({type:r,typeName:H.ZodPromise,...ue(e)});let Lt=class extends he{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===H.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{B(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ie:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ie:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!os(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>os(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);_e.assertNever(s)}};Lt.create=(r,e,t)=>new Lt({schema:r,typeName:H.ZodEffects,effect:e,...ue(t)});Lt.createWithPreprocess=(r,e,t)=>new Lt({schema:e,effect:{type:"preprocess",transform:r},typeName:H.ZodEffects,...ue(t)});let Tr=class extends he{_parse(e){return this._getType(e)===U.undefined?vt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Tr.create=(r,e)=>new Tr({innerType:r,typeName:H.ZodOptional,...ue(e)});let hn=class extends he{_parse(e){return this._getType(e)===U.null?vt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};hn.create=(r,e)=>new hn({innerType:r,typeName:H.ZodNullable,...ue(e)});let bs=class extends he{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===U.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};bs.create=(r,e)=>new bs({innerType:r,typeName:H.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ue(e)});let Fa=class extends he{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Ba(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Rt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Rt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Fa.create=(r,e)=>new Fa({innerType:r,typeName:H.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ue(e)});let Wa=class extends he{_parse(e){if(this._getType(e)!==U.nan){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.nan,received:t.parsedType}),ie}return{status:"valid",value:e.data}}};Wa.create=r=>new Wa({typeName:H.ZodNaN,...ue(r)});const xp=Symbol("zod_brand");let rl=class extends he{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Wo=class nl extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ie:s.status==="dirty"?(t.dirty(),Ju(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ie:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new nl({in:e,out:t,typeName:H.ZodPipeline})}},Ya=class extends he{_parse(e){const t=this._def.innerType._parse(e);return os(t)&&(t.value=Object.freeze(t.value)),t}};Ya.create=(r,e)=>new Ya({innerType:r,typeName:H.ZodReadonly,...ue(e)});const sl=(r,e={},t)=>r?Pn.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...l,fatal:c})}}):Pn.create(),Sp={object:Et.lazycreate};var H;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(H||(H={}));const Np=(r,e={message:`Input not instance of ${r.name}`})=>sl(t=>t instanceof r,e),al=zn.create,il=cs.create,Ep=Wa.create,Ap=us.create,ol=ls.create,Ip=ds.create,Zp=Va.create,$p=hs.create,Cp=ps.create,jp=Pn.create,Rp=an.create,zp=Ar.create,Pp=qa.create,Mp=ln.create,Up=Et.create,Dp=Et.strictCreate,Lp=fs.create,Bp=Hu.create,Vp=ms.create,qp=Br.create,Kp=ys.create,Fp=Ka.create,Wp=dn.create,Yp=el.create,Jp=gs.create,Gp=vs.create,Hp=Vr.create,Xp=ws.create,Qp=Mn.create,Yc=Lt.create,ef=Tr.create,tf=hn.create,rf=Lt.createWithPreprocess,nf=Wo.create,sf=()=>al().optional(),af=()=>il().optional(),of=()=>ol().optional(),cf={string:r=>zn.create({...r,coerce:!0}),number:r=>cs.create({...r,coerce:!0}),boolean:r=>ls.create({...r,coerce:!0}),bigint:r=>us.create({...r,coerce:!0}),date:r=>ds.create({...r,coerce:!0})},uf=ie;var x=Object.freeze({__proto__:null,defaultErrorMap:is,setErrorMap:hp,getErrorMap:Da,makeIssue:La,EMPTY_PATH:pp,addIssueToContext:B,ParseStatus:ct,INVALID:ie,DIRTY:Ju,OK:vt,isAborted:go,isDirty:vo,isValid:os,isAsync:Ba,get util(){return _e},get objectUtil(){return yo},ZodParsedType:U,getParsedType:Rr,ZodType:he,ZodString:zn,ZodNumber:cs,ZodBigInt:us,ZodBoolean:ls,ZodDate:ds,ZodSymbol:Va,ZodUndefined:hs,ZodNull:ps,ZodAny:Pn,ZodUnknown:an,ZodNever:Ar,ZodVoid:qa,ZodArray:ln,ZodObject:Et,ZodUnion:fs,ZodDiscriminatedUnion:Hu,ZodIntersection:ms,ZodTuple:Br,ZodRecord:ys,ZodMap:Ka,ZodSet:dn,ZodFunction:el,ZodLazy:gs,ZodLiteral:vs,ZodEnum:Vr,ZodNativeEnum:ws,ZodPromise:Mn,ZodEffects:Lt,ZodTransformer:Lt,ZodOptional:Tr,ZodNullable:hn,ZodDefault:bs,ZodCatch:Fa,ZodNaN:Wa,BRAND:xp,ZodBranded:rl,ZodPipeline:Wo,ZodReadonly:Ya,custom:sl,Schema:he,ZodSchema:he,late:Sp,get ZodFirstPartyTypeKind(){return H},coerce:cf,any:jp,array:Mp,bigint:Ap,boolean:ol,date:Ip,discriminatedUnion:Bp,effect:Yc,enum:Hp,function:Yp,instanceof:Np,intersection:Vp,lazy:Jp,literal:Gp,map:Fp,nan:Ep,nativeEnum:Xp,never:zp,null:Cp,nullable:tf,number:il,object:Up,oboolean:of,onumber:af,optional:ef,ostring:sf,pipeline:nf,preprocess:rf,promise:Qp,record:Kp,set:Wp,strictObject:Dp,string:al,symbol:Zp,transformer:Yc,tuple:qp,undefined:$p,union:Lp,unknown:Rp,void:Pp,NEVER:uf,ZodIssueCode:Z,quotelessJson:dp,ZodError:Rt});const Yo=x.tuple([x.number(),x.number()]),cl=x.object({width:x.number(),height:x.number()}),lf=x.object({signedWidth:x.number(),signedHeight:x.number()}),df=["width","height"];x.enum(df);const hf=["start","center","end"],pf=["signedWidth","signedHeight"];x.enum(pf);const Ja=x.object({x:x.number(),y:x.number()}),ff=x.object({clientX:x.number(),clientY:x.number()}),mf=["x","y"],ul=x.enum(mf),ll=["top","right","bottom","left"];x.enum(ll);const yf=["left","right"],dl=x.enum(yf),gf=["top","bottom"],hl=x.enum(gf),pl=["center"],Jc=x.enum(pl),vf=[...ll,...pl],fl=x.enum(vf);x.enum(hf);const wf=["first","last"];x.enum(wf);const bf=x.object({lower:x.number(),upper:x.number()});x.union([bf,Yo]);x.union([ul,fl]);x.union([ul,fl,x.instanceof(String)]);const ss=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),_f(t)},_f=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var At=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},me={},Oi={};Object.defineProperty(Oi,"__esModule",{value:!0});function kf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}Oi.default=kf;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});function Of(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}Ti.default=Of;var xi={};Object.defineProperty(xi,"__esModule",{value:!0});function Tf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}xi.default=Tf;var Jo={};Object.defineProperty(Jo,"__esModule",{value:!0});function xf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Jo.default=xf;var Go={};Object.defineProperty(Go,"__esModule",{value:!0});function Sf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}Go.default=Sf;var Ho={};Object.defineProperty(Ho,"__esModule",{value:!0});function Nf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}Ho.default=Nf;var Xo={};Object.defineProperty(Xo,"__esModule",{value:!0});function Ef(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,s){return n+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}Xo.default=Ef;var Qo={};Object.defineProperty(Qo,"__esModule",{value:!0});function Af(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,s){return t+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}Qo.default=Af;var Si={};Object.defineProperty(Si,"__esModule",{value:!0});function If(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}Si.default=If;var ec={},bn={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(bn);var Zf=At&&At.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(ec,"__esModule",{value:!0});var ar=bn;function wa(r,e){if(e===void 0&&(e=ar.DefaultOption),!ar.isValidObject(r))return null;e=ar.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toLowerCase();e.recursive&&(ar.isValidObject(s)?ar.belongToTypes(s,e.keepTypesOnRecursion)||(s=wa(s,e)):e.recursiveInArray&&ar.isArrayObject(s)&&(s=Zf(s).map(function(i){var o=i;if(ar.isValidObject(i))ar.belongToTypes(o,e.keepTypesOnRecursion)||(o=wa(i,e));else if(ar.isArrayObject(i)){var c=wa({key:i},e);o=c.key}return o}))),t[a]=s}),t}ec.default=wa;var tc={},$f=At&&At.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(tc,"__esModule",{value:!0});var ir=bn;function ba(r,e){if(e===void 0&&(e=ir.DefaultOption),!ir.isValidObject(r))return null;e=ir.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toUpperCase();e.recursive&&(ir.isValidObject(s)?ir.belongToTypes(s,e.keepTypesOnRecursion)||(s=ba(s,e)):e.recursiveInArray&&ir.isArrayObject(s)&&(s=$f(s).map(function(i){var o=i;if(ir.isValidObject(i))ir.belongToTypes(o,e.keepTypesOnRecursion)||(o=ba(i,e));else if(ir.isArrayObject(i)){var c=ba({key:i},e);o=c.key}return o}))),t[a]=s}),t}tc.default=ba;var rc={},Cf=At&&At.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(rc,"__esModule",{value:!0});var or=bn,jf=Oi;function _a(r,e){if(e===void 0&&(e=or.DefaultOption),!or.isValidObject(r))return null;e=or.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=jf.default(n);e.recursive&&(or.isValidObject(s)?or.belongToTypes(s,e.keepTypesOnRecursion)||(s=_a(s,e)):e.recursiveInArray&&or.isArrayObject(s)&&(s=Cf(s).map(function(i){var o=i;if(or.isValidObject(i))or.belongToTypes(o,e.keepTypesOnRecursion)||(o=_a(i,e));else if(or.isArrayObject(i)){var c=_a({key:i},e);o=c.key}return o}))),t[a]=s}),t}rc.default=_a;var nc={},Rf=At&&At.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(nc,"__esModule",{value:!0});var cr=bn,zf=Ti;function ka(r,e){if(e===void 0&&(e=cr.DefaultOption),!cr.isValidObject(r))return null;e=cr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=zf.default(n);e.recursive&&(cr.isValidObject(s)?cr.belongToTypes(s,e.keepTypesOnRecursion)||(s=ka(s,e)):e.recursiveInArray&&cr.isArrayObject(s)&&(s=Rf(s).map(function(i){var o=i;if(cr.isValidObject(i))cr.belongToTypes(o,e.keepTypesOnRecursion)||(o=ka(i,e));else if(cr.isArrayObject(i)){var c=ka({key:i},e);o=c.key}return o}))),t[a]=s}),t}nc.default=ka;var sc={},Pf=At&&At.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(sc,"__esModule",{value:!0});var ur=bn,Mf=xi;function Oa(r,e){if(e===void 0&&(e=ur.DefaultOption),!ur.isValidObject(r))return null;e=ur.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Mf.default(n);e.recursive&&(ur.isValidObject(s)?ur.belongToTypes(s,e.keepTypesOnRecursion)||(s=Oa(s,e)):e.recursiveInArray&&ur.isArrayObject(s)&&(s=Pf(s).map(function(i){var o=i;if(ur.isValidObject(i))ur.belongToTypes(o,e.keepTypesOnRecursion)||(o=Oa(i,e));else if(ur.isArrayObject(i)){var c=Oa({key:i},e);o=c.key}return o}))),t[a]=s}),t}sc.default=Oa;var ac={},Uf=At&&At.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(ac,"__esModule",{value:!0});var lr=bn,Df=Si;function Ta(r,e){if(e===void 0&&(e=lr.DefaultOption),!lr.isValidObject(r))return null;e=lr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Df.default(n);e.recursive&&(lr.isValidObject(s)?lr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ta(s,e)):e.recursiveInArray&&lr.isArrayObject(s)&&(s=Uf(s).map(function(i){var o=i;if(lr.isValidObject(i))lr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ta(i,e));else if(lr.isArrayObject(i)){var c=Ta({key:i},e);o=c.key}return o}))),t[a]=s}),t}ac.default=Ta;Object.defineProperty(me,"__esModule",{value:!0});me.kebabKeys=me.pascalKeys=me.snakeKeys=me.camelKeys=me.upperKeys=me.lowerKeys=me.toLowerCase=me.toUpperCase=me.toKebabCase=me.toHeaderCase=me.toSentenceCase=me.toTextCase=me.toPathCase=me.toDotCase=me.toPascalCase=me.toSnakeCase=me.toCamelCase=void 0;var ml=Oi;me.toCamelCase=ml.default;var yl=Ti;me.toSnakeCase=yl.default;var gl=xi;me.toPascalCase=gl.default;var vl=Jo;me.toDotCase=vl.default;var wl=Go;me.toPathCase=wl.default;var bl=Ho;me.toTextCase=bl.default;var _l=Xo;me.toSentenceCase=_l.default;var kl=Qo;me.toHeaderCase=kl.default;var Ol=Si;me.toKebabCase=Ol.default;var Tl=ec;me.lowerKeys=Tl.default;var xl=tc;me.upperKeys=xl.default;var Sl=rc;me.camelKeys=Sl.default;var Nl=nc;me.snakeKeys=Nl.default;var El=sc;me.pascalKeys=El.default;var Al=ac;me.kebabKeys=Al.default;var Il=function(r){return String(r||"").toLowerCase()};me.toLowerCase=Il;var Zl=function(r){return String(r||"").toUpperCase()};me.toUpperCase=Zl;var Lf={toCamelCase:ml.default,toSnakeCase:yl.default,toPascalCase:gl.default,toDotCase:vl.default,toPathCase:wl.default,toTextCase:bl.default,toSentenceCase:_l.default,toHeaderCase:kl.default,toKebabCase:Ol.default,toUpperCase:Zl,toLowerCase:Il,lowerKeys:Tl.default,upperKeys:xl.default,camelKeys:Sl.default,snakeKeys:Nl.default,pascalKeys:El.default,kebabKeys:Al.default};me.default=Lf;var $l=me;const Cl={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Bf=r=>$l.snakeKeys(r,Cl),Vf=r=>$l.camelKeys(r,Cl);var Un;(r=>{r.toSnake=Bf,r.toCamel=Vf,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Un||(Un={}));x.object({x:dl.or(Jc),y:hl.or(Jc)});const qf=x.object({x:dl,y:hl}),Kf=Object.freeze({x:"left",y:"top"}),Ff=(r,e)=>r.x===e.x&&r.y===e.y,Gc=x.union([x.number(),Ja,Yo,cl,lf,ff]),Wf=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},Hc={x:0,y:0},ua=x.union([x.number(),x.string()]);x.object({top:ua,left:ua,width:ua,height:ua});x.object({left:x.number(),top:x.number(),right:x.number(),bottom:x.number()});x.object({one:Ja,two:Ja,root:qf});const ic=(r,e,t=0,n=0,s)=>{const a={one:{...Hc},two:{...Hc},root:s??Kf};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:s??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},Wi=r=>{const e=ic(r);return{lower:e.one.x,upper:e.two.x}},Yi=r=>{const e=ic(r);return{lower:e.one.y,upper:e.two.y}},Yf=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Jf=x.object({signedWidth:x.number(),signedHeight:x.number()});x.union([cl,Jf,Ja,Yo]);const Gf=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);x.object({offset:Gc,scale:Gc});const Hf=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Xf=r=>(e,t,n,s)=>[e,s?n/r:n*r],Qf=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:s,upper:a}=e,{lower:i,upper:o}=r,c=a-s,l=o-i;if(t==="dimension")return[r,n*(l/c)];const m=(n-s)*(l/c)+i;return[r,m]},em=r=>(e,t,n)=>[r,n],tm=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:s}=r;return[r,s-(t-n)]},rm=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=Gf(n,s,a),[e,n]},ko=class es{constructor(){N(this,"ops",[]),N(this,"currBounds",null),N(this,"currType",null),N(this,"reversed",!1),this.ops=[]}static translate(e){return new es().translate(e)}static magnify(e){return new es().magnify(e)}static scale(e,t){return new es().scale(e,t)}translate(e){const t=this.new(),n=Hf(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Xf(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=ss(e,t),s=this.new(),a=Qf(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=ss(e,t),s=this.new(),a=rm(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=ss(e,t),s=this.new(),a=em(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=tm();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new es;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,s],a)=>a(n,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||t.some(([i,o])=>s>=i&&s<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>s);a!==-1&&t.push([s,a])}),t.forEach(([n,s])=>{const a=e.ops.slice(n,s);a.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...a)}),e.reversed=!e.reversed,e}};N(ko,"IDENTITY",new ko);let Xc=ko;const Qc=class gr{constructor(e=new Xc,t=new Xc,n=null){N(this,"x"),N(this,"y"),N(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new gr().translate(e,t)}static translateX(e){return new gr().translateX(e)}static translateY(e){return new gr().translateY(e)}static clamp(e){return new gr().clamp(e)}static magnify(e){return new gr().magnify(e)}static scale(e){return new gr().scale(e)}static reBound(e){return new gr().reBound(e)}translate(e,t){const n=Wf(e,t),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(Yf(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Ff(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Wi(e)),t.y=t.y.scale(Yi(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Wi(e)),t.y=this.y.reBound(Yi(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Wi(e)),t.y=this.y.clamp(Yi(e)),t}copy(){const e=new gr;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return ic(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};N(Qc,"IDENTITY",new Qc);const jl=(r,e)=>{const t=new Se(e);if(![Re.DAY,Re.HOUR,Re.MINUTE,Re.SECOND,Re.MILLISECOND,Re.MICROSECOND,Re.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof Se?new Se(n):new Re(n)},Ae=class se{constructor(e,t="UTC"){if(N(this,"value"),N(this,"encodeValue",!0),e==null)this.value=se.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*se.MILLISECOND.valueOf();else if(typeof e=="string")this.value=se.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=se.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=se.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=se.MAX:e=se.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const s=new Date(e,t-1,n,0,0,0,0);return new se(BigInt(s.getTime())*se.MILLISECOND.valueOf()).truncate(se.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,s,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let c=se.hours(parseInt(n??"00",10)).add(se.minutes(parseInt(s??"00",10))).add(se.seconds(parseInt(i??"00",10))).add(se.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(se.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return se.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new se(BigInt(n.getTime())*se.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(se.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(e="UTC"){const t=this.date(),n=t.toLocaleString("default",{month:"short"}),s=t.toLocaleString("default",{day:"numeric"});return`${n} ${s}`}static get utcOffset(){return new Re(BigInt(new Date().getTimezoneOffset())*se.MINUTE.valueOf())}static since(e){return new se().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new se(e).valueOf()}span(e){return this.range(e).span}range(e){return new $t(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new se(e).valueOf()}afterEq(e){return this.valueOf()>=new se(e).valueOf()}before(e){return this.valueOf()<new se(e).valueOf()}beforeEq(e){return this.valueOf()<=new se(e).valueOf()}add(e){return new se(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new se(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/se.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return jl(this,e)}get isToday(){return this.truncate(Re.DAY).equals(se.now().truncate(Re.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new se(new Date)}static max(...e){let t=se.MIN;for(const n of e){const s=new se(n);s.after(t)&&(t=s)}return t}static min(...e){let t=se.MAX;for(const n of e){const s=new se(n);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new se(e)}static microseconds(e){return se.nanoseconds(e*1e3)}static milliseconds(e){return se.microseconds(e*1e3)}static seconds(e){return se.milliseconds(e*1e3)}static minutes(e){return se.seconds(e*60)}static hours(e){return se.minutes(e*60)}static days(e){return se.hours(e*24)}};N(Ae,"NANOSECOND",Ae.nanoseconds(1)),N(Ae,"MICROSECOND",Ae.microseconds(1)),N(Ae,"MILLISECOND",Ae.milliseconds(1)),N(Ae,"SECOND",Ae.seconds(1)),N(Ae,"MINUTE",Ae.minutes(1)),N(Ae,"HOUR",Ae.hours(1)),N(Ae,"DAY",Ae.days(1)),N(Ae,"MAX",new Ae((1n<<63n)-1n)),N(Ae,"MIN",new Ae(0)),N(Ae,"ZERO",new Ae(0)),N(Ae,"z",x.union([x.object({value:x.bigint()}).transform(r=>new Ae(r.value)),x.string().transform(r=>new Ae(BigInt(r))),x.instanceof(Number).transform(r=>new Ae(r)),x.number().transform(r=>new Ae(r)),x.instanceof(Ae)]));let Se=Ae;const Ie=class Te{constructor(e){N(this,"value"),N(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new Te(e).valueOf()}greaterThan(e){return this.valueOf()>new Te(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new Te(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new Te(e).valueOf()}remainder(e){return jl(this,e)}truncate(e){return new Te(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(Te.DAY),t=this.truncate(Te.HOUR),n=this.truncate(Te.MINUTE),s=this.truncate(Te.SECOND),a=this.truncate(Te.MILLISECOND),i=this.truncate(Te.MICROSECOND),o=this.truncate(Te.NANOSECOND),c=e,l=t.sub(e),m=n.sub(t),T=s.sub(n),J=a.sub(s),ee=i.sub(a),Ee=o.sub(i);let te="";return c.isZero||(te+=`${c.days}d `),l.isZero||(te+=`${l.hours}h `),m.isZero||(te+=`${m.minutes}m `),T.isZero||(te+=`${T.seconds}s `),J.isZero||(te+=`${J.milliseconds}ms `),ee.isZero||(te+=`${ee.microseconds}µs `),Ee.isZero||(te+=`${Ee.nanoseconds}ns`),te.trim()}get days(){return Number(this.valueOf()/Te.DAY.valueOf())}get hours(){return Number(this.valueOf()/Te.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/Te.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/Te.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/Te.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/Te.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new Te(e).valueOf()}add(e){return new Te(this.valueOf()+new Te(e).valueOf())}sub(e){return new Te(this.valueOf()-new Te(e).valueOf())}static nanoseconds(e=1){return new Te(e)}static microseconds(e=1){return Te.nanoseconds(e*1e3)}static milliseconds(e=1){return Te.microseconds(e*1e3)}static seconds(e=1){return Te.milliseconds(e*1e3)}static minutes(e){return Te.seconds(e.valueOf()*60)}static hours(e){return Te.minutes(e*60)}static days(e){return Te.hours(e*24)}};N(Ie,"NANOSECOND",Ie.nanoseconds(1)),N(Ie,"MICROSECOND",Ie.microseconds(1)),N(Ie,"MILLISECOND",Ie.milliseconds(1)),N(Ie,"SECOND",Ie.seconds(1)),N(Ie,"MINUTE",Ie.minutes(1)),N(Ie,"HOUR",Ie.hours(1)),N(Ie,"DAY",Ie.days(1)),N(Ie,"MAX",new Ie((1n<<63n)-1n)),N(Ie,"MIN",new Ie(0)),N(Ie,"ZERO",new Ie(0)),N(Ie,"z",x.union([x.object({value:x.bigint()}).transform(r=>new Ie(r.value)),x.string().transform(r=>new Ie(BigInt(r))),x.instanceof(Number).transform(r=>new Ie(r)),x.number().transform(r=>new Ie(r)),x.instanceof(Ie)]));let Re=Ie;const ts=class xa extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new xa(e).valueOf()}get period(){return Re.seconds(1/this.valueOf())}sampleCount(e){return new Re(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ot(t).valueOf()}span(e){return Re.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new xa(e)}static khz(e){return xa.hz(e*1e3)}};N(ts,"z",x.union([x.number().transform(r=>new ts(r)),x.instanceof(Number).transform(r=>new ts(r)),x.instanceof(ts)]));let Ni=ts;const rt=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Ga(e*this.valueOf())}};N(rt,"UNKNOWN",new rt(0)),N(rt,"BIT128",new rt(16)),N(rt,"BIT64",new rt(8)),N(rt,"BIT32",new rt(4)),N(rt,"BIT16",new rt(2)),N(rt,"BIT8",new rt(1)),N(rt,"z",x.union([x.number().transform(r=>new rt(r)),x.instanceof(Number).transform(r=>new rt(r)),x.instanceof(rt)]));let ot=rt;const Kt=class Sa{constructor(e,t){N(this,"start"),N(this,"end"),this.start=new Se(e),this.end=new Se(t)}get span(){return new Re(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new Sa(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof Sa?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Sa(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};N(Kt,"MAX",new Kt(Se.MIN,Se.MAX)),N(Kt,"MIN",new Kt(Se.MAX,Se.MIN)),N(Kt,"ZERO",new Kt(Se.ZERO,Se.ZERO)),N(Kt,"z",x.union([x.object({start:Se.z,end:Se.z}).transform(r=>new Kt(r.start,r.end)),x.instanceof(Kt)]));let $t=Kt;const E=class vr extends String{constructor(e){if(e instanceof vr||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=vr.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(vr.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=vr.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(vr.JSON)||this.equals(vr.STRING)}get density(){const e=vr.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return vr.BIG_INT_TYPES.some(e=>e.equals(this))}};N(E,"UNKNOWN",new E("unknown")),N(E,"FLOAT64",new E("float64")),N(E,"FLOAT32",new E("float32")),N(E,"INT64",new E("int64")),N(E,"INT32",new E("int32")),N(E,"INT16",new E("int16")),N(E,"INT8",new E("int8")),N(E,"UINT64",new E("uint64")),N(E,"UINT32",new E("uint32")),N(E,"UINT16",new E("uint16")),N(E,"UINT8",new E("uint8")),N(E,"BOOLEAN",E.UINT8),N(E,"TIMESTAMP",new E("timestamp")),N(E,"UUID",new E("uuid")),N(E,"STRING",new E("string")),N(E,"JSON",new E("json")),N(E,"ARRAY_CONSTRUCTORS",new Map([[E.UINT8.toString(),Uint8Array],[E.UINT16.toString(),Uint16Array],[E.UINT32.toString(),Uint32Array],[E.UINT64.toString(),BigUint64Array],[E.FLOAT32.toString(),Float32Array],[E.FLOAT64.toString(),Float64Array],[E.INT8.toString(),Int8Array],[E.INT16.toString(),Int16Array],[E.INT32.toString(),Int32Array],[E.INT64.toString(),BigInt64Array],[E.TIMESTAMP.toString(),BigInt64Array],[E.STRING.toString(),Uint8Array],[E.JSON.toString(),Uint8Array],[E.UUID.toString(),Uint8Array]])),N(E,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,E.UINT8],[Uint16Array.name,E.UINT16],[Uint32Array.name,E.UINT32],[BigUint64Array.name,E.UINT64],[Float32Array.name,E.FLOAT32],[Float64Array.name,E.FLOAT64],[Int8Array.name,E.INT8],[Int16Array.name,E.INT16],[Int32Array.name,E.INT32],[BigInt64Array.name,E.INT64]])),N(E,"DENSITIES",new Map([[E.UINT8.toString(),ot.BIT8],[E.UINT16.toString(),ot.BIT16],[E.UINT32.toString(),ot.BIT32],[E.UINT64.toString(),ot.BIT64],[E.FLOAT32.toString(),ot.BIT32],[E.FLOAT64.toString(),ot.BIT64],[E.INT8.toString(),ot.BIT8],[E.INT16.toString(),ot.BIT16],[E.INT32.toString(),ot.BIT32],[E.INT64.toString(),ot.BIT64],[E.TIMESTAMP.toString(),ot.BIT64],[E.STRING.toString(),ot.UNKNOWN],[E.JSON.toString(),ot.UNKNOWN],[E.UUID.toString(),ot.BIT128]])),N(E,"ALL",[E.UNKNOWN,E.FLOAT64,E.FLOAT32,E.INT64,E.INT32,E.INT16,E.INT8,E.UINT64,E.UINT32,E.UINT16,E.UINT8,E.TIMESTAMP,E.UUID,E.STRING,E.JSON]),N(E,"BIG_INT_TYPES",[E.INT64,E.UINT64,E.TIMESTAMP]),N(E,"z",x.union([x.string().transform(r=>new E(r)),x.instanceof(E)]));let ze=E;const at=class Fe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return Fe.bytes(this.valueOf()+e.valueOf())}sub(e){return Fe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new Fe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return Fe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/Fe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/Fe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/Fe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/Fe.TERABYTE.valueOf()}toString(){const e=this.truncate(Fe.TERABYTE),t=this.truncate(Fe.GIGABYTE),n=this.truncate(Fe.MEGABYTE),s=this.truncate(Fe.KILOBYTE),a=this.truncate(Fe.BYTE),i=e,o=t.sub(e),c=n.sub(t),l=s.sub(n),m=a.sub(s);let T="";return i.isZero||(T+=`${i.terabytes}TB `),o.isZero||(T+=`${o.gigabytes}GB `),c.isZero||(T+=`${c.megabytes}MB `),l.isZero||(T+=`${l.kilobytes}KB `),(!m.isZero||T==="")&&(T+=`${m.valueOf()}B`),T.trim()}static bytes(e=1){return new Fe(e)}static kilobytes(e=1){return Fe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return Fe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return Fe.megabytes(e.valueOf()*1e3)}static terabytes(e){return Fe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};N(at,"BYTE",new at(1)),N(at,"KILOBYTE",at.kilobytes(1)),N(at,"MEGABYTE",at.megabytes(1)),N(at,"GIGABYTE",at.gigabytes(1)),N(at,"TERABYTE",at.terabytes(1)),N(at,"ZERO",new at(0)),N(at,"z",x.union([x.number().transform(r=>new at(r)),x.instanceof(at)]));let Ga=at;x.union([x.instanceof(Uint8Array),x.instanceof(Uint16Array),x.instanceof(Uint32Array),x.instanceof(BigUint64Array),x.instanceof(Float32Array),x.instanceof(Float64Array),x.instanceof(Int8Array),x.instanceof(Int16Array),x.instanceof(Int32Array),x.instanceof(BigInt64Array)]);const Rl=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof Se||r instanceof Re||r instanceof Date},nm=(r,e,t,n=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!r.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(n):rs(t,-n),sm=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof Zn?!0:Rl(r),rn=-1;let Zn=class wr{constructor(e){N(this,"key",""),N(this,"dataType"),N(this,"sampleOffset"),N(this,"gl"),N(this,"_data"),N(this,"_timeRange"),N(this,"alignment",0),N(this,"_cachedMin"),N(this,"_cachedMax"),N(this,"writePos",rn),N(this,"_refCount",0),N(this,"_cachedLength"),sm(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:s=0,glBufferUsage:a="static",alignment:i=0,key:o=op()}=e,{data:c}=e;if(c instanceof wr){this.key=c.key,this.dataType=c.dataType,this.sampleOffset=c.sampleOffset,this.gl=c.gl,this._data=c._data,this._timeRange=c._timeRange,this.alignment=c.alignment,this._cachedMin=c._cachedMin,this._cachedMax=c._cachedMax,this.writePos=c.writePos,this._refCount=c._refCount,this._cachedLength=c._cachedLength;return}const l=Rl(c),m=Array.isArray(c);if(t!=null)this.dataType=new ze(t);else{if(c instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(m||l){let T=c;if(!l){if(c.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");T=c[0]}if(typeof T=="string")this.dataType=ze.STRING;else if(typeof T=="number")this.dataType=ze.FLOAT64;else if(typeof T=="bigint")this.dataType=ze.INT64;else if(typeof T=="boolean")this.dataType=ze.BOOLEAN;else if(T instanceof Se||T instanceof Date||T instanceof Se)this.dataType=ze.TIMESTAMP;else if(typeof T=="object")this.dataType=ze.JSON;else throw new Error(`cannot infer data type of ${typeof T} when constructing a Series from a JS array`)}else this.dataType=new ze(c)}if(!m&&!l)this._data=c;else{let T=l?[c]:c;const J=T[0];(J instanceof Se||J instanceof Date||J instanceof Re)&&(T=T.map(ee=>new Se(ee).valueOf())),this.dataType.equals(ze.STRING)?(this._cachedLength=T.length,this._data=new TextEncoder().encode(T.join(`
1
+ "use strict";var op=Object.defineProperty;var cp=(r,e,t)=>e in r?op(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var h=(r,e,t)=>(cp(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("zod");var up=Object.defineProperty,lp=(r,e,t)=>e in r?up(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,x=(r,e,t)=>(lp(r,typeof e!="symbol"?e+"":e,t),t);let dp="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",hp=(r=21)=>{let e="",t=r;for(;t--;)e+=dp[Math.random()*64|0];return e};const pp=r=>r!=null&&typeof r=="object"&&"toString"in r,fp=(r,e=!1)=>{const t=pp(r)?"stringer":typeof r;let n;switch(t){case"string":n=(s,a)=>s.localeCompare(a);break;case"stringer":n=(s,a)=>s.toString().localeCompare(a.toString());break;case"number":n=(s,a)=>s-a;break;case"bigint":n=(s,a)=>s-a>BigInt(0)?1:-1;break;case"boolean":n=(s,a)=>Number(s)-Number(a);break;default:return console.warn("sortFunc: unknown type"),()=>-1}return e?mp(n):n},mp=r=>(e,t)=>r(t,e);var _e;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(_e||(_e={}));var mo;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(mo||(mo={}));const U=_e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Rr=r=>{switch(typeof r){case"undefined":return U.undefined;case"string":return U.string;case"number":return isNaN(r)?U.nan:U.number;case"boolean":return U.boolean;case"function":return U.function;case"bigint":return U.bigint;case"symbol":return U.symbol;case"object":return Array.isArray(r)?U.array:r===null?U.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?U.promise:typeof Map<"u"&&r instanceof Map?U.map:typeof Set<"u"&&r instanceof Set?U.set:typeof Date<"u"&&r instanceof Date?U.date:U.object;default:return U.unknown}},Z=_e.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),yp=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");let Rt=class extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,_e.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};Rt.create=r=>new Rt(r);const is=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===U.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case Z.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,_e.jsonStringifyReplacer)}`;break;case Z.unrecognized_keys:t=`Unrecognized key(s) in object: ${_e.joinValues(r.keys,", ")}`;break;case Z.invalid_union:t="Invalid input";break;case Z.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${_e.joinValues(r.options)}`;break;case Z.invalid_enum_value:t=`Invalid enum value. Expected ${_e.joinValues(r.options)}, received '${r.received}'`;break;case Z.invalid_arguments:t="Invalid function arguments";break;case Z.invalid_return_type:t="Invalid function return type";break;case Z.invalid_date:t="Invalid date";break;case Z.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:_e.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case Z.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case Z.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case Z.custom:t="Invalid input";break;case Z.invalid_intersection_types:t="Intersection results could not be merged";break;case Z.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case Z.not_finite:t="Number must be finite";break;default:t=e.defaultError,_e.assertNever(r)}return{message:t}};let Yu=is;function gp(r){Yu=r}function Ma(){return Yu}const Ua=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},vp=[];function B(r,e){const t=Ua({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ma(),is].filter(n=>!!n)});r.common.issues.push(t)}class ct{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return ie;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return ct.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return ie;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const ie=Object.freeze({status:"aborted"}),Ju=r=>({status:"dirty",value:r}),vt=r=>({status:"valid",value:r}),yo=r=>r.status==="aborted",go=r=>r.status==="dirty",os=r=>r.status==="valid",Da=r=>typeof Promise<"u"&&r instanceof Promise;var F;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(F||(F={}));let Ht=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}};const Wc=(r,e)=>{if(os(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Rt(r.common.issues);return this._error=t,this._error}}};function ue(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:s}}let he=class{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Rr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Rr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ct,ctx:{common:e.parent.common,data:e.data,parsedType:Rr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Da(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Rr(e)},a=this._parseSync({data:e,path:s.path,parent:s});return Wc(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Rr(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Da(s)?s:Promise.resolve(s));return Wc(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:Z.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new Lt({schema:this,typeName:H.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Tr.create(this,this._def)}nullable(){return dn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return un.create(this,this._def)}promise(){return Mn.create(this,this._def)}or(e){return fs.create([this,e],this._def)}and(e){return ms.create(this,e,this._def)}transform(e){return new Lt({...ue(this._def),schema:this,typeName:H.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ws({...ue(this._def),innerType:this,defaultValue:t,typeName:H.ZodDefault})}brand(){return new nl({typeName:H.ZodBranded,type:this,...ue(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new qa({...ue(this._def),innerType:this,catchValue:t,typeName:H.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Wo.create(this,e)}readonly(){return Fa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}};const wp=/^c[^\s-]{8,}$/i,bp=/^[a-z][a-z0-9]*$/,_p=/^[0-9A-HJKMNP-TV-Z]{26}$/,kp=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Op=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Tp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ki;const xp=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Sp=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,Np=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Ep(r,e){return!!((e==="v4"||!e)&&xp.test(r)||(e==="v6"||!e)&&Sp.test(r))}let zn=class Qn extends he{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==U.string){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:U.string,received:s.parsedType}),ie}const t=new ct;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:Z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:Z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?B(n,{code:Z.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&B(n,{code:Z.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")Op.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"email",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Ki||(Ki=new RegExp(Tp,"u")),Ki.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"emoji",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")kp.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"uuid",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")wp.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"cuid",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")bp.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"cuid2",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")_p.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"ulid",code:Z.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),B(n,{validation:"url",code:Z.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"regex",code:Z.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),B(n,{code:Z.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),B(n,{code:Z.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),B(n,{code:Z.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?Np(s).test(e.data)||(n=this._getOrReturnCtx(e,n),B(n,{code:Z.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?Ep(e.data,s.version)||(n=this._getOrReturnCtx(e,n),B(n,{validation:"ip",code:Z.invalid_string,message:s.message}),t.dirty()):_e.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:Z.invalid_string,...F.errToObj(n)})}_addCheck(e){return new Qn({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...F.errToObj(e)})}url(e){return this._addCheck({kind:"url",...F.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...F.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...F.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...F.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...F.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...F.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...F.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...F.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...F.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...F.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...F.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...F.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...F.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...F.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...F.errToObj(t)})}nonempty(e){return this.min(1,F.errToObj(e))}trim(){return new Qn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Qn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Qn({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};zn.create=r=>{var e;return new zn({checks:[],typeName:H.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ue(r)})};function Ap(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}let cs=class vo extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==U.number){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:U.number,received:s.parsedType}),ie}let t;const n=new ct;for(const s of this._def.checks)s.kind==="int"?_e.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:Z.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?Ap(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),B(t,{code:Z.not_finite,message:s.message}),n.dirty()):_e.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,F.toString(t))}gt(e,t){return this.setLimit("min",e,!1,F.toString(t))}lte(e,t){return this.setLimit("max",e,!0,F.toString(t))}lt(e,t){return this.setLimit("max",e,!1,F.toString(t))}setLimit(e,t,n,s){return new vo({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:F.toString(s)}]})}_addCheck(e){return new vo({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:F.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:F.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:F.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:F.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:F.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:F.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:F.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:F.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:F.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&_e.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};cs.create=r=>new cs({checks:[],typeName:H.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ue(r)});let us=class wo extends he{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==U.bigint){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:U.bigint,received:s.parsedType}),ie}let t;const n=new ct;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),B(t,{code:Z.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):_e.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,F.toString(t))}gt(e,t){return this.setLimit("min",e,!1,F.toString(t))}lte(e,t){return this.setLimit("max",e,!0,F.toString(t))}lt(e,t){return this.setLimit("max",e,!1,F.toString(t))}setLimit(e,t,n,s){return new wo({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:F.toString(s)}]})}_addCheck(e){return new wo({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:F.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:F.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:F.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:F.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:F.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};us.create=r=>{var e;return new us({checks:[],typeName:H.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ue(r)})};let ls=class extends he{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==U.boolean){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.boolean,received:t.parsedType}),ie}return vt(e.data)}};ls.create=r=>new ls({typeName:H.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ue(r)});let ds=class Gu extends he{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==U.date){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:U.date,received:s.parsedType}),ie}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_date}),ie}const t=new ct;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:Z.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),B(n,{code:Z.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):_e.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Gu({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:F.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:F.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};ds.create=r=>new ds({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:H.ZodDate,...ue(r)});let La=class extends he{_parse(e){if(this._getType(e)!==U.symbol){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.symbol,received:t.parsedType}),ie}return vt(e.data)}};La.create=r=>new La({typeName:H.ZodSymbol,...ue(r)});let hs=class extends he{_parse(e){if(this._getType(e)!==U.undefined){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.undefined,received:t.parsedType}),ie}return vt(e.data)}};hs.create=r=>new hs({typeName:H.ZodUndefined,...ue(r)});let ps=class extends he{_parse(e){if(this._getType(e)!==U.null){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.null,received:t.parsedType}),ie}return vt(e.data)}};ps.create=r=>new ps({typeName:H.ZodNull,...ue(r)});let Pn=class extends he{constructor(){super(...arguments),this._any=!0}_parse(e){return vt(e.data)}};Pn.create=r=>new Pn({typeName:H.ZodAny,...ue(r)});let sn=class extends he{constructor(){super(...arguments),this._unknown=!0}_parse(e){return vt(e.data)}};sn.create=r=>new sn({typeName:H.ZodUnknown,...ue(r)});class Ar extends he{_parse(e){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.never,received:t.parsedType}),ie}}Ar.create=r=>new Ar({typeName:H.ZodNever,...ue(r)});let Ba=class extends he{_parse(e){if(this._getType(e)!==U.undefined){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.void,received:t.parsedType}),ie}return vt(e.data)}};Ba.create=r=>new Ba({typeName:H.ZodVoid,...ue(r)});let un=class fa extends he{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==U.array)return B(t,{code:Z.invalid_type,expected:U.array,received:t.parsedType}),ie;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(B(t,{code:i?Z.too_big:Z.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(B(t,{code:Z.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(B(t,{code:Z.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new Ht(t,i,t.path,o)))).then(i=>ct.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Ht(t,i,t.path,o)));return ct.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new fa({...this._def,minLength:{value:e,message:F.toString(t)}})}max(e,t){return new fa({...this._def,maxLength:{value:e,message:F.toString(t)}})}length(e,t){return new fa({...this._def,exactLength:{value:e,message:F.toString(t)}})}nonempty(e){return this.min(1,e)}};un.create=(r,e)=>new un({type:r,minLength:null,maxLength:null,exactLength:null,typeName:H.ZodArray,...ue(e)});function Sn(r){if(r instanceof At){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Tr.create(Sn(n))}return new At({...r._def,shape:()=>e})}else return r instanceof un?new un({...r._def,type:Sn(r.element)}):r instanceof Tr?Tr.create(Sn(r.unwrap())):r instanceof dn?dn.create(Sn(r.unwrap())):r instanceof Br?Br.create(r.items.map(e=>Sn(e))):r}let At=class $t extends he{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=_e.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==U.object){const c=this._getOrReturnCtx(e);return B(c,{code:Z.invalid_type,expected:U.object,received:c.parsedType}),ie}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Ar&&this._def.unknownKeys==="strip"))for(const c in n.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=s[c],m=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Ht(n,m,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Ar){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(c==="strict")i.length>0&&(B(n,{code:Z.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const m=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Ht(n,m,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const m=await l.key;c.push({key:m,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>ct.mergeObjectSync(t,c)):ct.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return F.errToObj,new $t({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=F.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new $t({...this._def,unknownKeys:"strip"})}passthrough(){return new $t({...this._def,unknownKeys:"passthrough"})}extend(e){return new $t({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new $t({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:H.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new $t({...this._def,catchall:e})}pick(e){const t={};return _e.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new $t({...this._def,shape:()=>t})}omit(e){const t={};return _e.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new $t({...this._def,shape:()=>t})}deepPartial(){return Sn(this)}partial(e){const t={};return _e.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new $t({...this._def,shape:()=>t})}required(e){const t={};return _e.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Tr;)s=s._def.innerType;t[n]=s}}),new $t({...this._def,shape:()=>t})}keyof(){return rl(_e.objectKeys(this.shape))}};At.create=(r,e)=>new At({shape:()=>r,unknownKeys:"strip",catchall:Ar.create(),typeName:H.ZodObject,...ue(e)});At.strictCreate=(r,e)=>new At({shape:()=>r,unknownKeys:"strict",catchall:Ar.create(),typeName:H.ZodObject,...ue(e)});At.lazycreate=(r,e)=>new At({shape:r,unknownKeys:"strip",catchall:Ar.create(),typeName:H.ZodObject,...ue(e)});let fs=class extends he{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Rt(o.ctx.common.issues));return B(t,{code:Z.invalid_union,unionErrors:i}),ie}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of n){const l={...t,common:{...t.common,issues:[]},parent:null},m=c._parseSync({data:t.data,path:t.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new Rt(c));return B(t,{code:Z.invalid_union,unionErrors:o}),ie}}get options(){return this._def.options}};fs.create=(r,e)=>new fs({options:r,typeName:H.ZodUnion,...ue(e)});const ma=r=>r instanceof ys?ma(r.schema):r instanceof Lt?ma(r.innerType()):r instanceof gs?[r.value]:r instanceof Vr?r.options:r instanceof vs?Object.keys(r.enum):r instanceof ws?ma(r._def.innerType):r instanceof hs?[void 0]:r instanceof ps?[null]:null;let Hu=class Xu extends he{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==U.object)return B(t,{code:Z.invalid_type,expected:U.object,received:t.parsedType}),ie;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(B(t,{code:Z.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ie)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=ma(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Xu({typeName:H.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ue(n)})}};function bo(r,e){const t=Rr(r),n=Rr(e);if(r===e)return{valid:!0,data:r};if(t===U.object&&n===U.object){const s=_e.objectKeys(e),a=_e.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=bo(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===U.array&&n===U.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=bo(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===U.date&&n===U.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class ms extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(yo(a)||yo(i))return ie;const o=bo(a.value,i.value);return o.valid?((go(a)||go(i))&&t.dirty(),{status:t.value,value:o.data}):(B(n,{code:Z.invalid_intersection_types}),ie)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ms.create=(r,e,t)=>new ms({left:r,right:e,typeName:H.ZodIntersection,...ue(t)});let Br=class Qu extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==U.array)return B(n,{code:Z.invalid_type,expected:U.array,received:n.parsedType}),ie;if(n.data.length<this._def.items.length)return B(n,{code:Z.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ie;!this._def.rest&&n.data.length>this._def.items.length&&(B(n,{code:Z.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new Ht(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>ct.mergeArray(t,a)):ct.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Qu({...this._def,rest:e})}};Br.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Br({items:r,typeName:H.ZodTuple,rest:null,...ue(e)})};let el=class _o extends he{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==U.object)return B(n,{code:Z.invalid_type,expected:U.object,received:n.parsedType}),ie;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Ht(n,o,n.path,o)),value:i._parse(new Ht(n,n.data[o],n.path,o))});return n.common.async?ct.mergeObjectAsync(t,s):ct.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof he?new _o({keyType:e,valueType:t,typeName:H.ZodRecord,...ue(n)}):new _o({keyType:zn.create(),valueType:e,typeName:H.ZodRecord,...ue(t)})}},Va=class extends he{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==U.map)return B(n,{code:Z.invalid_type,expected:U.map,received:n.parsedType}),ie;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new Ht(n,o,n.path,[l,"key"])),value:a._parse(new Ht(n,c,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,m=await c.value;if(l.status==="aborted"||m.status==="aborted")return ie;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,m=c.value;if(l.status==="aborted"||m.status==="aborted")return ie;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}}}};Va.create=(r,e,t)=>new Va({valueType:e,keyType:r,typeName:H.ZodMap,...ue(t)});class ln extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==U.set)return B(n,{code:Z.invalid_type,expected:U.set,received:n.parsedType}),ie;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(B(n,{code:Z.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(B(n,{code:Z.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const m of c){if(m.status==="aborted")return ie;m.status==="dirty"&&t.dirty(),l.add(m.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Ht(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new ln({...this._def,minSize:{value:e,message:F.toString(t)}})}max(e,t){return new ln({...this._def,maxSize:{value:e,message:F.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}ln.create=(r,e)=>new ln({valueType:r,minSize:null,maxSize:null,typeName:H.ZodSet,...ue(e)});let tl=class ya extends he{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==U.function)return B(t,{code:Z.invalid_type,expected:U.function,received:t.parsedType}),ie;function n(o,c){return Ua({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ma(),is].filter(l=>!!l),issueData:{code:Z.invalid_arguments,argumentsError:c}})}function s(o,c){return Ua({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ma(),is].filter(l=>!!l),issueData:{code:Z.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Mn){const o=this;return vt(async function(...c){const l=new Rt([]),m=await o._def.args.parseAsync(c,a).catch(J=>{throw l.addIssue(n(c,J)),l}),T=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(T,a).catch(J=>{throw l.addIssue(s(T,J)),l})})}else{const o=this;return vt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Rt([n(c,l.error)]);const m=Reflect.apply(i,this,l.data),T=o._def.returns.safeParse(m,a);if(!T.success)throw new Rt([s(m,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ya({...this._def,args:Br.create(e).rest(sn.create())})}returns(e){return new ya({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ya({args:e||Br.create([]).rest(sn.create()),returns:t||sn.create(),typeName:H.ZodFunction,...ue(n)})}},ys=class extends he{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ys.create=(r,e)=>new ys({getter:r,typeName:H.ZodLazy,...ue(e)});let gs=class extends he{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return B(t,{received:t.data,code:Z.invalid_literal,expected:this._def.value}),ie}return{status:"valid",value:e.data}}get value(){return this._def.value}};gs.create=(r,e)=>new gs({value:r,typeName:H.ZodLiteral,...ue(e)});function rl(r,e){return new Vr({values:r,typeName:H.ZodEnum,...ue(e)})}class Vr extends he{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{expected:_e.joinValues(n),received:t.parsedType,code:Z.invalid_type}),ie}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return B(t,{received:t.data,code:Z.invalid_enum_value,options:n}),ie}return vt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Vr.create(e)}exclude(e){return Vr.create(this.options.filter(t=>!e.includes(t)))}}Vr.create=rl;let vs=class extends he{_parse(e){const t=_e.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==U.string&&n.parsedType!==U.number){const s=_e.objectValues(t);return B(n,{expected:_e.joinValues(s),received:n.parsedType,code:Z.invalid_type}),ie}if(t.indexOf(e.data)===-1){const s=_e.objectValues(t);return B(n,{received:n.data,code:Z.invalid_enum_value,options:s}),ie}return vt(e.data)}get enum(){return this._def.values}};vs.create=(r,e)=>new vs({values:r,typeName:H.ZodNativeEnum,...ue(e)});let Mn=class extends he{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==U.promise&&t.common.async===!1)return B(t,{code:Z.invalid_type,expected:U.promise,received:t.parsedType}),ie;const n=t.parsedType===U.promise?t.data:Promise.resolve(t.data);return vt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Mn.create=(r,e)=>new Mn({type:r,typeName:H.ZodPromise,...ue(e)});let Lt=class extends he{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===H.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{B(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ie:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ie:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!os(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>os(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);_e.assertNever(s)}};Lt.create=(r,e,t)=>new Lt({schema:r,typeName:H.ZodEffects,effect:e,...ue(t)});Lt.createWithPreprocess=(r,e,t)=>new Lt({schema:e,effect:{type:"preprocess",transform:r},typeName:H.ZodEffects,...ue(t)});let Tr=class extends he{_parse(e){return this._getType(e)===U.undefined?vt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};Tr.create=(r,e)=>new Tr({innerType:r,typeName:H.ZodOptional,...ue(e)});let dn=class extends he{_parse(e){return this._getType(e)===U.null?vt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};dn.create=(r,e)=>new dn({innerType:r,typeName:H.ZodNullable,...ue(e)});let ws=class extends he{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===U.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};ws.create=(r,e)=>new ws({innerType:r,typeName:H.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ue(e)});let qa=class extends he{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Da(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Rt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Rt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};qa.create=(r,e)=>new qa({innerType:r,typeName:H.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ue(e)});let Ka=class extends he{_parse(e){if(this._getType(e)!==U.nan){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:U.nan,received:t.parsedType}),ie}return{status:"valid",value:e.data}}};Ka.create=r=>new Ka({typeName:H.ZodNaN,...ue(r)});const Ip=Symbol("zod_brand");let nl=class extends he{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},Wo=class sl extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ie:s.status==="dirty"?(t.dirty(),Ju(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ie:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new sl({in:e,out:t,typeName:H.ZodPipeline})}},Fa=class extends he{_parse(e){const t=this._def.innerType._parse(e);return os(t)&&(t.value=Object.freeze(t.value)),t}};Fa.create=(r,e)=>new Fa({innerType:r,typeName:H.ZodReadonly,...ue(e)});const al=(r,e={},t)=>r?Pn.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...l,fatal:c})}}):Pn.create(),Zp={object:At.lazycreate};var H;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(H||(H={}));const $p=(r,e={message:`Input not instance of ${r.name}`})=>al(t=>t instanceof r,e),il=zn.create,ol=cs.create,Cp=Ka.create,jp=us.create,cl=ls.create,Rp=ds.create,zp=La.create,Pp=hs.create,Mp=ps.create,Up=Pn.create,Dp=sn.create,Lp=Ar.create,Bp=Ba.create,Vp=un.create,qp=At.create,Kp=At.strictCreate,Fp=fs.create,Wp=Hu.create,Yp=ms.create,Jp=Br.create,Gp=el.create,Hp=Va.create,Xp=ln.create,Qp=tl.create,ef=ys.create,tf=gs.create,rf=Vr.create,nf=vs.create,sf=Mn.create,Yc=Lt.create,af=Tr.create,of=dn.create,cf=Lt.createWithPreprocess,uf=Wo.create,lf=()=>il().optional(),df=()=>ol().optional(),hf=()=>cl().optional(),pf={string:r=>zn.create({...r,coerce:!0}),number:r=>cs.create({...r,coerce:!0}),boolean:r=>ls.create({...r,coerce:!0}),bigint:r=>us.create({...r,coerce:!0}),date:r=>ds.create({...r,coerce:!0})},ff=ie;var S=Object.freeze({__proto__:null,defaultErrorMap:is,setErrorMap:gp,getErrorMap:Ma,makeIssue:Ua,EMPTY_PATH:vp,addIssueToContext:B,ParseStatus:ct,INVALID:ie,DIRTY:Ju,OK:vt,isAborted:yo,isDirty:go,isValid:os,isAsync:Da,get util(){return _e},get objectUtil(){return mo},ZodParsedType:U,getParsedType:Rr,ZodType:he,ZodString:zn,ZodNumber:cs,ZodBigInt:us,ZodBoolean:ls,ZodDate:ds,ZodSymbol:La,ZodUndefined:hs,ZodNull:ps,ZodAny:Pn,ZodUnknown:sn,ZodNever:Ar,ZodVoid:Ba,ZodArray:un,ZodObject:At,ZodUnion:fs,ZodDiscriminatedUnion:Hu,ZodIntersection:ms,ZodTuple:Br,ZodRecord:el,ZodMap:Va,ZodSet:ln,ZodFunction:tl,ZodLazy:ys,ZodLiteral:gs,ZodEnum:Vr,ZodNativeEnum:vs,ZodPromise:Mn,ZodEffects:Lt,ZodTransformer:Lt,ZodOptional:Tr,ZodNullable:dn,ZodDefault:ws,ZodCatch:qa,ZodNaN:Ka,BRAND:Ip,ZodBranded:nl,ZodPipeline:Wo,ZodReadonly:Fa,custom:al,Schema:he,ZodSchema:he,late:Zp,get ZodFirstPartyTypeKind(){return H},coerce:pf,any:Up,array:Vp,bigint:jp,boolean:cl,date:Rp,discriminatedUnion:Wp,effect:Yc,enum:rf,function:Qp,instanceof:$p,intersection:Yp,lazy:ef,literal:tf,map:Hp,nan:Cp,nativeEnum:nf,never:Lp,null:Mp,nullable:of,number:ol,object:qp,oboolean:hf,onumber:df,optional:af,ostring:lf,pipeline:uf,preprocess:cf,promise:sf,record:Gp,set:Xp,strictObject:Kp,string:il,symbol:zp,transformer:Yc,tuple:Jp,undefined:Pp,union:Fp,unknown:Dp,void:Bp,NEVER:ff,ZodIssueCode:Z,quotelessJson:yp,ZodError:Rt});const Yo=S.tuple([S.number(),S.number()]),ul=S.object({width:S.number(),height:S.number()}),mf=S.object({signedWidth:S.number(),signedHeight:S.number()}),yf=["width","height"];S.enum(yf);const gf=["start","center","end"],vf=["signedWidth","signedHeight"];S.enum(vf);const Wa=S.object({x:S.number(),y:S.number()}),wf=S.object({clientX:S.number(),clientY:S.number()}),bf=["x","y"],ll=S.enum(bf),dl=["top","right","bottom","left"];S.enum(dl);const _f=["left","right"],hl=S.enum(_f),kf=["top","bottom"],pl=S.enum(kf),fl=["center"],Jc=S.enum(fl),Of=[...dl,...fl],ml=S.enum(Of);S.enum(gf);const Tf=["first","last"];S.enum(Tf);const xf=S.object({lower:S.number(),upper:S.number()});S.union([xf,Yo]);S.union([ll,ml]);S.union([ll,ml,S.instanceof(String)]);const ss=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),Sf(t)},Sf=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var It=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},me={},_i={};Object.defineProperty(_i,"__esModule",{value:!0});function Nf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}_i.default=Nf;var ki={};Object.defineProperty(ki,"__esModule",{value:!0});function Ef(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}ki.default=Ef;var Oi={};Object.defineProperty(Oi,"__esModule",{value:!0});function Af(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}Oi.default=Af;var Jo={};Object.defineProperty(Jo,"__esModule",{value:!0});function If(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Jo.default=If;var Go={};Object.defineProperty(Go,"__esModule",{value:!0});function Zf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}Go.default=Zf;var Ho={};Object.defineProperty(Ho,"__esModule",{value:!0});function $f(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}Ho.default=$f;var Xo={};Object.defineProperty(Xo,"__esModule",{value:!0});function Cf(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,s){return n+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}Xo.default=Cf;var Qo={};Object.defineProperty(Qo,"__esModule",{value:!0});function jf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,s){return t+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}Qo.default=jf;var Ti={};Object.defineProperty(Ti,"__esModule",{value:!0});function Rf(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}Ti.default=Rf;var ec={},bn={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(bn);var zf=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(ec,"__esModule",{value:!0});var ar=bn;function ga(r,e){if(e===void 0&&(e=ar.DefaultOption),!ar.isValidObject(r))return null;e=ar.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toLowerCase();e.recursive&&(ar.isValidObject(s)?ar.belongToTypes(s,e.keepTypesOnRecursion)||(s=ga(s,e)):e.recursiveInArray&&ar.isArrayObject(s)&&(s=zf(s).map(function(i){var o=i;if(ar.isValidObject(i))ar.belongToTypes(o,e.keepTypesOnRecursion)||(o=ga(i,e));else if(ar.isArrayObject(i)){var c=ga({key:i},e);o=c.key}return o}))),t[a]=s}),t}ec.default=ga;var tc={},Pf=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(tc,"__esModule",{value:!0});var ir=bn;function va(r,e){if(e===void 0&&(e=ir.DefaultOption),!ir.isValidObject(r))return null;e=ir.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toUpperCase();e.recursive&&(ir.isValidObject(s)?ir.belongToTypes(s,e.keepTypesOnRecursion)||(s=va(s,e)):e.recursiveInArray&&ir.isArrayObject(s)&&(s=Pf(s).map(function(i){var o=i;if(ir.isValidObject(i))ir.belongToTypes(o,e.keepTypesOnRecursion)||(o=va(i,e));else if(ir.isArrayObject(i)){var c=va({key:i},e);o=c.key}return o}))),t[a]=s}),t}tc.default=va;var rc={},Mf=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(rc,"__esModule",{value:!0});var or=bn,Uf=_i;function wa(r,e){if(e===void 0&&(e=or.DefaultOption),!or.isValidObject(r))return null;e=or.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Uf.default(n);e.recursive&&(or.isValidObject(s)?or.belongToTypes(s,e.keepTypesOnRecursion)||(s=wa(s,e)):e.recursiveInArray&&or.isArrayObject(s)&&(s=Mf(s).map(function(i){var o=i;if(or.isValidObject(i))or.belongToTypes(o,e.keepTypesOnRecursion)||(o=wa(i,e));else if(or.isArrayObject(i)){var c=wa({key:i},e);o=c.key}return o}))),t[a]=s}),t}rc.default=wa;var nc={},Df=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(nc,"__esModule",{value:!0});var cr=bn,Lf=ki;function ba(r,e){if(e===void 0&&(e=cr.DefaultOption),!cr.isValidObject(r))return null;e=cr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Lf.default(n);e.recursive&&(cr.isValidObject(s)?cr.belongToTypes(s,e.keepTypesOnRecursion)||(s=ba(s,e)):e.recursiveInArray&&cr.isArrayObject(s)&&(s=Df(s).map(function(i){var o=i;if(cr.isValidObject(i))cr.belongToTypes(o,e.keepTypesOnRecursion)||(o=ba(i,e));else if(cr.isArrayObject(i)){var c=ba({key:i},e);o=c.key}return o}))),t[a]=s}),t}nc.default=ba;var sc={},Bf=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(sc,"__esModule",{value:!0});var ur=bn,Vf=Oi;function _a(r,e){if(e===void 0&&(e=ur.DefaultOption),!ur.isValidObject(r))return null;e=ur.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Vf.default(n);e.recursive&&(ur.isValidObject(s)?ur.belongToTypes(s,e.keepTypesOnRecursion)||(s=_a(s,e)):e.recursiveInArray&&ur.isArrayObject(s)&&(s=Bf(s).map(function(i){var o=i;if(ur.isValidObject(i))ur.belongToTypes(o,e.keepTypesOnRecursion)||(o=_a(i,e));else if(ur.isArrayObject(i)){var c=_a({key:i},e);o=c.key}return o}))),t[a]=s}),t}sc.default=_a;var ac={},qf=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(ac,"__esModule",{value:!0});var lr=bn,Kf=Ti;function ka(r,e){if(e===void 0&&(e=lr.DefaultOption),!lr.isValidObject(r))return null;e=lr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Kf.default(n);e.recursive&&(lr.isValidObject(s)?lr.belongToTypes(s,e.keepTypesOnRecursion)||(s=ka(s,e)):e.recursiveInArray&&lr.isArrayObject(s)&&(s=qf(s).map(function(i){var o=i;if(lr.isValidObject(i))lr.belongToTypes(o,e.keepTypesOnRecursion)||(o=ka(i,e));else if(lr.isArrayObject(i)){var c=ka({key:i},e);o=c.key}return o}))),t[a]=s}),t}ac.default=ka;Object.defineProperty(me,"__esModule",{value:!0});me.kebabKeys=me.pascalKeys=me.snakeKeys=me.camelKeys=me.upperKeys=me.lowerKeys=me.toLowerCase=me.toUpperCase=me.toKebabCase=me.toHeaderCase=me.toSentenceCase=me.toTextCase=me.toPathCase=me.toDotCase=me.toPascalCase=me.toSnakeCase=me.toCamelCase=void 0;var yl=_i;me.toCamelCase=yl.default;var gl=ki;me.toSnakeCase=gl.default;var vl=Oi;me.toPascalCase=vl.default;var wl=Jo;me.toDotCase=wl.default;var bl=Go;me.toPathCase=bl.default;var _l=Ho;me.toTextCase=_l.default;var kl=Xo;me.toSentenceCase=kl.default;var Ol=Qo;me.toHeaderCase=Ol.default;var Tl=Ti;me.toKebabCase=Tl.default;var xl=ec;me.lowerKeys=xl.default;var Sl=tc;me.upperKeys=Sl.default;var Nl=rc;me.camelKeys=Nl.default;var El=nc;me.snakeKeys=El.default;var Al=sc;me.pascalKeys=Al.default;var Il=ac;me.kebabKeys=Il.default;var Zl=function(r){return String(r||"").toLowerCase()};me.toLowerCase=Zl;var $l=function(r){return String(r||"").toUpperCase()};me.toUpperCase=$l;var Ff={toCamelCase:yl.default,toSnakeCase:gl.default,toPascalCase:vl.default,toDotCase:wl.default,toPathCase:bl.default,toTextCase:_l.default,toSentenceCase:kl.default,toHeaderCase:Ol.default,toKebabCase:Tl.default,toUpperCase:$l,toLowerCase:Zl,lowerKeys:xl.default,upperKeys:Sl.default,camelKeys:Nl.default,snakeKeys:El.default,pascalKeys:Al.default,kebabKeys:Il.default};me.default=Ff;var Cl=me;const jl={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Wf=r=>Cl.snakeKeys(r,jl),Yf=r=>Cl.camelKeys(r,jl);var Un;(r=>{r.toSnake=Wf,r.toCamel=Yf,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Un||(Un={}));S.object({x:hl.or(Jc),y:pl.or(Jc)});const Jf=S.object({x:hl,y:pl}),Gf=Object.freeze({x:"left",y:"top"}),Hf=(r,e)=>r.x===e.x&&r.y===e.y,Gc=S.union([S.number(),Wa,Yo,ul,mf,wf]),Xf=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},Hc={x:0,y:0},oa=S.union([S.number(),S.string()]);S.object({top:oa,left:oa,width:oa,height:oa});S.object({left:S.number(),top:S.number(),right:S.number(),bottom:S.number()});S.object({one:Wa,two:Wa,root:Jf});const ic=(r,e,t=0,n=0,s)=>{const a={one:{...Hc},two:{...Hc},root:s??Gf};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:s??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},Fi=r=>{const e=ic(r);return{lower:e.one.x,upper:e.two.x}},Wi=r=>{const e=ic(r);return{lower:e.one.y,upper:e.two.y}},Qf=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,em=S.object({signedWidth:S.number(),signedHeight:S.number()});S.union([ul,em,Wa,Yo]);const tm=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);S.object({offset:Gc,scale:Gc});const rm=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],nm=r=>(e,t,n,s)=>[e,s?n/r:n*r],sm=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:s,upper:a}=e,{lower:i,upper:o}=r,c=a-s,l=o-i;if(t==="dimension")return[r,n*(l/c)];const m=(n-s)*(l/c)+i;return[r,m]},am=r=>(e,t,n)=>[r,n],im=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:s}=r;return[r,s-(t-n)]},om=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=tm(n,s,a),[e,n]},ko=class es{constructor(){x(this,"ops",[]),x(this,"currBounds",null),x(this,"currType",null),x(this,"reversed",!1),this.ops=[]}static translate(e){return new es().translate(e)}static magnify(e){return new es().magnify(e)}static scale(e,t){return new es().scale(e,t)}translate(e){const t=this.new(),n=rm(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=nm(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=ss(e,t),s=this.new(),a=sm(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=ss(e,t),s=this.new(),a=om(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=ss(e,t),s=this.new(),a=am(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=im();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new es;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,s],a)=>a(n,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||t.some(([i,o])=>s>=i&&s<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>s);a!==-1&&t.push([s,a])}),t.forEach(([n,s])=>{const a=e.ops.slice(n,s);a.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...a)}),e.reversed=!e.reversed,e}};x(ko,"IDENTITY",new ko);let Xc=ko;const Qc=class gr{constructor(e=new Xc,t=new Xc,n=null){x(this,"x"),x(this,"y"),x(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new gr().translate(e,t)}static translateX(e){return new gr().translateX(e)}static translateY(e){return new gr().translateY(e)}static clamp(e){return new gr().clamp(e)}static magnify(e){return new gr().magnify(e)}static scale(e){return new gr().scale(e)}static reBound(e){return new gr().reBound(e)}translate(e,t){const n=Xf(e,t),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(Qf(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Hf(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Fi(e)),t.y=t.y.scale(Wi(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Fi(e)),t.y=this.y.reBound(Wi(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Fi(e)),t.y=this.y.clamp(Wi(e)),t}copy(){const e=new gr;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return ic(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};x(Qc,"IDENTITY",new Qc);const Rl=(r,e)=>{const t=new Ae(e);if(![ze.DAY,ze.HOUR,ze.MINUTE,ze.SECOND,ze.MILLISECOND,ze.MICROSECOND,ze.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof Ae?new Ae(n):new ze(n)},Ie=class se{constructor(e,t="UTC"){if(x(this,"value"),x(this,"encodeValue",!0),e==null)this.value=se.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*se.MILLISECOND.valueOf();else if(typeof e=="string")this.value=se.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=se.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=se.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=se.MAX:e=se.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const s=new Date(e,t-1,n,0,0,0,0);return new se(BigInt(s.getTime())*se.MILLISECOND.valueOf()).truncate(se.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,s,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let c=se.hours(parseInt(n??"00",10)).add(se.minutes(parseInt(s??"00",10))).add(se.seconds(parseInt(i??"00",10))).add(se.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(se.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return se.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new se(BigInt(n.getTime())*se.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(se.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(e="UTC"){const t=this.date(),n=t.toLocaleString("default",{month:"short"}),s=t.toLocaleString("default",{day:"numeric"});return`${n} ${s}`}static get utcOffset(){return new ze(BigInt(new Date().getTimezoneOffset())*se.MINUTE.valueOf())}static since(e){return new se().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new se(e).valueOf()}span(e){return this.range(e).span}range(e){return new Et(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new se(e).valueOf()}afterEq(e){return this.valueOf()>=new se(e).valueOf()}before(e){return this.valueOf()<new se(e).valueOf()}beforeEq(e){return this.valueOf()<=new se(e).valueOf()}add(e){return new se(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new se(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/se.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Rl(this,e)}get isToday(){return this.truncate(ze.DAY).equals(se.now().truncate(ze.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new se(new Date)}static max(...e){let t=se.MIN;for(const n of e){const s=new se(n);s.after(t)&&(t=s)}return t}static min(...e){let t=se.MAX;for(const n of e){const s=new se(n);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new se(e)}static microseconds(e){return se.nanoseconds(e*1e3)}static milliseconds(e){return se.microseconds(e*1e3)}static seconds(e){return se.milliseconds(e*1e3)}static minutes(e){return se.seconds(e*60)}static hours(e){return se.minutes(e*60)}static days(e){return se.hours(e*24)}};x(Ie,"NANOSECOND",Ie.nanoseconds(1)),x(Ie,"MICROSECOND",Ie.microseconds(1)),x(Ie,"MILLISECOND",Ie.milliseconds(1)),x(Ie,"SECOND",Ie.seconds(1)),x(Ie,"MINUTE",Ie.minutes(1)),x(Ie,"HOUR",Ie.hours(1)),x(Ie,"DAY",Ie.days(1)),x(Ie,"MAX",new Ie((1n<<63n)-1n)),x(Ie,"MIN",new Ie(0)),x(Ie,"ZERO",new Ie(0)),x(Ie,"z",S.union([S.object({value:S.bigint()}).transform(r=>new Ie(r.value)),S.string().transform(r=>new Ie(BigInt(r))),S.instanceof(Number).transform(r=>new Ie(r)),S.number().transform(r=>new Ie(r)),S.instanceof(Ie)]));let Ae=Ie;const Ze=class Te{constructor(e){x(this,"value"),x(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new Te(e).valueOf()}greaterThan(e){return this.valueOf()>new Te(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new Te(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new Te(e).valueOf()}remainder(e){return Rl(this,e)}truncate(e){return new Te(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(Te.DAY),t=this.truncate(Te.HOUR),n=this.truncate(Te.MINUTE),s=this.truncate(Te.SECOND),a=this.truncate(Te.MILLISECOND),i=this.truncate(Te.MICROSECOND),o=this.truncate(Te.NANOSECOND),c=e,l=t.sub(e),m=n.sub(t),T=s.sub(n),J=a.sub(s),ee=i.sub(a),Ne=o.sub(i);let te="";return c.isZero||(te+=`${c.days}d `),l.isZero||(te+=`${l.hours}h `),m.isZero||(te+=`${m.minutes}m `),T.isZero||(te+=`${T.seconds}s `),J.isZero||(te+=`${J.milliseconds}ms `),ee.isZero||(te+=`${ee.microseconds}µs `),Ne.isZero||(te+=`${Ne.nanoseconds}ns`),te.trim()}get days(){return Number(this.valueOf()/Te.DAY.valueOf())}get hours(){return Number(this.valueOf()/Te.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/Te.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/Te.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/Te.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/Te.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new Te(e).valueOf()}add(e){return new Te(this.valueOf()+new Te(e).valueOf())}sub(e){return new Te(this.valueOf()-new Te(e).valueOf())}static nanoseconds(e=1){return new Te(e)}static microseconds(e=1){return Te.nanoseconds(e*1e3)}static milliseconds(e=1){return Te.microseconds(e*1e3)}static seconds(e=1){return Te.milliseconds(e*1e3)}static minutes(e){return Te.seconds(e.valueOf()*60)}static hours(e){return Te.minutes(e*60)}static days(e){return Te.hours(e*24)}};x(Ze,"NANOSECOND",Ze.nanoseconds(1)),x(Ze,"MICROSECOND",Ze.microseconds(1)),x(Ze,"MILLISECOND",Ze.milliseconds(1)),x(Ze,"SECOND",Ze.seconds(1)),x(Ze,"MINUTE",Ze.minutes(1)),x(Ze,"HOUR",Ze.hours(1)),x(Ze,"DAY",Ze.days(1)),x(Ze,"MAX",new Ze((1n<<63n)-1n)),x(Ze,"MIN",new Ze(0)),x(Ze,"ZERO",new Ze(0)),x(Ze,"z",S.union([S.object({value:S.bigint()}).transform(r=>new Ze(r.value)),S.string().transform(r=>new Ze(BigInt(r))),S.instanceof(Number).transform(r=>new Ze(r)),S.number().transform(r=>new Ze(r)),S.instanceof(Ze)]));let ze=Ze;const ts=class Oa extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Oa(e).valueOf()}get period(){return ze.seconds(1/this.valueOf())}sampleCount(e){return new ze(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ot(t).valueOf()}span(e){return ze.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Oa(e)}static khz(e){return Oa.hz(e*1e3)}};x(ts,"z",S.union([S.number().transform(r=>new ts(r)),S.instanceof(Number).transform(r=>new ts(r)),S.instanceof(ts)]));let xi=ts;const rt=class extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}length(e){return e.valueOf()/this.valueOf()}size(e){return new Ya(e*this.valueOf())}};x(rt,"UNKNOWN",new rt(0)),x(rt,"BIT128",new rt(16)),x(rt,"BIT64",new rt(8)),x(rt,"BIT32",new rt(4)),x(rt,"BIT16",new rt(2)),x(rt,"BIT8",new rt(1)),x(rt,"z",S.union([S.number().transform(r=>new rt(r)),S.instanceof(Number).transform(r=>new rt(r)),S.instanceof(rt)]));let ot=rt;const Kt=class Ta{constructor(e,t){x(this,"start"),x(this,"end"),this.start=new Ae(e),this.end=new Ae(t)}get span(){return new ze(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new Ta(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof Ta?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Ta(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};x(Kt,"MAX",new Kt(Ae.MIN,Ae.MAX)),x(Kt,"MIN",new Kt(Ae.MAX,Ae.MIN)),x(Kt,"ZERO",new Kt(Ae.ZERO,Ae.ZERO)),x(Kt,"z",S.union([S.object({start:Ae.z,end:Ae.z}).transform(r=>new Kt(r.start,r.end)),S.instanceof(Kt)]));let Et=Kt;const E=class vr extends String{constructor(e){if(e instanceof vr||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=vr.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(vr.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=vr.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(vr.JSON)||this.equals(vr.STRING)}get density(){const e=vr.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return vr.BIG_INT_TYPES.some(e=>e.equals(this))}};x(E,"UNKNOWN",new E("unknown")),x(E,"FLOAT64",new E("float64")),x(E,"FLOAT32",new E("float32")),x(E,"INT64",new E("int64")),x(E,"INT32",new E("int32")),x(E,"INT16",new E("int16")),x(E,"INT8",new E("int8")),x(E,"UINT64",new E("uint64")),x(E,"UINT32",new E("uint32")),x(E,"UINT16",new E("uint16")),x(E,"UINT8",new E("uint8")),x(E,"BOOLEAN",E.UINT8),x(E,"TIMESTAMP",new E("timestamp")),x(E,"UUID",new E("uuid")),x(E,"STRING",new E("string")),x(E,"JSON",new E("json")),x(E,"ARRAY_CONSTRUCTORS",new Map([[E.UINT8.toString(),Uint8Array],[E.UINT16.toString(),Uint16Array],[E.UINT32.toString(),Uint32Array],[E.UINT64.toString(),BigUint64Array],[E.FLOAT32.toString(),Float32Array],[E.FLOAT64.toString(),Float64Array],[E.INT8.toString(),Int8Array],[E.INT16.toString(),Int16Array],[E.INT32.toString(),Int32Array],[E.INT64.toString(),BigInt64Array],[E.TIMESTAMP.toString(),BigInt64Array],[E.STRING.toString(),Uint8Array],[E.JSON.toString(),Uint8Array],[E.UUID.toString(),Uint8Array]])),x(E,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,E.UINT8],[Uint16Array.name,E.UINT16],[Uint32Array.name,E.UINT32],[BigUint64Array.name,E.UINT64],[Float32Array.name,E.FLOAT32],[Float64Array.name,E.FLOAT64],[Int8Array.name,E.INT8],[Int16Array.name,E.INT16],[Int32Array.name,E.INT32],[BigInt64Array.name,E.INT64]])),x(E,"DENSITIES",new Map([[E.UINT8.toString(),ot.BIT8],[E.UINT16.toString(),ot.BIT16],[E.UINT32.toString(),ot.BIT32],[E.UINT64.toString(),ot.BIT64],[E.FLOAT32.toString(),ot.BIT32],[E.FLOAT64.toString(),ot.BIT64],[E.INT8.toString(),ot.BIT8],[E.INT16.toString(),ot.BIT16],[E.INT32.toString(),ot.BIT32],[E.INT64.toString(),ot.BIT64],[E.TIMESTAMP.toString(),ot.BIT64],[E.STRING.toString(),ot.UNKNOWN],[E.JSON.toString(),ot.UNKNOWN],[E.UUID.toString(),ot.BIT128]])),x(E,"ALL",[E.UNKNOWN,E.FLOAT64,E.FLOAT32,E.INT64,E.INT32,E.INT16,E.INT8,E.UINT64,E.UINT32,E.UINT16,E.UINT8,E.TIMESTAMP,E.UUID,E.STRING,E.JSON]),x(E,"BIG_INT_TYPES",[E.INT64,E.UINT64,E.TIMESTAMP]),x(E,"z",S.union([S.string().transform(r=>new E(r)),S.instanceof(E)]));let Ee=E;const at=class Fe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return Fe.bytes(this.valueOf()+e.valueOf())}sub(e){return Fe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new Fe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return Fe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/Fe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/Fe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/Fe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/Fe.TERABYTE.valueOf()}toString(){const e=this.truncate(Fe.TERABYTE),t=this.truncate(Fe.GIGABYTE),n=this.truncate(Fe.MEGABYTE),s=this.truncate(Fe.KILOBYTE),a=this.truncate(Fe.BYTE),i=e,o=t.sub(e),c=n.sub(t),l=s.sub(n),m=a.sub(s);let T="";return i.isZero||(T+=`${i.terabytes}TB `),o.isZero||(T+=`${o.gigabytes}GB `),c.isZero||(T+=`${c.megabytes}MB `),l.isZero||(T+=`${l.kilobytes}KB `),(!m.isZero||T==="")&&(T+=`${m.valueOf()}B`),T.trim()}static bytes(e=1){return new Fe(e)}static kilobytes(e=1){return Fe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return Fe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return Fe.megabytes(e.valueOf()*1e3)}static terabytes(e){return Fe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};x(at,"BYTE",new at(1)),x(at,"KILOBYTE",at.kilobytes(1)),x(at,"MEGABYTE",at.megabytes(1)),x(at,"GIGABYTE",at.gigabytes(1)),x(at,"TERABYTE",at.terabytes(1)),x(at,"ZERO",new at(0)),x(at,"z",S.union([S.number().transform(r=>new at(r)),S.instanceof(at)]));let Ya=at;S.union([S.instanceof(Uint8Array),S.instanceof(Uint16Array),S.instanceof(Uint32Array),S.instanceof(BigUint64Array),S.instanceof(Float32Array),S.instanceof(Float64Array),S.instanceof(Int8Array),S.instanceof(Int16Array),S.instanceof(Int32Array),S.instanceof(BigInt64Array)]);const zl=r=>{const e=typeof r;return e==="string"||e==="number"||e==="boolean"||e==="bigint"||r instanceof Ae||r instanceof ze||r instanceof Date},cm=(r,e,t,n=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!r.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(n):rs(t,-n),um=r=>r==null?!1:Array.isArray(r)||r instanceof ArrayBuffer||ArrayBuffer.isView(r)&&!(r instanceof DataView)||r instanceof Zn?!0:zl(r),tn=-1;let Zn=class wr{constructor(e){x(this,"key",""),x(this,"dataType"),x(this,"sampleOffset"),x(this,"gl"),x(this,"_data"),x(this,"_timeRange"),x(this,"alignment",0),x(this,"_cachedMin"),x(this,"_cachedMax"),x(this,"writePos",tn),x(this,"_refCount",0),x(this,"_cachedLength"),um(e)&&(e={data:e});const{dataType:t,timeRange:n,sampleOffset:s=0,glBufferUsage:a="static",alignment:i=0,key:o=hp()}=e,{data:c}=e;if(c instanceof wr){this.key=c.key,this.dataType=c.dataType,this.sampleOffset=c.sampleOffset,this.gl=c.gl,this._data=c._data,this._timeRange=c._timeRange,this.alignment=c.alignment,this._cachedMin=c._cachedMin,this._cachedMax=c._cachedMax,this.writePos=c.writePos,this._refCount=c._refCount,this._cachedLength=c._cachedLength;return}const l=zl(c),m=Array.isArray(c);if(t!=null)this.dataType=new Ee(t);else{if(c instanceof ArrayBuffer)throw new Error("cannot infer data type from an ArrayBuffer instance when constructing a Series. Please provide a data type.");if(m||l){let T=c;if(!l){if(c.length===0)throw new Error("cannot infer data type from a zero length JS array when constructing a Series. Please provide a data type.");T=c[0]}if(typeof T=="string")this.dataType=Ee.STRING;else if(typeof T=="number")this.dataType=Ee.FLOAT64;else if(typeof T=="bigint")this.dataType=Ee.INT64;else if(typeof T=="boolean")this.dataType=Ee.BOOLEAN;else if(T instanceof Ae||T instanceof Date||T instanceof Ae)this.dataType=Ee.TIMESTAMP;else if(typeof T=="object")this.dataType=Ee.JSON;else throw new Error(`cannot infer data type of ${typeof T} when constructing a Series from a JS array`)}else this.dataType=new Ee(c)}if(!m&&!l)this._data=c;else{let T=l?[c]:c;const J=T[0];(J instanceof Ae||J instanceof Date||J instanceof ze)&&(T=T.map(ee=>new Ae(ee).valueOf())),this.dataType.equals(Ee.STRING)?(this._cachedLength=T.length,this._data=new TextEncoder().encode(T.join(`
2
2
  `)+`
3
- `)):this.dataType.equals(ze.JSON)?(this._cachedLength=T.length,this._data=new TextEncoder().encode(T.map(ee=>JSON.stringify(ee)).join(`
3
+ `)):this.dataType.equals(Ee.JSON)?(this._cachedLength=T.length,this._data=new TextEncoder().encode(T.map(ee=>JSON.stringify(ee)).join(`
4
4
  `)+`
5
- `)):this._data=new this.dataType.Array(T).buffer}this.key=o,this.alignment=i,this.sampleOffset=s??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new ze(t).Array(e),a=new wr({data:s.buffer,dataType:t,...n});return a.writePos=0,a}static generateTimestamps(e,t,n){const s=n.spanRange(t.span(e)),a=new BigInt64Array(e);for(let i=0;i<e;i++)a[i]=BigInt(n.add(t.span(i)).valueOf());return new wr({data:a,dataType:ze.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(e.join(`
5
+ `)):this._data=new this.dataType.Array(T).buffer}this.key=o,this.alignment=i,this.sampleOffset=s??0,this._timeRange=n,this.gl={control:null,buffer:null,prevBuffer:0,bufferUsage:a}}static alloc({capacity:e,dataType:t,...n}){if(e===0)throw new Error("[Series] - cannot allocate an array of length 0");const s=new new Ee(t).Array(e),a=new wr({data:s.buffer,dataType:t,...n});return a.writePos=0,a}static generateTimestamps(e,t,n){const s=n.spanRange(t.span(e)),a=new BigInt64Array(e);for(let i=0;i<e;i++)a[i]=BigInt(n.add(t.span(i)).valueOf());return new wr({data:a,dataType:Ee.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(e.join(`
6
6
  `)+`
7
- `);return new wr({data:n,dataType:ze.STRING,timeRange:t})}static fromJSON(e,t){const n=new TextEncoder().encode(e.map(s=>JSON.stringify(s)).join(`
7
+ `);return new wr({data:n,dataType:Ee.STRING,timeRange:t})}static fromJSON(e,t){const n=new TextEncoder().encode(e.map(s=>JSON.stringify(s)).join(`
8
8
  `)+`
9
- `);return new wr({data:n,dataType:ze.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===rn)return 0;const t=this.capacity-this.writePos,n=t<e.length?e.slice(0,t):e;return this.underlyingData.set(n.data,this.writePos),this.maybeRecomputeMinMax(n),this._cachedLength=void 0,this.writePos+=n.length,n.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===rn?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals(ze.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
10
- `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(ze.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=ze.UUID.density.valueOf(),t=Array(this.length);for(let n=0;n<this.length;n++){const s=this.buffer.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(s),i=>i.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[n]=a}return t}parseJSON(e){if(!this.dataType.equals(ze.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
11
- `).slice(0,-1).map(t=>e.parse(JSON.parse(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Ga(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===rn?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===rn?this.data.length:this.writePos}calculateCachedLength(){let e=0;return this.data.forEach(t=>{t===10&&e++}),this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=nm(this.dataType,e,this.data[s],t);return new wr({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(ze.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),rs(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(ze.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),rs(this._cachedMin,this.sampleOffset))}get bounds(){return ss(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return rs(this.max,-this.min)}at(e,t){e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return rs(n,this.sampleOffset)}binarySearch(e){let t=0,n=this.length-1;const s=up(e);for(;t<=n;){const a=Math.floor((t+n)/2),i=s(this.at(a,!0),e);if(i===0)return a;i<0?t=a+1:n=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(ze.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:s}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==rn){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(s).valueOf(),i=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,i.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=rn}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return ss(this.alignment,this.alignment+this.length)}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}slice(e,t){if(e<=0&&(t==null||t>=this.length))return this;const n=this.data.slice(e,t);return new wr({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+e})}reAlign(e){return new wr({data:this.buffer,dataType:this.dataType,timeRange:$t.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};const rs=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:Number(r)+Number(e),oc=x.record(x.union([x.number(),x.string(),x.symbol()]),x.unknown()),zl=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),am=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";am();const im=["MacOS","Windows","Linux","Docker"];x.enum(im);const om=(r,e)=>{let t=null;return e===0?r:(...n)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>r(...n),e)}},eu=r=>[...new Set(r)],cm=(...r)=>r.map(Pl).join(""),Pl=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),um=r=>r.endsWith("/")?r.slice(0,-1):r;var kn;let lm=(kn=class{constructor({host:r,port:e,protocol:t="",pathPrefix:n=""}){N(this,"protocol"),N(this,"host"),N(this,"port"),N(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=Pl(n)}replace(r){return new kn({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new kn({...this,pathPrefix:cm(this.path,r)})}toString(){return um(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},N(kn,"UNKNOWN",new kn({host:"unknown",port:0})),kn);const Ne=r=>Array.isArray(r)?r:[r];var Oo;try{Oo=new TextDecoder}catch{}var z,St,p=0,Pe={},we,Mr,Tt=0,Yt=0,Xe,xr,kt=[],ge,tu={useRecords:!1,mapsAsObjects:!0};let Ml=class{};const Ul=new Ml;Ul.name="MessagePack 0xC1";var Dr=!1,Dl=2,ru;try{new Function("")}catch{Dl=1/0}let Ll=class To{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=!1&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(z)return Fl(()=>(So(),this?this.unpack(e,t):To.prototype.unpack.call(tu,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(St=t.end||e.length,p=t.start||0):(p=0,St=t>-1?t:e.length),Yt=0,Mr=null,Xe=null,z=e;try{ge=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw z=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof To){if(Pe=this,this.structures)return we=this.structures,la(t);(!we||we.length>0)&&(we=[])}else Pe=tu,(!we||we.length>0)&&(we=[]);return la(t)}unpackMultiple(e,t){let n,s=0;try{Dr=!0;let a=e.length,i=this?this.unpack(e,a):Ei.unpack(e,a);if(t){if(t(i,s,p)===!1)return;for(;p<a;)if(s=p,t(la(),s,p)===!1)return}else{for(n=[i];p<a;)s=p,n.push(la());return n}}catch(a){throw a.lastPosition=s,a.values=n,a}finally{Dr=!1,So()}}_mergeStructures(e,t){e=e||[],Object.isFrozen(e)&&(e=e.map(n=>n.slice(0)));for(let n=0,s=e.length;n<s;n++){let a=e[n];a&&(a.isShared=!0,n>=32&&(a.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let s=e[n],a=t[n];a&&(s&&((e.restoreStructures||(e.restoreStructures=[]))[n]=s),e[n]=a)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function la(r){try{if(!Pe.trusted&&!Dr){let t=we.sharedLength||0;t<we.length&&(we.length=t)}let e;if(Pe.randomAccessStructure&&z[p]<64&&z[p]>=32&&ru?(e=ru(z,p,St,Pe),z=null,!(r&&r.lazy)&&e&&(e=e.toJSON()),p=St):e=Ve(),Xe&&(p=Xe.postBundlePosition,Xe=null),Dr&&(we.restoreStructures=null),p==St)we&&we.restoreStructures&&nu(),we=null,z=null,xr&&(xr=null);else{if(p>St)throw new Error("Unexpected end of MessagePack data");if(!Dr){let t;try{t=JSON.stringify(e,(n,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(n){t="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+t)}}return e}catch(e){throw we&&we.restoreStructures&&nu(),So(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||p>St)&&(e.incomplete=!0),e}}function nu(){for(let r in we.restoreStructures)we[r]=we.restoreStructures[r];we.restoreStructures=null}function Ve(){let r=z[p++];if(r<160)if(r<128){if(r<64)return r;{let e=we[r&63]||Pe.getStructures&&Bl()[r&63];return e?(e.read||(e.read=cc(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,Pe.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=ql();n==="__proto__"&&(n="__proto_"),e[n]=Ve()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Ve(),Ve());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Ve();return Pe.freezeData?Object.freeze(e):e}else if(r<192){let e=r-160;if(Yt>=p)return Mr.slice(p-Tt,(p+=e)-Tt);if(Yt==0&&St<140){let t=e<16?uc(e):Vl(e);if(t!=null)return t}return xo(e)}else{let e;switch(r){case 192:return null;case 193:return Xe?(e=Ve(),e>0?Xe[1].slice(Xe.position1,Xe.position1+=e):Xe[0].slice(Xe.position0,Xe.position0-=e)):Ul;case 194:return!1;case 195:return!0;case 196:if(e=z[p++],e===void 0)throw new Error("Unexpected end of buffer");return Ji(e);case 197:return e=ge.getUint16(p),p+=2,Ji(e);case 198:return e=ge.getUint32(p),p+=4,Ji(e);case 199:return nn(z[p++]);case 200:return e=ge.getUint16(p),p+=2,nn(e);case 201:return e=ge.getUint32(p),p+=4,nn(e);case 202:if(e=ge.getFloat32(p),Pe.useFloat32>2){let t=lc[(z[p]&127)<<1|z[p+1]>>7];return p+=4,(t*e+(e>0?.5:-.5)>>0)/t}return p+=4,e;case 203:return e=ge.getFloat64(p),p+=8,e;case 204:return z[p++];case 205:return e=ge.getUint16(p),p+=2,e;case 206:return e=ge.getUint32(p),p+=4,e;case 207:return Pe.int64AsType==="number"?(e=ge.getUint32(p)*4294967296,e+=ge.getUint32(p+4)):Pe.int64AsType==="string"?e=ge.getBigUint64(p).toString():Pe.int64AsType==="auto"?(e=ge.getBigUint64(p),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ge.getBigUint64(p),p+=8,e;case 208:return ge.getInt8(p++);case 209:return e=ge.getInt16(p),p+=2,e;case 210:return e=ge.getInt32(p),p+=4,e;case 211:return Pe.int64AsType==="number"?(e=ge.getInt32(p)*4294967296,e+=ge.getUint32(p+4)):Pe.int64AsType==="string"?e=ge.getBigInt64(p).toString():Pe.int64AsType==="auto"?(e=ge.getBigInt64(p),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ge.getBigInt64(p),p+=8,e;case 212:if(e=z[p++],e==114)return uu(z[p++]&63);{let t=kt[e];if(t)return t.read?(p++,t.read(Ve())):t.noBuffer?(p++,t()):t(z.subarray(p,++p));throw new Error("Unknown extension "+e)}case 213:return e=z[p],e==114?(p++,uu(z[p++]&63,z[p++])):nn(2);case 214:return nn(4);case 215:return nn(8);case 216:return nn(16);case 217:return e=z[p++],Yt>=p?Mr.slice(p-Tt,(p+=e)-Tt):hm(e);case 218:return e=ge.getUint16(p),p+=2,Yt>=p?Mr.slice(p-Tt,(p+=e)-Tt):pm(e);case 219:return e=ge.getUint32(p),p+=4,Yt>=p?Mr.slice(p-Tt,(p+=e)-Tt):fm(e);case 220:return e=ge.getUint16(p),p+=2,au(e);case 221:return e=ge.getUint32(p),p+=4,au(e);case 222:return e=ge.getUint16(p),p+=2,iu(e);case 223:return e=ge.getUint32(p),p+=4,iu(e);default:if(r>=224)return r-256;if(r===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+r)}}}const dm=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function cc(r,e){function t(){if(t.count++>Dl){let s=r.read=new Function("r","return function(){return "+(Pe.freezeData?"Object.freeze":"")+"({"+r.map(a=>a==="__proto__"?"__proto_:r()":dm.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"})}")(Ve);return r.highByte===0&&(r.read=su(e,r.read)),s()}let n={};for(let s=0,a=r.length;s<a;s++){let i=r[s];i==="__proto__"&&(i="__proto_"),n[i]=Ve()}return Pe.freezeData?Object.freeze(n):n}return t.count=0,r.highByte===0?su(e,t):t}const su=(r,e)=>function(){let t=z[p++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),s=we[n]||Bl()[n];if(!s)throw new Error("Record id is not defined for "+n);return s.read||(s.read=cc(s,r)),s.read()};function Bl(){let r=Fl(()=>(z=null,Pe.getStructures()));return we=Pe._mergeStructures(r,we)}var xo=Hs,hm=Hs,pm=Hs,fm=Hs;function Hs(r){let e;if(r<16&&(e=uc(r)))return e;if(r>64&&Oo)return Oo.decode(z.subarray(p,p+=r));const t=p+r,n=[];for(e="";p<t;){const s=z[p++];if(!(s&128))n.push(s);else if((s&224)===192){const a=z[p++]&63;n.push((s&31)<<6|a)}else if((s&240)===224){const a=z[p++]&63,i=z[p++]&63;n.push((s&31)<<12|a<<6|i)}else if((s&248)===240){const a=z[p++]&63,i=z[p++]&63,o=z[p++]&63;let c=(s&7)<<18|a<<12|i<<6|o;c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c)}else n.push(s);n.length>=4096&&(e+=Ge.apply(String,n),n.length=0)}return n.length>0&&(e+=Ge.apply(String,n)),e}function au(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Ve();return Pe.freezeData?Object.freeze(e):e}function iu(r){if(Pe.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=ql();n==="__proto__"&&(n="__proto_"),e[n]=Ve()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Ve(),Ve());return e}}var Ge=String.fromCharCode;function Vl(r){let e=p,t=new Array(r);for(let n=0;n<r;n++){const s=z[p++];if((s&128)>0){p=e;return}t[n]=s}return Ge.apply(String,t)}function uc(r){if(r<4)if(r<2){if(r===0)return"";{let e=z[p++];if((e&128)>1){p-=1;return}return Ge(e)}}else{let e=z[p++],t=z[p++];if((e&128)>0||(t&128)>0){p-=2;return}if(r<3)return Ge(e,t);let n=z[p++];if((n&128)>0){p-=3;return}return Ge(e,t,n)}else{let e=z[p++],t=z[p++],n=z[p++],s=z[p++];if((e&128)>0||(t&128)>0||(n&128)>0||(s&128)>0){p-=4;return}if(r<6){if(r===4)return Ge(e,t,n,s);{let a=z[p++];if((a&128)>0){p-=5;return}return Ge(e,t,n,s,a)}}else if(r<8){let a=z[p++],i=z[p++];if((a&128)>0||(i&128)>0){p-=6;return}if(r<7)return Ge(e,t,n,s,a,i);let o=z[p++];if((o&128)>0){p-=7;return}return Ge(e,t,n,s,a,i,o)}else{let a=z[p++],i=z[p++],o=z[p++],c=z[p++];if((a&128)>0||(i&128)>0||(o&128)>0||(c&128)>0){p-=8;return}if(r<10){if(r===8)return Ge(e,t,n,s,a,i,o,c);{let l=z[p++];if((l&128)>0){p-=9;return}return Ge(e,t,n,s,a,i,o,c,l)}}else if(r<12){let l=z[p++],m=z[p++];if((l&128)>0||(m&128)>0){p-=10;return}if(r<11)return Ge(e,t,n,s,a,i,o,c,l,m);let T=z[p++];if((T&128)>0){p-=11;return}return Ge(e,t,n,s,a,i,o,c,l,m,T)}else{let l=z[p++],m=z[p++],T=z[p++],J=z[p++];if((l&128)>0||(m&128)>0||(T&128)>0||(J&128)>0){p-=12;return}if(r<14){if(r===12)return Ge(e,t,n,s,a,i,o,c,l,m,T,J);{let ee=z[p++];if((ee&128)>0){p-=13;return}return Ge(e,t,n,s,a,i,o,c,l,m,T,J,ee)}}else{let ee=z[p++],Ee=z[p++];if((ee&128)>0||(Ee&128)>0){p-=14;return}if(r<15)return Ge(e,t,n,s,a,i,o,c,l,m,T,J,ee,Ee);let te=z[p++];if((te&128)>0){p-=15;return}return Ge(e,t,n,s,a,i,o,c,l,m,T,J,ee,Ee,te)}}}}}function ou(){let r=z[p++],e;if(r<192)e=r-160;else switch(r){case 217:e=z[p++];break;case 218:e=ge.getUint16(p),p+=2;break;case 219:e=ge.getUint32(p),p+=4;break;default:throw new Error("Expected string")}return Hs(e)}function Ji(r){return Pe.copyBuffers?Uint8Array.prototype.slice.call(z,p,p+=r):z.subarray(p,p+=r)}function nn(r){let e=z[p++];if(kt[e]){let t;return kt[e](z.subarray(p,t=p+=r),n=>{p=n;try{return Ve()}finally{p=t}})}else throw new Error("Unknown extension type "+e)}var cu=new Array(4096);function ql(){let r=z[p++];if(r>=160&&r<192){if(r=r-160,Yt>=p)return Mr.slice(p-Tt,(p+=r)-Tt);if(!(Yt==0&&St<180))return xo(r)}else return p--,Ve().toString();let e=(r<<5^(r>1?ge.getUint16(p):r>0?z[p]:0))&4095,t=cu[e],n=p,s=p+r-3,a,i=0;if(t&&t.bytes==r){for(;n<s;){if(a=ge.getUint32(n),a!=t[i++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(a=z[n++],a!=t[i++]){n=1879048192;break}if(n===s)return p=n,t.string;s-=3,n=p}for(t=[],cu[e]=t,t.bytes=r;n<s;)a=ge.getUint32(n),t.push(a),n+=4;for(s+=3;n<s;)a=z[n++],t.push(a);let o=r<16?uc(r):Vl(r);return o!=null?t.string=o:t.string=xo(r)}const uu=(r,e)=>{let t=Ve().map(a=>a.toString()),n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let s=we[r];return s&&(s.isShared||Dr)&&((we.restoreStructures||(we.restoreStructures=[]))[r]=s),we[r]=t,t.read=cc(t,n),t.read()};kt[0]=()=>{};kt[0].noBuffer=!0;let mm={Error,TypeError,ReferenceError};kt[101]=()=>{let r=Ve();return(mm[r[0]]||Error)(r[1])};kt[105]=r=>{let e=ge.getUint32(p-4);xr||(xr=new Map);let t=z[p],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};xr.set(e,s);let a=Ve();return s.used?Object.assign(n,a):(s.target=a,a)};kt[112]=r=>{let e=ge.getUint32(p-4),t=xr.get(e);return t.used=!0,t.target};kt[115]=()=>new Set(Ve());const Kl=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");let ym=typeof globalThis=="object"?globalThis:window;kt[116]=r=>{let e=r[0],t=Kl[e];if(!t)throw new Error("Could not find typed array for code "+e);return new ym[t](Uint8Array.prototype.slice.call(r,1).buffer)};kt[120]=()=>{let r=Ve();return new RegExp(r[0],r[1])};const gm=[];kt[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=p;return p+=e-r.length,Xe=gm,Xe=[ou(),ou()],Xe.position0=0,Xe.position1=0,Xe.postBundlePosition=p,p=t,Ve()};kt[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function Fl(r){let e=St,t=p,n=Tt,s=Yt,a=Mr,i=xr,o=Xe,c=new Uint8Array(z.slice(0,St)),l=we,m=we.slice(0,we.length),T=Pe,J=Dr,ee=r();return St=e,p=t,Tt=n,Yt=s,Mr=a,xr=i,Xe=o,z=c,Dr=J,we=l,we.splice(0,we.length,...m),Pe=T,ge=new DataView(z.buffer,z.byteOffset,z.byteLength),ee}function So(){z=null,xr=null,we=null}const lc=new Array(147);for(let r=0;r<256;r++)lc[r]=+("1e"+Math.floor(45.15-r*.30103));var Ei=new Ll({useRecords:!1});const vm=Ei.unpack;Ei.unpackMultiple;Ei.unpack;let wm=new Float32Array(1);new Uint8Array(wm.buffer,0,4);let Na;try{Na=new TextEncoder}catch{}let No,Wl;const Ai=typeof Buffer<"u",da=Ai?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,Yl=Ai?Buffer:Uint8Array,lu=Ai?4294967296:2144337920;let b,Hn,Ze,v=0,pt,Ue=null,bm;const _m=21760,km=/[\u0080-\uFFFF]/,On=Symbol("record-id");let Om=class extends Ll{constructor(e){super(e),this.offset=0;let t,n,s,a,i=Yl.prototype.utf8Write?function(d,O){return b.utf8Write(d,O,4294967295)}:Na&&Na.encodeInto?function(d,O){return Na.encodeInto(d,b.subarray(O)).written}:!1,o=this;e||(e={});let c=e&&e.sequential,l=e.structures||e.saveStructures,m=e.maxSharedStructures;if(m==null&&(m=l?32:0),m>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let T=e.maxOwnStructures;T==null&&(T=l?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let J=m>32||T+m>64,ee=m+64,Ee=m+T+64;if(Ee>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let te=[],rr=0,nr=0;this.pack=this.encode=function(d,O){if(b||(b=new da(8192),Ze=b.dataView||(b.dataView=new DataView(b.buffer,0,8192)),v=0),pt=b.length-10,pt-v<2048?(b=new da(b.length),Ze=b.dataView||(b.dataView=new DataView(b.buffer,0,b.length)),pt=b.length-10,v=0):v=v+7&2147483640,t=v,O&Im&&(v+=O&255),a=o.structuredClone?new Map:null,o.bundleStrings&&typeof d!="string"?(Ue=[],Ue.size=1/0):Ue=null,s=o.structures,s){s.uninitialized&&(s=o._mergeStructures(o.getStructures()));let y=s.sharedLength||0;if(y>m)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+s.sharedLength);if(!s.transitions){s.transitions=Object.create(null);for(let g=0;g<y;g++){let k=s[g];if(!k)continue;let R,M=s.transitions;for(let I=0,ne=k.length;I<ne;I++){let K=k[I];R=M[K],R||(R=M[K]=Object.create(null)),M=R}M[On]=g+64}this.lastNamedStructuresLength=y}c||(s.nextId=y+64)}n&&(n=!1);try{o.randomAccessStructure&&d&&d.constructor&&d.constructor===Object?Ki(d):re(d);let y=Ue;if(Ue&&pu(t,re,0),a&&a.idsToInsert){let g=a.idsToInsert.sort((I,ne)=>I.offset>ne.offset?1:-1),k=g.length,R=-1;for(;y&&k>0;){let I=g[--k].offset+t;I<y.stringsPosition+t&&R===-1&&(R=0),I>y.position+t?R>=0&&(R+=6):(R>=0&&(Ze.setUint32(y.position+t,Ze.getUint32(y.position+t)+R),R=-1),y=y.previous,k++)}R>=0&&y&&Ze.setUint32(y.position+t,Ze.getUint32(y.position+t)+R),v+=g.length*6,v>pt&&et(v),o.offset=v;let M=xm(b.subarray(t,v),g);return a=null,M}return o.offset=v,O&Em?(b.start=t,b.end=v,b):b.subarray(t,v)}finally{if(s&&(Fn(),n&&o.saveStructures)){let y=s.sharedLength||0,g=b.subarray(t,v),k=Sm(s,o);return o.saveStructures(k,k.isCompatible)===!1?o.pack(d,O):(o.lastNamedStructuresLength=y,g)}O&Am&&(v=t)}};const Fn=()=>{nr<10&&nr++;let d=s.sharedLength||0;if(s.length>d&&!c&&(s.length=d),rr>1e4)s.transitions=null,nr=0,rr=0,te.length>0&&(te=[]);else if(te.length>0&&!c){for(let O=0,y=te.length;O<y;O++)te[O][On]=0;te=[]}},en=d=>{var O=d.length;O<16?b[v++]=144|O:O<65536?(b[v++]=220,b[v++]=O>>8,b[v++]=O&255):(b[v++]=221,Ze.setUint32(v,O),v+=4);for(let y=0;y<O;y++)re(d[y])},re=d=>{v>pt&&(b=et(v));var O=typeof d,y;if(O==="string"){let g=d.length;if(Ue&&g>=4&&g<4096){if((Ue.size+=g)>_m){let I,ne=(Ue[0]?Ue[0].length*3+Ue[1].length:0)+10;v+ne>pt&&(b=et(v+ne));let K;Ue.position?(K=Ue,b[v]=200,v+=3,b[v++]=98,I=v-t,v+=4,pu(t,re,0),Ze.setUint16(I+t-3,v-t-I)):(b[v++]=214,b[v++]=98,I=v-t,v+=4),Ue=["",""],Ue.previous=K,Ue.size=0,Ue.position=I}let M=km.test(d);Ue[M?0:1]+=d,b[v++]=193,re(M?-g:g);return}let k;g<32?k=1:g<256?k=2:g<65536?k=3:k=5;let R=g*3;if(v+R>pt&&(b=et(v+R)),g<64||!i){let M,I,ne,K=v+k;for(M=0;M<g;M++)I=d.charCodeAt(M),I<128?b[K++]=I:I<2048?(b[K++]=I>>6|192,b[K++]=I&63|128):(I&64512)===55296&&((ne=d.charCodeAt(M+1))&64512)===56320?(I=65536+((I&1023)<<10)+(ne&1023),M++,b[K++]=I>>18|240,b[K++]=I>>12&63|128,b[K++]=I>>6&63|128,b[K++]=I&63|128):(b[K++]=I>>12|224,b[K++]=I>>6&63|128,b[K++]=I&63|128);y=K-v-k}else y=i(d,v+k);y<32?b[v++]=160|y:y<256?(k<2&&b.copyWithin(v+2,v+1,v+1+y),b[v++]=217,b[v++]=y):y<65536?(k<3&&b.copyWithin(v+3,v+2,v+2+y),b[v++]=218,b[v++]=y>>8,b[v++]=y&255):(k<5&&b.copyWithin(v+5,v+3,v+3+y),b[v++]=219,Ze.setUint32(v,y),v+=4),v+=y}else if(O==="number")if(d>>>0===d)d<32||d<128&&this.useRecords===!1||d<64&&!this.randomAccessStructure?b[v++]=d:d<256?(b[v++]=204,b[v++]=d):d<65536?(b[v++]=205,b[v++]=d>>8,b[v++]=d&255):(b[v++]=206,Ze.setUint32(v,d),v+=4);else if(d>>0===d)d>=-32?b[v++]=256+d:d>=-128?(b[v++]=208,b[v++]=d+256):d>=-32768?(b[v++]=209,Ze.setInt16(v,d),v+=2):(b[v++]=210,Ze.setInt32(v,d),v+=4);else{let g;if((g=this.useFloat32)>0&&d<4294967296&&d>=-2147483648){b[v++]=202,Ze.setFloat32(v,d);let k;if(g<4||(k=d*lc[(b[v]&127)<<1|b[v+1]>>7])>>0===k){v+=4;return}else v--}b[v++]=203,Ze.setFloat64(v,d),v+=8}else if(O==="object"||O==="function")if(!d)b[v++]=192;else{if(a){let k=a.get(d);if(k){if(!k.id){let R=a.idsToInsert||(a.idsToInsert=[]);k.id=R.push(k)}b[v++]=214,b[v++]=112,Ze.setUint32(v,k.id),v+=4;return}else a.set(d,{offset:v-t})}let g=d.constructor;if(g===Object)sr(d,!0);else if(g===Array)en(d);else if(g===Map)if(this.mapAsEmptyObject)b[v++]=128;else{y=d.size,y<16?b[v++]=128|y:y<65536?(b[v++]=222,b[v++]=y>>8,b[v++]=y&255):(b[v++]=223,Ze.setUint32(v,y),v+=4);for(let[k,R]of d)re(k),re(R)}else{for(let k=0,R=No.length;k<R;k++){let M=Wl[k];if(d instanceof M){let I=No[k];if(I.write){I.type&&(b[v++]=212,b[v++]=I.type,b[v++]=0);let tt=I.write.call(this,d);tt===d?Array.isArray(d)?en(d):sr(d):re(tt);return}let ne=b,K=Ze,Ke=v;b=null;let ht;try{ht=I.pack.call(this,d,tt=>(b=ne,ne=null,v+=tt,v>pt&&et(v),{target:b,targetView:Ze,position:v-tt}),re)}finally{ne&&(b=ne,Ze=K,v=Ke,pt=b.length-10)}ht&&(ht.length+v>pt&&et(ht.length+v),v=Tm(ht,b,v,I.type));return}}if(Array.isArray(d))en(d);else{if(d.toJSON){const k=d.toJSON();if(k!==d)return re(k)}if(O==="function")return re(this.writeFunction&&this.writeFunction(d));sr(d,!d.hasOwnProperty)}}}else if(O==="boolean")b[v++]=d?195:194;else if(O==="bigint"){if(d<BigInt(1)<<BigInt(63)&&d>=-(BigInt(1)<<BigInt(63)))b[v++]=211,Ze.setBigInt64(v,d);else if(d<BigInt(1)<<BigInt(64)&&d>0)b[v++]=207,Ze.setBigUint64(v,d);else if(this.largeBigIntToFloat)b[v++]=203,Ze.setFloat64(v,Number(d));else throw new RangeError(d+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");v+=8}else if(O==="undefined")this.encodeUndefinedAsNil?b[v++]=192:(b[v++]=212,b[v++]=0,b[v++]=0);else throw new Error("Unknown type: "+O)},Wn=this.variableMapSize||this.coercibleKeyAsNumber?d=>{let O=Object.keys(d),y=O.length;y<16?b[v++]=128|y:y<65536?(b[v++]=222,b[v++]=y>>8,b[v++]=y&255):(b[v++]=223,Ze.setUint32(v,y),v+=4);let g;if(this.coercibleKeyAsNumber)for(let k=0;k<y;k++){g=O[k];let R=Number(g);re(isNaN(R)?g:R),re(d[g])}else for(let k=0;k<y;k++)re(g=O[k]),re(d[g])}:(d,O)=>{b[v++]=222;let y=v-t;v+=2;let g=0;for(let k in d)(O||d.hasOwnProperty(k))&&(re(k),re(d[k]),g++);b[y+++t]=g>>8,b[y+t]=g&255},Yn=this.useRecords===!1?Wn:e.progressiveRecords&&!J?(d,O)=>{let y,g=s.transitions||(s.transitions=Object.create(null)),k=v++-t,R;for(let M in d)if(O||d.hasOwnProperty(M)){if(y=g[M],y)g=y;else{let I=Object.keys(d),ne=g;g=s.transitions;let K=0;for(let Ke=0,ht=I.length;Ke<ht;Ke++){let tt=I[Ke];y=g[tt],y||(y=g[tt]=Object.create(null),K++),g=y}k+t+1==v?(v--,tn(g,I,K)):Gn(g,I,k,K),R=!0,g=ne[M]}re(d[M])}if(!R){let M=g[On];M?b[k+t]=M:Gn(g,Object.keys(d),k,0)}}:(d,O)=>{let y,g=s.transitions||(s.transitions=Object.create(null)),k=0;for(let M in d)(O||d.hasOwnProperty(M))&&(y=g[M],y||(y=g[M]=Object.create(null),k++),g=y);let R=g[On];R?R>=96&&J?(b[v++]=((R-=96)&31)+96,b[v++]=R>>5):b[v++]=R:tn(g,g.__keys__||Object.keys(d),k);for(let M in d)(O||d.hasOwnProperty(M))&&re(d[M])},Jn=typeof this.useRecords=="function"&&this.useRecords,sr=Jn?(d,O)=>{Jn(d)?Yn(d,O):Wn(d,O)}:Yn,et=d=>{let O;if(d>16777216){if(d-t>lu)throw new Error("Packed buffer would be larger than maximum buffer size");O=Math.min(lu,Math.round(Math.max((d-t)*(d>67108864?1.25:2),4194304)/4096)*4096)}else O=(Math.max(d-t<<2,b.length-1)>>12)+1<<12;let y=new da(O);return Ze=y.dataView||(y.dataView=new DataView(y.buffer,0,O)),d=Math.min(d,b.length),b.copy?b.copy(y,0,t,d):y.set(b.slice(t,d)),v-=t,t=0,pt=y.length-10,b=y},tn=(d,O,y)=>{let g=s.nextId;g||(g=64),g<ee&&this.shouldShareStructure&&!this.shouldShareStructure(O)?(g=s.nextOwnId,g<Ee||(g=ee),s.nextOwnId=g+1):(g>=Ee&&(g=ee),s.nextId=g+1);let k=O.highByte=g>=96&&J?g-96>>5:-1;d[On]=g,d.__keys__=O,s[g-64]=O,g<ee?(O.isShared=!0,s.sharedLength=g-63,n=!0,k>=0?(b[v++]=(g&31)+96,b[v++]=k):b[v++]=g):(k>=0?(b[v++]=213,b[v++]=114,b[v++]=(g&31)+96,b[v++]=k):(b[v++]=212,b[v++]=114,b[v++]=g),y&&(rr+=nr*y),te.length>=T&&(te.shift()[On]=0),te.push(d),re(O))},Gn=(d,O,y,g)=>{let k=b,R=v,M=pt,I=t;b=Hn,v=0,t=0,b||(Hn=b=new da(8192)),pt=b.length-10,tn(d,O,g),Hn=b;let ne=v;if(b=k,v=R,pt=M,t=I,ne>1){let K=v+ne-1;K>pt&&et(K);let Ke=y+t;b.copyWithin(Ke+ne,Ke+1,v),b.set(Hn.slice(0,ne),Ke),v=K}else b[y+t]=Hn[0]},Ki=(d,O)=>{let y=bm(d,b,t,v,s,et,(g,k,R)=>{if(R)return n=!0;v=k;let M=b;return re(g),Fn(),M!==b?{position:v,targetView:Ze,target:b}:v},this);if(y===0)return sr(d,!0);v=y}}useBuffer(e){b=e,Ze=new DataView(b.buffer,b.byteOffset,b.byteLength),v=0}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};Wl=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Ml];No=[{pack(r,e,t){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:s,targetView:a,position:i}=e(6);s[i++]=214,s[i++]=255,a.setUint32(i,n)}else if(n>0&&n<4294967296){let{target:s,targetView:a,position:i}=e(10);s[i++]=215,s[i++]=255,a.setUint32(i,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),a.setUint32(i+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:s,targetView:a,position:i}=e(3);s[i++]=212,s[i++]=255,s[i++]=255}else{let{target:s,targetView:a,position:i}=e(15);s[i++]=199,s[i++]=12,s[i++]=255,a.setUint32(i,r.getMilliseconds()*1e6),a.setBigInt64(i+4,BigInt(Math.floor(n)))}}},{pack(r,e,t){if(this.setAsEmptyObject)return e(0),t({});let n=Array.from(r),{target:s,position:a}=e(this.moreTypes?3:0);this.moreTypes&&(s[a++]=212,s[a++]=115,s[a++]=0),t(n)}},{pack(r,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=101,n[s++]=0),t([r.name,r.message])}},{pack(r,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=120,n[s++]=0),t([r.source,r.flags])}},{pack(r,e){this.moreTypes?du(r,16,e):hu(Ai?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==Yl&&this.moreTypes?du(r,Kl.indexOf(t.name),e):hu(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function du(r,e,t,n){let s=r.byteLength;if(s+1<256){var{target:a,position:i}=t(4+s);a[i++]=199,a[i++]=s+1}else if(s+1<65536){var{target:a,position:i}=t(5+s);a[i++]=200,a[i++]=s+1>>8,a[i++]=s+1&255}else{var{target:a,position:i,targetView:o}=t(7+s);a[i++]=201,o.setUint32(i,s+1),i+=4}a[i++]=116,a[i++]=e,a.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),i)}function hu(r,e){let t=r.byteLength;var n,s;if(t<256){var{target:n,position:s}=e(t+2);n[s++]=196,n[s++]=t}else if(t<65536){var{target:n,position:s}=e(t+3);n[s++]=197,n[s++]=t>>8,n[s++]=t&255}else{var{target:n,position:s,targetView:a}=e(t+5);n[s++]=198,a.setUint32(s,t),s+=4}n.set(r,s)}function Tm(r,e,t,n){let s=r.length;switch(s){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:s<256?(e[t++]=199,e[t++]=s):s<65536?(e[t++]=200,e[t++]=s>>8,e[t++]=s&255):(e[t++]=201,e[t++]=s>>24,e[t++]=s>>16&255,e[t++]=s>>8&255,e[t++]=s&255)}return e[t++]=n,e.set(r,t),t+=s,t}function xm(r,e){let t,n=e.length*6,s=r.length-n;for(;t=e.pop();){let a=t.offset,i=t.id;r.copyWithin(a+n,a,s),n-=6;let o=a+n;r[o++]=214,r[o++]=105,r[o++]=i>>24,r[o++]=i>>16&255,r[o++]=i>>8&255,r[o++]=i&255,s=a}return r}function pu(r,e,t){if(Ue.length>0){Ze.setUint32(Ue.position+r,v+t-Ue.position-r),Ue.stringsPosition=v-r;let n=Ue;Ue=null,e(n[0]),e(n[1])}}function Sm(r,e){return r.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},r}let Jl=new Om({useRecords:!1});const Nm=Jl.pack;Jl.pack;const Em=512,Am=1024,Im=2048;let Gl=class{constructor(){N(this,"contentType","application/msgpack")}encode(e){return Nm(Un.toSnake(e))}decode(e,t){const n=Un.toCamel(vm(new Uint8Array(e)));return t!=null?t.parse(n):n}},Hl=class{constructor(){N(this,"contentType","application/json"),N(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(Un.toSnake(e),(n,s)=>ArrayBuffer.isView(s)?Array.from(s):zl(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s);return new TextEncoder().encode(t)}decode(e,t){const n=Un.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(n):n}static registerCustomType(){}};const Zm=[new Gl,new Hl],Xl=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:Zm,JSONEncoderDecoder:Hl,MsgpackEncoderDecoder:Gl},Symbol.toStringTag,{value:"Module"}));let $m=class{constructor(e){N(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,n)=>n(e))}};const Ha=Object.freeze(Object.defineProperty({__proto__:null,Observer:$m},Symbol.toStringTag,{value:"Module"})),Xs=u.z.number(),Qs=u.z.object({name:u.z.string(),key:u.z.number(),rate:Ni.z,dataType:ze.z,leaseholder:u.z.number(),index:u.z.number(),isIndex:u.z.boolean(),alias:u.z.string().optional()}),Ql=Qs.extend({key:u.z.number().optional(),leaseholder:u.z.number().optional(),index:u.z.number().optional(),rate:Ni.z.optional(),isIndex:u.z.boolean().optional()}),ed=r=>r.map(e=>({name:e.name,dataType:e.dataType,rate:e.rate??0,leaseholder:e.leaseholder,index:e.index,isIndex:e.isIndex})),Cm=u.z.object({channels:Ql.array()}),jm=u.z.object({channels:Qs.array()}),bi=class bi{constructor(e){h(this,"client");this.client=e}async create(e){const t={channels:ed(e)},[n,s]=await this.client.send(bi.ENDPOINT,t,Cm,jm);if(s!=null)throw s;return n.channels}};h(bi,"ENDPOINT","/channel/create");let Xa=bi;const Rm=new Error("request for lock canceled");var zm=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(m){try{l(n.next(m))}catch(T){i(T)}}function c(m){try{l(n.throw(m))}catch(T){i(T)}}function l(m){m.done?a(m.value):s(m.value).then(o,c)}l((n=n.apply(r,e||[])).next())})};class Pm{constructor(e,t=Rm){this._value=e,this._cancelError=t,this._weightedQueues=[],this._weightedWaiters=[]}acquire(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((t,n)=>{this._weightedQueues[e-1]||(this._weightedQueues[e-1]=[]),this._weightedQueues[e-1].push({resolve:t,reject:n}),this._dispatch()})}runExclusive(e,t=1){return zm(this,void 0,void 0,function*(){const[n,s]=yield this.acquire(t);try{return yield e(n)}finally{s()}})}waitForUnlock(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise(t=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),this._weightedWaiters[e-1].push(t),this._dispatch()})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatch()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatch()}cancel(){this._weightedQueues.forEach(e=>e.forEach(t=>t.reject(this._cancelError))),this._weightedQueues=[]}_dispatch(){var e;for(let t=this._value;t>0;t--){const n=(e=this._weightedQueues[t-1])===null||e===void 0?void 0:e.shift();if(!n)continue;const s=this._value,a=t;this._value-=t,t=this._value+1,n.resolve([s,this._newReleaser(a)])}this._drainUnlockWaiters()}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){for(let e=this._value;e>0;e--)this._weightedWaiters[e-1]&&(this._weightedWaiters[e-1].forEach(t=>t()),this._weightedWaiters[e-1]=[])}}var Mm=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(m){try{l(n.next(m))}catch(T){i(T)}}function c(m){try{l(n.throw(m))}catch(T){i(T)}}function l(m){m.done?a(m.value):s(m.value).then(o,c)}l((n=n.apply(r,e||[])).next())})};class Um{constructor(e){this._semaphore=new Pm(1,e)}acquire(){return Mm(this,void 0,void 0,function*(){const[,e]=yield this._semaphore.acquire();return e})}runExclusive(e){return this._semaphore.runExclusive(()=>e())}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}var Dm=Object.defineProperty,Lm=(r,e,t)=>e in r?Dm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ye=(r,e,t)=>(Lm(r,typeof e!="symbol"?e+"":e,t),t),Bm=Object.defineProperty,Vm=(r,e,t)=>e in r?Bm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,j=(r,e,t)=>(Vm(r,typeof e!="symbol"?e+"":e,t),t),ke;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(ke||(ke={}));var Eo;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Eo||(Eo={}));const D=ke.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),zr=r=>{switch(typeof r){case"undefined":return D.undefined;case"string":return D.string;case"number":return isNaN(r)?D.nan:D.number;case"boolean":return D.boolean;case"function":return D.function;case"bigint":return D.bigint;case"symbol":return D.symbol;case"object":return Array.isArray(r)?D.array:r===null?D.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?D.promise:typeof Map<"u"&&r instanceof Map?D.map:typeof Set<"u"&&r instanceof Set?D.set:typeof Date<"u"&&r instanceof Date?D.date:D.object;default:return D.unknown}},$=ke.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),qm=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class zt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,ke.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}zt.create=r=>new zt(r);const _s=(r,e)=>{let t;switch(r.code){case $.invalid_type:r.received===D.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case $.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,ke.jsonStringifyReplacer)}`;break;case $.unrecognized_keys:t=`Unrecognized key(s) in object: ${ke.joinValues(r.keys,", ")}`;break;case $.invalid_union:t="Invalid input";break;case $.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ke.joinValues(r.options)}`;break;case $.invalid_enum_value:t=`Invalid enum value. Expected ${ke.joinValues(r.options)}, received '${r.received}'`;break;case $.invalid_arguments:t="Invalid function arguments";break;case $.invalid_return_type:t="Invalid function return type";break;case $.invalid_date:t="Invalid date";break;case $.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:ke.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case $.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case $.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case $.custom:t="Invalid input";break;case $.invalid_intersection_types:t="Intersection results could not be merged";break;case $.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case $.not_finite:t="Number must be finite";break;default:t=e.defaultError,ke.assertNever(r)}return{message:t}};let td=_s;function Km(r){td=r}function Qa(){return td}const ei=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},Fm=[];function V(r,e){const t=ei({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Qa(),_s].filter(n=>!!n)});r.common.issues.push(t)}class ut{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return oe;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return ut.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return oe;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const oe=Object.freeze({status:"aborted"}),rd=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),Ao=r=>r.status==="aborted",Io=r=>r.status==="dirty",ks=r=>r.status==="valid",ti=r=>typeof Promise<"u"&&r instanceof Promise;var W;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(W||(W={}));class Xt{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const fu=(r,e)=>{if(ks(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new zt(r.common.issues);return this._error=t,this._error}}};function le(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:s}}class pe{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return zr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:zr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ut,ctx:{common:e.parent.common,data:e.data,parsedType:zr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ti(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zr(e)},a=this._parseSync({data:e,path:s.path,parent:s});return fu(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zr(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(ti(s)?s:Promise.resolve(s));return fu(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:$.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new Bt({schema:this,typeName:X.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Sr.create(this,this._def)}nullable(){return mn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Pt.create(this,this._def)}promise(){return Ln.create(this,this._def)}or(e){return Ss.create([this,e],this._def)}and(e){return Ns.create(this,e,this._def)}transform(e){return new Bt({...le(this._def),schema:this,typeName:X.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new $s({...le(this._def),innerType:this,defaultValue:t,typeName:X.ZodDefault})}brand(){return new sd({typeName:X.ZodBranded,type:this,...le(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ai({...le(this._def),innerType:this,catchValue:t,typeName:X.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ea.create(this,e)}readonly(){return oi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Wm=/^c[^\s-]{8,}$/i,Ym=/^[a-z][a-z0-9]*$/,Jm=/^[0-9A-HJKMNP-TV-Z]{26}$/,Gm=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Hm=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Xm="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Gi;const Qm=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,ey=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ty=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function ry(r,e){return!!((e==="v4"||!e)&&Qm.test(r)||(e==="v6"||!e)&&ey.test(r))}class Ct extends pe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==D.string){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:D.string,received:s.parsedType}),oe}const t=new ut;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:$.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:$.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?V(n,{code:$.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&V(n,{code:$.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")Hm.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"email",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Gi||(Gi=new RegExp(Xm,"u")),Gi.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"emoji",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")Gm.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"uuid",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")Wm.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"cuid",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")Ym.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"cuid2",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")Jm.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"ulid",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),V(n,{validation:"url",code:$.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"regex",code:$.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),V(n,{code:$.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),V(n,{code:$.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),V(n,{code:$.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?ty(s).test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{code:$.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?ry(e.data,s.version)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"ip",code:$.invalid_string,message:s.message}),t.dirty()):ke.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:$.invalid_string,...W.errToObj(n)})}_addCheck(e){return new Ct({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...W.errToObj(e)})}url(e){return this._addCheck({kind:"url",...W.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...W.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...W.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...W.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...W.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...W.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...W.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...W.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...W.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...W.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...W.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...W.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...W.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...W.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...W.errToObj(t)})}nonempty(e){return this.min(1,W.errToObj(e))}trim(){return new Ct({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ct({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ct({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ct.create=r=>{var e;return new Ct({checks:[],typeName:X.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...le(r)})};function ny(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class qr extends pe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==D.number){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:D.number,received:s.parsedType}),oe}let t;const n=new ut;for(const s of this._def.checks)s.kind==="int"?ke.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),V(t,{code:$.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?ny(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),V(t,{code:$.not_finite,message:s.message}),n.dirty()):ke.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,W.toString(t))}gt(e,t){return this.setLimit("min",e,!1,W.toString(t))}lte(e,t){return this.setLimit("max",e,!0,W.toString(t))}lt(e,t){return this.setLimit("max",e,!1,W.toString(t))}setLimit(e,t,n,s){return new qr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:W.toString(s)}]})}_addCheck(e){return new qr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:W.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:W.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:W.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:W.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:W.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:W.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ke.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}qr.create=r=>new qr({checks:[],typeName:X.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...le(r)});class Kr extends pe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==D.bigint){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:D.bigint,received:s.parsedType}),oe}let t;const n=new ut;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):ke.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,W.toString(t))}gt(e,t){return this.setLimit("min",e,!1,W.toString(t))}lte(e,t){return this.setLimit("max",e,!0,W.toString(t))}lt(e,t){return this.setLimit("max",e,!1,W.toString(t))}setLimit(e,t,n,s){return new Kr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:W.toString(s)}]})}_addCheck(e){return new Kr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:W.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:W.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Kr.create=r=>{var e;return new Kr({checks:[],typeName:X.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...le(r)})};class Os extends pe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==D.boolean){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.boolean,received:t.parsedType}),oe}return wt(e.data)}}Os.create=r=>new Os({typeName:X.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...le(r)});class pn extends pe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==D.date){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:D.date,received:s.parsedType}),oe}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_date}),oe}const t=new ut;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:$.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:$.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):ke.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new pn({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:W.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:W.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}pn.create=r=>new pn({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:X.ZodDate,...le(r)});class ri extends pe{_parse(e){if(this._getType(e)!==D.symbol){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.symbol,received:t.parsedType}),oe}return wt(e.data)}}ri.create=r=>new ri({typeName:X.ZodSymbol,...le(r)});class Ts extends pe{_parse(e){if(this._getType(e)!==D.undefined){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.undefined,received:t.parsedType}),oe}return wt(e.data)}}Ts.create=r=>new Ts({typeName:X.ZodUndefined,...le(r)});class xs extends pe{_parse(e){if(this._getType(e)!==D.null){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.null,received:t.parsedType}),oe}return wt(e.data)}}xs.create=r=>new xs({typeName:X.ZodNull,...le(r)});class Dn extends pe{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}Dn.create=r=>new Dn({typeName:X.ZodAny,...le(r)});class on extends pe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}on.create=r=>new on({typeName:X.ZodUnknown,...le(r)});class Ir extends pe{_parse(e){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.never,received:t.parsedType}),oe}}Ir.create=r=>new Ir({typeName:X.ZodNever,...le(r)});class ni extends pe{_parse(e){if(this._getType(e)!==D.undefined){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.void,received:t.parsedType}),oe}return wt(e.data)}}ni.create=r=>new ni({typeName:X.ZodVoid,...le(r)});class Pt extends pe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==D.array)return V(t,{code:$.invalid_type,expected:D.array,received:t.parsedType}),oe;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(V(t,{code:i?$.too_big:$.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(V(t,{code:$.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(V(t,{code:$.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new Xt(t,i,t.path,o)))).then(i=>ut.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Xt(t,i,t.path,o)));return ut.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Pt({...this._def,minLength:{value:e,message:W.toString(t)}})}max(e,t){return new Pt({...this._def,maxLength:{value:e,message:W.toString(t)}})}length(e,t){return new Pt({...this._def,exactLength:{value:e,message:W.toString(t)}})}nonempty(e){return this.min(1,e)}}Pt.create=(r,e)=>new Pt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:X.ZodArray,...le(e)});function Nn(r){if(r instanceof Le){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Sr.create(Nn(n))}return new Le({...r._def,shape:()=>e})}else return r instanceof Pt?new Pt({...r._def,type:Nn(r.element)}):r instanceof Sr?Sr.create(Nn(r.unwrap())):r instanceof mn?mn.create(Nn(r.unwrap())):r instanceof Qt?Qt.create(r.items.map(e=>Nn(e))):r}class Le extends pe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=ke.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==D.object){const c=this._getOrReturnCtx(e);return V(c,{code:$.invalid_type,expected:D.object,received:c.parsedType}),oe}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Ir&&this._def.unknownKeys==="strip"))for(const c in n.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=s[c],m=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Xt(n,m,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Ir){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(c==="strict")i.length>0&&(V(n,{code:$.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const m=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Xt(n,m,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const m=await l.key;c.push({key:m,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>ut.mergeObjectSync(t,c)):ut.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return W.errToObj,new Le({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=W.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Le({...this._def,unknownKeys:"strip"})}passthrough(){return new Le({...this._def,unknownKeys:"passthrough"})}extend(e){return new Le({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Le({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:X.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Le({...this._def,catchall:e})}pick(e){const t={};return ke.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Le({...this._def,shape:()=>t})}omit(e){const t={};return ke.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Le({...this._def,shape:()=>t})}deepPartial(){return Nn(this)}partial(e){const t={};return ke.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Le({...this._def,shape:()=>t})}required(e){const t={};return ke.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Sr;)s=s._def.innerType;t[n]=s}}),new Le({...this._def,shape:()=>t})}keyof(){return nd(ke.objectKeys(this.shape))}}Le.create=(r,e)=>new Le({shape:()=>r,unknownKeys:"strip",catchall:Ir.create(),typeName:X.ZodObject,...le(e)});Le.strictCreate=(r,e)=>new Le({shape:()=>r,unknownKeys:"strict",catchall:Ir.create(),typeName:X.ZodObject,...le(e)});Le.lazycreate=(r,e)=>new Le({shape:r,unknownKeys:"strip",catchall:Ir.create(),typeName:X.ZodObject,...le(e)});class Ss extends pe{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new zt(o.ctx.common.issues));return V(t,{code:$.invalid_union,unionErrors:i}),oe}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of n){const l={...t,common:{...t.common,issues:[]},parent:null},m=c._parseSync({data:t.data,path:t.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new zt(c));return V(t,{code:$.invalid_union,unionErrors:o}),oe}}get options(){return this._def.options}}Ss.create=(r,e)=>new Ss({options:r,typeName:X.ZodUnion,...le(e)});const Ea=r=>r instanceof As?Ea(r.schema):r instanceof Bt?Ea(r.innerType()):r instanceof Is?[r.value]:r instanceof Fr?r.options:r instanceof Zs?Object.keys(r.enum):r instanceof $s?Ea(r._def.innerType):r instanceof Ts?[void 0]:r instanceof xs?[null]:null;class Ii extends pe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.object)return V(t,{code:$.invalid_type,expected:D.object,received:t.parsedType}),oe;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(V(t,{code:$.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),oe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=Ea(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Ii({typeName:X.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...le(n)})}}function Zo(r,e){const t=zr(r),n=zr(e);if(r===e)return{valid:!0,data:r};if(t===D.object&&n===D.object){const s=ke.objectKeys(e),a=ke.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Zo(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===D.array&&n===D.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Zo(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===D.date&&n===D.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Ns extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Ao(a)||Ao(i))return oe;const o=Zo(a.value,i.value);return o.valid?((Io(a)||Io(i))&&t.dirty(),{status:t.value,value:o.data}):(V(n,{code:$.invalid_intersection_types}),oe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Ns.create=(r,e,t)=>new Ns({left:r,right:e,typeName:X.ZodIntersection,...le(t)});class Qt extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.array)return V(n,{code:$.invalid_type,expected:D.array,received:n.parsedType}),oe;if(n.data.length<this._def.items.length)return V(n,{code:$.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),oe;!this._def.rest&&n.data.length>this._def.items.length&&(V(n,{code:$.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new Xt(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>ut.mergeArray(t,a)):ut.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Qt({...this._def,rest:e})}}Qt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Qt({items:r,typeName:X.ZodTuple,rest:null,...le(e)})};class Es extends pe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.object)return V(n,{code:$.invalid_type,expected:D.object,received:n.parsedType}),oe;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Xt(n,o,n.path,o)),value:i._parse(new Xt(n,n.data[o],n.path,o))});return n.common.async?ut.mergeObjectAsync(t,s):ut.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof pe?new Es({keyType:e,valueType:t,typeName:X.ZodRecord,...le(n)}):new Es({keyType:Ct.create(),valueType:e,typeName:X.ZodRecord,...le(t)})}}class si extends pe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.map)return V(n,{code:$.invalid_type,expected:D.map,received:n.parsedType}),oe;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new Xt(n,o,n.path,[l,"key"])),value:a._parse(new Xt(n,c,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,m=await c.value;if(l.status==="aborted"||m.status==="aborted")return oe;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,m=c.value;if(l.status==="aborted"||m.status==="aborted")return oe;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}}}}si.create=(r,e,t)=>new si({valueType:e,keyType:r,typeName:X.ZodMap,...le(t)});class fn extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.set)return V(n,{code:$.invalid_type,expected:D.set,received:n.parsedType}),oe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(V(n,{code:$.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(V(n,{code:$.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const m of c){if(m.status==="aborted")return oe;m.status==="dirty"&&t.dirty(),l.add(m.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Xt(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new fn({...this._def,minSize:{value:e,message:W.toString(t)}})}max(e,t){return new fn({...this._def,maxSize:{value:e,message:W.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}fn.create=(r,e)=>new fn({valueType:r,minSize:null,maxSize:null,typeName:X.ZodSet,...le(e)});class $n extends pe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.function)return V(t,{code:$.invalid_type,expected:D.function,received:t.parsedType}),oe;function n(o,c){return ei({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Qa(),_s].filter(l=>!!l),issueData:{code:$.invalid_arguments,argumentsError:c}})}function s(o,c){return ei({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Qa(),_s].filter(l=>!!l),issueData:{code:$.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Ln){const o=this;return wt(async function(...c){const l=new zt([]),m=await o._def.args.parseAsync(c,a).catch(J=>{throw l.addIssue(n(c,J)),l}),T=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(T,a).catch(J=>{throw l.addIssue(s(T,J)),l})})}else{const o=this;return wt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new zt([n(c,l.error)]);const m=Reflect.apply(i,this,l.data),T=o._def.returns.safeParse(m,a);if(!T.success)throw new zt([s(m,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new $n({...this._def,args:Qt.create(e).rest(on.create())})}returns(e){return new $n({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new $n({args:e||Qt.create([]).rest(on.create()),returns:t||on.create(),typeName:X.ZodFunction,...le(n)})}}class As extends pe{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}As.create=(r,e)=>new As({getter:r,typeName:X.ZodLazy,...le(e)});class Is extends pe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return V(t,{received:t.data,code:$.invalid_literal,expected:this._def.value}),oe}return{status:"valid",value:e.data}}get value(){return this._def.value}}Is.create=(r,e)=>new Is({value:r,typeName:X.ZodLiteral,...le(e)});function nd(r,e){return new Fr({values:r,typeName:X.ZodEnum,...le(e)})}class Fr extends pe{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return V(t,{expected:ke.joinValues(n),received:t.parsedType,code:$.invalid_type}),oe}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return V(t,{received:t.data,code:$.invalid_enum_value,options:n}),oe}return wt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Fr.create(e)}exclude(e){return Fr.create(this.options.filter(t=>!e.includes(t)))}}Fr.create=nd;class Zs extends pe{_parse(e){const t=ke.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==D.string&&n.parsedType!==D.number){const s=ke.objectValues(t);return V(n,{expected:ke.joinValues(s),received:n.parsedType,code:$.invalid_type}),oe}if(t.indexOf(e.data)===-1){const s=ke.objectValues(t);return V(n,{received:n.data,code:$.invalid_enum_value,options:s}),oe}return wt(e.data)}get enum(){return this._def.values}}Zs.create=(r,e)=>new Zs({values:r,typeName:X.ZodNativeEnum,...le(e)});class Ln extends pe{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.promise&&t.common.async===!1)return V(t,{code:$.invalid_type,expected:D.promise,received:t.parsedType}),oe;const n=t.parsedType===D.promise?t.data:Promise.resolve(t.data);return wt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ln.create=(r,e)=>new Ln({type:r,typeName:X.ZodPromise,...le(e)});class Bt extends pe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===X.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{V(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?oe:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?oe:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ks(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>ks(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);ke.assertNever(s)}}Bt.create=(r,e,t)=>new Bt({schema:r,typeName:X.ZodEffects,effect:e,...le(t)});Bt.createWithPreprocess=(r,e,t)=>new Bt({schema:e,effect:{type:"preprocess",transform:r},typeName:X.ZodEffects,...le(t)});class Sr extends pe{_parse(e){return this._getType(e)===D.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Sr.create=(r,e)=>new Sr({innerType:r,typeName:X.ZodOptional,...le(e)});class mn extends pe{_parse(e){return this._getType(e)===D.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mn.create=(r,e)=>new mn({innerType:r,typeName:X.ZodNullable,...le(e)});class $s extends pe{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===D.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}$s.create=(r,e)=>new $s({innerType:r,typeName:X.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...le(e)});class ai extends pe{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ti(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new zt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new zt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ai.create=(r,e)=>new ai({innerType:r,typeName:X.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...le(e)});class ii extends pe{_parse(e){if(this._getType(e)!==D.nan){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.nan,received:t.parsedType}),oe}return{status:"valid",value:e.data}}}ii.create=r=>new ii({typeName:X.ZodNaN,...le(r)});const sy=Symbol("zod_brand");class sd extends pe{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class ea extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?oe:s.status==="dirty"?(t.dirty(),rd(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?oe:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new ea({in:e,out:t,typeName:X.ZodPipeline})}}class oi extends pe{_parse(e){const t=this._def.innerType._parse(e);return ks(t)&&(t.value=Object.freeze(t.value)),t}}oi.create=(r,e)=>new oi({innerType:r,typeName:X.ZodReadonly,...le(e)});const ad=(r,e={},t)=>r?Dn.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...l,fatal:c})}}):Dn.create(),ay={object:Le.lazycreate};var X;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(X||(X={}));const iy=(r,e={message:`Input not instance of ${r.name}`})=>ad(t=>t instanceof r,e),id=Ct.create,od=qr.create,oy=ii.create,cy=Kr.create,cd=Os.create,uy=pn.create,ly=ri.create,dy=Ts.create,hy=xs.create,py=Dn.create,fy=on.create,my=Ir.create,yy=ni.create,gy=Pt.create,vy=Le.create,wy=Le.strictCreate,by=Ss.create,_y=Ii.create,ky=Ns.create,Oy=Qt.create,Ty=Es.create,xy=si.create,Sy=fn.create,Ny=$n.create,Ey=As.create,Ay=Is.create,Iy=Fr.create,Zy=Zs.create,$y=Ln.create,mu=Bt.create,Cy=Sr.create,jy=mn.create,Ry=Bt.createWithPreprocess,zy=ea.create,Py=()=>id().optional(),My=()=>od().optional(),Uy=()=>cd().optional(),Dy={string:r=>Ct.create({...r,coerce:!0}),number:r=>qr.create({...r,coerce:!0}),boolean:r=>Os.create({...r,coerce:!0}),bigint:r=>Kr.create({...r,coerce:!0}),date:r=>pn.create({...r,coerce:!0})},Ly=oe;var S=Object.freeze({__proto__:null,defaultErrorMap:_s,setErrorMap:Km,getErrorMap:Qa,makeIssue:ei,EMPTY_PATH:Fm,addIssueToContext:V,ParseStatus:ut,INVALID:oe,DIRTY:rd,OK:wt,isAborted:Ao,isDirty:Io,isValid:ks,isAsync:ti,get util(){return ke},get objectUtil(){return Eo},ZodParsedType:D,getParsedType:zr,ZodType:pe,ZodString:Ct,ZodNumber:qr,ZodBigInt:Kr,ZodBoolean:Os,ZodDate:pn,ZodSymbol:ri,ZodUndefined:Ts,ZodNull:xs,ZodAny:Dn,ZodUnknown:on,ZodNever:Ir,ZodVoid:ni,ZodArray:Pt,ZodObject:Le,ZodUnion:Ss,ZodDiscriminatedUnion:Ii,ZodIntersection:Ns,ZodTuple:Qt,ZodRecord:Es,ZodMap:si,ZodSet:fn,ZodFunction:$n,ZodLazy:As,ZodLiteral:Is,ZodEnum:Fr,ZodNativeEnum:Zs,ZodPromise:Ln,ZodEffects:Bt,ZodTransformer:Bt,ZodOptional:Sr,ZodNullable:mn,ZodDefault:$s,ZodCatch:ai,ZodNaN:ii,BRAND:sy,ZodBranded:sd,ZodPipeline:ea,ZodReadonly:oi,custom:ad,Schema:pe,ZodSchema:pe,late:ay,get ZodFirstPartyTypeKind(){return X},coerce:Dy,any:py,array:gy,bigint:cy,boolean:cd,date:uy,discriminatedUnion:_y,effect:mu,enum:Iy,function:Ny,instanceof:iy,intersection:ky,lazy:Ey,literal:Ay,map:xy,nan:oy,nativeEnum:Zy,never:my,null:hy,nullable:jy,number:od,object:vy,oboolean:Uy,onumber:My,optional:Cy,ostring:Py,pipeline:zy,preprocess:Ry,promise:$y,record:Ty,set:Sy,strictObject:wy,string:id,symbol:ly,transformer:mu,tuple:Oy,undefined:dy,union:by,unknown:fy,void:yy,NEVER:Ly,ZodIssueCode:$,quotelessJson:qm,ZodError:zt});const dc=S.tuple([S.number(),S.number()]),ud=S.object({width:S.number(),height:S.number()}),By=S.object({signedWidth:S.number(),signedHeight:S.number()}),Vy=["width","height"];S.enum(Vy);const qy=["start","center","end"],Ky=["signedWidth","signedHeight"];S.enum(Ky);const ci=S.object({x:S.number(),y:S.number()}),Fy=S.object({clientX:S.number(),clientY:S.number()}),Wy=["x","y"],ld=S.enum(Wy),dd=["top","right","bottom","left"];S.enum(dd);const Yy=["left","right"],hd=S.enum(Yy),Jy=["top","bottom"],pd=S.enum(Jy),fd=["center"],yu=S.enum(fd),Gy=[...dd,...fd],md=S.enum(Gy);S.enum(qy);const Hy=["first","last"];S.enum(Hy);const Xy=S.object({lower:S.number(),upper:S.number()});S.union([Xy,dc]);S.union([ld,md]);S.union([ld,md,S.instanceof(String)]);const Hi=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),Qy(t)},Qy=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var It=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ye={},Zi={};Object.defineProperty(Zi,"__esModule",{value:!0});function eg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}Zi.default=eg;var $i={};Object.defineProperty($i,"__esModule",{value:!0});function tg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}$i.default=tg;var Ci={};Object.defineProperty(Ci,"__esModule",{value:!0});function rg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}Ci.default=rg;var hc={};Object.defineProperty(hc,"__esModule",{value:!0});function ng(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}hc.default=ng;var pc={};Object.defineProperty(pc,"__esModule",{value:!0});function sg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}pc.default=sg;var fc={};Object.defineProperty(fc,"__esModule",{value:!0});function ag(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}fc.default=ag;var mc={};Object.defineProperty(mc,"__esModule",{value:!0});function ig(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,s){return n+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}mc.default=ig;var yc={};Object.defineProperty(yc,"__esModule",{value:!0});function og(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,s){return t+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}yc.default=og;var ji={};Object.defineProperty(ji,"__esModule",{value:!0});function cg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}ji.default=cg;var gc={},_n={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(_n);var ug=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(gc,"__esModule",{value:!0});var dr=_n;function Aa(r,e){if(e===void 0&&(e=dr.DefaultOption),!dr.isValidObject(r))return null;e=dr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toLowerCase();e.recursive&&(dr.isValidObject(s)?dr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Aa(s,e)):e.recursiveInArray&&dr.isArrayObject(s)&&(s=ug(s).map(function(i){var o=i;if(dr.isValidObject(i))dr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Aa(i,e));else if(dr.isArrayObject(i)){var c=Aa({key:i},e);o=c.key}return o}))),t[a]=s}),t}gc.default=Aa;var vc={},lg=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(vc,"__esModule",{value:!0});var hr=_n;function Ia(r,e){if(e===void 0&&(e=hr.DefaultOption),!hr.isValidObject(r))return null;e=hr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toUpperCase();e.recursive&&(hr.isValidObject(s)?hr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ia(s,e)):e.recursiveInArray&&hr.isArrayObject(s)&&(s=lg(s).map(function(i){var o=i;if(hr.isValidObject(i))hr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ia(i,e));else if(hr.isArrayObject(i)){var c=Ia({key:i},e);o=c.key}return o}))),t[a]=s}),t}vc.default=Ia;var wc={},dg=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(wc,"__esModule",{value:!0});var pr=_n,hg=Zi;function Za(r,e){if(e===void 0&&(e=pr.DefaultOption),!pr.isValidObject(r))return null;e=pr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=hg.default(n);e.recursive&&(pr.isValidObject(s)?pr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Za(s,e)):e.recursiveInArray&&pr.isArrayObject(s)&&(s=dg(s).map(function(i){var o=i;if(pr.isValidObject(i))pr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Za(i,e));else if(pr.isArrayObject(i)){var c=Za({key:i},e);o=c.key}return o}))),t[a]=s}),t}wc.default=Za;var bc={},pg=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(bc,"__esModule",{value:!0});var fr=_n,fg=$i;function $a(r,e){if(e===void 0&&(e=fr.DefaultOption),!fr.isValidObject(r))return null;e=fr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=fg.default(n);e.recursive&&(fr.isValidObject(s)?fr.belongToTypes(s,e.keepTypesOnRecursion)||(s=$a(s,e)):e.recursiveInArray&&fr.isArrayObject(s)&&(s=pg(s).map(function(i){var o=i;if(fr.isValidObject(i))fr.belongToTypes(o,e.keepTypesOnRecursion)||(o=$a(i,e));else if(fr.isArrayObject(i)){var c=$a({key:i},e);o=c.key}return o}))),t[a]=s}),t}bc.default=$a;var _c={},mg=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(_c,"__esModule",{value:!0});var mr=_n,yg=Ci;function Ca(r,e){if(e===void 0&&(e=mr.DefaultOption),!mr.isValidObject(r))return null;e=mr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=yg.default(n);e.recursive&&(mr.isValidObject(s)?mr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ca(s,e)):e.recursiveInArray&&mr.isArrayObject(s)&&(s=mg(s).map(function(i){var o=i;if(mr.isValidObject(i))mr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ca(i,e));else if(mr.isArrayObject(i)){var c=Ca({key:i},e);o=c.key}return o}))),t[a]=s}),t}_c.default=Ca;var kc={},gg=It&&It.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(kc,"__esModule",{value:!0});var yr=_n,vg=ji;function ja(r,e){if(e===void 0&&(e=yr.DefaultOption),!yr.isValidObject(r))return null;e=yr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=vg.default(n);e.recursive&&(yr.isValidObject(s)?yr.belongToTypes(s,e.keepTypesOnRecursion)||(s=ja(s,e)):e.recursiveInArray&&yr.isArrayObject(s)&&(s=gg(s).map(function(i){var o=i;if(yr.isValidObject(i))yr.belongToTypes(o,e.keepTypesOnRecursion)||(o=ja(i,e));else if(yr.isArrayObject(i)){var c=ja({key:i},e);o=c.key}return o}))),t[a]=s}),t}kc.default=ja;Object.defineProperty(ye,"__esModule",{value:!0});ye.kebabKeys=ye.pascalKeys=ye.snakeKeys=ye.camelKeys=ye.upperKeys=ye.lowerKeys=ye.toLowerCase=ye.toUpperCase=ye.toKebabCase=ye.toHeaderCase=ye.toSentenceCase=ye.toTextCase=ye.toPathCase=ye.toDotCase=ye.toPascalCase=ye.toSnakeCase=ye.toCamelCase=void 0;var yd=Zi;ye.toCamelCase=yd.default;var gd=$i;ye.toSnakeCase=gd.default;var vd=Ci;ye.toPascalCase=vd.default;var wd=hc;ye.toDotCase=wd.default;var bd=pc;ye.toPathCase=bd.default;var _d=fc;ye.toTextCase=_d.default;var kd=mc;ye.toSentenceCase=kd.default;var Od=yc;ye.toHeaderCase=Od.default;var Td=ji;ye.toKebabCase=Td.default;var xd=gc;ye.lowerKeys=xd.default;var Sd=vc;ye.upperKeys=Sd.default;var Nd=wc;ye.camelKeys=Nd.default;var Ed=bc;ye.snakeKeys=Ed.default;var Ad=_c;ye.pascalKeys=Ad.default;var Id=kc;ye.kebabKeys=Id.default;var Zd=function(r){return String(r||"").toLowerCase()};ye.toLowerCase=Zd;var $d=function(r){return String(r||"").toUpperCase()};ye.toUpperCase=$d;var wg={toCamelCase:yd.default,toSnakeCase:gd.default,toPascalCase:vd.default,toDotCase:wd.default,toPathCase:bd.default,toTextCase:_d.default,toSentenceCase:kd.default,toHeaderCase:Od.default,toKebabCase:Td.default,toUpperCase:$d,toLowerCase:Zd,lowerKeys:xd.default,upperKeys:Sd.default,camelKeys:Nd.default,snakeKeys:Ed.default,pascalKeys:Ad.default,kebabKeys:Id.default};ye.default=wg;var Cd=ye;const jd={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},bg=r=>Cd.snakeKeys(r,jd),_g=r=>Cd.camelKeys(r,jd);var Bn;(r=>{r.toSnake=bg,r.toCamel=_g,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Bn||(Bn={}));S.object({x:hd.or(yu),y:pd.or(yu)});const kg=S.object({x:hd,y:pd}),Og=Object.freeze({x:"left",y:"top"}),Tg=(r,e)=>r.x===e.x&&r.y===e.y,gu=S.union([S.number(),ci,dc,ud,By,Fy]),xg=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},vu={x:0,y:0},ha=S.union([S.number(),S.string()]);S.object({top:ha,left:ha,width:ha,height:ha});S.object({left:S.number(),top:S.number(),right:S.number(),bottom:S.number()});S.object({one:ci,two:ci,root:kg});const Oc=(r,e,t=0,n=0,s)=>{const a={one:{...vu},two:{...vu},root:s??Og};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:s??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},Xi=r=>{const e=Oc(r);return{lower:e.one.x,upper:e.two.x}},Qi=r=>{const e=Oc(r);return{lower:e.one.y,upper:e.two.y}},Sg=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Ng=S.object({signedWidth:S.number(),signedHeight:S.number()});S.union([ud,Ng,ci,dc]);const Eg=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);S.object({offset:gu,scale:gu});const Ag=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Ig=r=>(e,t,n,s)=>[e,s?n/r:n*r],Zg=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:s,upper:a}=e,{lower:i,upper:o}=r,c=a-s,l=o-i;if(t==="dimension")return[r,n*(l/c)];const m=(n-s)*(l/c)+i;return[r,m]},$g=r=>(e,t,n)=>[r,n],Cg=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:s}=r;return[r,s-(t-n)]},jg=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=Eg(n,s,a),[e,n]},$o=class ns{constructor(){j(this,"ops",[]),j(this,"currBounds",null),j(this,"currType",null),j(this,"reversed",!1),this.ops=[]}static translate(e){return new ns().translate(e)}static magnify(e){return new ns().magnify(e)}static scale(e,t){return new ns().scale(e,t)}translate(e){const t=this.new(),n=Ag(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Ig(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=Hi(e,t),s=this.new(),a=Zg(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=Hi(e,t),s=this.new(),a=jg(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=Hi(e,t),s=this.new(),a=$g(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=Cg();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new ns;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,s],a)=>a(n,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||t.some(([i,o])=>s>=i&&s<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>s);a!==-1&&t.push([s,a])}),t.forEach(([n,s])=>{const a=e.ops.slice(n,s);a.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...a)}),e.reversed=!e.reversed,e}};j($o,"IDENTITY",new $o);let wu=$o;const bu=class br{constructor(e=new wu,t=new wu,n=null){j(this,"x"),j(this,"y"),j(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new br().translate(e,t)}static translateX(e){return new br().translateX(e)}static translateY(e){return new br().translateY(e)}static clamp(e){return new br().clamp(e)}static magnify(e){return new br().magnify(e)}static scale(e){return new br().scale(e)}static reBound(e){return new br().reBound(e)}translate(e,t){const n=xg(e,t),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(Sg(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Tg(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Xi(e)),t.y=t.y.scale(Qi(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Xi(e)),t.y=this.y.reBound(Qi(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Xi(e)),t.y=this.y.clamp(Qi(e)),t}copy(){const e=new br;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return Oc(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};j(bu,"IDENTITY",new bu);const Rd=(r,e)=>{const t=new _t(e);if(![yt.DAY,yt.HOUR,yt.MINUTE,yt.SECOND,yt.MILLISECOND,yt.MICROSECOND,yt.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof _t?new _t(n):new yt(n)},$e=class ae{constructor(e,t="UTC"){if(j(this,"value"),j(this,"encodeValue",!0),e==null)this.value=ae.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*ae.MILLISECOND.valueOf();else if(typeof e=="string")this.value=ae.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=ae.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=ae.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=ae.MAX:e=ae.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const s=new Date(e,t-1,n,0,0,0,0);return new ae(BigInt(s.getTime())*ae.MILLISECOND.valueOf()).truncate(ae.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,s,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let c=ae.hours(parseInt(n??"00",10)).add(ae.minutes(parseInt(s??"00",10))).add(ae.seconds(parseInt(i??"00",10))).add(ae.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(ae.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return ae.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new ae(BigInt(n.getTime())*ae.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(ae.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(e="UTC"){const t=this.date(),n=t.toLocaleString("default",{month:"short"}),s=t.toLocaleString("default",{day:"numeric"});return`${n} ${s}`}static get utcOffset(){return new yt(BigInt(new Date().getTimezoneOffset())*ae.MINUTE.valueOf())}static since(e){return new ae().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new ae(e).valueOf()}span(e){return this.range(e).span}range(e){return new Rg(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new ae(e).valueOf()}afterEq(e){return this.valueOf()>=new ae(e).valueOf()}before(e){return this.valueOf()<new ae(e).valueOf()}beforeEq(e){return this.valueOf()<=new ae(e).valueOf()}add(e){return new ae(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new ae(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/ae.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Rd(this,e)}get isToday(){return this.truncate(yt.DAY).equals(ae.now().truncate(yt.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new ae(new Date)}static max(...e){let t=ae.MIN;for(const n of e){const s=new ae(n);s.after(t)&&(t=s)}return t}static min(...e){let t=ae.MAX;for(const n of e){const s=new ae(n);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new ae(e)}static microseconds(e){return ae.nanoseconds(e*1e3)}static milliseconds(e){return ae.microseconds(e*1e3)}static seconds(e){return ae.milliseconds(e*1e3)}static minutes(e){return ae.seconds(e*60)}static hours(e){return ae.minutes(e*60)}static days(e){return ae.hours(e*24)}};j($e,"NANOSECOND",$e.nanoseconds(1)),j($e,"MICROSECOND",$e.microseconds(1)),j($e,"MILLISECOND",$e.milliseconds(1)),j($e,"SECOND",$e.seconds(1)),j($e,"MINUTE",$e.minutes(1)),j($e,"HOUR",$e.hours(1)),j($e,"DAY",$e.days(1)),j($e,"MAX",new $e((1n<<63n)-1n)),j($e,"MIN",new $e(0)),j($e,"ZERO",new $e(0)),j($e,"z",S.union([S.object({value:S.bigint()}).transform(r=>new $e(r.value)),S.string().transform(r=>new $e(BigInt(r))),S.instanceof(Number).transform(r=>new $e(r)),S.number().transform(r=>new $e(r)),S.instanceof($e)]));let _t=$e;const Ce=class xe{constructor(e){j(this,"value"),j(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new xe(e).valueOf()}greaterThan(e){return this.valueOf()>new xe(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new xe(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new xe(e).valueOf()}remainder(e){return Rd(this,e)}truncate(e){return new xe(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(xe.DAY),t=this.truncate(xe.HOUR),n=this.truncate(xe.MINUTE),s=this.truncate(xe.SECOND),a=this.truncate(xe.MILLISECOND),i=this.truncate(xe.MICROSECOND),o=this.truncate(xe.NANOSECOND),c=e,l=t.sub(e),m=n.sub(t),T=s.sub(n),J=a.sub(s),ee=i.sub(a),Ee=o.sub(i);let te="";return c.isZero||(te+=`${c.days}d `),l.isZero||(te+=`${l.hours}h `),m.isZero||(te+=`${m.minutes}m `),T.isZero||(te+=`${T.seconds}s `),J.isZero||(te+=`${J.milliseconds}ms `),ee.isZero||(te+=`${ee.microseconds}µs `),Ee.isZero||(te+=`${Ee.nanoseconds}ns`),te.trim()}get days(){return Number(this.valueOf()/xe.DAY.valueOf())}get hours(){return Number(this.valueOf()/xe.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/xe.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/xe.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/xe.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/xe.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new xe(e).valueOf()}add(e){return new xe(this.valueOf()+new xe(e).valueOf())}sub(e){return new xe(this.valueOf()-new xe(e).valueOf())}static nanoseconds(e=1){return new xe(e)}static microseconds(e=1){return xe.nanoseconds(e*1e3)}static milliseconds(e=1){return xe.microseconds(e*1e3)}static seconds(e=1){return xe.milliseconds(e*1e3)}static minutes(e){return xe.seconds(e.valueOf()*60)}static hours(e){return xe.minutes(e*60)}static days(e){return xe.hours(e*24)}};j(Ce,"NANOSECOND",Ce.nanoseconds(1)),j(Ce,"MICROSECOND",Ce.microseconds(1)),j(Ce,"MILLISECOND",Ce.milliseconds(1)),j(Ce,"SECOND",Ce.seconds(1)),j(Ce,"MINUTE",Ce.minutes(1)),j(Ce,"HOUR",Ce.hours(1)),j(Ce,"DAY",Ce.days(1)),j(Ce,"MAX",new Ce((1n<<63n)-1n)),j(Ce,"MIN",new Ce(0)),j(Ce,"ZERO",new Ce(0)),j(Ce,"z",S.union([S.object({value:S.bigint()}).transform(r=>new Ce(r.value)),S.string().transform(r=>new Ce(BigInt(r))),S.instanceof(Number).transform(r=>new Ce(r)),S.number().transform(r=>new Ce(r)),S.instanceof(Ce)]));let yt=Ce;const pa=class Ra extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Ra(e).valueOf()}get period(){return yt.seconds(1/this.valueOf())}sampleCount(e){return new yt(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new mt(t).valueOf()}span(e){return yt.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Ra(e)}static khz(e){return Ra.hz(e*1e3)}};j(pa,"z",S.union([S.number().transform(r=>new pa(r)),S.instanceof(Number).transform(r=>new pa(r)),S.instanceof(pa)]));const nt=class extends Number{constructor(r){r instanceof Number?super(r.valueOf()):super(r)}length(r){return r.valueOf()/this.valueOf()}size(r){return new zg(r*this.valueOf())}};j(nt,"UNKNOWN",new nt(0)),j(nt,"BIT128",new nt(16)),j(nt,"BIT64",new nt(8)),j(nt,"BIT32",new nt(4)),j(nt,"BIT16",new nt(2)),j(nt,"BIT8",new nt(1)),j(nt,"z",S.union([S.number().transform(r=>new nt(r)),S.instanceof(Number).transform(r=>new nt(r)),S.instanceof(nt)]));let mt=nt;const Ft=class za{constructor(e,t){j(this,"start"),j(this,"end"),this.start=new _t(e),this.end=new _t(t)}get span(){return new yt(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new za(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof za?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new za(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};j(Ft,"MAX",new Ft(_t.MIN,_t.MAX)),j(Ft,"MIN",new Ft(_t.MAX,_t.MIN)),j(Ft,"ZERO",new Ft(_t.ZERO,_t.ZERO)),j(Ft,"z",S.union([S.object({start:_t.z,end:_t.z}).transform(r=>new Ft(r.start,r.end)),S.instanceof(Ft)]));let Rg=Ft;const A=class _r extends String{constructor(e){if(e instanceof _r||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=_r.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(_r.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=_r.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(_r.JSON)||this.equals(_r.STRING)}get density(){const e=_r.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return _r.BIG_INT_TYPES.some(e=>e.equals(this))}};j(A,"UNKNOWN",new A("unknown")),j(A,"FLOAT64",new A("float64")),j(A,"FLOAT32",new A("float32")),j(A,"INT64",new A("int64")),j(A,"INT32",new A("int32")),j(A,"INT16",new A("int16")),j(A,"INT8",new A("int8")),j(A,"UINT64",new A("uint64")),j(A,"UINT32",new A("uint32")),j(A,"UINT16",new A("uint16")),j(A,"UINT8",new A("uint8")),j(A,"BOOLEAN",A.UINT8),j(A,"TIMESTAMP",new A("timestamp")),j(A,"UUID",new A("uuid")),j(A,"STRING",new A("string")),j(A,"JSON",new A("json")),j(A,"ARRAY_CONSTRUCTORS",new Map([[A.UINT8.toString(),Uint8Array],[A.UINT16.toString(),Uint16Array],[A.UINT32.toString(),Uint32Array],[A.UINT64.toString(),BigUint64Array],[A.FLOAT32.toString(),Float32Array],[A.FLOAT64.toString(),Float64Array],[A.INT8.toString(),Int8Array],[A.INT16.toString(),Int16Array],[A.INT32.toString(),Int32Array],[A.INT64.toString(),BigInt64Array],[A.TIMESTAMP.toString(),BigInt64Array],[A.STRING.toString(),Uint8Array],[A.JSON.toString(),Uint8Array],[A.UUID.toString(),Uint8Array]])),j(A,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,A.UINT8],[Uint16Array.name,A.UINT16],[Uint32Array.name,A.UINT32],[BigUint64Array.name,A.UINT64],[Float32Array.name,A.FLOAT32],[Float64Array.name,A.FLOAT64],[Int8Array.name,A.INT8],[Int16Array.name,A.INT16],[Int32Array.name,A.INT32],[BigInt64Array.name,A.INT64]])),j(A,"DENSITIES",new Map([[A.UINT8.toString(),mt.BIT8],[A.UINT16.toString(),mt.BIT16],[A.UINT32.toString(),mt.BIT32],[A.UINT64.toString(),mt.BIT64],[A.FLOAT32.toString(),mt.BIT32],[A.FLOAT64.toString(),mt.BIT64],[A.INT8.toString(),mt.BIT8],[A.INT16.toString(),mt.BIT16],[A.INT32.toString(),mt.BIT32],[A.INT64.toString(),mt.BIT64],[A.TIMESTAMP.toString(),mt.BIT64],[A.STRING.toString(),mt.UNKNOWN],[A.JSON.toString(),mt.UNKNOWN],[A.UUID.toString(),mt.BIT128]])),j(A,"ALL",[A.UNKNOWN,A.FLOAT64,A.FLOAT32,A.INT64,A.INT32,A.INT16,A.INT8,A.UINT64,A.UINT32,A.UINT16,A.UINT8,A.TIMESTAMP,A.UUID,A.STRING,A.JSON]),j(A,"BIG_INT_TYPES",[A.INT64,A.UINT64,A.TIMESTAMP]),j(A,"z",S.union([S.string().transform(r=>new A(r)),S.instanceof(A)]));const it=class We extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return We.bytes(this.valueOf()+e.valueOf())}sub(e){return We.bytes(this.valueOf()-e.valueOf())}truncate(e){return new We(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return We.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/We.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/We.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/We.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/We.TERABYTE.valueOf()}toString(){const e=this.truncate(We.TERABYTE),t=this.truncate(We.GIGABYTE),n=this.truncate(We.MEGABYTE),s=this.truncate(We.KILOBYTE),a=this.truncate(We.BYTE),i=e,o=t.sub(e),c=n.sub(t),l=s.sub(n),m=a.sub(s);let T="";return i.isZero||(T+=`${i.terabytes}TB `),o.isZero||(T+=`${o.gigabytes}GB `),c.isZero||(T+=`${c.megabytes}MB `),l.isZero||(T+=`${l.kilobytes}KB `),(!m.isZero||T==="")&&(T+=`${m.valueOf()}B`),T.trim()}static bytes(e=1){return new We(e)}static kilobytes(e=1){return We.bytes(e.valueOf()*1e3)}static megabytes(e=1){return We.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return We.megabytes(e.valueOf()*1e3)}static terabytes(e){return We.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};j(it,"BYTE",new it(1)),j(it,"KILOBYTE",it.kilobytes(1)),j(it,"MEGABYTE",it.megabytes(1)),j(it,"GIGABYTE",it.gigabytes(1)),j(it,"TERABYTE",it.terabytes(1)),j(it,"ZERO",new it(0)),j(it,"z",S.union([S.number().transform(r=>new it(r)),S.instanceof(it)]));let zg=it;S.union([S.instanceof(Uint8Array),S.instanceof(Uint16Array),S.instanceof(Uint32Array),S.instanceof(BigUint64Array),S.instanceof(Float32Array),S.instanceof(Float64Array),S.instanceof(Int8Array),S.instanceof(Int16Array),S.instanceof(Int32Array),S.instanceof(BigInt64Array)]);S.record(S.union([S.number(),S.string(),S.symbol()]),S.unknown());const Pg=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),zd=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Mg=zd(),Pd=["MacOS","Windows","Linux","Docker"],Ug=S.enum(Pd);let eo;const Dg=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},Lg=(r={})=>{const{force:e,default:t}=r;return e??eo??(eo=Dg(),eo??t)},Md=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Pd,RUNTIME:Mg,detect:zd,getOS:Lg,osZ:Ug},Symbol.toStringTag,{value:"Module"})),Bg=(...r)=>r.map(Ud).join(""),Ud=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Vg=r=>r.endsWith("/")?r.slice(0,-1):r,qg=(r,e="")=>r===null?"":"?"+Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&");var Tn;let Kg=(Tn=class{constructor({host:r,port:e,protocol:t="",pathPrefix:n=""}){j(this,"protocol"),j(this,"host"),j(this,"port"),j(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=Ud(n)}replace(r){return new Tn({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new Tn({...this,pathPrefix:Bg(this.path,r)})}toString(){return Vg(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},j(Tn,"UNKNOWN",new Tn({host:"unknown",port:0})),Tn);var Co;try{Co=new TextDecoder}catch{}var P,Nt,f=0,Me={},be,Ur,xt=0,Jt=0,Qe,Nr,Ot=[],ve,_u={useRecords:!1,mapsAsObjects:!0};class Dd{}const Ld=new Dd;Ld.name="MessagePack 0xC1";var Lr=!1,Bd=2,ku;try{new Function("")}catch{Bd=1/0}class Cs{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=!1&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(P)return Wd(()=>(Ro(),this?this.unpack(e,t):Cs.prototype.unpack.call(_u,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(Nt=t.end||e.length,f=t.start||0):(f=0,Nt=t>-1?t:e.length),Jt=0,Ur=null,Qe=null,P=e;try{ve=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw P=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof Cs){if(Me=this,this.structures)return be=this.structures,fa(t);(!be||be.length>0)&&(be=[])}else Me=_u,(!be||be.length>0)&&(be=[]);return fa(t)}unpackMultiple(e,t){let n,s=0;try{Lr=!0;let a=e.length,i=this?this.unpack(e,a):Ri.unpack(e,a);if(t){if(t(i,s,f)===!1)return;for(;f<a;)if(s=f,t(fa(),s,f)===!1)return}else{for(n=[i];f<a;)s=f,n.push(fa());return n}}catch(a){throw a.lastPosition=s,a.values=n,a}finally{Lr=!1,Ro()}}_mergeStructures(e,t){e=e||[],Object.isFrozen(e)&&(e=e.map(n=>n.slice(0)));for(let n=0,s=e.length;n<s;n++){let a=e[n];a&&(a.isShared=!0,n>=32&&(a.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let s=e[n],a=t[n];a&&(s&&((e.restoreStructures||(e.restoreStructures=[]))[n]=s),e[n]=a)}return this.structures=e}decode(e,t){return this.unpack(e,t)}}function fa(r){try{if(!Me.trusted&&!Lr){let t=be.sharedLength||0;t<be.length&&(be.length=t)}let e;if(Me.randomAccessStructure&&P[f]<64&&P[f]>=32&&ku?(e=ku(P,f,Nt,Me),P=null,!(r&&r.lazy)&&e&&(e=e.toJSON()),f=Nt):e=qe(),Qe&&(f=Qe.postBundlePosition,Qe=null),Lr&&(be.restoreStructures=null),f==Nt)be&&be.restoreStructures&&Ou(),be=null,P=null,Nr&&(Nr=null);else{if(f>Nt)throw new Error("Unexpected end of MessagePack data");if(!Lr){let t;try{t=JSON.stringify(e,(n,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(n){t="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+t)}}return e}catch(e){throw be&&be.restoreStructures&&Ou(),Ro(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||f>Nt)&&(e.incomplete=!0),e}}function Ou(){for(let r in be.restoreStructures)be[r]=be.restoreStructures[r];be.restoreStructures=null}function qe(){let r=P[f++];if(r<160)if(r<128){if(r<64)return r;{let e=be[r&63]||Me.getStructures&&Vd()[r&63];return e?(e.read||(e.read=Tc(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,Me.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Kd();n==="__proto__"&&(n="__proto_"),e[n]=qe()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(qe(),qe());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=qe();return Me.freezeData?Object.freeze(e):e}else if(r<192){let e=r-160;if(Jt>=f)return Ur.slice(f-xt,(f+=e)-xt);if(Jt==0&&Nt<140){let t=e<16?xc(e):qd(e);if(t!=null)return t}return jo(e)}else{let e;switch(r){case 192:return null;case 193:return Qe?(e=qe(),e>0?Qe[1].slice(Qe.position1,Qe.position1+=e):Qe[0].slice(Qe.position0,Qe.position0-=e)):Ld;case 194:return!1;case 195:return!0;case 196:if(e=P[f++],e===void 0)throw new Error("Unexpected end of buffer");return to(e);case 197:return e=ve.getUint16(f),f+=2,to(e);case 198:return e=ve.getUint32(f),f+=4,to(e);case 199:return sn(P[f++]);case 200:return e=ve.getUint16(f),f+=2,sn(e);case 201:return e=ve.getUint32(f),f+=4,sn(e);case 202:if(e=ve.getFloat32(f),Me.useFloat32>2){let t=Sc[(P[f]&127)<<1|P[f+1]>>7];return f+=4,(t*e+(e>0?.5:-.5)>>0)/t}return f+=4,e;case 203:return e=ve.getFloat64(f),f+=8,e;case 204:return P[f++];case 205:return e=ve.getUint16(f),f+=2,e;case 206:return e=ve.getUint32(f),f+=4,e;case 207:return Me.int64AsType==="number"?(e=ve.getUint32(f)*4294967296,e+=ve.getUint32(f+4)):Me.int64AsType==="string"?e=ve.getBigUint64(f).toString():Me.int64AsType==="auto"?(e=ve.getBigUint64(f),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ve.getBigUint64(f),f+=8,e;case 208:return ve.getInt8(f++);case 209:return e=ve.getInt16(f),f+=2,e;case 210:return e=ve.getInt32(f),f+=4,e;case 211:return Me.int64AsType==="number"?(e=ve.getInt32(f)*4294967296,e+=ve.getUint32(f+4)):Me.int64AsType==="string"?e=ve.getBigInt64(f).toString():Me.int64AsType==="auto"?(e=ve.getBigInt64(f),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ve.getBigInt64(f),f+=8,e;case 212:if(e=P[f++],e==114)return Au(P[f++]&63);{let t=Ot[e];if(t)return t.read?(f++,t.read(qe())):t.noBuffer?(f++,t()):t(P.subarray(f,++f));throw new Error("Unknown extension "+e)}case 213:return e=P[f],e==114?(f++,Au(P[f++]&63,P[f++])):sn(2);case 214:return sn(4);case 215:return sn(8);case 216:return sn(16);case 217:return e=P[f++],Jt>=f?Ur.slice(f-xt,(f+=e)-xt):Wg(e);case 218:return e=ve.getUint16(f),f+=2,Jt>=f?Ur.slice(f-xt,(f+=e)-xt):Yg(e);case 219:return e=ve.getUint32(f),f+=4,Jt>=f?Ur.slice(f-xt,(f+=e)-xt):Jg(e);case 220:return e=ve.getUint16(f),f+=2,xu(e);case 221:return e=ve.getUint32(f),f+=4,xu(e);case 222:return e=ve.getUint16(f),f+=2,Su(e);case 223:return e=ve.getUint32(f),f+=4,Su(e);default:if(r>=224)return r-256;if(r===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+r)}}}const Fg=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Tc(r,e){function t(){if(t.count++>Bd){let s=r.read=new Function("r","return function(){return "+(Me.freezeData?"Object.freeze":"")+"({"+r.map(a=>a==="__proto__"?"__proto_:r()":Fg.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"})}")(qe);return r.highByte===0&&(r.read=Tu(e,r.read)),s()}let n={};for(let s=0,a=r.length;s<a;s++){let i=r[s];i==="__proto__"&&(i="__proto_"),n[i]=qe()}return Me.freezeData?Object.freeze(n):n}return t.count=0,r.highByte===0?Tu(e,t):t}const Tu=(r,e)=>function(){let t=P[f++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),s=be[n]||Vd()[n];if(!s)throw new Error("Record id is not defined for "+n);return s.read||(s.read=Tc(s,r)),s.read()};function Vd(){let r=Wd(()=>(P=null,Me.getStructures()));return be=Me._mergeStructures(r,be)}var jo=ta,Wg=ta,Yg=ta,Jg=ta;function ta(r){let e;if(r<16&&(e=xc(r)))return e;if(r>64&&Co)return Co.decode(P.subarray(f,f+=r));const t=f+r,n=[];for(e="";f<t;){const s=P[f++];if(!(s&128))n.push(s);else if((s&224)===192){const a=P[f++]&63;n.push((s&31)<<6|a)}else if((s&240)===224){const a=P[f++]&63,i=P[f++]&63;n.push((s&31)<<12|a<<6|i)}else if((s&248)===240){const a=P[f++]&63,i=P[f++]&63,o=P[f++]&63;let c=(s&7)<<18|a<<12|i<<6|o;c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c)}else n.push(s);n.length>=4096&&(e+=He.apply(String,n),n.length=0)}return n.length>0&&(e+=He.apply(String,n)),e}function xu(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=qe();return Me.freezeData?Object.freeze(e):e}function Su(r){if(Me.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Kd();n==="__proto__"&&(n="__proto_"),e[n]=qe()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(qe(),qe());return e}}var He=String.fromCharCode;function qd(r){let e=f,t=new Array(r);for(let n=0;n<r;n++){const s=P[f++];if((s&128)>0){f=e;return}t[n]=s}return He.apply(String,t)}function xc(r){if(r<4)if(r<2){if(r===0)return"";{let e=P[f++];if((e&128)>1){f-=1;return}return He(e)}}else{let e=P[f++],t=P[f++];if((e&128)>0||(t&128)>0){f-=2;return}if(r<3)return He(e,t);let n=P[f++];if((n&128)>0){f-=3;return}return He(e,t,n)}else{let e=P[f++],t=P[f++],n=P[f++],s=P[f++];if((e&128)>0||(t&128)>0||(n&128)>0||(s&128)>0){f-=4;return}if(r<6){if(r===4)return He(e,t,n,s);{let a=P[f++];if((a&128)>0){f-=5;return}return He(e,t,n,s,a)}}else if(r<8){let a=P[f++],i=P[f++];if((a&128)>0||(i&128)>0){f-=6;return}if(r<7)return He(e,t,n,s,a,i);let o=P[f++];if((o&128)>0){f-=7;return}return He(e,t,n,s,a,i,o)}else{let a=P[f++],i=P[f++],o=P[f++],c=P[f++];if((a&128)>0||(i&128)>0||(o&128)>0||(c&128)>0){f-=8;return}if(r<10){if(r===8)return He(e,t,n,s,a,i,o,c);{let l=P[f++];if((l&128)>0){f-=9;return}return He(e,t,n,s,a,i,o,c,l)}}else if(r<12){let l=P[f++],m=P[f++];if((l&128)>0||(m&128)>0){f-=10;return}if(r<11)return He(e,t,n,s,a,i,o,c,l,m);let T=P[f++];if((T&128)>0){f-=11;return}return He(e,t,n,s,a,i,o,c,l,m,T)}else{let l=P[f++],m=P[f++],T=P[f++],J=P[f++];if((l&128)>0||(m&128)>0||(T&128)>0||(J&128)>0){f-=12;return}if(r<14){if(r===12)return He(e,t,n,s,a,i,o,c,l,m,T,J);{let ee=P[f++];if((ee&128)>0){f-=13;return}return He(e,t,n,s,a,i,o,c,l,m,T,J,ee)}}else{let ee=P[f++],Ee=P[f++];if((ee&128)>0||(Ee&128)>0){f-=14;return}if(r<15)return He(e,t,n,s,a,i,o,c,l,m,T,J,ee,Ee);let te=P[f++];if((te&128)>0){f-=15;return}return He(e,t,n,s,a,i,o,c,l,m,T,J,ee,Ee,te)}}}}}function Nu(){let r=P[f++],e;if(r<192)e=r-160;else switch(r){case 217:e=P[f++];break;case 218:e=ve.getUint16(f),f+=2;break;case 219:e=ve.getUint32(f),f+=4;break;default:throw new Error("Expected string")}return ta(e)}function to(r){return Me.copyBuffers?Uint8Array.prototype.slice.call(P,f,f+=r):P.subarray(f,f+=r)}function sn(r){let e=P[f++];if(Ot[e]){let t;return Ot[e](P.subarray(f,t=f+=r),n=>{f=n;try{return qe()}finally{f=t}})}else throw new Error("Unknown extension type "+e)}var Eu=new Array(4096);function Kd(){let r=P[f++];if(r>=160&&r<192){if(r=r-160,Jt>=f)return Ur.slice(f-xt,(f+=r)-xt);if(!(Jt==0&&Nt<180))return jo(r)}else return f--,qe().toString();let e=(r<<5^(r>1?ve.getUint16(f):r>0?P[f]:0))&4095,t=Eu[e],n=f,s=f+r-3,a,i=0;if(t&&t.bytes==r){for(;n<s;){if(a=ve.getUint32(n),a!=t[i++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(a=P[n++],a!=t[i++]){n=1879048192;break}if(n===s)return f=n,t.string;s-=3,n=f}for(t=[],Eu[e]=t,t.bytes=r;n<s;)a=ve.getUint32(n),t.push(a),n+=4;for(s+=3;n<s;)a=P[n++],t.push(a);let o=r<16?xc(r):qd(r);return o!=null?t.string=o:t.string=jo(r)}const Au=(r,e)=>{let t=qe().map(a=>a.toString()),n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let s=be[r];return s&&(s.isShared||Lr)&&((be.restoreStructures||(be.restoreStructures=[]))[r]=s),be[r]=t,t.read=Tc(t,n),t.read()};Ot[0]=()=>{};Ot[0].noBuffer=!0;let Gg={Error,TypeError,ReferenceError};Ot[101]=()=>{let r=qe();return(Gg[r[0]]||Error)(r[1])};Ot[105]=r=>{let e=ve.getUint32(f-4);Nr||(Nr=new Map);let t=P[f],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};Nr.set(e,s);let a=qe();return s.used?Object.assign(n,a):(s.target=a,a)};Ot[112]=r=>{let e=ve.getUint32(f-4),t=Nr.get(e);return t.used=!0,t.target};Ot[115]=()=>new Set(qe());const Fd=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");let Hg=typeof globalThis=="object"?globalThis:window;Ot[116]=r=>{let e=r[0],t=Fd[e];if(!t)throw new Error("Could not find typed array for code "+e);return new Hg[t](Uint8Array.prototype.slice.call(r,1).buffer)};Ot[120]=()=>{let r=qe();return new RegExp(r[0],r[1])};const Xg=[];Ot[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=f;return f+=e-r.length,Qe=Xg,Qe=[Nu(),Nu()],Qe.position0=0,Qe.position1=0,Qe.postBundlePosition=f,f=t,qe()};Ot[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function Wd(r){let e=Nt,t=f,n=xt,s=Jt,a=Ur,i=Nr,o=Qe,c=new Uint8Array(P.slice(0,Nt)),l=be,m=be.slice(0,be.length),T=Me,J=Lr,ee=r();return Nt=e,f=t,xt=n,Jt=s,Ur=a,Nr=i,Qe=o,P=c,Lr=J,be=l,be.splice(0,be.length,...m),Me=T,ve=new DataView(P.buffer,P.byteOffset,P.byteLength),ee}function Ro(){P=null,Nr=null,be=null}const Sc=new Array(147);for(let r=0;r<256;r++)Sc[r]=+("1e"+Math.floor(45.15-r*.30103));var Ri=new Cs({useRecords:!1});const Qg=Ri.unpack;Ri.unpackMultiple;Ri.unpack;let ev=new Float32Array(1);new Uint8Array(ev.buffer,0,4);let Pa;try{Pa=new TextEncoder}catch{}let zo,Yd;const zi=typeof Buffer<"u",ma=zi?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,Jd=zi?Buffer:Uint8Array,Iu=zi?4294967296:2144337920;let _,Xn,je,w=0,ft,De=null,tv;const rv=21760,nv=/[\u0080-\uFFFF]/,xn=Symbol("record-id");class sv extends Cs{constructor(e){super(e),this.offset=0;let t,n,s,a,i=Jd.prototype.utf8Write?function(d,O){return _.utf8Write(d,O,4294967295)}:Pa&&Pa.encodeInto?function(d,O){return Pa.encodeInto(d,_.subarray(O)).written}:!1,o=this;e||(e={});let c=e&&e.sequential,l=e.structures||e.saveStructures,m=e.maxSharedStructures;if(m==null&&(m=l?32:0),m>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let T=e.maxOwnStructures;T==null&&(T=l?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let J=m>32||T+m>64,ee=m+64,Ee=m+T+64;if(Ee>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let te=[],rr=0,nr=0;this.pack=this.encode=function(d,O){if(_||(_=new ma(8192),je=_.dataView||(_.dataView=new DataView(_.buffer,0,8192)),w=0),ft=_.length-10,ft-w<2048?(_=new ma(_.length),je=_.dataView||(_.dataView=new DataView(_.buffer,0,_.length)),ft=_.length-10,w=0):w=w+7&2147483640,t=w,O&dv&&(w+=O&255),a=o.structuredClone?new Map:null,o.bundleStrings&&typeof d!="string"?(De=[],De.size=1/0):De=null,s=o.structures,s){s.uninitialized&&(s=o._mergeStructures(o.getStructures()));let y=s.sharedLength||0;if(y>m)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+s.sharedLength);if(!s.transitions){s.transitions=Object.create(null);for(let g=0;g<y;g++){let k=s[g];if(!k)continue;let R,M=s.transitions;for(let I=0,ne=k.length;I<ne;I++){let K=k[I];R=M[K],R||(R=M[K]=Object.create(null)),M=R}M[xn]=g+64}this.lastNamedStructuresLength=y}c||(s.nextId=y+64)}n&&(n=!1);try{o.randomAccessStructure&&d&&d.constructor&&d.constructor===Object?Ki(d):re(d);let y=De;if(De&&Cu(t,re,0),a&&a.idsToInsert){let g=a.idsToInsert.sort((I,ne)=>I.offset>ne.offset?1:-1),k=g.length,R=-1;for(;y&&k>0;){let I=g[--k].offset+t;I<y.stringsPosition+t&&R===-1&&(R=0),I>y.position+t?R>=0&&(R+=6):(R>=0&&(je.setUint32(y.position+t,je.getUint32(y.position+t)+R),R=-1),y=y.previous,k++)}R>=0&&y&&je.setUint32(y.position+t,je.getUint32(y.position+t)+R),w+=g.length*6,w>ft&&et(w),o.offset=w;let M=iv(_.subarray(t,w),g);return a=null,M}return o.offset=w,O&uv?(_.start=t,_.end=w,_):_.subarray(t,w)}finally{if(s&&(Fn(),n&&o.saveStructures)){let y=s.sharedLength||0,g=_.subarray(t,w),k=ov(s,o);return o.saveStructures(k,k.isCompatible)===!1?o.pack(d,O):(o.lastNamedStructuresLength=y,g)}O&lv&&(w=t)}};const Fn=()=>{nr<10&&nr++;let d=s.sharedLength||0;if(s.length>d&&!c&&(s.length=d),rr>1e4)s.transitions=null,nr=0,rr=0,te.length>0&&(te=[]);else if(te.length>0&&!c){for(let O=0,y=te.length;O<y;O++)te[O][xn]=0;te=[]}},en=d=>{var O=d.length;O<16?_[w++]=144|O:O<65536?(_[w++]=220,_[w++]=O>>8,_[w++]=O&255):(_[w++]=221,je.setUint32(w,O),w+=4);for(let y=0;y<O;y++)re(d[y])},re=d=>{w>ft&&(_=et(w));var O=typeof d,y;if(O==="string"){let g=d.length;if(De&&g>=4&&g<4096){if((De.size+=g)>rv){let I,ne=(De[0]?De[0].length*3+De[1].length:0)+10;w+ne>ft&&(_=et(w+ne));let K;De.position?(K=De,_[w]=200,w+=3,_[w++]=98,I=w-t,w+=4,Cu(t,re,0),je.setUint16(I+t-3,w-t-I)):(_[w++]=214,_[w++]=98,I=w-t,w+=4),De=["",""],De.previous=K,De.size=0,De.position=I}let M=nv.test(d);De[M?0:1]+=d,_[w++]=193,re(M?-g:g);return}let k;g<32?k=1:g<256?k=2:g<65536?k=3:k=5;let R=g*3;if(w+R>ft&&(_=et(w+R)),g<64||!i){let M,I,ne,K=w+k;for(M=0;M<g;M++)I=d.charCodeAt(M),I<128?_[K++]=I:I<2048?(_[K++]=I>>6|192,_[K++]=I&63|128):(I&64512)===55296&&((ne=d.charCodeAt(M+1))&64512)===56320?(I=65536+((I&1023)<<10)+(ne&1023),M++,_[K++]=I>>18|240,_[K++]=I>>12&63|128,_[K++]=I>>6&63|128,_[K++]=I&63|128):(_[K++]=I>>12|224,_[K++]=I>>6&63|128,_[K++]=I&63|128);y=K-w-k}else y=i(d,w+k);y<32?_[w++]=160|y:y<256?(k<2&&_.copyWithin(w+2,w+1,w+1+y),_[w++]=217,_[w++]=y):y<65536?(k<3&&_.copyWithin(w+3,w+2,w+2+y),_[w++]=218,_[w++]=y>>8,_[w++]=y&255):(k<5&&_.copyWithin(w+5,w+3,w+3+y),_[w++]=219,je.setUint32(w,y),w+=4),w+=y}else if(O==="number")if(d>>>0===d)d<32||d<128&&this.useRecords===!1||d<64&&!this.randomAccessStructure?_[w++]=d:d<256?(_[w++]=204,_[w++]=d):d<65536?(_[w++]=205,_[w++]=d>>8,_[w++]=d&255):(_[w++]=206,je.setUint32(w,d),w+=4);else if(d>>0===d)d>=-32?_[w++]=256+d:d>=-128?(_[w++]=208,_[w++]=d+256):d>=-32768?(_[w++]=209,je.setInt16(w,d),w+=2):(_[w++]=210,je.setInt32(w,d),w+=4);else{let g;if((g=this.useFloat32)>0&&d<4294967296&&d>=-2147483648){_[w++]=202,je.setFloat32(w,d);let k;if(g<4||(k=d*Sc[(_[w]&127)<<1|_[w+1]>>7])>>0===k){w+=4;return}else w--}_[w++]=203,je.setFloat64(w,d),w+=8}else if(O==="object"||O==="function")if(!d)_[w++]=192;else{if(a){let k=a.get(d);if(k){if(!k.id){let R=a.idsToInsert||(a.idsToInsert=[]);k.id=R.push(k)}_[w++]=214,_[w++]=112,je.setUint32(w,k.id),w+=4;return}else a.set(d,{offset:w-t})}let g=d.constructor;if(g===Object)sr(d,!0);else if(g===Array)en(d);else if(g===Map)if(this.mapAsEmptyObject)_[w++]=128;else{y=d.size,y<16?_[w++]=128|y:y<65536?(_[w++]=222,_[w++]=y>>8,_[w++]=y&255):(_[w++]=223,je.setUint32(w,y),w+=4);for(let[k,R]of d)re(k),re(R)}else{for(let k=0,R=zo.length;k<R;k++){let M=Yd[k];if(d instanceof M){let I=zo[k];if(I.write){I.type&&(_[w++]=212,_[w++]=I.type,_[w++]=0);let tt=I.write.call(this,d);tt===d?Array.isArray(d)?en(d):sr(d):re(tt);return}let ne=_,K=je,Ke=w;_=null;let ht;try{ht=I.pack.call(this,d,tt=>(_=ne,ne=null,w+=tt,w>ft&&et(w),{target:_,targetView:je,position:w-tt}),re)}finally{ne&&(_=ne,je=K,w=Ke,ft=_.length-10)}ht&&(ht.length+w>ft&&et(ht.length+w),w=av(ht,_,w,I.type));return}}if(Array.isArray(d))en(d);else{if(d.toJSON){const k=d.toJSON();if(k!==d)return re(k)}if(O==="function")return re(this.writeFunction&&this.writeFunction(d));sr(d,!d.hasOwnProperty)}}}else if(O==="boolean")_[w++]=d?195:194;else if(O==="bigint"){if(d<BigInt(1)<<BigInt(63)&&d>=-(BigInt(1)<<BigInt(63)))_[w++]=211,je.setBigInt64(w,d);else if(d<BigInt(1)<<BigInt(64)&&d>0)_[w++]=207,je.setBigUint64(w,d);else if(this.largeBigIntToFloat)_[w++]=203,je.setFloat64(w,Number(d));else throw new RangeError(d+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");w+=8}else if(O==="undefined")this.encodeUndefinedAsNil?_[w++]=192:(_[w++]=212,_[w++]=0,_[w++]=0);else throw new Error("Unknown type: "+O)},Wn=this.variableMapSize||this.coercibleKeyAsNumber?d=>{let O=Object.keys(d),y=O.length;y<16?_[w++]=128|y:y<65536?(_[w++]=222,_[w++]=y>>8,_[w++]=y&255):(_[w++]=223,je.setUint32(w,y),w+=4);let g;if(this.coercibleKeyAsNumber)for(let k=0;k<y;k++){g=O[k];let R=Number(g);re(isNaN(R)?g:R),re(d[g])}else for(let k=0;k<y;k++)re(g=O[k]),re(d[g])}:(d,O)=>{_[w++]=222;let y=w-t;w+=2;let g=0;for(let k in d)(O||d.hasOwnProperty(k))&&(re(k),re(d[k]),g++);_[y+++t]=g>>8,_[y+t]=g&255},Yn=this.useRecords===!1?Wn:e.progressiveRecords&&!J?(d,O)=>{let y,g=s.transitions||(s.transitions=Object.create(null)),k=w++-t,R;for(let M in d)if(O||d.hasOwnProperty(M)){if(y=g[M],y)g=y;else{let I=Object.keys(d),ne=g;g=s.transitions;let K=0;for(let Ke=0,ht=I.length;Ke<ht;Ke++){let tt=I[Ke];y=g[tt],y||(y=g[tt]=Object.create(null),K++),g=y}k+t+1==w?(w--,tn(g,I,K)):Gn(g,I,k,K),R=!0,g=ne[M]}re(d[M])}if(!R){let M=g[xn];M?_[k+t]=M:Gn(g,Object.keys(d),k,0)}}:(d,O)=>{let y,g=s.transitions||(s.transitions=Object.create(null)),k=0;for(let M in d)(O||d.hasOwnProperty(M))&&(y=g[M],y||(y=g[M]=Object.create(null),k++),g=y);let R=g[xn];R?R>=96&&J?(_[w++]=((R-=96)&31)+96,_[w++]=R>>5):_[w++]=R:tn(g,g.__keys__||Object.keys(d),k);for(let M in d)(O||d.hasOwnProperty(M))&&re(d[M])},Jn=typeof this.useRecords=="function"&&this.useRecords,sr=Jn?(d,O)=>{Jn(d)?Yn(d,O):Wn(d,O)}:Yn,et=d=>{let O;if(d>16777216){if(d-t>Iu)throw new Error("Packed buffer would be larger than maximum buffer size");O=Math.min(Iu,Math.round(Math.max((d-t)*(d>67108864?1.25:2),4194304)/4096)*4096)}else O=(Math.max(d-t<<2,_.length-1)>>12)+1<<12;let y=new ma(O);return je=y.dataView||(y.dataView=new DataView(y.buffer,0,O)),d=Math.min(d,_.length),_.copy?_.copy(y,0,t,d):y.set(_.slice(t,d)),w-=t,t=0,ft=y.length-10,_=y},tn=(d,O,y)=>{let g=s.nextId;g||(g=64),g<ee&&this.shouldShareStructure&&!this.shouldShareStructure(O)?(g=s.nextOwnId,g<Ee||(g=ee),s.nextOwnId=g+1):(g>=Ee&&(g=ee),s.nextId=g+1);let k=O.highByte=g>=96&&J?g-96>>5:-1;d[xn]=g,d.__keys__=O,s[g-64]=O,g<ee?(O.isShared=!0,s.sharedLength=g-63,n=!0,k>=0?(_[w++]=(g&31)+96,_[w++]=k):_[w++]=g):(k>=0?(_[w++]=213,_[w++]=114,_[w++]=(g&31)+96,_[w++]=k):(_[w++]=212,_[w++]=114,_[w++]=g),y&&(rr+=nr*y),te.length>=T&&(te.shift()[xn]=0),te.push(d),re(O))},Gn=(d,O,y,g)=>{let k=_,R=w,M=ft,I=t;_=Xn,w=0,t=0,_||(Xn=_=new ma(8192)),ft=_.length-10,tn(d,O,g),Xn=_;let ne=w;if(_=k,w=R,ft=M,t=I,ne>1){let K=w+ne-1;K>ft&&et(K);let Ke=y+t;_.copyWithin(Ke+ne,Ke+1,w),_.set(Xn.slice(0,ne),Ke),w=K}else _[y+t]=Xn[0]},Ki=(d,O)=>{let y=tv(d,_,t,w,s,et,(g,k,R)=>{if(R)return n=!0;w=k;let M=_;return re(g),Fn(),M!==_?{position:w,targetView:je,target:_}:w},this);if(y===0)return sr(d,!0);w=y}}useBuffer(e){_=e,je=new DataView(_.buffer,_.byteOffset,_.byteLength),w=0}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}Yd=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Dd];zo=[{pack(r,e,t){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:s,targetView:a,position:i}=e(6);s[i++]=214,s[i++]=255,a.setUint32(i,n)}else if(n>0&&n<4294967296){let{target:s,targetView:a,position:i}=e(10);s[i++]=215,s[i++]=255,a.setUint32(i,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),a.setUint32(i+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:s,targetView:a,position:i}=e(3);s[i++]=212,s[i++]=255,s[i++]=255}else{let{target:s,targetView:a,position:i}=e(15);s[i++]=199,s[i++]=12,s[i++]=255,a.setUint32(i,r.getMilliseconds()*1e6),a.setBigInt64(i+4,BigInt(Math.floor(n)))}}},{pack(r,e,t){if(this.setAsEmptyObject)return e(0),t({});let n=Array.from(r),{target:s,position:a}=e(this.moreTypes?3:0);this.moreTypes&&(s[a++]=212,s[a++]=115,s[a++]=0),t(n)}},{pack(r,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=101,n[s++]=0),t([r.name,r.message])}},{pack(r,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=120,n[s++]=0),t([r.source,r.flags])}},{pack(r,e){this.moreTypes?Zu(r,16,e):$u(zi?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==Jd&&this.moreTypes?Zu(r,Fd.indexOf(t.name),e):$u(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function Zu(r,e,t,n){let s=r.byteLength;if(s+1<256){var{target:a,position:i}=t(4+s);a[i++]=199,a[i++]=s+1}else if(s+1<65536){var{target:a,position:i}=t(5+s);a[i++]=200,a[i++]=s+1>>8,a[i++]=s+1&255}else{var{target:a,position:i,targetView:o}=t(7+s);a[i++]=201,o.setUint32(i,s+1),i+=4}a[i++]=116,a[i++]=e,a.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),i)}function $u(r,e){let t=r.byteLength;var n,s;if(t<256){var{target:n,position:s}=e(t+2);n[s++]=196,n[s++]=t}else if(t<65536){var{target:n,position:s}=e(t+3);n[s++]=197,n[s++]=t>>8,n[s++]=t&255}else{var{target:n,position:s,targetView:a}=e(t+5);n[s++]=198,a.setUint32(s,t),s+=4}n.set(r,s)}function av(r,e,t,n){let s=r.length;switch(s){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:s<256?(e[t++]=199,e[t++]=s):s<65536?(e[t++]=200,e[t++]=s>>8,e[t++]=s&255):(e[t++]=201,e[t++]=s>>24,e[t++]=s>>16&255,e[t++]=s>>8&255,e[t++]=s&255)}return e[t++]=n,e.set(r,t),t+=s,t}function iv(r,e){let t,n=e.length*6,s=r.length-n;for(;t=e.pop();){let a=t.offset,i=t.id;r.copyWithin(a+n,a,s),n-=6;let o=a+n;r[o++]=214,r[o++]=105,r[o++]=i>>24,r[o++]=i>>16&255,r[o++]=i>>8&255,r[o++]=i&255,s=a}return r}function Cu(r,e,t){if(De.length>0){je.setUint32(De.position+r,w+t-De.position-r),De.stringsPosition=w-r;let n=De;De=null,e(n[0]),e(n[1])}}function ov(r,e){return r.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},r}let Gd=new sv({useRecords:!1});const cv=Gd.pack;Gd.pack;const uv=512,lv=1024,dv=2048;class hv{constructor(){j(this,"contentType","application/msgpack")}encode(e){return cv(Bn.toSnake(e))}decode(e,t){const n=Bn.toCamel(Qg(new Uint8Array(e)));return t!=null?t.parse(n):n}}class pv{constructor(){j(this,"contentType","application/json"),j(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(Bn.toSnake(e),(n,s)=>ArrayBuffer.isView(s)?Array.from(s):Pg(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s);return new TextEncoder().encode(t)}decode(e,t){const n=Bn.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(n):n}static registerCustomType(){}}new hv,new pv;var Oe;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(Oe||(Oe={}));var Po;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Po||(Po={}));const L=Oe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pr=r=>{switch(typeof r){case"undefined":return L.undefined;case"string":return L.string;case"number":return isNaN(r)?L.nan:L.number;case"boolean":return L.boolean;case"function":return L.function;case"bigint":return L.bigint;case"symbol":return L.symbol;case"object":return Array.isArray(r)?L.array:r===null?L.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?L.promise:typeof Map<"u"&&r instanceof Map?L.map:typeof Set<"u"&&r instanceof Set?L.set:typeof Date<"u"&&r instanceof Date?L.date:L.object;default:return L.unknown}},C=Oe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),fv=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Mt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Oe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Mt.create=r=>new Mt(r);const js=(r,e)=>{let t;switch(r.code){case C.invalid_type:r.received===L.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case C.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Oe.jsonStringifyReplacer)}`;break;case C.unrecognized_keys:t=`Unrecognized key(s) in object: ${Oe.joinValues(r.keys,", ")}`;break;case C.invalid_union:t="Invalid input";break;case C.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Oe.joinValues(r.options)}`;break;case C.invalid_enum_value:t=`Invalid enum value. Expected ${Oe.joinValues(r.options)}, received '${r.received}'`;break;case C.invalid_arguments:t="Invalid function arguments";break;case C.invalid_return_type:t="Invalid function return type";break;case C.invalid_date:t="Invalid date";break;case C.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Oe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case C.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case C.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case C.custom:t="Invalid input";break;case C.invalid_intersection_types:t="Intersection results could not be merged";break;case C.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case C.not_finite:t="Number must be finite";break;default:t=e.defaultError,Oe.assertNever(r)}return{message:t}};let Hd=js;function mv(r){Hd=r}function ui(){return Hd}const li=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},yv=[];function q(r,e){const t=li({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,ui(),js].filter(n=>!!n)});r.common.issues.push(t)}class lt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return ce;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return lt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return ce;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const ce=Object.freeze({status:"aborted"}),Xd=r=>({status:"dirty",value:r}),bt=r=>({status:"valid",value:r}),Mo=r=>r.status==="aborted",Uo=r=>r.status==="dirty",Rs=r=>r.status==="valid",di=r=>typeof Promise<"u"&&r instanceof Promise;var Y;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Y||(Y={}));class er{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ju=(r,e)=>{if(Rs(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Mt(r.common.issues);return this._error=t,this._error}}};function de(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:s}}class fe{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Pr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Pr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new lt,ctx:{common:e.parent.common,data:e.data,parsedType:Pr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(di(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pr(e)},a=this._parseSync({data:e,path:s.path,parent:s});return ju(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pr(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(di(s)?s:Promise.resolve(s));return ju(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:C.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new Vt({schema:this,typeName:Q.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Er.create(this,this._def)}nullable(){return vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ut.create(this,this._def)}promise(){return qn.create(this,this._def)}or(e){return Us.create([this,e],this._def)}and(e){return Ds.create(this,e,this._def)}transform(e){return new Vt({...de(this._def),schema:this,typeName:Q.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Ks({...de(this._def),innerType:this,defaultValue:t,typeName:Q.ZodDefault})}brand(){return new eh({typeName:Q.ZodBranded,type:this,...de(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new mi({...de(this._def),innerType:this,catchValue:t,typeName:Q.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ra.create(this,e)}readonly(){return gi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const gv=/^c[^\s-]{8,}$/i,vv=/^[a-z][a-z0-9]*$/,wv=/^[0-9A-HJKMNP-TV-Z]{26}$/,bv=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,_v=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,kv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ro;const Ov=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Tv=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,xv=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Sv(r,e){return!!((e==="v4"||!e)&&Ov.test(r)||(e==="v6"||!e)&&Tv.test(r))}class jt extends fe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==L.string){const s=this._getOrReturnCtx(e);return q(s,{code:C.invalid_type,expected:L.string,received:s.parsedType}),ce}const t=new lt;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:C.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?q(n,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&q(n,{code:C.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")_v.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"email",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")ro||(ro=new RegExp(kv,"u")),ro.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"emoji",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")bv.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"uuid",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")gv.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"cuid",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")vv.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"cuid2",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")wv.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"ulid",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),q(n,{validation:"url",code:C.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"regex",code:C.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),q(n,{code:C.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),q(n,{code:C.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),q(n,{code:C.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?xv(s).test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{code:C.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?Sv(e.data,s.version)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"ip",code:C.invalid_string,message:s.message}),t.dirty()):Oe.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:C.invalid_string,...Y.errToObj(n)})}_addCheck(e){return new jt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Y.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...Y.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Y.errToObj(t)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new jt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new jt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new jt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}jt.create=r=>{var e;return new jt({checks:[],typeName:Q.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...de(r)})};function Nv(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class Wr extends fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==L.number){const s=this._getOrReturnCtx(e);return q(s,{code:C.invalid_type,expected:L.number,received:s.parsedType}),ce}let t;const n=new lt;for(const s of this._def.checks)s.kind==="int"?Oe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),q(t,{code:C.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?Nv(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),q(t,{code:C.not_finite,message:s.message}),n.dirty()):Oe.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,n,s){return new Wr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Y.toString(s)}]})}_addCheck(e){return new Wr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Oe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Wr.create=r=>new Wr({checks:[],typeName:Q.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...de(r)});class Yr extends fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==L.bigint){const s=this._getOrReturnCtx(e);return q(s,{code:C.invalid_type,expected:L.bigint,received:s.parsedType}),ce}let t;const n=new lt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Oe.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,n,s){return new Yr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Y.toString(s)}]})}_addCheck(e){return new Yr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Yr.create=r=>{var e;return new Yr({checks:[],typeName:Q.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...de(r)})};class zs extends fe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==L.boolean){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.boolean,received:t.parsedType}),ce}return bt(e.data)}}zs.create=r=>new zs({typeName:Q.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...de(r)});class yn extends fe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==L.date){const s=this._getOrReturnCtx(e);return q(s,{code:C.invalid_type,expected:L.date,received:s.parsedType}),ce}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return q(s,{code:C.invalid_date}),ce}const t=new lt;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:C.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:C.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Oe.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new yn({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Y.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}yn.create=r=>new yn({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Q.ZodDate,...de(r)});class hi extends fe{_parse(e){if(this._getType(e)!==L.symbol){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.symbol,received:t.parsedType}),ce}return bt(e.data)}}hi.create=r=>new hi({typeName:Q.ZodSymbol,...de(r)});class Ps extends fe{_parse(e){if(this._getType(e)!==L.undefined){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.undefined,received:t.parsedType}),ce}return bt(e.data)}}Ps.create=r=>new Ps({typeName:Q.ZodUndefined,...de(r)});class Ms extends fe{_parse(e){if(this._getType(e)!==L.null){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.null,received:t.parsedType}),ce}return bt(e.data)}}Ms.create=r=>new Ms({typeName:Q.ZodNull,...de(r)});class Vn extends fe{constructor(){super(...arguments),this._any=!0}_parse(e){return bt(e.data)}}Vn.create=r=>new Vn({typeName:Q.ZodAny,...de(r)});class cn extends fe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return bt(e.data)}}cn.create=r=>new cn({typeName:Q.ZodUnknown,...de(r)});class Zr extends fe{_parse(e){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.never,received:t.parsedType}),ce}}Zr.create=r=>new Zr({typeName:Q.ZodNever,...de(r)});class pi extends fe{_parse(e){if(this._getType(e)!==L.undefined){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.void,received:t.parsedType}),ce}return bt(e.data)}}pi.create=r=>new pi({typeName:Q.ZodVoid,...de(r)});class Ut extends fe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==L.array)return q(t,{code:C.invalid_type,expected:L.array,received:t.parsedType}),ce;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(q(t,{code:i?C.too_big:C.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(q(t,{code:C.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(q(t,{code:C.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new er(t,i,t.path,o)))).then(i=>lt.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new er(t,i,t.path,o)));return lt.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Ut({...this._def,minLength:{value:e,message:Y.toString(t)}})}max(e,t){return new Ut({...this._def,maxLength:{value:e,message:Y.toString(t)}})}length(e,t){return new Ut({...this._def,exactLength:{value:e,message:Y.toString(t)}})}nonempty(e){return this.min(1,e)}}Ut.create=(r,e)=>new Ut({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Q.ZodArray,...de(e)});function En(r){if(r instanceof Be){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Er.create(En(n))}return new Be({...r._def,shape:()=>e})}else return r instanceof Ut?new Ut({...r._def,type:En(r.element)}):r instanceof Er?Er.create(En(r.unwrap())):r instanceof vn?vn.create(En(r.unwrap())):r instanceof tr?tr.create(r.items.map(e=>En(e))):r}class Be extends fe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Oe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==L.object){const c=this._getOrReturnCtx(e);return q(c,{code:C.invalid_type,expected:L.object,received:c.parsedType}),ce}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Zr&&this._def.unknownKeys==="strip"))for(const c in n.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=s[c],m=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new er(n,m,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Zr){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(c==="strict")i.length>0&&(q(n,{code:C.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const m=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new er(n,m,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const m=await l.key;c.push({key:m,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>lt.mergeObjectSync(t,c)):lt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new Be({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=Y.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Be({...this._def,unknownKeys:"strip"})}passthrough(){return new Be({...this._def,unknownKeys:"passthrough"})}extend(e){return new Be({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Be({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Q.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Be({...this._def,catchall:e})}pick(e){const t={};return Oe.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Be({...this._def,shape:()=>t})}omit(e){const t={};return Oe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Be({...this._def,shape:()=>t})}deepPartial(){return En(this)}partial(e){const t={};return Oe.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Be({...this._def,shape:()=>t})}required(e){const t={};return Oe.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Er;)s=s._def.innerType;t[n]=s}}),new Be({...this._def,shape:()=>t})}keyof(){return Qd(Oe.objectKeys(this.shape))}}Be.create=(r,e)=>new Be({shape:()=>r,unknownKeys:"strip",catchall:Zr.create(),typeName:Q.ZodObject,...de(e)});Be.strictCreate=(r,e)=>new Be({shape:()=>r,unknownKeys:"strict",catchall:Zr.create(),typeName:Q.ZodObject,...de(e)});Be.lazycreate=(r,e)=>new Be({shape:r,unknownKeys:"strip",catchall:Zr.create(),typeName:Q.ZodObject,...de(e)});class Us extends fe{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Mt(o.ctx.common.issues));return q(t,{code:C.invalid_union,unionErrors:i}),ce}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of n){const l={...t,common:{...t.common,issues:[]},parent:null},m=c._parseSync({data:t.data,path:t.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new Mt(c));return q(t,{code:C.invalid_union,unionErrors:o}),ce}}get options(){return this._def.options}}Us.create=(r,e)=>new Us({options:r,typeName:Q.ZodUnion,...de(e)});const Ma=r=>r instanceof Bs?Ma(r.schema):r instanceof Vt?Ma(r.innerType()):r instanceof Vs?[r.value]:r instanceof Jr?r.options:r instanceof qs?Object.keys(r.enum):r instanceof Ks?Ma(r._def.innerType):r instanceof Ps?[void 0]:r instanceof Ms?[null]:null;class Pi extends fe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.object)return q(t,{code:C.invalid_type,expected:L.object,received:t.parsedType}),ce;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(q(t,{code:C.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ce)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=Ma(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Pi({typeName:Q.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...de(n)})}}function Do(r,e){const t=Pr(r),n=Pr(e);if(r===e)return{valid:!0,data:r};if(t===L.object&&n===L.object){const s=Oe.objectKeys(e),a=Oe.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Do(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===L.array&&n===L.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Do(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===L.date&&n===L.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Ds extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Mo(a)||Mo(i))return ce;const o=Do(a.value,i.value);return o.valid?((Uo(a)||Uo(i))&&t.dirty(),{status:t.value,value:o.data}):(q(n,{code:C.invalid_intersection_types}),ce)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Ds.create=(r,e,t)=>new Ds({left:r,right:e,typeName:Q.ZodIntersection,...de(t)});class tr extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.array)return q(n,{code:C.invalid_type,expected:L.array,received:n.parsedType}),ce;if(n.data.length<this._def.items.length)return q(n,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ce;!this._def.rest&&n.data.length>this._def.items.length&&(q(n,{code:C.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new er(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>lt.mergeArray(t,a)):lt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new tr({...this._def,rest:e})}}tr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new tr({items:r,typeName:Q.ZodTuple,rest:null,...de(e)})};class Ls extends fe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.object)return q(n,{code:C.invalid_type,expected:L.object,received:n.parsedType}),ce;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new er(n,o,n.path,o)),value:i._parse(new er(n,n.data[o],n.path,o))});return n.common.async?lt.mergeObjectAsync(t,s):lt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof fe?new Ls({keyType:e,valueType:t,typeName:Q.ZodRecord,...de(n)}):new Ls({keyType:jt.create(),valueType:e,typeName:Q.ZodRecord,...de(t)})}}class fi extends fe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.map)return q(n,{code:C.invalid_type,expected:L.map,received:n.parsedType}),ce;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new er(n,o,n.path,[l,"key"])),value:a._parse(new er(n,c,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,m=await c.value;if(l.status==="aborted"||m.status==="aborted")return ce;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,m=c.value;if(l.status==="aborted"||m.status==="aborted")return ce;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}}}}fi.create=(r,e,t)=>new fi({valueType:e,keyType:r,typeName:Q.ZodMap,...de(t)});class gn extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.set)return q(n,{code:C.invalid_type,expected:L.set,received:n.parsedType}),ce;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(q(n,{code:C.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(q(n,{code:C.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const m of c){if(m.status==="aborted")return ce;m.status==="dirty"&&t.dirty(),l.add(m.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new er(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new gn({...this._def,minSize:{value:e,message:Y.toString(t)}})}max(e,t){return new gn({...this._def,maxSize:{value:e,message:Y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}gn.create=(r,e)=>new gn({valueType:r,minSize:null,maxSize:null,typeName:Q.ZodSet,...de(e)});class Cn extends fe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.function)return q(t,{code:C.invalid_type,expected:L.function,received:t.parsedType}),ce;function n(o,c){return li({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ui(),js].filter(l=>!!l),issueData:{code:C.invalid_arguments,argumentsError:c}})}function s(o,c){return li({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,ui(),js].filter(l=>!!l),issueData:{code:C.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof qn){const o=this;return bt(async function(...c){const l=new Mt([]),m=await o._def.args.parseAsync(c,a).catch(J=>{throw l.addIssue(n(c,J)),l}),T=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(T,a).catch(J=>{throw l.addIssue(s(T,J)),l})})}else{const o=this;return bt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Mt([n(c,l.error)]);const m=Reflect.apply(i,this,l.data),T=o._def.returns.safeParse(m,a);if(!T.success)throw new Mt([s(m,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Cn({...this._def,args:tr.create(e).rest(cn.create())})}returns(e){return new Cn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Cn({args:e||tr.create([]).rest(cn.create()),returns:t||cn.create(),typeName:Q.ZodFunction,...de(n)})}}class Bs extends fe{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Bs.create=(r,e)=>new Bs({getter:r,typeName:Q.ZodLazy,...de(e)});class Vs extends fe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return q(t,{received:t.data,code:C.invalid_literal,expected:this._def.value}),ce}return{status:"valid",value:e.data}}get value(){return this._def.value}}Vs.create=(r,e)=>new Vs({value:r,typeName:Q.ZodLiteral,...de(e)});function Qd(r,e){return new Jr({values:r,typeName:Q.ZodEnum,...de(e)})}class Jr extends fe{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{expected:Oe.joinValues(n),received:t.parsedType,code:C.invalid_type}),ce}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{received:t.data,code:C.invalid_enum_value,options:n}),ce}return bt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Jr.create(e)}exclude(e){return Jr.create(this.options.filter(t=>!e.includes(t)))}}Jr.create=Qd;class qs extends fe{_parse(e){const t=Oe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==L.string&&n.parsedType!==L.number){const s=Oe.objectValues(t);return q(n,{expected:Oe.joinValues(s),received:n.parsedType,code:C.invalid_type}),ce}if(t.indexOf(e.data)===-1){const s=Oe.objectValues(t);return q(n,{received:n.data,code:C.invalid_enum_value,options:s}),ce}return bt(e.data)}get enum(){return this._def.values}}qs.create=(r,e)=>new qs({values:r,typeName:Q.ZodNativeEnum,...de(e)});class qn extends fe{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.promise&&t.common.async===!1)return q(t,{code:C.invalid_type,expected:L.promise,received:t.parsedType}),ce;const n=t.parsedType===L.promise?t.data:Promise.resolve(t.data);return bt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}qn.create=(r,e)=>new qn({type:r,typeName:Q.ZodPromise,...de(e)});class Vt extends fe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{q(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ce:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ce:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Rs(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Rs(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);Oe.assertNever(s)}}Vt.create=(r,e,t)=>new Vt({schema:r,typeName:Q.ZodEffects,effect:e,...de(t)});Vt.createWithPreprocess=(r,e,t)=>new Vt({schema:e,effect:{type:"preprocess",transform:r},typeName:Q.ZodEffects,...de(t)});class Er extends fe{_parse(e){return this._getType(e)===L.undefined?bt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Er.create=(r,e)=>new Er({innerType:r,typeName:Q.ZodOptional,...de(e)});class vn extends fe{_parse(e){return this._getType(e)===L.null?bt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}vn.create=(r,e)=>new vn({innerType:r,typeName:Q.ZodNullable,...de(e)});class Ks extends fe{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===L.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Ks.create=(r,e)=>new Ks({innerType:r,typeName:Q.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...de(e)});class mi extends fe{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return di(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Mt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Mt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}mi.create=(r,e)=>new mi({innerType:r,typeName:Q.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...de(e)});class yi extends fe{_parse(e){if(this._getType(e)!==L.nan){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.nan,received:t.parsedType}),ce}return{status:"valid",value:e.data}}}yi.create=r=>new yi({typeName:Q.ZodNaN,...de(r)});const Ev=Symbol("zod_brand");class eh extends fe{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class ra extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ce:s.status==="dirty"?(t.dirty(),Xd(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ce:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new ra({in:e,out:t,typeName:Q.ZodPipeline})}}class gi extends fe{_parse(e){const t=this._def.innerType._parse(e);return Rs(t)&&(t.value=Object.freeze(t.value)),t}}gi.create=(r,e)=>new gi({innerType:r,typeName:Q.ZodReadonly,...de(e)});const th=(r,e={},t)=>r?Vn.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...l,fatal:c})}}):Vn.create(),Av={object:Be.lazycreate};var Q;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(Q||(Q={}));const Iv=(r,e={message:`Input not instance of ${r.name}`})=>th(t=>t instanceof r,e),rh=jt.create,nh=Wr.create,Zv=yi.create,$v=Yr.create,sh=zs.create,Cv=yn.create,jv=hi.create,Rv=Ps.create,zv=Ms.create,Pv=Vn.create,Mv=cn.create,Uv=Zr.create,Dv=pi.create,Lv=Ut.create,Bv=Be.create,Vv=Be.strictCreate,qv=Us.create,Kv=Pi.create,Fv=Ds.create,Wv=tr.create,Yv=Ls.create,Jv=fi.create,Gv=gn.create,Hv=Cn.create,Xv=Bs.create,Qv=Vs.create,ew=Jr.create,tw=qs.create,rw=qn.create,Ru=Vt.create,nw=Er.create,sw=vn.create,aw=Vt.createWithPreprocess,iw=ra.create,ow=()=>rh().optional(),cw=()=>nh().optional(),uw=()=>sh().optional(),lw={string:r=>jt.create({...r,coerce:!0}),number:r=>Wr.create({...r,coerce:!0}),boolean:r=>zs.create({...r,coerce:!0}),bigint:r=>Yr.create({...r,coerce:!0}),date:r=>yn.create({...r,coerce:!0})},dw=ce;var Or=Object.freeze({__proto__:null,defaultErrorMap:js,setErrorMap:mv,getErrorMap:ui,makeIssue:li,EMPTY_PATH:yv,addIssueToContext:q,ParseStatus:lt,INVALID:ce,DIRTY:Xd,OK:bt,isAborted:Mo,isDirty:Uo,isValid:Rs,isAsync:di,get util(){return Oe},get objectUtil(){return Po},ZodParsedType:L,getParsedType:Pr,ZodType:fe,ZodString:jt,ZodNumber:Wr,ZodBigInt:Yr,ZodBoolean:zs,ZodDate:yn,ZodSymbol:hi,ZodUndefined:Ps,ZodNull:Ms,ZodAny:Vn,ZodUnknown:cn,ZodNever:Zr,ZodVoid:pi,ZodArray:Ut,ZodObject:Be,ZodUnion:Us,ZodDiscriminatedUnion:Pi,ZodIntersection:Ds,ZodTuple:tr,ZodRecord:Ls,ZodMap:fi,ZodSet:gn,ZodFunction:Cn,ZodLazy:Bs,ZodLiteral:Vs,ZodEnum:Jr,ZodNativeEnum:qs,ZodPromise:qn,ZodEffects:Vt,ZodTransformer:Vt,ZodOptional:Er,ZodNullable:vn,ZodDefault:Ks,ZodCatch:mi,ZodNaN:yi,BRAND:Ev,ZodBranded:eh,ZodPipeline:ra,ZodReadonly:gi,custom:th,Schema:fe,ZodSchema:fe,late:Av,get ZodFirstPartyTypeKind(){return Q},coerce:lw,any:Pv,array:Lv,bigint:$v,boolean:sh,date:Cv,discriminatedUnion:Kv,effect:Ru,enum:ew,function:Hv,instanceof:Iv,intersection:Fv,lazy:Xv,literal:Qv,map:Jv,nan:Zv,nativeEnum:tw,never:Uv,null:zv,nullable:sw,number:nh,object:Bv,oboolean:uw,onumber:cw,optional:nw,ostring:ow,pipeline:iw,preprocess:aw,promise:rw,record:Yv,set:Gv,strictObject:Vv,string:rh,symbol:jv,transformer:Ru,tuple:Wv,undefined:Rv,union:qv,unknown:Mv,void:Dv,NEVER:dw,ZodIssueCode:C,quotelessJson:fv,ZodError:Mt});class na extends Error{constructor(e,t){super(e),Ye(this,"discriminator","FreighterError"),Ye(this,"type"),this.type=t}}const hw=r=>{if(r==null||typeof r!="object")return!1;const e=r;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Lo="unknown",zu="nil",Mi="freighter",sa=Or.object({type:Or.string(),data:Or.string()});class pw{constructor(){Ye(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:zu,data:""};if(hw(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:Lo,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===zu)return null;if(e.type===Lo)return new Pu(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Pu(e.data)}}const ah=new pw,ih=({encode:r,decode:e})=>ah.register({encode:r,decode:e}),Nc=r=>ah.decode(r);class Pu extends na{constructor(e){super(e,Lo)}}class Fs extends na{constructor(){super("EOF",Mi)}}class vi extends na{constructor(){super("StreamClosed",Mi)}}class Ws extends na{constructor(e={}){const{message:t="Unreachable",url:n=Kg.UNKNOWN}=e;super(t,Mi),Ye(this,"url"),this.url=n}}const Ua="freighter",fw=r=>{if(r.type!==Mi)return null;if(r instanceof Fs)return{type:Ua,data:"EOF"};if(r instanceof vi)return{type:Ua,data:"StreamClosed"};if(r instanceof Ws)return{type:Ua,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},mw=r=>{if(r.type!==Ua)return null;switch(r.data){case"EOF":return new Fs;case"StreamClosed":return new vi;case"Unreachable":return new Ws;default:throw new Error(`Unknown error type: ${r.data}`)}};ih({encode:fw,decode:mw});class oh{constructor(){Ye(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const s=async a=>{if(n===this.middleware.length)return await t(a);const i=this.middleware[n];return n++,await i(a,s)};return await s(e)}}const ch="Content-Type",Mu=r=>{if(Md.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(s,a)=>await e(s,{...a,agent:n})};class yw extends oh{constructor(e,t,n=!1){return super(),Ye(this,"endpoint"),Ye(this,"encoder"),Ye(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=Mu(this.endpoint.protocol),new Proxy(this,{get:(s,a,i)=>a==="endpoint"?this.endpoint:Reflect.get(s,a,i)})}get headers(){return{[ch]:this.encoder.contentType}}async send(e,t,n,s){t=n==null?void 0:n.parse(t);let a=null;const i=this.endpoint.child(e),o={};o.method="POST",o.body=this.encoder.encode(t??{});const[,c]=await this.executeMiddleware({target:i.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async l=>{const m={...l,params:{}};o.headers={...this.headers,...l.params};let T;try{T=await Mu(l.protocol)(l.target,o)}catch(ee){let Ee=ee;return Ee.message==="Load failed"&&(Ee=new Ws({url:i})),[m,Ee]}const J=await T.arrayBuffer();if(T!=null&&T.ok)return s!=null&&(a=this.encoder.decode(J,s)),[m,null];try{if(T.status!==400)return[m,new Error(T.statusText)];const ee=this.encoder.decode(J,sa),Ee=Nc(ee);return[m,Ee]}catch(ee){return[m,new Error(`[freighter] - failed to decode error: ${T.statusText}: ${ee.message}`)]}});return[a,c]}}const G=async(r,e,t,n,s)=>{const[a,i]=await r.send(e,t,n,s);if(i!=null)throw i;return a},gw=()=>Md.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),vw=Or.object({type:Or.union([Or.literal("data"),Or.literal("close")]),payload:Or.unknown().optional(),error:Or.optional(sa)});class ww{constructor(e,t,n,s){Ye(this,"encoder"),Ye(this,"reqSchema"),Ye(this,"resSchema"),Ye(this,"ws"),Ye(this,"serverClosed"),Ye(this,"sendClosed"),Ye(this,"receiveDataQueue",[]),Ye(this,"receiveCallbacksQueue",[]),this.encoder=t,this.reqSchema=n,this.resSchema=s,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new Fs;if(this.sendClosed)throw new vi;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=Nc(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}listenForMessages(){this.ws.onmessage=e=>{const t=this.encoder.decode(e.data,vw),n=this.receiveCallbacksQueue.shift();n!=null?n.resolve(t):this.receiveDataQueue.push(t)},this.ws.onclose=e=>{this.serverClosed=Tw(e)?new Fs:new vi}}}const bw="freighterctx",_w=1e3,kw=1001,Ow=[_w,kw],Tw=r=>Ow.includes(r.code),uh=class lh extends oh{constructor(e,t,n=!1){super(),Ye(this,"baseUrl"),Ye(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=t}async stream(e,t,n){const s=gw();let a;const[,i]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async o=>{const c=s(this.buildURL(e,o)),l={...o,params:{}};c.binaryType=lh.MESSAGE_TYPE;const m=await this.wrapSocket(c,t,n);return m instanceof Error?[l,m]:(a=m,[l,null])});if(i!=null)throw i;return a}buildURL(e,t){const n=qg({[ch]:this.encoder.contentType,...t.params},bw);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise(s=>{e.onopen=()=>{s(new ww(e,this.encoder,t,n))},e.onerror=a=>{const i=a;s(new Error(i.message))}})}};Ye(uh,"MESSAGE_TYPE","arraybuffer");let xw=uh;const kr="sy.api.";var $r=(r=>(r.General=kr+"general",r.Parse=kr+"parse",r.Auth=kr+"auth",r.Unexpected=kr+"unexpected",r.Validation=kr+"validation",r.Query=kr+"query",r.Route=kr+"route",r))($r||{});class Hr extends na{constructor(e){super(e,kr)}}class gt extends Hr{constructor(t){var e=(...sk)=>(super(...sk),h(this,"fields"),this);typeof t=="string"?(e(t),this.fields=[]):Array.isArray(t)?(e(t.map(n=>`${n.field}: ${n.message}`).join(`
12
- `)),this.fields=t):(e(`${t.field}: ${t.message}`),this.fields=[t])}}class dh extends Hr{}class hh extends Hr{}class Ec extends Hr{}class wn extends Hr{constructor(e){super(`
9
+ `);return new wr({data:n,dataType:Ee.JSON,timeRange:t})}acquire(e){this._refCount++,e!=null&&this.updateGLBuffer(e)}release(){if(this._refCount--,this._refCount===0&&this.gl.control!=null)this.maybeGarbageCollectGLBuffer(this.gl.control);else if(this._refCount<0)throw new Error("cannot release an array with a negative reference count")}write(e){if(!e.dataType.equals(this.dataType))throw new Error("buffer must be of the same type as this array");if(this.writePos===tn)return 0;const t=this.capacity-this.writePos,n=t<e.length?e.slice(0,t):e;return this.underlyingData.set(n.data,this.writePos),this.maybeRecomputeMinMax(n),this._cachedLength=void 0,this.writePos+=n.length,n.length}get buffer(){return this._data}get underlyingData(){return new this.dataType.Array(this._data)}get data(){return this.writePos===tn?this.underlyingData:new this.dataType.Array(this._data,0,this.writePos)}toStrings(){if(!this.dataType.equals(Ee.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
10
+ `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(Ee.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=Ee.UUID.density.valueOf(),t=Array(this.length);for(let n=0;n<this.length;n++){const s=this.buffer.slice(n*e,(n+1)*e),a=Array.from(new Uint8Array(s),i=>i.toString(16).padStart(2,"0")).join("").replace(/(.{8})(.{4})(.{4})(.{4})(.{12})/,"$1-$2-$3-$4-$5");t[n]=a}return t}parseJSON(e){if(!this.dataType.equals(Ee.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
11
+ `).slice(0,-1).map(t=>e.parse(JSON.parse(t)))}get timeRange(){if(this._timeRange==null)throw new Error("time range not set on series");return this._timeRange}get byteCapacity(){return new Ya(this.buffer.byteLength)}get capacity(){return this.dataType.density.length(this.byteCapacity)}get byteLength(){return this.writePos===tn?this.byteCapacity:this.dataType.density.size(this.writePos)}get length(){return this._cachedLength!=null?this._cachedLength:this.dataType.isVariable?this.calculateCachedLength():this.writePos===tn?this.data.length:this.writePos}calculateCachedLength(){if(!this.dataType.isVariable)throw new Error("cannot calculate length of a non-variable length data type");let e=0;return this.data.forEach(t=>{t===10&&e++}),this._cachedLength=e,e}convert(e,t=0){if(this.dataType.equals(e))return this;const n=new e.Array(this.length);for(let s=0;s<this.length;s++)n[s]=cm(this.dataType,e,this.data[s],t);return new wr({data:n.buffer,dataType:e,timeRange:this._timeRange,sampleOffset:t,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment})}calcRawMax(){if(this.length===0)return-1/0;if(this.dataType.equals(Ee.TIMESTAMP))this._cachedMax=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._cachedMax=e.reduce((t,n)=>t>n?t:n)}return this._cachedMax}get max(){if(this.dataType.isVariable)throw new Error("cannot calculate maximum on a variable length data type");return this.writePos===0?-1/0:(this._cachedMax==null&&(this._cachedMax=this.calcRawMax()),rs(this._cachedMax,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(Ee.TIMESTAMP))this._cachedMin=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._cachedMin=e.reduce((t,n)=>t<n?t:n)}return this._cachedMin}get min(){if(this.dataType.isVariable)throw new Error("cannot calculate minimum on a variable length data type");return this.writePos===0?1/0:(this._cachedMin==null&&(this._cachedMin=this.calcRawMin()),rs(this._cachedMin,this.sampleOffset))}get bounds(){return ss(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._cachedMin!=null){const t=e._cachedMin??e.calcRawMin();t<this._cachedMin&&(this._cachedMin=t)}if(this._cachedMax!=null){const t=e._cachedMax??e.calcRawMax();t>this._cachedMax&&(this._cachedMax=t)}}enrich(){this.max,this.min}get range(){return rs(this.max,-this.min)}at(e,t){if(this.dataType.isVariable)return this.atVariable(e,t??!1);e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t===!0)throw new Error(`[series] - no value at index ${e}`);return}return rs(n,this.sampleOffset)}atVariable(e,t){e<0&&(e=this.length+e);let n=0,s=0;for(let i=0;i<this.data.length;i++)if(this.data[i]===10){if(e===0){s=i;break}n=i+1,e--}if(s===0&&(s=this.data.length),n>=s||e>0){if(t)throw new Error(`[series] - no value at index ${e}`);return}const a=this.data.slice(n,s);return this.dataType.equals(Ee.STRING)?new TextDecoder().decode(a):JSON.parse(new TextDecoder().decode(a))}binarySearch(e){let t=0,n=this.length-1;const s=fp(e);for(;t<=n;){const a=Math.floor((t+n)/2),i=s(this.at(a,!0),e);if(i===0)return a;i<0?t=a+1:n=a-1}return t}updateGLBuffer(e){if(this.gl.control=e,!this.dataType.equals(Ee.FLOAT32))throw new Error("Only FLOAT32 arrays can be used in WebGL");const{buffer:t,bufferUsage:n,prevBuffer:s}=this.gl;if(t==null&&(this.gl.buffer=e.createBuffer()),this.writePos!==s)if(e.bindBuffer(e.ARRAY_BUFFER,this.gl.buffer),this.writePos!==tn){s===0&&e.bufferData(e.ARRAY_BUFFER,this.byteCapacity.valueOf(),e.STATIC_DRAW);const a=this.dataType.density.size(s).valueOf(),i=this.underlyingData.slice(this.gl.prevBuffer,this.writePos);e.bufferSubData(e.ARRAY_BUFFER,a,i.buffer),this.gl.prevBuffer=this.writePos}else e.bufferData(e.ARRAY_BUFFER,this.buffer,n==="static"?e.STATIC_DRAW:e.DYNAMIC_DRAW),this.gl.prevBuffer=tn}as(e){if(!new Ee(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get digest(){var e;return{key:this.key,dataType:this.dataType.toString(),sampleOffset:this.sampleOffset,alignment:this.alignmentBounds,timeRange:(e=this._timeRange)==null?void 0:e.toString(),length:this.length,capacity:this.capacity}}get memInfo(){return{key:this.key,length:this.length,byteLength:this.byteLength,glBuffer:this.gl.buffer!=null}}get alignmentBounds(){return ss(this.alignment,this.alignment+this.length)}maybeGarbageCollectGLBuffer(e){this.gl.buffer!=null&&(e.deleteBuffer(this.gl.buffer),this.gl.buffer=null,this.gl.prevBuffer=0,this.gl.control=null)}get glBuffer(){if(this.gl.buffer==null)throw new Error("gl buffer not initialized");return this.gl.prevBuffer!==this.writePos&&console.warn("buffer not updated"),this.gl.buffer}[Symbol.iterator](){if(this.dataType.isVariable){const e=new lm(this);return this.dataType.equals(Ee.JSON)?new dm(e):e}return new hm(this)}slice(e,t){if(e<=0&&(t==null||t>=this.length))return this;const n=this.data.slice(e,t);return new wr({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+e})}reAlign(e){return new wr({data:this.buffer,dataType:this.dataType,timeRange:Et.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};class lm{constructor(e){if(x(this,"series"),x(this,"index"),x(this,"decoder"),!e.dataType.isVariable)throw new Error("cannot create a variable series iterator for a non-variable series");this.series=e,this.index=0,this.decoder=new TextDecoder}next(){const e=this.index,t=this.series.data;for(;this.index<t.length&&t[this.index]!==10;)this.index++;const n=this.index;return e===n?{done:!0,value:void 0}:(this.index++,{done:!1,value:this.decoder.decode(this.series.buffer.slice(e,n))})}[Symbol.iterator](){return this}}var Pl;class dm{constructor(e){x(this,"wrapped"),x(this,Pl,"JSONSeriesIterator"),this.wrapped=e}next(){const e=this.wrapped.next();return e.done===!0?{done:!0,value:void 0}:{done:!1,value:JSON.parse(e.value)}}[Symbol.iterator](){return this}}Pl=Symbol.toStringTag;var Ml;class hm{constructor(e){x(this,"series"),x(this,"index"),x(this,Ml,"SeriesIterator"),this.series=e,this.index=0}next(){return this.index>=this.series.length?{done:!0,value:void 0}:{done:!1,value:this.series.at(this.index++,!0)}}[Symbol.iterator](){return this}}Ml=Symbol.toStringTag;const rs=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:Number(r)+Number(e);let Ul=class{constructor(e){if(x(this,"series"),e.length!==0){const t=e[0].dataType;for(let n=1;n<e.length;n++)if(!e[n].dataType.equals(t))throw new Error("[multi-series] - series must have the same data type")}this.series=e}as(e){if(!new Ee(e).equals(this.dataType))throw new Error(`cannot convert series of type ${this.dataType.toString()} to ${e.toString()}`);return this}get dataType(){return this.series.length===0?Ee.UNKNOWN:this.series[0].dataType}get timeRange(){return this.series.length===0?Et.ZERO:new Et(this.series[0].timeRange.start,this.series[this.series.length-1].timeRange.end)}push(e){this.series.push(e)}get length(){return this.series.reduce((e,t)=>e+t.length,0)}at(e,t=!1){e<0&&(e=this.length+e);for(const n of this.series){if(e<n.length)return n.at(e,t);e-=n.length}if(t)throw new Error(`[series] - no value at index ${e}`)}[Symbol.iterator](){return this.series.length===0?{next(){return{done:!0,value:void 0}}}:new pm(this.series)}};var Dl;class pm{constructor(e){x(this,"series"),x(this,"seriesIndex"),x(this,"internal"),x(this,Dl,"MultiSeriesIterator"),this.series=e,this.seriesIndex=0,this.internal=e[0][Symbol.iterator]()}next(){const e=this.internal.next();return e.done===!1?e:this.seriesIndex===this.series.length-1?{done:!0,value:void 0}:(this.internal=this.series[++this.seriesIndex][Symbol.iterator](),this.next())}[Symbol.iterator](){return this}}Dl=Symbol.toStringTag;const oc=S.record(S.union([S.number(),S.string(),S.symbol()]),S.unknown()),Ll=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),fm=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";fm();const mm=["MacOS","Windows","Linux","Docker"];S.enum(mm);const ym=(r,e)=>{let t=null;return e===0?r:(...n)=>{t!==null&&(clearTimeout(t),t=null),t=setTimeout(()=>r(...n),e)}},eu=r=>[...new Set(r)],gm=(...r)=>r.map(Bl).join(""),Bl=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),vm=r=>r.endsWith("/")?r.slice(0,-1):r;var kn;let wm=(kn=class{constructor({host:r,port:e,protocol:t="",pathPrefix:n=""}){x(this,"protocol"),x(this,"host"),x(this,"port"),x(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=Bl(n)}replace(r){return new kn({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new kn({...this,pathPrefix:gm(this.path,r)})}toString(){return vm(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},x(kn,"UNKNOWN",new kn({host:"unknown",port:0})),kn);const Se=r=>Array.isArray(r)?r:[r];var Oo;try{Oo=new TextDecoder}catch{}var z,St,p=0,Pe={},we,Mr,Tt=0,Yt=0,Xe,xr,kt=[],ge,tu={useRecords:!1,mapsAsObjects:!0};let Vl=class{};const ql=new Vl;ql.name="MessagePack 0xC1";var Dr=!1,Kl=2,ru;try{new Function("")}catch{Kl=1/0}let Fl=class To{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=!1&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(z)return Hl(()=>(So(),this?this.unpack(e,t):To.prototype.unpack.call(tu,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(St=t.end||e.length,p=t.start||0):(p=0,St=t>-1?t:e.length),Yt=0,Mr=null,Xe=null,z=e;try{ge=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw z=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof To){if(Pe=this,this.structures)return we=this.structures,ca(t);(!we||we.length>0)&&(we=[])}else Pe=tu,(!we||we.length>0)&&(we=[]);return ca(t)}unpackMultiple(e,t){let n,s=0;try{Dr=!0;let a=e.length,i=this?this.unpack(e,a):Si.unpack(e,a);if(t){if(t(i,s,p)===!1)return;for(;p<a;)if(s=p,t(ca(),s,p)===!1)return}else{for(n=[i];p<a;)s=p,n.push(ca());return n}}catch(a){throw a.lastPosition=s,a.values=n,a}finally{Dr=!1,So()}}_mergeStructures(e,t){e=e||[],Object.isFrozen(e)&&(e=e.map(n=>n.slice(0)));for(let n=0,s=e.length;n<s;n++){let a=e[n];a&&(a.isShared=!0,n>=32&&(a.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let s=e[n],a=t[n];a&&(s&&((e.restoreStructures||(e.restoreStructures=[]))[n]=s),e[n]=a)}return this.structures=e}decode(e,t){return this.unpack(e,t)}};function ca(r){try{if(!Pe.trusted&&!Dr){let t=we.sharedLength||0;t<we.length&&(we.length=t)}let e;if(Pe.randomAccessStructure&&z[p]<64&&z[p]>=32&&ru?(e=ru(z,p,St,Pe),z=null,!(r&&r.lazy)&&e&&(e=e.toJSON()),p=St):e=Ve(),Xe&&(p=Xe.postBundlePosition,Xe=null),Dr&&(we.restoreStructures=null),p==St)we&&we.restoreStructures&&nu(),we=null,z=null,xr&&(xr=null);else{if(p>St)throw new Error("Unexpected end of MessagePack data");if(!Dr){let t;try{t=JSON.stringify(e,(n,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(n){t="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+t)}}return e}catch(e){throw we&&we.restoreStructures&&nu(),So(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||p>St)&&(e.incomplete=!0),e}}function nu(){for(let r in we.restoreStructures)we[r]=we.restoreStructures[r];we.restoreStructures=null}function Ve(){let r=z[p++];if(r<160)if(r<128){if(r<64)return r;{let e=we[r&63]||Pe.getStructures&&Wl()[r&63];return e?(e.read||(e.read=cc(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,Pe.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Jl();n==="__proto__"&&(n="__proto_"),e[n]=Ve()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Ve(),Ve());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Ve();return Pe.freezeData?Object.freeze(e):e}else if(r<192){let e=r-160;if(Yt>=p)return Mr.slice(p-Tt,(p+=e)-Tt);if(Yt==0&&St<140){let t=e<16?uc(e):Yl(e);if(t!=null)return t}return xo(e)}else{let e;switch(r){case 192:return null;case 193:return Xe?(e=Ve(),e>0?Xe[1].slice(Xe.position1,Xe.position1+=e):Xe[0].slice(Xe.position0,Xe.position0-=e)):ql;case 194:return!1;case 195:return!0;case 196:if(e=z[p++],e===void 0)throw new Error("Unexpected end of buffer");return Yi(e);case 197:return e=ge.getUint16(p),p+=2,Yi(e);case 198:return e=ge.getUint32(p),p+=4,Yi(e);case 199:return rn(z[p++]);case 200:return e=ge.getUint16(p),p+=2,rn(e);case 201:return e=ge.getUint32(p),p+=4,rn(e);case 202:if(e=ge.getFloat32(p),Pe.useFloat32>2){let t=lc[(z[p]&127)<<1|z[p+1]>>7];return p+=4,(t*e+(e>0?.5:-.5)>>0)/t}return p+=4,e;case 203:return e=ge.getFloat64(p),p+=8,e;case 204:return z[p++];case 205:return e=ge.getUint16(p),p+=2,e;case 206:return e=ge.getUint32(p),p+=4,e;case 207:return Pe.int64AsType==="number"?(e=ge.getUint32(p)*4294967296,e+=ge.getUint32(p+4)):Pe.int64AsType==="string"?e=ge.getBigUint64(p).toString():Pe.int64AsType==="auto"?(e=ge.getBigUint64(p),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ge.getBigUint64(p),p+=8,e;case 208:return ge.getInt8(p++);case 209:return e=ge.getInt16(p),p+=2,e;case 210:return e=ge.getInt32(p),p+=4,e;case 211:return Pe.int64AsType==="number"?(e=ge.getInt32(p)*4294967296,e+=ge.getUint32(p+4)):Pe.int64AsType==="string"?e=ge.getBigInt64(p).toString():Pe.int64AsType==="auto"?(e=ge.getBigInt64(p),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ge.getBigInt64(p),p+=8,e;case 212:if(e=z[p++],e==114)return uu(z[p++]&63);{let t=kt[e];if(t)return t.read?(p++,t.read(Ve())):t.noBuffer?(p++,t()):t(z.subarray(p,++p));throw new Error("Unknown extension "+e)}case 213:return e=z[p],e==114?(p++,uu(z[p++]&63,z[p++])):rn(2);case 214:return rn(4);case 215:return rn(8);case 216:return rn(16);case 217:return e=z[p++],Yt>=p?Mr.slice(p-Tt,(p+=e)-Tt):_m(e);case 218:return e=ge.getUint16(p),p+=2,Yt>=p?Mr.slice(p-Tt,(p+=e)-Tt):km(e);case 219:return e=ge.getUint32(p),p+=4,Yt>=p?Mr.slice(p-Tt,(p+=e)-Tt):Om(e);case 220:return e=ge.getUint16(p),p+=2,au(e);case 221:return e=ge.getUint32(p),p+=4,au(e);case 222:return e=ge.getUint16(p),p+=2,iu(e);case 223:return e=ge.getUint32(p),p+=4,iu(e);default:if(r>=224)return r-256;if(r===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+r)}}}const bm=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function cc(r,e){function t(){if(t.count++>Kl){let s=r.read=new Function("r","return function(){return "+(Pe.freezeData?"Object.freeze":"")+"({"+r.map(a=>a==="__proto__"?"__proto_:r()":bm.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"})}")(Ve);return r.highByte===0&&(r.read=su(e,r.read)),s()}let n={};for(let s=0,a=r.length;s<a;s++){let i=r[s];i==="__proto__"&&(i="__proto_"),n[i]=Ve()}return Pe.freezeData?Object.freeze(n):n}return t.count=0,r.highByte===0?su(e,t):t}const su=(r,e)=>function(){let t=z[p++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),s=we[n]||Wl()[n];if(!s)throw new Error("Record id is not defined for "+n);return s.read||(s.read=cc(s,r)),s.read()};function Wl(){let r=Hl(()=>(z=null,Pe.getStructures()));return we=Pe._mergeStructures(r,we)}var xo=Js,_m=Js,km=Js,Om=Js;function Js(r){let e;if(r<16&&(e=uc(r)))return e;if(r>64&&Oo)return Oo.decode(z.subarray(p,p+=r));const t=p+r,n=[];for(e="";p<t;){const s=z[p++];if(!(s&128))n.push(s);else if((s&224)===192){const a=z[p++]&63;n.push((s&31)<<6|a)}else if((s&240)===224){const a=z[p++]&63,i=z[p++]&63;n.push((s&31)<<12|a<<6|i)}else if((s&248)===240){const a=z[p++]&63,i=z[p++]&63,o=z[p++]&63;let c=(s&7)<<18|a<<12|i<<6|o;c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c)}else n.push(s);n.length>=4096&&(e+=Ge.apply(String,n),n.length=0)}return n.length>0&&(e+=Ge.apply(String,n)),e}function au(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Ve();return Pe.freezeData?Object.freeze(e):e}function iu(r){if(Pe.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Jl();n==="__proto__"&&(n="__proto_"),e[n]=Ve()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Ve(),Ve());return e}}var Ge=String.fromCharCode;function Yl(r){let e=p,t=new Array(r);for(let n=0;n<r;n++){const s=z[p++];if((s&128)>0){p=e;return}t[n]=s}return Ge.apply(String,t)}function uc(r){if(r<4)if(r<2){if(r===0)return"";{let e=z[p++];if((e&128)>1){p-=1;return}return Ge(e)}}else{let e=z[p++],t=z[p++];if((e&128)>0||(t&128)>0){p-=2;return}if(r<3)return Ge(e,t);let n=z[p++];if((n&128)>0){p-=3;return}return Ge(e,t,n)}else{let e=z[p++],t=z[p++],n=z[p++],s=z[p++];if((e&128)>0||(t&128)>0||(n&128)>0||(s&128)>0){p-=4;return}if(r<6){if(r===4)return Ge(e,t,n,s);{let a=z[p++];if((a&128)>0){p-=5;return}return Ge(e,t,n,s,a)}}else if(r<8){let a=z[p++],i=z[p++];if((a&128)>0||(i&128)>0){p-=6;return}if(r<7)return Ge(e,t,n,s,a,i);let o=z[p++];if((o&128)>0){p-=7;return}return Ge(e,t,n,s,a,i,o)}else{let a=z[p++],i=z[p++],o=z[p++],c=z[p++];if((a&128)>0||(i&128)>0||(o&128)>0||(c&128)>0){p-=8;return}if(r<10){if(r===8)return Ge(e,t,n,s,a,i,o,c);{let l=z[p++];if((l&128)>0){p-=9;return}return Ge(e,t,n,s,a,i,o,c,l)}}else if(r<12){let l=z[p++],m=z[p++];if((l&128)>0||(m&128)>0){p-=10;return}if(r<11)return Ge(e,t,n,s,a,i,o,c,l,m);let T=z[p++];if((T&128)>0){p-=11;return}return Ge(e,t,n,s,a,i,o,c,l,m,T)}else{let l=z[p++],m=z[p++],T=z[p++],J=z[p++];if((l&128)>0||(m&128)>0||(T&128)>0||(J&128)>0){p-=12;return}if(r<14){if(r===12)return Ge(e,t,n,s,a,i,o,c,l,m,T,J);{let ee=z[p++];if((ee&128)>0){p-=13;return}return Ge(e,t,n,s,a,i,o,c,l,m,T,J,ee)}}else{let ee=z[p++],Ne=z[p++];if((ee&128)>0||(Ne&128)>0){p-=14;return}if(r<15)return Ge(e,t,n,s,a,i,o,c,l,m,T,J,ee,Ne);let te=z[p++];if((te&128)>0){p-=15;return}return Ge(e,t,n,s,a,i,o,c,l,m,T,J,ee,Ne,te)}}}}}function ou(){let r=z[p++],e;if(r<192)e=r-160;else switch(r){case 217:e=z[p++];break;case 218:e=ge.getUint16(p),p+=2;break;case 219:e=ge.getUint32(p),p+=4;break;default:throw new Error("Expected string")}return Js(e)}function Yi(r){return Pe.copyBuffers?Uint8Array.prototype.slice.call(z,p,p+=r):z.subarray(p,p+=r)}function rn(r){let e=z[p++];if(kt[e]){let t;return kt[e](z.subarray(p,t=p+=r),n=>{p=n;try{return Ve()}finally{p=t}})}else throw new Error("Unknown extension type "+e)}var cu=new Array(4096);function Jl(){let r=z[p++];if(r>=160&&r<192){if(r=r-160,Yt>=p)return Mr.slice(p-Tt,(p+=r)-Tt);if(!(Yt==0&&St<180))return xo(r)}else return p--,Ve().toString();let e=(r<<5^(r>1?ge.getUint16(p):r>0?z[p]:0))&4095,t=cu[e],n=p,s=p+r-3,a,i=0;if(t&&t.bytes==r){for(;n<s;){if(a=ge.getUint32(n),a!=t[i++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(a=z[n++],a!=t[i++]){n=1879048192;break}if(n===s)return p=n,t.string;s-=3,n=p}for(t=[],cu[e]=t,t.bytes=r;n<s;)a=ge.getUint32(n),t.push(a),n+=4;for(s+=3;n<s;)a=z[n++],t.push(a);let o=r<16?uc(r):Yl(r);return o!=null?t.string=o:t.string=xo(r)}const uu=(r,e)=>{let t=Ve().map(a=>a.toString()),n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let s=we[r];return s&&(s.isShared||Dr)&&((we.restoreStructures||(we.restoreStructures=[]))[r]=s),we[r]=t,t.read=cc(t,n),t.read()};kt[0]=()=>{};kt[0].noBuffer=!0;let Tm={Error,TypeError,ReferenceError};kt[101]=()=>{let r=Ve();return(Tm[r[0]]||Error)(r[1])};kt[105]=r=>{let e=ge.getUint32(p-4);xr||(xr=new Map);let t=z[p],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};xr.set(e,s);let a=Ve();return s.used?Object.assign(n,a):(s.target=a,a)};kt[112]=r=>{let e=ge.getUint32(p-4),t=xr.get(e);return t.used=!0,t.target};kt[115]=()=>new Set(Ve());const Gl=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");let xm=typeof globalThis=="object"?globalThis:window;kt[116]=r=>{let e=r[0],t=Gl[e];if(!t)throw new Error("Could not find typed array for code "+e);return new xm[t](Uint8Array.prototype.slice.call(r,1).buffer)};kt[120]=()=>{let r=Ve();return new RegExp(r[0],r[1])};const Sm=[];kt[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=p;return p+=e-r.length,Xe=Sm,Xe=[ou(),ou()],Xe.position0=0,Xe.position1=0,Xe.postBundlePosition=p,p=t,Ve()};kt[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function Hl(r){let e=St,t=p,n=Tt,s=Yt,a=Mr,i=xr,o=Xe,c=new Uint8Array(z.slice(0,St)),l=we,m=we.slice(0,we.length),T=Pe,J=Dr,ee=r();return St=e,p=t,Tt=n,Yt=s,Mr=a,xr=i,Xe=o,z=c,Dr=J,we=l,we.splice(0,we.length,...m),Pe=T,ge=new DataView(z.buffer,z.byteOffset,z.byteLength),ee}function So(){z=null,xr=null,we=null}const lc=new Array(147);for(let r=0;r<256;r++)lc[r]=+("1e"+Math.floor(45.15-r*.30103));var Si=new Fl({useRecords:!1});const Nm=Si.unpack;Si.unpackMultiple;Si.unpack;let Em=new Float32Array(1);new Uint8Array(Em.buffer,0,4);let xa;try{xa=new TextEncoder}catch{}let No,Xl;const Ni=typeof Buffer<"u",ua=Ni?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,Ql=Ni?Buffer:Uint8Array,lu=Ni?4294967296:2144337920;let b,Hn,$e,v=0,pt,Ue=null,Am;const Im=21760,Zm=/[\u0080-\uFFFF]/,On=Symbol("record-id");let $m=class extends Fl{constructor(e){super(e),this.offset=0;let t,n,s,a,i=Ql.prototype.utf8Write?function(d,O){return b.utf8Write(d,O,4294967295)}:xa&&xa.encodeInto?function(d,O){return xa.encodeInto(d,b.subarray(O)).written}:!1,o=this;e||(e={});let c=e&&e.sequential,l=e.structures||e.saveStructures,m=e.maxSharedStructures;if(m==null&&(m=l?32:0),m>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let T=e.maxOwnStructures;T==null&&(T=l?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let J=m>32||T+m>64,ee=m+64,Ne=m+T+64;if(Ne>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let te=[],rr=0,nr=0;this.pack=this.encode=function(d,O){if(b||(b=new ua(8192),$e=b.dataView||(b.dataView=new DataView(b.buffer,0,8192)),v=0),pt=b.length-10,pt-v<2048?(b=new ua(b.length),$e=b.dataView||(b.dataView=new DataView(b.buffer,0,b.length)),pt=b.length-10,v=0):v=v+7&2147483640,t=v,O&Um&&(v+=O&255),a=o.structuredClone?new Map:null,o.bundleStrings&&typeof d!="string"?(Ue=[],Ue.size=1/0):Ue=null,s=o.structures,s){s.uninitialized&&(s=o._mergeStructures(o.getStructures()));let y=s.sharedLength||0;if(y>m)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+s.sharedLength);if(!s.transitions){s.transitions=Object.create(null);for(let g=0;g<y;g++){let k=s[g];if(!k)continue;let R,M=s.transitions;for(let I=0,ne=k.length;I<ne;I++){let K=k[I];R=M[K],R||(R=M[K]=Object.create(null)),M=R}M[On]=g+64}this.lastNamedStructuresLength=y}c||(s.nextId=y+64)}n&&(n=!1);try{o.randomAccessStructure&&d&&d.constructor&&d.constructor===Object?qi(d):re(d);let y=Ue;if(Ue&&pu(t,re,0),a&&a.idsToInsert){let g=a.idsToInsert.sort((I,ne)=>I.offset>ne.offset?1:-1),k=g.length,R=-1;for(;y&&k>0;){let I=g[--k].offset+t;I<y.stringsPosition+t&&R===-1&&(R=0),I>y.position+t?R>=0&&(R+=6):(R>=0&&($e.setUint32(y.position+t,$e.getUint32(y.position+t)+R),R=-1),y=y.previous,k++)}R>=0&&y&&$e.setUint32(y.position+t,$e.getUint32(y.position+t)+R),v+=g.length*6,v>pt&&et(v),o.offset=v;let M=jm(b.subarray(t,v),g);return a=null,M}return o.offset=v,O&Pm?(b.start=t,b.end=v,b):b.subarray(t,v)}finally{if(s&&(Fn(),n&&o.saveStructures)){let y=s.sharedLength||0,g=b.subarray(t,v),k=Rm(s,o);return o.saveStructures(k,k.isCompatible)===!1?o.pack(d,O):(o.lastNamedStructuresLength=y,g)}O&Mm&&(v=t)}};const Fn=()=>{nr<10&&nr++;let d=s.sharedLength||0;if(s.length>d&&!c&&(s.length=d),rr>1e4)s.transitions=null,nr=0,rr=0,te.length>0&&(te=[]);else if(te.length>0&&!c){for(let O=0,y=te.length;O<y;O++)te[O][On]=0;te=[]}},Qr=d=>{var O=d.length;O<16?b[v++]=144|O:O<65536?(b[v++]=220,b[v++]=O>>8,b[v++]=O&255):(b[v++]=221,$e.setUint32(v,O),v+=4);for(let y=0;y<O;y++)re(d[y])},re=d=>{v>pt&&(b=et(v));var O=typeof d,y;if(O==="string"){let g=d.length;if(Ue&&g>=4&&g<4096){if((Ue.size+=g)>Im){let I,ne=(Ue[0]?Ue[0].length*3+Ue[1].length:0)+10;v+ne>pt&&(b=et(v+ne));let K;Ue.position?(K=Ue,b[v]=200,v+=3,b[v++]=98,I=v-t,v+=4,pu(t,re,0),$e.setUint16(I+t-3,v-t-I)):(b[v++]=214,b[v++]=98,I=v-t,v+=4),Ue=["",""],Ue.previous=K,Ue.size=0,Ue.position=I}let M=Zm.test(d);Ue[M?0:1]+=d,b[v++]=193,re(M?-g:g);return}let k;g<32?k=1:g<256?k=2:g<65536?k=3:k=5;let R=g*3;if(v+R>pt&&(b=et(v+R)),g<64||!i){let M,I,ne,K=v+k;for(M=0;M<g;M++)I=d.charCodeAt(M),I<128?b[K++]=I:I<2048?(b[K++]=I>>6|192,b[K++]=I&63|128):(I&64512)===55296&&((ne=d.charCodeAt(M+1))&64512)===56320?(I=65536+((I&1023)<<10)+(ne&1023),M++,b[K++]=I>>18|240,b[K++]=I>>12&63|128,b[K++]=I>>6&63|128,b[K++]=I&63|128):(b[K++]=I>>12|224,b[K++]=I>>6&63|128,b[K++]=I&63|128);y=K-v-k}else y=i(d,v+k);y<32?b[v++]=160|y:y<256?(k<2&&b.copyWithin(v+2,v+1,v+1+y),b[v++]=217,b[v++]=y):y<65536?(k<3&&b.copyWithin(v+3,v+2,v+2+y),b[v++]=218,b[v++]=y>>8,b[v++]=y&255):(k<5&&b.copyWithin(v+5,v+3,v+3+y),b[v++]=219,$e.setUint32(v,y),v+=4),v+=y}else if(O==="number")if(d>>>0===d)d<32||d<128&&this.useRecords===!1||d<64&&!this.randomAccessStructure?b[v++]=d:d<256?(b[v++]=204,b[v++]=d):d<65536?(b[v++]=205,b[v++]=d>>8,b[v++]=d&255):(b[v++]=206,$e.setUint32(v,d),v+=4);else if(d>>0===d)d>=-32?b[v++]=256+d:d>=-128?(b[v++]=208,b[v++]=d+256):d>=-32768?(b[v++]=209,$e.setInt16(v,d),v+=2):(b[v++]=210,$e.setInt32(v,d),v+=4);else{let g;if((g=this.useFloat32)>0&&d<4294967296&&d>=-2147483648){b[v++]=202,$e.setFloat32(v,d);let k;if(g<4||(k=d*lc[(b[v]&127)<<1|b[v+1]>>7])>>0===k){v+=4;return}else v--}b[v++]=203,$e.setFloat64(v,d),v+=8}else if(O==="object"||O==="function")if(!d)b[v++]=192;else{if(a){let k=a.get(d);if(k){if(!k.id){let R=a.idsToInsert||(a.idsToInsert=[]);k.id=R.push(k)}b[v++]=214,b[v++]=112,$e.setUint32(v,k.id),v+=4;return}else a.set(d,{offset:v-t})}let g=d.constructor;if(g===Object)sr(d,!0);else if(g===Array)Qr(d);else if(g===Map)if(this.mapAsEmptyObject)b[v++]=128;else{y=d.size,y<16?b[v++]=128|y:y<65536?(b[v++]=222,b[v++]=y>>8,b[v++]=y&255):(b[v++]=223,$e.setUint32(v,y),v+=4);for(let[k,R]of d)re(k),re(R)}else{for(let k=0,R=No.length;k<R;k++){let M=Xl[k];if(d instanceof M){let I=No[k];if(I.write){I.type&&(b[v++]=212,b[v++]=I.type,b[v++]=0);let tt=I.write.call(this,d);tt===d?Array.isArray(d)?Qr(d):sr(d):re(tt);return}let ne=b,K=$e,Ke=v;b=null;let ht;try{ht=I.pack.call(this,d,tt=>(b=ne,ne=null,v+=tt,v>pt&&et(v),{target:b,targetView:$e,position:v-tt}),re)}finally{ne&&(b=ne,$e=K,v=Ke,pt=b.length-10)}ht&&(ht.length+v>pt&&et(ht.length+v),v=Cm(ht,b,v,I.type));return}}if(Array.isArray(d))Qr(d);else{if(d.toJSON){const k=d.toJSON();if(k!==d)return re(k)}if(O==="function")return re(this.writeFunction&&this.writeFunction(d));sr(d,!d.hasOwnProperty)}}}else if(O==="boolean")b[v++]=d?195:194;else if(O==="bigint"){if(d<BigInt(1)<<BigInt(63)&&d>=-(BigInt(1)<<BigInt(63)))b[v++]=211,$e.setBigInt64(v,d);else if(d<BigInt(1)<<BigInt(64)&&d>0)b[v++]=207,$e.setBigUint64(v,d);else if(this.largeBigIntToFloat)b[v++]=203,$e.setFloat64(v,Number(d));else throw new RangeError(d+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");v+=8}else if(O==="undefined")this.encodeUndefinedAsNil?b[v++]=192:(b[v++]=212,b[v++]=0,b[v++]=0);else throw new Error("Unknown type: "+O)},Wn=this.variableMapSize||this.coercibleKeyAsNumber?d=>{let O=Object.keys(d),y=O.length;y<16?b[v++]=128|y:y<65536?(b[v++]=222,b[v++]=y>>8,b[v++]=y&255):(b[v++]=223,$e.setUint32(v,y),v+=4);let g;if(this.coercibleKeyAsNumber)for(let k=0;k<y;k++){g=O[k];let R=Number(g);re(isNaN(R)?g:R),re(d[g])}else for(let k=0;k<y;k++)re(g=O[k]),re(d[g])}:(d,O)=>{b[v++]=222;let y=v-t;v+=2;let g=0;for(let k in d)(O||d.hasOwnProperty(k))&&(re(k),re(d[k]),g++);b[y+++t]=g>>8,b[y+t]=g&255},Yn=this.useRecords===!1?Wn:e.progressiveRecords&&!J?(d,O)=>{let y,g=s.transitions||(s.transitions=Object.create(null)),k=v++-t,R;for(let M in d)if(O||d.hasOwnProperty(M)){if(y=g[M],y)g=y;else{let I=Object.keys(d),ne=g;g=s.transitions;let K=0;for(let Ke=0,ht=I.length;Ke<ht;Ke++){let tt=I[Ke];y=g[tt],y||(y=g[tt]=Object.create(null),K++),g=y}k+t+1==v?(v--,en(g,I,K)):Gn(g,I,k,K),R=!0,g=ne[M]}re(d[M])}if(!R){let M=g[On];M?b[k+t]=M:Gn(g,Object.keys(d),k,0)}}:(d,O)=>{let y,g=s.transitions||(s.transitions=Object.create(null)),k=0;for(let M in d)(O||d.hasOwnProperty(M))&&(y=g[M],y||(y=g[M]=Object.create(null),k++),g=y);let R=g[On];R?R>=96&&J?(b[v++]=((R-=96)&31)+96,b[v++]=R>>5):b[v++]=R:en(g,g.__keys__||Object.keys(d),k);for(let M in d)(O||d.hasOwnProperty(M))&&re(d[M])},Jn=typeof this.useRecords=="function"&&this.useRecords,sr=Jn?(d,O)=>{Jn(d)?Yn(d,O):Wn(d,O)}:Yn,et=d=>{let O;if(d>16777216){if(d-t>lu)throw new Error("Packed buffer would be larger than maximum buffer size");O=Math.min(lu,Math.round(Math.max((d-t)*(d>67108864?1.25:2),4194304)/4096)*4096)}else O=(Math.max(d-t<<2,b.length-1)>>12)+1<<12;let y=new ua(O);return $e=y.dataView||(y.dataView=new DataView(y.buffer,0,O)),d=Math.min(d,b.length),b.copy?b.copy(y,0,t,d):y.set(b.slice(t,d)),v-=t,t=0,pt=y.length-10,b=y},en=(d,O,y)=>{let g=s.nextId;g||(g=64),g<ee&&this.shouldShareStructure&&!this.shouldShareStructure(O)?(g=s.nextOwnId,g<Ne||(g=ee),s.nextOwnId=g+1):(g>=Ne&&(g=ee),s.nextId=g+1);let k=O.highByte=g>=96&&J?g-96>>5:-1;d[On]=g,d.__keys__=O,s[g-64]=O,g<ee?(O.isShared=!0,s.sharedLength=g-63,n=!0,k>=0?(b[v++]=(g&31)+96,b[v++]=k):b[v++]=g):(k>=0?(b[v++]=213,b[v++]=114,b[v++]=(g&31)+96,b[v++]=k):(b[v++]=212,b[v++]=114,b[v++]=g),y&&(rr+=nr*y),te.length>=T&&(te.shift()[On]=0),te.push(d),re(O))},Gn=(d,O,y,g)=>{let k=b,R=v,M=pt,I=t;b=Hn,v=0,t=0,b||(Hn=b=new ua(8192)),pt=b.length-10,en(d,O,g),Hn=b;let ne=v;if(b=k,v=R,pt=M,t=I,ne>1){let K=v+ne-1;K>pt&&et(K);let Ke=y+t;b.copyWithin(Ke+ne,Ke+1,v),b.set(Hn.slice(0,ne),Ke),v=K}else b[y+t]=Hn[0]},qi=(d,O)=>{let y=Am(d,b,t,v,s,et,(g,k,R)=>{if(R)return n=!0;v=k;let M=b;return re(g),Fn(),M!==b?{position:v,targetView:$e,target:b}:v},this);if(y===0)return sr(d,!0);v=y}}useBuffer(e){b=e,$e=new DataView(b.buffer,b.byteOffset,b.byteLength),v=0}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}};Xl=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Vl];No=[{pack(r,e,t){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:s,targetView:a,position:i}=e(6);s[i++]=214,s[i++]=255,a.setUint32(i,n)}else if(n>0&&n<4294967296){let{target:s,targetView:a,position:i}=e(10);s[i++]=215,s[i++]=255,a.setUint32(i,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),a.setUint32(i+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:s,targetView:a,position:i}=e(3);s[i++]=212,s[i++]=255,s[i++]=255}else{let{target:s,targetView:a,position:i}=e(15);s[i++]=199,s[i++]=12,s[i++]=255,a.setUint32(i,r.getMilliseconds()*1e6),a.setBigInt64(i+4,BigInt(Math.floor(n)))}}},{pack(r,e,t){if(this.setAsEmptyObject)return e(0),t({});let n=Array.from(r),{target:s,position:a}=e(this.moreTypes?3:0);this.moreTypes&&(s[a++]=212,s[a++]=115,s[a++]=0),t(n)}},{pack(r,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=101,n[s++]=0),t([r.name,r.message])}},{pack(r,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=120,n[s++]=0),t([r.source,r.flags])}},{pack(r,e){this.moreTypes?du(r,16,e):hu(Ni?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==Ql&&this.moreTypes?du(r,Gl.indexOf(t.name),e):hu(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function du(r,e,t,n){let s=r.byteLength;if(s+1<256){var{target:a,position:i}=t(4+s);a[i++]=199,a[i++]=s+1}else if(s+1<65536){var{target:a,position:i}=t(5+s);a[i++]=200,a[i++]=s+1>>8,a[i++]=s+1&255}else{var{target:a,position:i,targetView:o}=t(7+s);a[i++]=201,o.setUint32(i,s+1),i+=4}a[i++]=116,a[i++]=e,a.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),i)}function hu(r,e){let t=r.byteLength;var n,s;if(t<256){var{target:n,position:s}=e(t+2);n[s++]=196,n[s++]=t}else if(t<65536){var{target:n,position:s}=e(t+3);n[s++]=197,n[s++]=t>>8,n[s++]=t&255}else{var{target:n,position:s,targetView:a}=e(t+5);n[s++]=198,a.setUint32(s,t),s+=4}n.set(r,s)}function Cm(r,e,t,n){let s=r.length;switch(s){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:s<256?(e[t++]=199,e[t++]=s):s<65536?(e[t++]=200,e[t++]=s>>8,e[t++]=s&255):(e[t++]=201,e[t++]=s>>24,e[t++]=s>>16&255,e[t++]=s>>8&255,e[t++]=s&255)}return e[t++]=n,e.set(r,t),t+=s,t}function jm(r,e){let t,n=e.length*6,s=r.length-n;for(;t=e.pop();){let a=t.offset,i=t.id;r.copyWithin(a+n,a,s),n-=6;let o=a+n;r[o++]=214,r[o++]=105,r[o++]=i>>24,r[o++]=i>>16&255,r[o++]=i>>8&255,r[o++]=i&255,s=a}return r}function pu(r,e,t){if(Ue.length>0){$e.setUint32(Ue.position+r,v+t-Ue.position-r),Ue.stringsPosition=v-r;let n=Ue;Ue=null,e(n[0]),e(n[1])}}function Rm(r,e){return r.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},r}let ed=new $m({useRecords:!1});const zm=ed.pack;ed.pack;const Pm=512,Mm=1024,Um=2048;let td=class{constructor(){x(this,"contentType","application/msgpack")}encode(e){return zm(Un.toSnake(e))}decode(e,t){const n=Un.toCamel(Nm(new Uint8Array(e)));return t!=null?t.parse(n):n}},rd=class{constructor(){x(this,"contentType","application/json"),x(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(Un.toSnake(e),(n,s)=>ArrayBuffer.isView(s)?Array.from(s):Ll(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s);return new TextEncoder().encode(t)}decode(e,t){const n=Un.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(n):n}static registerCustomType(){}};const Dm=[new td,new rd],nd=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:Dm,JSONEncoderDecoder:rd,MsgpackEncoderDecoder:td},Symbol.toStringTag,{value:"Module"}));let Lm=class{constructor(e){x(this,"handlers"),this.handlers=e??new Map}onChange(e){return this.handlers.set(e,null),()=>this.handlers.delete(e)}notify(e){this.handlers.forEach((t,n)=>n(e))}};const Ja=Object.freeze(Object.defineProperty({__proto__:null,Observer:Lm},Symbol.toStringTag,{value:"Module"})),Gs=u.z.number(),Hs=u.z.object({name:u.z.string(),key:u.z.number(),rate:xi.z,dataType:Ee.z,leaseholder:u.z.number(),index:u.z.number(),isIndex:u.z.boolean(),alias:u.z.string().optional()}),sd=Hs.extend({key:u.z.number().optional(),leaseholder:u.z.number().optional(),index:u.z.number().optional(),rate:xi.z.optional(),isIndex:u.z.boolean().optional()}),ad=r=>r.map(e=>({name:e.name,dataType:e.dataType,rate:e.rate??0,leaseholder:e.leaseholder,index:e.index,isIndex:e.isIndex})),Bm=u.z.object({channels:sd.array()}),Vm=u.z.object({channels:Hs.array()}),vi=class vi{constructor(e){h(this,"client");this.client=e}async create(e){const t={channels:ad(e)},[n,s]=await this.client.send(vi.ENDPOINT,t,Bm,Vm);if(s!=null)throw s;return n.channels}};h(vi,"ENDPOINT","/channel/create");let Ga=vi;const qm=new Error("request for lock canceled");var Km=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(m){try{l(n.next(m))}catch(T){i(T)}}function c(m){try{l(n.throw(m))}catch(T){i(T)}}function l(m){m.done?a(m.value):s(m.value).then(o,c)}l((n=n.apply(r,e||[])).next())})};class Fm{constructor(e,t=qm){this._value=e,this._cancelError=t,this._weightedQueues=[],this._weightedWaiters=[]}acquire(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise((t,n)=>{this._weightedQueues[e-1]||(this._weightedQueues[e-1]=[]),this._weightedQueues[e-1].push({resolve:t,reject:n}),this._dispatch()})}runExclusive(e,t=1){return Km(this,void 0,void 0,function*(){const[n,s]=yield this.acquire(t);try{return yield e(n)}finally{s()}})}waitForUnlock(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);return new Promise(t=>{this._weightedWaiters[e-1]||(this._weightedWaiters[e-1]=[]),this._weightedWaiters[e-1].push(t),this._dispatch()})}isLocked(){return this._value<=0}getValue(){return this._value}setValue(e){this._value=e,this._dispatch()}release(e=1){if(e<=0)throw new Error(`invalid weight ${e}: must be positive`);this._value+=e,this._dispatch()}cancel(){this._weightedQueues.forEach(e=>e.forEach(t=>t.reject(this._cancelError))),this._weightedQueues=[]}_dispatch(){var e;for(let t=this._value;t>0;t--){const n=(e=this._weightedQueues[t-1])===null||e===void 0?void 0:e.shift();if(!n)continue;const s=this._value,a=t;this._value-=t,t=this._value+1,n.resolve([s,this._newReleaser(a)])}this._drainUnlockWaiters()}_newReleaser(e){let t=!1;return()=>{t||(t=!0,this.release(e))}}_drainUnlockWaiters(){for(let e=this._value;e>0;e--)this._weightedWaiters[e-1]&&(this._weightedWaiters[e-1].forEach(t=>t()),this._weightedWaiters[e-1]=[])}}var Wm=function(r,e,t,n){function s(a){return a instanceof t?a:new t(function(i){i(a)})}return new(t||(t=Promise))(function(a,i){function o(m){try{l(n.next(m))}catch(T){i(T)}}function c(m){try{l(n.throw(m))}catch(T){i(T)}}function l(m){m.done?a(m.value):s(m.value).then(o,c)}l((n=n.apply(r,e||[])).next())})};class Ym{constructor(e){this._semaphore=new Fm(1,e)}acquire(){return Wm(this,void 0,void 0,function*(){const[,e]=yield this._semaphore.acquire();return e})}runExclusive(e){return this._semaphore.runExclusive(()=>e())}isLocked(){return this._semaphore.isLocked()}waitForUnlock(){return this._semaphore.waitForUnlock()}release(){this._semaphore.isLocked()&&this._semaphore.release()}cancel(){return this._semaphore.cancel()}}var Jm=Object.defineProperty,Gm=(r,e,t)=>e in r?Jm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,Ye=(r,e,t)=>(Gm(r,typeof e!="symbol"?e+"":e,t),t),Hm=Object.defineProperty,Xm=(r,e,t)=>e in r?Hm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,j=(r,e,t)=>(Xm(r,typeof e!="symbol"?e+"":e,t),t),ke;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(ke||(ke={}));var Eo;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Eo||(Eo={}));const D=ke.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),zr=r=>{switch(typeof r){case"undefined":return D.undefined;case"string":return D.string;case"number":return isNaN(r)?D.nan:D.number;case"boolean":return D.boolean;case"function":return D.function;case"bigint":return D.bigint;case"symbol":return D.symbol;case"object":return Array.isArray(r)?D.array:r===null?D.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?D.promise:typeof Map<"u"&&r instanceof Map?D.map:typeof Set<"u"&&r instanceof Set?D.set:typeof Date<"u"&&r instanceof Date?D.date:D.object;default:return D.unknown}},$=ke.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Qm=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class zt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,ke.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}zt.create=r=>new zt(r);const bs=(r,e)=>{let t;switch(r.code){case $.invalid_type:r.received===D.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case $.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,ke.jsonStringifyReplacer)}`;break;case $.unrecognized_keys:t=`Unrecognized key(s) in object: ${ke.joinValues(r.keys,", ")}`;break;case $.invalid_union:t="Invalid input";break;case $.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${ke.joinValues(r.options)}`;break;case $.invalid_enum_value:t=`Invalid enum value. Expected ${ke.joinValues(r.options)}, received '${r.received}'`;break;case $.invalid_arguments:t="Invalid function arguments";break;case $.invalid_return_type:t="Invalid function return type";break;case $.invalid_date:t="Invalid date";break;case $.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:ke.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case $.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case $.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case $.custom:t="Invalid input";break;case $.invalid_intersection_types:t="Intersection results could not be merged";break;case $.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case $.not_finite:t="Number must be finite";break;default:t=e.defaultError,ke.assertNever(r)}return{message:t}};let id=bs;function ey(r){id=r}function Ha(){return id}const Xa=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},ty=[];function V(r,e){const t=Xa({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ha(),bs].filter(n=>!!n)});r.common.issues.push(t)}class ut{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return oe;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return ut.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return oe;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const oe=Object.freeze({status:"aborted"}),od=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),Ao=r=>r.status==="aborted",Io=r=>r.status==="dirty",_s=r=>r.status==="valid",Qa=r=>typeof Promise<"u"&&r instanceof Promise;var W;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(W||(W={}));class Xt{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const fu=(r,e)=>{if(_s(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new zt(r.common.issues);return this._error=t,this._error}}};function le(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:s}}class pe{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return zr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:zr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ut,ctx:{common:e.parent.common,data:e.data,parsedType:zr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(Qa(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zr(e)},a=this._parseSync({data:e,path:s.path,parent:s});return fu(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:zr(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(Qa(s)?s:Promise.resolve(s));return fu(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:$.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new Bt({schema:this,typeName:X.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Sr.create(this,this._def)}nullable(){return fn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Pt.create(this,this._def)}promise(){return Ln.create(this,this._def)}or(e){return xs.create([this,e],this._def)}and(e){return Ss.create(this,e,this._def)}transform(e){return new Bt({...le(this._def),schema:this,typeName:X.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Zs({...le(this._def),innerType:this,defaultValue:t,typeName:X.ZodDefault})}brand(){return new ud({typeName:X.ZodBranded,type:this,...le(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new ni({...le(this._def),innerType:this,catchValue:t,typeName:X.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Xs.create(this,e)}readonly(){return ai.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ry=/^c[^\s-]{8,}$/i,ny=/^[a-z][a-z0-9]*$/,sy=/^[0-9A-HJKMNP-TV-Z]{26}$/,ay=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,iy=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,oy="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ji;const cy=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,uy=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ly=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function dy(r,e){return!!((e==="v4"||!e)&&cy.test(r)||(e==="v6"||!e)&&uy.test(r))}class Ct extends pe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==D.string){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:D.string,received:s.parsedType}),oe}const t=new ut;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:$.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:$.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?V(n,{code:$.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&V(n,{code:$.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")iy.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"email",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")Ji||(Ji=new RegExp(oy,"u")),Ji.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"emoji",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")ay.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"uuid",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")ry.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"cuid",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")ny.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"cuid2",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")sy.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"ulid",code:$.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),V(n,{validation:"url",code:$.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"regex",code:$.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),V(n,{code:$.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),V(n,{code:$.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),V(n,{code:$.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?ly(s).test(e.data)||(n=this._getOrReturnCtx(e,n),V(n,{code:$.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?dy(e.data,s.version)||(n=this._getOrReturnCtx(e,n),V(n,{validation:"ip",code:$.invalid_string,message:s.message}),t.dirty()):ke.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:$.invalid_string,...W.errToObj(n)})}_addCheck(e){return new Ct({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...W.errToObj(e)})}url(e){return this._addCheck({kind:"url",...W.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...W.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...W.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...W.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...W.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...W.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...W.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...W.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...W.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...W.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...W.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...W.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...W.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...W.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...W.errToObj(t)})}nonempty(e){return this.min(1,W.errToObj(e))}trim(){return new Ct({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Ct({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Ct({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Ct.create=r=>{var e;return new Ct({checks:[],typeName:X.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...le(r)})};function hy(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class qr extends pe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==D.number){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:D.number,received:s.parsedType}),oe}let t;const n=new ut;for(const s of this._def.checks)s.kind==="int"?ke.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),V(t,{code:$.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?hy(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),V(t,{code:$.not_finite,message:s.message}),n.dirty()):ke.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,W.toString(t))}gt(e,t){return this.setLimit("min",e,!1,W.toString(t))}lte(e,t){return this.setLimit("max",e,!0,W.toString(t))}lt(e,t){return this.setLimit("max",e,!1,W.toString(t))}setLimit(e,t,n,s){return new qr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:W.toString(s)}]})}_addCheck(e){return new qr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:W.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:W.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:W.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:W.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:W.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:W.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&ke.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}qr.create=r=>new qr({checks:[],typeName:X.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...le(r)});class Kr extends pe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==D.bigint){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:D.bigint,received:s.parsedType}),oe}let t;const n=new ut;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),V(t,{code:$.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):ke.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,W.toString(t))}gt(e,t){return this.setLimit("min",e,!1,W.toString(t))}lte(e,t){return this.setLimit("max",e,!0,W.toString(t))}lt(e,t){return this.setLimit("max",e,!1,W.toString(t))}setLimit(e,t,n,s){return new Kr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:W.toString(s)}]})}_addCheck(e){return new Kr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:W.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:W.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:W.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:W.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:W.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Kr.create=r=>{var e;return new Kr({checks:[],typeName:X.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...le(r)})};class ks extends pe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==D.boolean){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.boolean,received:t.parsedType}),oe}return wt(e.data)}}ks.create=r=>new ks({typeName:X.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...le(r)});class hn extends pe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==D.date){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:D.date,received:s.parsedType}),oe}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_date}),oe}const t=new ut;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:$.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),V(n,{code:$.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):ke.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new hn({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:W.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:W.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}hn.create=r=>new hn({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:X.ZodDate,...le(r)});class ei extends pe{_parse(e){if(this._getType(e)!==D.symbol){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.symbol,received:t.parsedType}),oe}return wt(e.data)}}ei.create=r=>new ei({typeName:X.ZodSymbol,...le(r)});class Os extends pe{_parse(e){if(this._getType(e)!==D.undefined){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.undefined,received:t.parsedType}),oe}return wt(e.data)}}Os.create=r=>new Os({typeName:X.ZodUndefined,...le(r)});class Ts extends pe{_parse(e){if(this._getType(e)!==D.null){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.null,received:t.parsedType}),oe}return wt(e.data)}}Ts.create=r=>new Ts({typeName:X.ZodNull,...le(r)});class Dn extends pe{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}Dn.create=r=>new Dn({typeName:X.ZodAny,...le(r)});class an extends pe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}an.create=r=>new an({typeName:X.ZodUnknown,...le(r)});class Ir extends pe{_parse(e){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.never,received:t.parsedType}),oe}}Ir.create=r=>new Ir({typeName:X.ZodNever,...le(r)});class ti extends pe{_parse(e){if(this._getType(e)!==D.undefined){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.void,received:t.parsedType}),oe}return wt(e.data)}}ti.create=r=>new ti({typeName:X.ZodVoid,...le(r)});class Pt extends pe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==D.array)return V(t,{code:$.invalid_type,expected:D.array,received:t.parsedType}),oe;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(V(t,{code:i?$.too_big:$.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(V(t,{code:$.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(V(t,{code:$.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new Xt(t,i,t.path,o)))).then(i=>ut.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Xt(t,i,t.path,o)));return ut.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Pt({...this._def,minLength:{value:e,message:W.toString(t)}})}max(e,t){return new Pt({...this._def,maxLength:{value:e,message:W.toString(t)}})}length(e,t){return new Pt({...this._def,exactLength:{value:e,message:W.toString(t)}})}nonempty(e){return this.min(1,e)}}Pt.create=(r,e)=>new Pt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:X.ZodArray,...le(e)});function Nn(r){if(r instanceof Le){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Sr.create(Nn(n))}return new Le({...r._def,shape:()=>e})}else return r instanceof Pt?new Pt({...r._def,type:Nn(r.element)}):r instanceof Sr?Sr.create(Nn(r.unwrap())):r instanceof fn?fn.create(Nn(r.unwrap())):r instanceof Qt?Qt.create(r.items.map(e=>Nn(e))):r}class Le extends pe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=ke.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==D.object){const c=this._getOrReturnCtx(e);return V(c,{code:$.invalid_type,expected:D.object,received:c.parsedType}),oe}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Ir&&this._def.unknownKeys==="strip"))for(const c in n.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=s[c],m=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Xt(n,m,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Ir){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(c==="strict")i.length>0&&(V(n,{code:$.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const m=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Xt(n,m,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const m=await l.key;c.push({key:m,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>ut.mergeObjectSync(t,c)):ut.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return W.errToObj,new Le({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=W.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Le({...this._def,unknownKeys:"strip"})}passthrough(){return new Le({...this._def,unknownKeys:"passthrough"})}extend(e){return new Le({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Le({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:X.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Le({...this._def,catchall:e})}pick(e){const t={};return ke.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Le({...this._def,shape:()=>t})}omit(e){const t={};return ke.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Le({...this._def,shape:()=>t})}deepPartial(){return Nn(this)}partial(e){const t={};return ke.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Le({...this._def,shape:()=>t})}required(e){const t={};return ke.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Sr;)s=s._def.innerType;t[n]=s}}),new Le({...this._def,shape:()=>t})}keyof(){return cd(ke.objectKeys(this.shape))}}Le.create=(r,e)=>new Le({shape:()=>r,unknownKeys:"strip",catchall:Ir.create(),typeName:X.ZodObject,...le(e)});Le.strictCreate=(r,e)=>new Le({shape:()=>r,unknownKeys:"strict",catchall:Ir.create(),typeName:X.ZodObject,...le(e)});Le.lazycreate=(r,e)=>new Le({shape:r,unknownKeys:"strip",catchall:Ir.create(),typeName:X.ZodObject,...le(e)});class xs extends pe{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new zt(o.ctx.common.issues));return V(t,{code:$.invalid_union,unionErrors:i}),oe}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of n){const l={...t,common:{...t.common,issues:[]},parent:null},m=c._parseSync({data:t.data,path:t.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new zt(c));return V(t,{code:$.invalid_union,unionErrors:o}),oe}}get options(){return this._def.options}}xs.create=(r,e)=>new xs({options:r,typeName:X.ZodUnion,...le(e)});const Sa=r=>r instanceof Es?Sa(r.schema):r instanceof Bt?Sa(r.innerType()):r instanceof As?[r.value]:r instanceof Fr?r.options:r instanceof Is?Object.keys(r.enum):r instanceof Zs?Sa(r._def.innerType):r instanceof Os?[void 0]:r instanceof Ts?[null]:null;class Ei extends pe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.object)return V(t,{code:$.invalid_type,expected:D.object,received:t.parsedType}),oe;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(V(t,{code:$.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),oe)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=Sa(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Ei({typeName:X.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...le(n)})}}function Zo(r,e){const t=zr(r),n=zr(e);if(r===e)return{valid:!0,data:r};if(t===D.object&&n===D.object){const s=ke.objectKeys(e),a=ke.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Zo(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===D.array&&n===D.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Zo(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===D.date&&n===D.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Ss extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Ao(a)||Ao(i))return oe;const o=Zo(a.value,i.value);return o.valid?((Io(a)||Io(i))&&t.dirty(),{status:t.value,value:o.data}):(V(n,{code:$.invalid_intersection_types}),oe)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Ss.create=(r,e,t)=>new Ss({left:r,right:e,typeName:X.ZodIntersection,...le(t)});class Qt extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.array)return V(n,{code:$.invalid_type,expected:D.array,received:n.parsedType}),oe;if(n.data.length<this._def.items.length)return V(n,{code:$.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),oe;!this._def.rest&&n.data.length>this._def.items.length&&(V(n,{code:$.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new Xt(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>ut.mergeArray(t,a)):ut.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Qt({...this._def,rest:e})}}Qt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Qt({items:r,typeName:X.ZodTuple,rest:null,...le(e)})};class Ns extends pe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.object)return V(n,{code:$.invalid_type,expected:D.object,received:n.parsedType}),oe;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Xt(n,o,n.path,o)),value:i._parse(new Xt(n,n.data[o],n.path,o))});return n.common.async?ut.mergeObjectAsync(t,s):ut.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof pe?new Ns({keyType:e,valueType:t,typeName:X.ZodRecord,...le(n)}):new Ns({keyType:Ct.create(),valueType:e,typeName:X.ZodRecord,...le(t)})}}class ri extends pe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.map)return V(n,{code:$.invalid_type,expected:D.map,received:n.parsedType}),oe;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new Xt(n,o,n.path,[l,"key"])),value:a._parse(new Xt(n,c,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,m=await c.value;if(l.status==="aborted"||m.status==="aborted")return oe;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,m=c.value;if(l.status==="aborted"||m.status==="aborted")return oe;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}}}}ri.create=(r,e,t)=>new ri({valueType:e,keyType:r,typeName:X.ZodMap,...le(t)});class pn extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.set)return V(n,{code:$.invalid_type,expected:D.set,received:n.parsedType}),oe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(V(n,{code:$.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(V(n,{code:$.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const m of c){if(m.status==="aborted")return oe;m.status==="dirty"&&t.dirty(),l.add(m.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Xt(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new pn({...this._def,minSize:{value:e,message:W.toString(t)}})}max(e,t){return new pn({...this._def,maxSize:{value:e,message:W.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}pn.create=(r,e)=>new pn({valueType:r,minSize:null,maxSize:null,typeName:X.ZodSet,...le(e)});class $n extends pe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.function)return V(t,{code:$.invalid_type,expected:D.function,received:t.parsedType}),oe;function n(o,c){return Xa({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ha(),bs].filter(l=>!!l),issueData:{code:$.invalid_arguments,argumentsError:c}})}function s(o,c){return Xa({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ha(),bs].filter(l=>!!l),issueData:{code:$.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof Ln){const o=this;return wt(async function(...c){const l=new zt([]),m=await o._def.args.parseAsync(c,a).catch(J=>{throw l.addIssue(n(c,J)),l}),T=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(T,a).catch(J=>{throw l.addIssue(s(T,J)),l})})}else{const o=this;return wt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new zt([n(c,l.error)]);const m=Reflect.apply(i,this,l.data),T=o._def.returns.safeParse(m,a);if(!T.success)throw new zt([s(m,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new $n({...this._def,args:Qt.create(e).rest(an.create())})}returns(e){return new $n({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new $n({args:e||Qt.create([]).rest(an.create()),returns:t||an.create(),typeName:X.ZodFunction,...le(n)})}}class Es extends pe{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Es.create=(r,e)=>new Es({getter:r,typeName:X.ZodLazy,...le(e)});class As extends pe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return V(t,{received:t.data,code:$.invalid_literal,expected:this._def.value}),oe}return{status:"valid",value:e.data}}get value(){return this._def.value}}As.create=(r,e)=>new As({value:r,typeName:X.ZodLiteral,...le(e)});function cd(r,e){return new Fr({values:r,typeName:X.ZodEnum,...le(e)})}class Fr extends pe{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return V(t,{expected:ke.joinValues(n),received:t.parsedType,code:$.invalid_type}),oe}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return V(t,{received:t.data,code:$.invalid_enum_value,options:n}),oe}return wt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Fr.create(e)}exclude(e){return Fr.create(this.options.filter(t=>!e.includes(t)))}}Fr.create=cd;class Is extends pe{_parse(e){const t=ke.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==D.string&&n.parsedType!==D.number){const s=ke.objectValues(t);return V(n,{expected:ke.joinValues(s),received:n.parsedType,code:$.invalid_type}),oe}if(t.indexOf(e.data)===-1){const s=ke.objectValues(t);return V(n,{received:n.data,code:$.invalid_enum_value,options:s}),oe}return wt(e.data)}get enum(){return this._def.values}}Is.create=(r,e)=>new Is({values:r,typeName:X.ZodNativeEnum,...le(e)});class Ln extends pe{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.promise&&t.common.async===!1)return V(t,{code:$.invalid_type,expected:D.promise,received:t.parsedType}),oe;const n=t.parsedType===D.promise?t.data:Promise.resolve(t.data);return wt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Ln.create=(r,e)=>new Ln({type:r,typeName:X.ZodPromise,...le(e)});class Bt extends pe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===X.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{V(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?oe:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?oe:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!_s(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>_s(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);ke.assertNever(s)}}Bt.create=(r,e,t)=>new Bt({schema:r,typeName:X.ZodEffects,effect:e,...le(t)});Bt.createWithPreprocess=(r,e,t)=>new Bt({schema:e,effect:{type:"preprocess",transform:r},typeName:X.ZodEffects,...le(t)});class Sr extends pe{_parse(e){return this._getType(e)===D.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Sr.create=(r,e)=>new Sr({innerType:r,typeName:X.ZodOptional,...le(e)});class fn extends pe{_parse(e){return this._getType(e)===D.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}fn.create=(r,e)=>new fn({innerType:r,typeName:X.ZodNullable,...le(e)});class Zs extends pe{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===D.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Zs.create=(r,e)=>new Zs({innerType:r,typeName:X.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...le(e)});class ni extends pe{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Qa(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new zt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new zt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ni.create=(r,e)=>new ni({innerType:r,typeName:X.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...le(e)});class si extends pe{_parse(e){if(this._getType(e)!==D.nan){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:D.nan,received:t.parsedType}),oe}return{status:"valid",value:e.data}}}si.create=r=>new si({typeName:X.ZodNaN,...le(r)});const py=Symbol("zod_brand");class ud extends pe{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class Xs extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?oe:s.status==="dirty"?(t.dirty(),od(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?oe:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new Xs({in:e,out:t,typeName:X.ZodPipeline})}}class ai extends pe{_parse(e){const t=this._def.innerType._parse(e);return _s(t)&&(t.value=Object.freeze(t.value)),t}}ai.create=(r,e)=>new ai({innerType:r,typeName:X.ZodReadonly,...le(e)});const ld=(r,e={},t)=>r?Dn.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...l,fatal:c})}}):Dn.create(),fy={object:Le.lazycreate};var X;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(X||(X={}));const my=(r,e={message:`Input not instance of ${r.name}`})=>ld(t=>t instanceof r,e),dd=Ct.create,hd=qr.create,yy=si.create,gy=Kr.create,pd=ks.create,vy=hn.create,wy=ei.create,by=Os.create,_y=Ts.create,ky=Dn.create,Oy=an.create,Ty=Ir.create,xy=ti.create,Sy=Pt.create,Ny=Le.create,Ey=Le.strictCreate,Ay=xs.create,Iy=Ei.create,Zy=Ss.create,$y=Qt.create,Cy=Ns.create,jy=ri.create,Ry=pn.create,zy=$n.create,Py=Es.create,My=As.create,Uy=Fr.create,Dy=Is.create,Ly=Ln.create,mu=Bt.create,By=Sr.create,Vy=fn.create,qy=Bt.createWithPreprocess,Ky=Xs.create,Fy=()=>dd().optional(),Wy=()=>hd().optional(),Yy=()=>pd().optional(),Jy={string:r=>Ct.create({...r,coerce:!0}),number:r=>qr.create({...r,coerce:!0}),boolean:r=>ks.create({...r,coerce:!0}),bigint:r=>Kr.create({...r,coerce:!0}),date:r=>hn.create({...r,coerce:!0})},Gy=oe;var N=Object.freeze({__proto__:null,defaultErrorMap:bs,setErrorMap:ey,getErrorMap:Ha,makeIssue:Xa,EMPTY_PATH:ty,addIssueToContext:V,ParseStatus:ut,INVALID:oe,DIRTY:od,OK:wt,isAborted:Ao,isDirty:Io,isValid:_s,isAsync:Qa,get util(){return ke},get objectUtil(){return Eo},ZodParsedType:D,getParsedType:zr,ZodType:pe,ZodString:Ct,ZodNumber:qr,ZodBigInt:Kr,ZodBoolean:ks,ZodDate:hn,ZodSymbol:ei,ZodUndefined:Os,ZodNull:Ts,ZodAny:Dn,ZodUnknown:an,ZodNever:Ir,ZodVoid:ti,ZodArray:Pt,ZodObject:Le,ZodUnion:xs,ZodDiscriminatedUnion:Ei,ZodIntersection:Ss,ZodTuple:Qt,ZodRecord:Ns,ZodMap:ri,ZodSet:pn,ZodFunction:$n,ZodLazy:Es,ZodLiteral:As,ZodEnum:Fr,ZodNativeEnum:Is,ZodPromise:Ln,ZodEffects:Bt,ZodTransformer:Bt,ZodOptional:Sr,ZodNullable:fn,ZodDefault:Zs,ZodCatch:ni,ZodNaN:si,BRAND:py,ZodBranded:ud,ZodPipeline:Xs,ZodReadonly:ai,custom:ld,Schema:pe,ZodSchema:pe,late:fy,get ZodFirstPartyTypeKind(){return X},coerce:Jy,any:ky,array:Sy,bigint:gy,boolean:pd,date:vy,discriminatedUnion:Iy,effect:mu,enum:Uy,function:zy,instanceof:my,intersection:Zy,lazy:Py,literal:My,map:jy,nan:yy,nativeEnum:Dy,never:Ty,null:_y,nullable:Vy,number:hd,object:Ny,oboolean:Yy,onumber:Wy,optional:By,ostring:Fy,pipeline:Ky,preprocess:qy,promise:Ly,record:Cy,set:Ry,strictObject:Ey,string:dd,symbol:wy,transformer:mu,tuple:$y,undefined:by,union:Ay,unknown:Oy,void:xy,NEVER:Gy,ZodIssueCode:$,quotelessJson:Qm,ZodError:zt});const dc=N.tuple([N.number(),N.number()]),fd=N.object({width:N.number(),height:N.number()}),Hy=N.object({signedWidth:N.number(),signedHeight:N.number()}),Xy=["width","height"];N.enum(Xy);const Qy=["start","center","end"],eg=["signedWidth","signedHeight"];N.enum(eg);const ii=N.object({x:N.number(),y:N.number()}),tg=N.object({clientX:N.number(),clientY:N.number()}),rg=["x","y"],md=N.enum(rg),yd=["top","right","bottom","left"];N.enum(yd);const ng=["left","right"],gd=N.enum(ng),sg=["top","bottom"],vd=N.enum(sg),wd=["center"],yu=N.enum(wd),ag=[...yd,...wd],bd=N.enum(ag);N.enum(Qy);const ig=["first","last"];N.enum(ig);const og=N.object({lower:N.number(),upper:N.number()});N.union([og,dc]);N.union([md,bd]);N.union([md,bd,N.instanceof(String)]);const Gi=(r,e)=>{const t={lower:0,upper:0};return typeof r=="number"?e!=null?(t.lower=r,t.upper=e):(t.lower=0,t.upper=r):Array.isArray(r)?[t.lower,t.upper]=r:(t.lower=r.lower,t.upper=r.upper),cg(t)},cg=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var Zt=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ye={},Ai={};Object.defineProperty(Ai,"__esModule",{value:!0});function ug(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w)/g,function(e,t,n){return n.toUpperCase()}):""}Ai.default=ug;var Ii={};Object.defineProperty(Ii,"__esModule",{value:!0});function lg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}Ii.default=lg;var Zi={};Object.defineProperty(Zi,"__esModule",{value:!0});function dg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"$").replace(/[^A-Za-z0-9]+/g,"$").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"$"+n}).toLowerCase().replace(/(\$)(\w?)/g,function(e,t,n){return n.toUpperCase()}):""}Zi.default=dg;var hc={};Object.defineProperty(hc,"__esModule",{value:!0});function hg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}hc.default=hg;var pc={};Object.defineProperty(pc,"__esModule",{value:!0});function pg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"/").toLowerCase():""}pc.default=pg;var fc={};Object.defineProperty(fc,"__esModule",{value:!0});function fg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase():""}fc.default=fg;var mc={};Object.defineProperty(mc,"__esModule",{value:!0});function mg(r){if(r===void 0&&(r=""),!r)return"";var e=String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(t,n,s){return n+"_"+s.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase();return e.charAt(0).toUpperCase()+e.slice(1)}mc.default=mg;var yc={};Object.defineProperty(yc,"__esModule",{value:!0});function yg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g," ").toLowerCase().replace(/( ?)(\w+)( ?)/g,function(e,t,n,s){return t+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}yc.default=yg;var $i={};Object.defineProperty($i,"__esModule",{value:!0});function gg(r){return r===void 0&&(r=""),r?String(r).replace(/^[^A-Za-z0-9]*|[^A-Za-z0-9]*$/g,"").replace(/([a-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"-").toLowerCase():""}$i.default=gg;var gc={},_n={};(function(r){Object.defineProperty(r,"__esModule",{value:!0}),r.belongToTypes=r.isValidObject=r.isArrayObject=r.validateOptions=r.DefaultOption=void 0,r.DefaultOption={recursive:!1,recursiveInArray:!1,keepTypesOnRecursion:[]},r.validateOptions=function(e){return e===void 0&&(e=r.DefaultOption),e.recursive==null?e=r.DefaultOption:e.recursiveInArray==null&&(e.recursiveInArray=!1),e},r.isArrayObject=function(e){return e!=null&&Array.isArray(e)},r.isValidObject=function(e){return e!=null&&typeof e=="object"&&!Array.isArray(e)},r.belongToTypes=function(e,t){return(t||[]).some(function(n){return e instanceof n})}})(_n);var vg=Zt&&Zt.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(gc,"__esModule",{value:!0});var dr=_n;function Na(r,e){if(e===void 0&&(e=dr.DefaultOption),!dr.isValidObject(r))return null;e=dr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toLowerCase();e.recursive&&(dr.isValidObject(s)?dr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Na(s,e)):e.recursiveInArray&&dr.isArrayObject(s)&&(s=vg(s).map(function(i){var o=i;if(dr.isValidObject(i))dr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Na(i,e));else if(dr.isArrayObject(i)){var c=Na({key:i},e);o=c.key}return o}))),t[a]=s}),t}gc.default=Na;var vc={},wg=Zt&&Zt.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(vc,"__esModule",{value:!0});var hr=_n;function Ea(r,e){if(e===void 0&&(e=hr.DefaultOption),!hr.isValidObject(r))return null;e=hr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=n.toUpperCase();e.recursive&&(hr.isValidObject(s)?hr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ea(s,e)):e.recursiveInArray&&hr.isArrayObject(s)&&(s=wg(s).map(function(i){var o=i;if(hr.isValidObject(i))hr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ea(i,e));else if(hr.isArrayObject(i)){var c=Ea({key:i},e);o=c.key}return o}))),t[a]=s}),t}vc.default=Ea;var wc={},bg=Zt&&Zt.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(wc,"__esModule",{value:!0});var pr=_n,_g=Ai;function Aa(r,e){if(e===void 0&&(e=pr.DefaultOption),!pr.isValidObject(r))return null;e=pr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=_g.default(n);e.recursive&&(pr.isValidObject(s)?pr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Aa(s,e)):e.recursiveInArray&&pr.isArrayObject(s)&&(s=bg(s).map(function(i){var o=i;if(pr.isValidObject(i))pr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Aa(i,e));else if(pr.isArrayObject(i)){var c=Aa({key:i},e);o=c.key}return o}))),t[a]=s}),t}wc.default=Aa;var bc={},kg=Zt&&Zt.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(bc,"__esModule",{value:!0});var fr=_n,Og=Ii;function Ia(r,e){if(e===void 0&&(e=fr.DefaultOption),!fr.isValidObject(r))return null;e=fr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Og.default(n);e.recursive&&(fr.isValidObject(s)?fr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Ia(s,e)):e.recursiveInArray&&fr.isArrayObject(s)&&(s=kg(s).map(function(i){var o=i;if(fr.isValidObject(i))fr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Ia(i,e));else if(fr.isArrayObject(i)){var c=Ia({key:i},e);o=c.key}return o}))),t[a]=s}),t}bc.default=Ia;var _c={},Tg=Zt&&Zt.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(_c,"__esModule",{value:!0});var mr=_n,xg=Zi;function Za(r,e){if(e===void 0&&(e=mr.DefaultOption),!mr.isValidObject(r))return null;e=mr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=xg.default(n);e.recursive&&(mr.isValidObject(s)?mr.belongToTypes(s,e.keepTypesOnRecursion)||(s=Za(s,e)):e.recursiveInArray&&mr.isArrayObject(s)&&(s=Tg(s).map(function(i){var o=i;if(mr.isValidObject(i))mr.belongToTypes(o,e.keepTypesOnRecursion)||(o=Za(i,e));else if(mr.isArrayObject(i)){var c=Za({key:i},e);o=c.key}return o}))),t[a]=s}),t}_c.default=Za;var kc={},Sg=Zt&&Zt.__spreadArrays||function(){for(var r=0,e=0,t=arguments.length;e<t;e++)r+=arguments[e].length;for(var n=Array(r),s=0,e=0;e<t;e++)for(var a=arguments[e],i=0,o=a.length;i<o;i++,s++)n[s]=a[i];return n};Object.defineProperty(kc,"__esModule",{value:!0});var yr=_n,Ng=$i;function $a(r,e){if(e===void 0&&(e=yr.DefaultOption),!yr.isValidObject(r))return null;e=yr.validateOptions(e);var t={};return Object.keys(r).forEach(function(n){var s=r[n],a=Ng.default(n);e.recursive&&(yr.isValidObject(s)?yr.belongToTypes(s,e.keepTypesOnRecursion)||(s=$a(s,e)):e.recursiveInArray&&yr.isArrayObject(s)&&(s=Sg(s).map(function(i){var o=i;if(yr.isValidObject(i))yr.belongToTypes(o,e.keepTypesOnRecursion)||(o=$a(i,e));else if(yr.isArrayObject(i)){var c=$a({key:i},e);o=c.key}return o}))),t[a]=s}),t}kc.default=$a;Object.defineProperty(ye,"__esModule",{value:!0});ye.kebabKeys=ye.pascalKeys=ye.snakeKeys=ye.camelKeys=ye.upperKeys=ye.lowerKeys=ye.toLowerCase=ye.toUpperCase=ye.toKebabCase=ye.toHeaderCase=ye.toSentenceCase=ye.toTextCase=ye.toPathCase=ye.toDotCase=ye.toPascalCase=ye.toSnakeCase=ye.toCamelCase=void 0;var _d=Ai;ye.toCamelCase=_d.default;var kd=Ii;ye.toSnakeCase=kd.default;var Od=Zi;ye.toPascalCase=Od.default;var Td=hc;ye.toDotCase=Td.default;var xd=pc;ye.toPathCase=xd.default;var Sd=fc;ye.toTextCase=Sd.default;var Nd=mc;ye.toSentenceCase=Nd.default;var Ed=yc;ye.toHeaderCase=Ed.default;var Ad=$i;ye.toKebabCase=Ad.default;var Id=gc;ye.lowerKeys=Id.default;var Zd=vc;ye.upperKeys=Zd.default;var $d=wc;ye.camelKeys=$d.default;var Cd=bc;ye.snakeKeys=Cd.default;var jd=_c;ye.pascalKeys=jd.default;var Rd=kc;ye.kebabKeys=Rd.default;var zd=function(r){return String(r||"").toLowerCase()};ye.toLowerCase=zd;var Pd=function(r){return String(r||"").toUpperCase()};ye.toUpperCase=Pd;var Eg={toCamelCase:_d.default,toSnakeCase:kd.default,toPascalCase:Od.default,toDotCase:Td.default,toPathCase:xd.default,toTextCase:Sd.default,toSentenceCase:Nd.default,toHeaderCase:Ed.default,toKebabCase:Ad.default,toUpperCase:Pd,toLowerCase:zd,lowerKeys:Id.default,upperKeys:Zd.default,camelKeys:$d.default,snakeKeys:Cd.default,pascalKeys:jd.default,kebabKeys:Rd.default};ye.default=Eg;var Md=ye;const Ud={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Ag=r=>Md.snakeKeys(r,Ud),Ig=r=>Md.camelKeys(r,Ud);var Bn;(r=>{r.toSnake=Ag,r.toCamel=Ig,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Bn||(Bn={}));N.object({x:gd.or(yu),y:vd.or(yu)});const Zg=N.object({x:gd,y:vd}),$g=Object.freeze({x:"left",y:"top"}),Cg=(r,e)=>r.x===e.x&&r.y===e.y,gu=N.union([N.number(),ii,dc,fd,Hy,tg]),jg=(r,e)=>{if(typeof r=="string"){if(e===void 0)throw new Error("The y coordinate must be given.");return r==="x"?{x:e,y:0}:{x:0,y:e}}return typeof r=="number"?{x:r,y:e??r}:Array.isArray(r)?{x:r[0],y:r[1]}:"signedWidth"in r?{x:r.signedWidth,y:r.signedHeight}:"clientX"in r?{x:r.clientX,y:r.clientY}:"width"in r?{x:r.width,y:r.height}:{x:r.x,y:r.y}},vu={x:0,y:0},la=N.union([N.number(),N.string()]);N.object({top:la,left:la,width:la,height:la});N.object({left:N.number(),top:N.number(),right:N.number(),bottom:N.number()});N.object({one:ii,two:ii,root:Zg});const Oc=(r,e,t=0,n=0,s)=>{const a={one:{...vu},two:{...vu},root:s??$g};if(typeof r=="number"){if(typeof e!="number")throw new Error("Box constructor called with invalid arguments");return a.one={x:r,y:e},a.two={x:a.one.x+t,y:a.one.y+n},a}return"one"in r&&"two"in r&&"root"in r?{...r,root:s??r.root}:("getBoundingClientRect"in r&&(r=r.getBoundingClientRect()),"left"in r?(a.one={x:r.left,y:r.top},a.two={x:r.right,y:r.bottom},a):(a.one=r,e==null?a.two={x:a.one.x+t,y:a.one.y+n}:typeof e=="number"?a.two={x:a.one.x+e,y:a.one.y+t}:"width"in e?a.two={x:a.one.x+e.width,y:a.one.y+e.height}:"signedWidth"in e?a.two={x:a.one.x+e.signedWidth,y:a.one.y+e.signedHeight}:a.two=e,a))},Hi=r=>{const e=Oc(r);return{lower:e.one.x,upper:e.two.x}},Xi=r=>{const e=Oc(r);return{lower:e.one.y,upper:e.two.y}},Rg=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,zg=N.object({signedWidth:N.number(),signedHeight:N.number()});N.union([fd,zg,ii,dc]);const Pg=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);N.object({offset:gu,scale:gu});const Mg=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Ug=r=>(e,t,n,s)=>[e,s?n/r:n*r],Dg=r=>(e,t,n)=>{if(e===null)return[r,n];const{lower:s,upper:a}=e,{lower:i,upper:o}=r,c=a-s,l=o-i;if(t==="dimension")return[r,n*(l/c)];const m=(n-s)*(l/c)+i;return[r,m]},Lg=r=>(e,t,n)=>[r,n],Bg=()=>(r,e,t)=>{if(r===null)throw new Error("cannot invert without bounds");if(e==="dimension")return[r,t];const{lower:n,upper:s}=r;return[r,s-(t-n)]},Vg=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=Pg(n,s,a),[e,n]},$o=class ns{constructor(){j(this,"ops",[]),j(this,"currBounds",null),j(this,"currType",null),j(this,"reversed",!1),this.ops=[]}static translate(e){return new ns().translate(e)}static magnify(e){return new ns().magnify(e)}static scale(e,t){return new ns().scale(e,t)}translate(e){const t=this.new(),n=Mg(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Ug(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=Gi(e,t),s=this.new(),a=Dg(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=Gi(e,t),s=this.new(),a=Vg(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=Gi(e,t),s=this.new(),a=Lg(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=Bg();e.type="invert";const t=this.new();return t.ops.push(e),t}pos(e){return this.exec("position",e)}dim(e){return this.exec("dimension",e)}new(){const e=new ns;return e.ops=this.ops.slice(),e.reversed=this.reversed,e}exec(e,t){return this.currBounds=null,this.ops.reduce(([n,s],a)=>a(n,e,s,this.reversed),[null,t])[1]}reverse(){const e=this.new();e.ops.reverse();const t=[];return e.ops.forEach((n,s)=>{if(n.type==="scale"||t.some(([i,o])=>s>=i&&s<=o))return;const a=e.ops.findIndex((i,o)=>i.type==="scale"&&o>s);a!==-1&&t.push([s,a])}),t.forEach(([n,s])=>{const a=e.ops.slice(n,s);a.unshift(e.ops[s]),e.ops.splice(n,s-n+1,...a)}),e.reversed=!e.reversed,e}};j($o,"IDENTITY",new $o);let wu=$o;const bu=class br{constructor(e=new wu,t=new wu,n=null){j(this,"x"),j(this,"y"),j(this,"currRoot"),this.x=e,this.y=t,this.currRoot=n}static translate(e,t){return new br().translate(e,t)}static translateX(e){return new br().translateX(e)}static translateY(e){return new br().translateY(e)}static clamp(e){return new br().clamp(e)}static magnify(e){return new br().magnify(e)}static scale(e){return new br().scale(e)}static reBound(e){return new br().reBound(e)}translate(e,t){const n=jg(e,t),s=this.copy();return s.x=this.x.translate(n.x),s.y=this.y.translate(n.y),s}translateX(e){const t=this.copy();return t.x=this.x.translate(e),t}translateY(e){const t=this.copy();return t.y=this.y.translate(e),t}magnify(e){const t=this.copy();return t.x=this.x.magnify(e.x),t.y=this.y.magnify(e.y),t}scale(e){const t=this.copy();if(Rg(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!Cg(n,e.root)&&(n.x!==e.root.x&&(t.x=t.x.invert()),n.y!==e.root.y&&(t.y=t.y.invert())),t.x=t.x.scale(Hi(e)),t.y=t.y.scale(Xi(e)),t}return t.x=t.x.scale(e.width),t.y=t.y.scale(e.height),t}reBound(e){const t=this.copy();return t.x=this.x.reBound(Hi(e)),t.y=this.y.reBound(Xi(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Hi(e)),t.y=this.y.clamp(Xi(e)),t}copy(){const e=new br;return e.currRoot=this.currRoot,e.x=this.x,e.y=this.y,e}reverse(){const e=this.copy();return e.x=this.x.reverse(),e.y=this.y.reverse(),e}pos(e){return{x:this.x.pos(e.x),y:this.y.pos(e.y)}}box(e){return Oc(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};j(bu,"IDENTITY",new bu);const Dd=(r,e)=>{const t=new _t(e);if(![yt.DAY,yt.HOUR,yt.MINUTE,yt.SECOND,yt.MILLISECOND,yt.MICROSECOND,yt.NANOSECOND].some(s=>s.equals(t)))throw new Error("Invalid argument for remainder. Must be an even TimeSpan or Timestamp");const n=r.valueOf()%t.valueOf();return r instanceof _t?new _t(n):new yt(n)},Ce=class ae{constructor(e,t="UTC"){if(j(this,"value"),j(this,"encodeValue",!0),e==null)this.value=ae.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*ae.MILLISECOND.valueOf();else if(typeof e=="string")this.value=ae.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=ae.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=ae.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=ae.MAX:e=ae.MIN)),this.value=BigInt(e.valueOf())+n}}static parseDate([e=1970,t=1,n=1]){const s=new Date(e,t-1,n,0,0,0,0);return new ae(BigInt(s.getTime())*ae.MILLISECOND.valueOf()).truncate(ae.DAY).valueOf()}encode(){return this.value.toString()}valueOf(){return this.value}static parseTimeString(e,t="UTC"){const[n,s,a]=e.split(":");let i="00",o="00";a!=null&&([i,o]=a.split("."));let c=ae.hours(parseInt(n??"00",10)).add(ae.minutes(parseInt(s??"00",10))).add(ae.seconds(parseInt(i??"00",10))).add(ae.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(ae.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return ae.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new ae(BigInt(n.getTime())*ae.MILLISECOND.valueOf(),t).valueOf()}fString(e="ISO",t="UTC"){switch(e){case"ISODate":return this.toISOString(t).slice(0,10);case"ISOTime":return this.toISOString(t).slice(11,23);case"time":return this.timeString(!1,t);case"preciseTime":return this.timeString(!0,t);case"date":return this.dateString(t);case"preciseDate":return`${this.dateString(t)} ${this.timeString(!0,t)}`;case"dateTime":return`${this.dateString(t)} ${this.timeString(!1,t)}`;default:return this.toISOString(t)}}toISOString(e="UTC"){return e==="UTC"?this.date().toISOString():this.sub(ae.utcOffset).date().toISOString()}timeString(e=!1,t="UTC"){const n=this.toISOString(t);return e?n.slice(11,23):n.slice(11,19)}dateString(e="UTC"){const t=this.date(),n=t.toLocaleString("default",{month:"short"}),s=t.toLocaleString("default",{day:"numeric"});return`${n} ${s}`}static get utcOffset(){return new yt(BigInt(new Date().getTimezoneOffset())*ae.MINUTE.valueOf())}static since(e){return new ae().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new ae(e).valueOf()}span(e){return this.range(e).span}range(e){return new qg(this,e).makeValid()}spanRange(e){return this.range(this.add(e)).makeValid()}get isZero(){return this.valueOf()===BigInt(0)}after(e){return this.valueOf()>new ae(e).valueOf()}afterEq(e){return this.valueOf()>=new ae(e).valueOf()}before(e){return this.valueOf()<new ae(e).valueOf()}beforeEq(e){return this.valueOf()<=new ae(e).valueOf()}add(e){return new ae(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new ae(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/ae.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Dd(this,e)}get isToday(){return this.truncate(yt.DAY).equals(ae.now().truncate(yt.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new ae(new Date)}static max(...e){let t=ae.MIN;for(const n of e){const s=new ae(n);s.after(t)&&(t=s)}return t}static min(...e){let t=ae.MAX;for(const n of e){const s=new ae(n);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new ae(e)}static microseconds(e){return ae.nanoseconds(e*1e3)}static milliseconds(e){return ae.microseconds(e*1e3)}static seconds(e){return ae.milliseconds(e*1e3)}static minutes(e){return ae.seconds(e*60)}static hours(e){return ae.minutes(e*60)}static days(e){return ae.hours(e*24)}};j(Ce,"NANOSECOND",Ce.nanoseconds(1)),j(Ce,"MICROSECOND",Ce.microseconds(1)),j(Ce,"MILLISECOND",Ce.milliseconds(1)),j(Ce,"SECOND",Ce.seconds(1)),j(Ce,"MINUTE",Ce.minutes(1)),j(Ce,"HOUR",Ce.hours(1)),j(Ce,"DAY",Ce.days(1)),j(Ce,"MAX",new Ce((1n<<63n)-1n)),j(Ce,"MIN",new Ce(0)),j(Ce,"ZERO",new Ce(0)),j(Ce,"z",N.union([N.object({value:N.bigint()}).transform(r=>new Ce(r.value)),N.string().transform(r=>new Ce(BigInt(r))),N.instanceof(Number).transform(r=>new Ce(r)),N.number().transform(r=>new Ce(r)),N.instanceof(Ce)]));let _t=Ce;const je=class xe{constructor(e){j(this,"value"),j(this,"encodeValue",!0),typeof e=="number"&&(e=Math.trunc(e.valueOf())),this.value=BigInt(e.valueOf())}encode(){return this.value.toString()}valueOf(){return this.value}lessThan(e){return this.valueOf()<new xe(e).valueOf()}greaterThan(e){return this.valueOf()>new xe(e).valueOf()}lessThanOrEqual(e){return this.valueOf()<=new xe(e).valueOf()}greaterThanOrEqual(e){return this.valueOf()>=new xe(e).valueOf()}remainder(e){return Dd(this,e)}truncate(e){return new xe(BigInt(Math.trunc(Number(this.valueOf()/e.valueOf())))*e.valueOf())}toString(){const e=this.truncate(xe.DAY),t=this.truncate(xe.HOUR),n=this.truncate(xe.MINUTE),s=this.truncate(xe.SECOND),a=this.truncate(xe.MILLISECOND),i=this.truncate(xe.MICROSECOND),o=this.truncate(xe.NANOSECOND),c=e,l=t.sub(e),m=n.sub(t),T=s.sub(n),J=a.sub(s),ee=i.sub(a),Ne=o.sub(i);let te="";return c.isZero||(te+=`${c.days}d `),l.isZero||(te+=`${l.hours}h `),m.isZero||(te+=`${m.minutes}m `),T.isZero||(te+=`${T.seconds}s `),J.isZero||(te+=`${J.milliseconds}ms `),ee.isZero||(te+=`${ee.microseconds}µs `),Ne.isZero||(te+=`${Ne.nanoseconds}ns`),te.trim()}get days(){return Number(this.valueOf()/xe.DAY.valueOf())}get hours(){return Number(this.valueOf()/xe.HOUR.valueOf())}get minutes(){return Number(this.valueOf()/xe.MINUTE.valueOf())}get seconds(){return Number(this.valueOf()/xe.SECOND.valueOf())}get milliseconds(){return Number(this.valueOf()/xe.MILLISECOND.valueOf())}get microseconds(){return Number(this.valueOf()/xe.MICROSECOND.valueOf())}get nanoseconds(){return Number(this.valueOf())}get isZero(){return this.valueOf()===BigInt(0)}equals(e){return this.valueOf()===new xe(e).valueOf()}add(e){return new xe(this.valueOf()+new xe(e).valueOf())}sub(e){return new xe(this.valueOf()-new xe(e).valueOf())}static nanoseconds(e=1){return new xe(e)}static microseconds(e=1){return xe.nanoseconds(e*1e3)}static milliseconds(e=1){return xe.microseconds(e*1e3)}static seconds(e=1){return xe.milliseconds(e*1e3)}static minutes(e){return xe.seconds(e.valueOf()*60)}static hours(e){return xe.minutes(e*60)}static days(e){return xe.hours(e*24)}};j(je,"NANOSECOND",je.nanoseconds(1)),j(je,"MICROSECOND",je.microseconds(1)),j(je,"MILLISECOND",je.milliseconds(1)),j(je,"SECOND",je.seconds(1)),j(je,"MINUTE",je.minutes(1)),j(je,"HOUR",je.hours(1)),j(je,"DAY",je.days(1)),j(je,"MAX",new je((1n<<63n)-1n)),j(je,"MIN",new je(0)),j(je,"ZERO",new je(0)),j(je,"z",N.union([N.object({value:N.bigint()}).transform(r=>new je(r.value)),N.string().transform(r=>new je(BigInt(r))),N.instanceof(Number).transform(r=>new je(r)),N.number().transform(r=>new je(r)),N.instanceof(je)]));let yt=je;const da=class Ca extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new Ca(e).valueOf()}get period(){return yt.seconds(1/this.valueOf())}sampleCount(e){return new yt(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new mt(t).valueOf()}span(e){return yt.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new Ca(e)}static khz(e){return Ca.hz(e*1e3)}};j(da,"z",N.union([N.number().transform(r=>new da(r)),N.instanceof(Number).transform(r=>new da(r)),N.instanceof(da)]));const nt=class extends Number{constructor(r){r instanceof Number?super(r.valueOf()):super(r)}length(r){return r.valueOf()/this.valueOf()}size(r){return new Kg(r*this.valueOf())}};j(nt,"UNKNOWN",new nt(0)),j(nt,"BIT128",new nt(16)),j(nt,"BIT64",new nt(8)),j(nt,"BIT32",new nt(4)),j(nt,"BIT16",new nt(2)),j(nt,"BIT8",new nt(1)),j(nt,"z",N.union([N.number().transform(r=>new nt(r)),N.instanceof(Number).transform(r=>new nt(r)),N.instanceof(nt)]));let mt=nt;const Ft=class ja{constructor(e,t){j(this,"start"),j(this,"end"),this.start=new _t(e),this.end=new _t(t)}get span(){return new yt(this.end.valueOf()-this.start.valueOf())}get isValid(){return this.start.valueOf()<=this.end.valueOf()}makeValid(){return this.isValid?this:this.swap()}get isZero(){return this.span.isZero}swap(){return new ja(this.end,this.start)}equals(e){return this.start.equals(e.start)&&this.end.equals(e.end)}toString(){return`${this.start.toString()} - ${this.end.toString()}`}toPrettyString(){return`${this.start.fString("preciseDate")} - ${this.span.toString()}`}overlapsWith(e){e=e.makeValid();const t=this.makeValid();return e.start.equals(t.start)?!0:e.end.equals(this.start)||e.start.equals(this.end)?!1:this.contains(e.end)||this.contains(e.start)||e.contains(this.start)||e.contains(this.end)}contains(e){return e instanceof ja?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new ja(this.start,this.end);return e.start.after(this.start)&&(t.start=e.start),e.start.after(this.end)&&(t.end=e.start),e.end.before(this.end)&&(t.end=e.end),e.end.before(this.start)&&(t.start=e.end),t}};j(Ft,"MAX",new Ft(_t.MIN,_t.MAX)),j(Ft,"MIN",new Ft(_t.MAX,_t.MIN)),j(Ft,"ZERO",new Ft(_t.ZERO,_t.ZERO)),j(Ft,"z",N.union([N.object({start:_t.z,end:_t.z}).transform(r=>new Ft(r.start,r.end)),N.instanceof(Ft)]));let qg=Ft;const A=class _r extends String{constructor(e){if(e instanceof _r||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=_r.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(_r.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=_r.ARRAY_CONSTRUCTORS.get(this.toString());if(e==null)throw new Error(`unable to find array constructor for ${this.valueOf()}`);return e}equals(e){return this.valueOf()===e.valueOf()}toString(){return this.valueOf()}get isVariable(){return this.equals(_r.JSON)||this.equals(_r.STRING)}get density(){const e=_r.DENSITIES.get(this.toString());if(e==null)throw new Error(`unable to find density for ${this.valueOf()}`);return e}checkArray(e){return e.constructor===this.Array}toJSON(){return this.toString()}get usesBigInt(){return _r.BIG_INT_TYPES.some(e=>e.equals(this))}};j(A,"UNKNOWN",new A("unknown")),j(A,"FLOAT64",new A("float64")),j(A,"FLOAT32",new A("float32")),j(A,"INT64",new A("int64")),j(A,"INT32",new A("int32")),j(A,"INT16",new A("int16")),j(A,"INT8",new A("int8")),j(A,"UINT64",new A("uint64")),j(A,"UINT32",new A("uint32")),j(A,"UINT16",new A("uint16")),j(A,"UINT8",new A("uint8")),j(A,"BOOLEAN",A.UINT8),j(A,"TIMESTAMP",new A("timestamp")),j(A,"UUID",new A("uuid")),j(A,"STRING",new A("string")),j(A,"JSON",new A("json")),j(A,"ARRAY_CONSTRUCTORS",new Map([[A.UINT8.toString(),Uint8Array],[A.UINT16.toString(),Uint16Array],[A.UINT32.toString(),Uint32Array],[A.UINT64.toString(),BigUint64Array],[A.FLOAT32.toString(),Float32Array],[A.FLOAT64.toString(),Float64Array],[A.INT8.toString(),Int8Array],[A.INT16.toString(),Int16Array],[A.INT32.toString(),Int32Array],[A.INT64.toString(),BigInt64Array],[A.TIMESTAMP.toString(),BigInt64Array],[A.STRING.toString(),Uint8Array],[A.JSON.toString(),Uint8Array],[A.UUID.toString(),Uint8Array]])),j(A,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,A.UINT8],[Uint16Array.name,A.UINT16],[Uint32Array.name,A.UINT32],[BigUint64Array.name,A.UINT64],[Float32Array.name,A.FLOAT32],[Float64Array.name,A.FLOAT64],[Int8Array.name,A.INT8],[Int16Array.name,A.INT16],[Int32Array.name,A.INT32],[BigInt64Array.name,A.INT64]])),j(A,"DENSITIES",new Map([[A.UINT8.toString(),mt.BIT8],[A.UINT16.toString(),mt.BIT16],[A.UINT32.toString(),mt.BIT32],[A.UINT64.toString(),mt.BIT64],[A.FLOAT32.toString(),mt.BIT32],[A.FLOAT64.toString(),mt.BIT64],[A.INT8.toString(),mt.BIT8],[A.INT16.toString(),mt.BIT16],[A.INT32.toString(),mt.BIT32],[A.INT64.toString(),mt.BIT64],[A.TIMESTAMP.toString(),mt.BIT64],[A.STRING.toString(),mt.UNKNOWN],[A.JSON.toString(),mt.UNKNOWN],[A.UUID.toString(),mt.BIT128]])),j(A,"ALL",[A.UNKNOWN,A.FLOAT64,A.FLOAT32,A.INT64,A.INT32,A.INT16,A.INT8,A.UINT64,A.UINT32,A.UINT16,A.UINT8,A.TIMESTAMP,A.UUID,A.STRING,A.JSON]),j(A,"BIG_INT_TYPES",[A.INT64,A.UINT64,A.TIMESTAMP]),j(A,"z",N.union([N.string().transform(r=>new A(r)),N.instanceof(A)]));const it=class We extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return We.bytes(this.valueOf()+e.valueOf())}sub(e){return We.bytes(this.valueOf()-e.valueOf())}truncate(e){return new We(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return We.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/We.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/We.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/We.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/We.TERABYTE.valueOf()}toString(){const e=this.truncate(We.TERABYTE),t=this.truncate(We.GIGABYTE),n=this.truncate(We.MEGABYTE),s=this.truncate(We.KILOBYTE),a=this.truncate(We.BYTE),i=e,o=t.sub(e),c=n.sub(t),l=s.sub(n),m=a.sub(s);let T="";return i.isZero||(T+=`${i.terabytes}TB `),o.isZero||(T+=`${o.gigabytes}GB `),c.isZero||(T+=`${c.megabytes}MB `),l.isZero||(T+=`${l.kilobytes}KB `),(!m.isZero||T==="")&&(T+=`${m.valueOf()}B`),T.trim()}static bytes(e=1){return new We(e)}static kilobytes(e=1){return We.bytes(e.valueOf()*1e3)}static megabytes(e=1){return We.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return We.megabytes(e.valueOf()*1e3)}static terabytes(e){return We.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};j(it,"BYTE",new it(1)),j(it,"KILOBYTE",it.kilobytes(1)),j(it,"MEGABYTE",it.megabytes(1)),j(it,"GIGABYTE",it.gigabytes(1)),j(it,"TERABYTE",it.terabytes(1)),j(it,"ZERO",new it(0)),j(it,"z",N.union([N.number().transform(r=>new it(r)),N.instanceof(it)]));let Kg=it;N.union([N.instanceof(Uint8Array),N.instanceof(Uint16Array),N.instanceof(Uint32Array),N.instanceof(BigUint64Array),N.instanceof(Float32Array),N.instanceof(Float64Array),N.instanceof(Int8Array),N.instanceof(Int16Array),N.instanceof(Int32Array),N.instanceof(BigInt64Array)]);N.record(N.union([N.number(),N.string(),N.symbol()]),N.unknown());const Fg=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),Ld=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Wg=Ld(),Bd=["MacOS","Windows","Linux","Docker"],Yg=N.enum(Bd);let Qi;const Jg=()=>{if(typeof window>"u")return;const r=window.navigator.userAgent.toLowerCase();if(r.includes("mac"))return"MacOS";if(r.includes("win"))return"Windows";if(r.includes("linux"))return"Linux"},Gg=(r={})=>{const{force:e,default:t}=r;return e??Qi??(Qi=Jg(),Qi??t)},Vd=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Bd,RUNTIME:Wg,detect:Ld,getOS:Gg,osZ:Yg},Symbol.toStringTag,{value:"Module"})),Hg=(...r)=>r.map(qd).join(""),qd=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Xg=r=>r.endsWith("/")?r.slice(0,-1):r,Qg=(r,e="")=>r===null?"":"?"+Object.entries(r).filter(([,t])=>t==null?!1:Array.isArray(t)?t.length>0:!0).map(([t,n])=>`${e}${t}=${n}`).join("&");var Tn;let ev=(Tn=class{constructor({host:r,port:e,protocol:t="",pathPrefix:n=""}){j(this,"protocol"),j(this,"host"),j(this,"port"),j(this,"path"),this.protocol=t,this.host=r,this.port=e,this.path=qd(n)}replace(r){return new Tn({host:r.host??this.host,port:r.port??this.port,protocol:r.protocol??this.protocol,pathPrefix:r.pathPrefix??this.path})}child(r){return new Tn({...this,pathPrefix:Hg(this.path,r)})}toString(){return Xg(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},j(Tn,"UNKNOWN",new Tn({host:"unknown",port:0})),Tn);var Co;try{Co=new TextDecoder}catch{}var P,Nt,f=0,Me={},be,Ur,xt=0,Jt=0,Qe,Nr,Ot=[],ve,_u={useRecords:!1,mapsAsObjects:!0};class Kd{}const Fd=new Kd;Fd.name="MessagePack 0xC1";var Lr=!1,Wd=2,ku;try{new Function("")}catch{Wd=1/0}class $s{constructor(e){e&&(e.useRecords===!1&&e.mapsAsObjects===void 0&&(e.mapsAsObjects=!0),e.sequential&&e.trusted!==!1&&(e.trusted=!0,!e.structures&&e.useRecords!=!1&&(e.structures=[],e.maxSharedStructures||(e.maxSharedStructures=0))),e.structures?e.structures.sharedLength=e.structures.length:e.getStructures&&((e.structures=[]).uninitialized=!0,e.structures.sharedLength=0),e.int64AsNumber&&(e.int64AsType="number")),Object.assign(this,e)}unpack(e,t){if(P)return Xd(()=>(Ro(),this?this.unpack(e,t):$s.prototype.unpack.call(_u,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(Nt=t.end||e.length,f=t.start||0):(f=0,Nt=t>-1?t:e.length),Jt=0,Ur=null,Qe=null,P=e;try{ve=e.dataView||(e.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength))}catch(n){throw P=null,e instanceof Uint8Array?n:new Error("Source must be a Uint8Array or Buffer but was a "+(e&&typeof e=="object"?e.constructor.name:typeof e))}if(this instanceof $s){if(Me=this,this.structures)return be=this.structures,ha(t);(!be||be.length>0)&&(be=[])}else Me=_u,(!be||be.length>0)&&(be=[]);return ha(t)}unpackMultiple(e,t){let n,s=0;try{Lr=!0;let a=e.length,i=this?this.unpack(e,a):Ci.unpack(e,a);if(t){if(t(i,s,f)===!1)return;for(;f<a;)if(s=f,t(ha(),s,f)===!1)return}else{for(n=[i];f<a;)s=f,n.push(ha());return n}}catch(a){throw a.lastPosition=s,a.values=n,a}finally{Lr=!1,Ro()}}_mergeStructures(e,t){e=e||[],Object.isFrozen(e)&&(e=e.map(n=>n.slice(0)));for(let n=0,s=e.length;n<s;n++){let a=e[n];a&&(a.isShared=!0,n>=32&&(a.highByte=n-32>>5))}e.sharedLength=e.length;for(let n in t||[])if(n>=0){let s=e[n],a=t[n];a&&(s&&((e.restoreStructures||(e.restoreStructures=[]))[n]=s),e[n]=a)}return this.structures=e}decode(e,t){return this.unpack(e,t)}}function ha(r){try{if(!Me.trusted&&!Lr){let t=be.sharedLength||0;t<be.length&&(be.length=t)}let e;if(Me.randomAccessStructure&&P[f]<64&&P[f]>=32&&ku?(e=ku(P,f,Nt,Me),P=null,!(r&&r.lazy)&&e&&(e=e.toJSON()),f=Nt):e=qe(),Qe&&(f=Qe.postBundlePosition,Qe=null),Lr&&(be.restoreStructures=null),f==Nt)be&&be.restoreStructures&&Ou(),be=null,P=null,Nr&&(Nr=null);else{if(f>Nt)throw new Error("Unexpected end of MessagePack data");if(!Lr){let t;try{t=JSON.stringify(e,(n,s)=>typeof s=="bigint"?`${s}n`:s).slice(0,100)}catch(n){t="(JSON view not available "+n+")"}throw new Error("Data read, but end of buffer not reached "+t)}}return e}catch(e){throw be&&be.restoreStructures&&Ou(),Ro(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||f>Nt)&&(e.incomplete=!0),e}}function Ou(){for(let r in be.restoreStructures)be[r]=be.restoreStructures[r];be.restoreStructures=null}function qe(){let r=P[f++];if(r<160)if(r<128){if(r<64)return r;{let e=be[r&63]||Me.getStructures&&Yd()[r&63];return e?(e.read||(e.read=Tc(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,Me.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Gd();n==="__proto__"&&(n="__proto_"),e[n]=qe()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(qe(),qe());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=qe();return Me.freezeData?Object.freeze(e):e}else if(r<192){let e=r-160;if(Jt>=f)return Ur.slice(f-xt,(f+=e)-xt);if(Jt==0&&Nt<140){let t=e<16?xc(e):Jd(e);if(t!=null)return t}return jo(e)}else{let e;switch(r){case 192:return null;case 193:return Qe?(e=qe(),e>0?Qe[1].slice(Qe.position1,Qe.position1+=e):Qe[0].slice(Qe.position0,Qe.position0-=e)):Fd;case 194:return!1;case 195:return!0;case 196:if(e=P[f++],e===void 0)throw new Error("Unexpected end of buffer");return eo(e);case 197:return e=ve.getUint16(f),f+=2,eo(e);case 198:return e=ve.getUint32(f),f+=4,eo(e);case 199:return nn(P[f++]);case 200:return e=ve.getUint16(f),f+=2,nn(e);case 201:return e=ve.getUint32(f),f+=4,nn(e);case 202:if(e=ve.getFloat32(f),Me.useFloat32>2){let t=Sc[(P[f]&127)<<1|P[f+1]>>7];return f+=4,(t*e+(e>0?.5:-.5)>>0)/t}return f+=4,e;case 203:return e=ve.getFloat64(f),f+=8,e;case 204:return P[f++];case 205:return e=ve.getUint16(f),f+=2,e;case 206:return e=ve.getUint32(f),f+=4,e;case 207:return Me.int64AsType==="number"?(e=ve.getUint32(f)*4294967296,e+=ve.getUint32(f+4)):Me.int64AsType==="string"?e=ve.getBigUint64(f).toString():Me.int64AsType==="auto"?(e=ve.getBigUint64(f),e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ve.getBigUint64(f),f+=8,e;case 208:return ve.getInt8(f++);case 209:return e=ve.getInt16(f),f+=2,e;case 210:return e=ve.getInt32(f),f+=4,e;case 211:return Me.int64AsType==="number"?(e=ve.getInt32(f)*4294967296,e+=ve.getUint32(f+4)):Me.int64AsType==="string"?e=ve.getBigInt64(f).toString():Me.int64AsType==="auto"?(e=ve.getBigInt64(f),e>=BigInt(-2)<<BigInt(52)&&e<=BigInt(2)<<BigInt(52)&&(e=Number(e))):e=ve.getBigInt64(f),f+=8,e;case 212:if(e=P[f++],e==114)return Au(P[f++]&63);{let t=Ot[e];if(t)return t.read?(f++,t.read(qe())):t.noBuffer?(f++,t()):t(P.subarray(f,++f));throw new Error("Unknown extension "+e)}case 213:return e=P[f],e==114?(f++,Au(P[f++]&63,P[f++])):nn(2);case 214:return nn(4);case 215:return nn(8);case 216:return nn(16);case 217:return e=P[f++],Jt>=f?Ur.slice(f-xt,(f+=e)-xt):rv(e);case 218:return e=ve.getUint16(f),f+=2,Jt>=f?Ur.slice(f-xt,(f+=e)-xt):nv(e);case 219:return e=ve.getUint32(f),f+=4,Jt>=f?Ur.slice(f-xt,(f+=e)-xt):sv(e);case 220:return e=ve.getUint16(f),f+=2,xu(e);case 221:return e=ve.getUint32(f),f+=4,xu(e);case 222:return e=ve.getUint16(f),f+=2,Su(e);case 223:return e=ve.getUint32(f),f+=4,Su(e);default:if(r>=224)return r-256;if(r===void 0){let t=new Error("Unexpected end of MessagePack data");throw t.incomplete=!0,t}throw new Error("Unknown MessagePack token "+r)}}}const tv=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function Tc(r,e){function t(){if(t.count++>Wd){let s=r.read=new Function("r","return function(){return "+(Me.freezeData?"Object.freeze":"")+"({"+r.map(a=>a==="__proto__"?"__proto_:r()":tv.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"})}")(qe);return r.highByte===0&&(r.read=Tu(e,r.read)),s()}let n={};for(let s=0,a=r.length;s<a;s++){let i=r[s];i==="__proto__"&&(i="__proto_"),n[i]=qe()}return Me.freezeData?Object.freeze(n):n}return t.count=0,r.highByte===0?Tu(e,t):t}const Tu=(r,e)=>function(){let t=P[f++];if(t===0)return e();let n=r<32?-(r+(t<<5)):r+(t<<5),s=be[n]||Yd()[n];if(!s)throw new Error("Record id is not defined for "+n);return s.read||(s.read=Tc(s,r)),s.read()};function Yd(){let r=Xd(()=>(P=null,Me.getStructures()));return be=Me._mergeStructures(r,be)}var jo=Qs,rv=Qs,nv=Qs,sv=Qs;function Qs(r){let e;if(r<16&&(e=xc(r)))return e;if(r>64&&Co)return Co.decode(P.subarray(f,f+=r));const t=f+r,n=[];for(e="";f<t;){const s=P[f++];if(!(s&128))n.push(s);else if((s&224)===192){const a=P[f++]&63;n.push((s&31)<<6|a)}else if((s&240)===224){const a=P[f++]&63,i=P[f++]&63;n.push((s&31)<<12|a<<6|i)}else if((s&248)===240){const a=P[f++]&63,i=P[f++]&63,o=P[f++]&63;let c=(s&7)<<18|a<<12|i<<6|o;c>65535&&(c-=65536,n.push(c>>>10&1023|55296),c=56320|c&1023),n.push(c)}else n.push(s);n.length>=4096&&(e+=He.apply(String,n),n.length=0)}return n.length>0&&(e+=He.apply(String,n)),e}function xu(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=qe();return Me.freezeData?Object.freeze(e):e}function Su(r){if(Me.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Gd();n==="__proto__"&&(n="__proto_"),e[n]=qe()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(qe(),qe());return e}}var He=String.fromCharCode;function Jd(r){let e=f,t=new Array(r);for(let n=0;n<r;n++){const s=P[f++];if((s&128)>0){f=e;return}t[n]=s}return He.apply(String,t)}function xc(r){if(r<4)if(r<2){if(r===0)return"";{let e=P[f++];if((e&128)>1){f-=1;return}return He(e)}}else{let e=P[f++],t=P[f++];if((e&128)>0||(t&128)>0){f-=2;return}if(r<3)return He(e,t);let n=P[f++];if((n&128)>0){f-=3;return}return He(e,t,n)}else{let e=P[f++],t=P[f++],n=P[f++],s=P[f++];if((e&128)>0||(t&128)>0||(n&128)>0||(s&128)>0){f-=4;return}if(r<6){if(r===4)return He(e,t,n,s);{let a=P[f++];if((a&128)>0){f-=5;return}return He(e,t,n,s,a)}}else if(r<8){let a=P[f++],i=P[f++];if((a&128)>0||(i&128)>0){f-=6;return}if(r<7)return He(e,t,n,s,a,i);let o=P[f++];if((o&128)>0){f-=7;return}return He(e,t,n,s,a,i,o)}else{let a=P[f++],i=P[f++],o=P[f++],c=P[f++];if((a&128)>0||(i&128)>0||(o&128)>0||(c&128)>0){f-=8;return}if(r<10){if(r===8)return He(e,t,n,s,a,i,o,c);{let l=P[f++];if((l&128)>0){f-=9;return}return He(e,t,n,s,a,i,o,c,l)}}else if(r<12){let l=P[f++],m=P[f++];if((l&128)>0||(m&128)>0){f-=10;return}if(r<11)return He(e,t,n,s,a,i,o,c,l,m);let T=P[f++];if((T&128)>0){f-=11;return}return He(e,t,n,s,a,i,o,c,l,m,T)}else{let l=P[f++],m=P[f++],T=P[f++],J=P[f++];if((l&128)>0||(m&128)>0||(T&128)>0||(J&128)>0){f-=12;return}if(r<14){if(r===12)return He(e,t,n,s,a,i,o,c,l,m,T,J);{let ee=P[f++];if((ee&128)>0){f-=13;return}return He(e,t,n,s,a,i,o,c,l,m,T,J,ee)}}else{let ee=P[f++],Ne=P[f++];if((ee&128)>0||(Ne&128)>0){f-=14;return}if(r<15)return He(e,t,n,s,a,i,o,c,l,m,T,J,ee,Ne);let te=P[f++];if((te&128)>0){f-=15;return}return He(e,t,n,s,a,i,o,c,l,m,T,J,ee,Ne,te)}}}}}function Nu(){let r=P[f++],e;if(r<192)e=r-160;else switch(r){case 217:e=P[f++];break;case 218:e=ve.getUint16(f),f+=2;break;case 219:e=ve.getUint32(f),f+=4;break;default:throw new Error("Expected string")}return Qs(e)}function eo(r){return Me.copyBuffers?Uint8Array.prototype.slice.call(P,f,f+=r):P.subarray(f,f+=r)}function nn(r){let e=P[f++];if(Ot[e]){let t;return Ot[e](P.subarray(f,t=f+=r),n=>{f=n;try{return qe()}finally{f=t}})}else throw new Error("Unknown extension type "+e)}var Eu=new Array(4096);function Gd(){let r=P[f++];if(r>=160&&r<192){if(r=r-160,Jt>=f)return Ur.slice(f-xt,(f+=r)-xt);if(!(Jt==0&&Nt<180))return jo(r)}else return f--,qe().toString();let e=(r<<5^(r>1?ve.getUint16(f):r>0?P[f]:0))&4095,t=Eu[e],n=f,s=f+r-3,a,i=0;if(t&&t.bytes==r){for(;n<s;){if(a=ve.getUint32(n),a!=t[i++]){n=1879048192;break}n+=4}for(s+=3;n<s;)if(a=P[n++],a!=t[i++]){n=1879048192;break}if(n===s)return f=n,t.string;s-=3,n=f}for(t=[],Eu[e]=t,t.bytes=r;n<s;)a=ve.getUint32(n),t.push(a),n+=4;for(s+=3;n<s;)a=P[n++],t.push(a);let o=r<16?xc(r):Jd(r);return o!=null?t.string=o:t.string=jo(r)}const Au=(r,e)=>{let t=qe().map(a=>a.toString()),n=r;e!==void 0&&(r=r<32?-((e<<5)+r):(e<<5)+r,t.highByte=e);let s=be[r];return s&&(s.isShared||Lr)&&((be.restoreStructures||(be.restoreStructures=[]))[r]=s),be[r]=t,t.read=Tc(t,n),t.read()};Ot[0]=()=>{};Ot[0].noBuffer=!0;let av={Error,TypeError,ReferenceError};Ot[101]=()=>{let r=qe();return(av[r[0]]||Error)(r[1])};Ot[105]=r=>{let e=ve.getUint32(f-4);Nr||(Nr=new Map);let t=P[f],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};Nr.set(e,s);let a=qe();return s.used?Object.assign(n,a):(s.target=a,a)};Ot[112]=r=>{let e=ve.getUint32(f-4),t=Nr.get(e);return t.used=!0,t.target};Ot[115]=()=>new Set(qe());const Hd=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");let iv=typeof globalThis=="object"?globalThis:window;Ot[116]=r=>{let e=r[0],t=Hd[e];if(!t)throw new Error("Could not find typed array for code "+e);return new iv[t](Uint8Array.prototype.slice.call(r,1).buffer)};Ot[120]=()=>{let r=qe();return new RegExp(r[0],r[1])};const ov=[];Ot[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=f;return f+=e-r.length,Qe=ov,Qe=[Nu(),Nu()],Qe.position0=0,Qe.position1=0,Qe.postBundlePosition=f,f=t,qe()};Ot[255]=r=>r.length==4?new Date((r[0]*16777216+(r[1]<<16)+(r[2]<<8)+r[3])*1e3):r.length==8?new Date(((r[0]<<22)+(r[1]<<14)+(r[2]<<6)+(r[3]>>2))/1e6+((r[3]&3)*4294967296+r[4]*16777216+(r[5]<<16)+(r[6]<<8)+r[7])*1e3):r.length==12?new Date(((r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3])/1e6+((r[4]&128?-281474976710656:0)+r[6]*1099511627776+r[7]*4294967296+r[8]*16777216+(r[9]<<16)+(r[10]<<8)+r[11])*1e3):new Date("invalid");function Xd(r){let e=Nt,t=f,n=xt,s=Jt,a=Ur,i=Nr,o=Qe,c=new Uint8Array(P.slice(0,Nt)),l=be,m=be.slice(0,be.length),T=Me,J=Lr,ee=r();return Nt=e,f=t,xt=n,Jt=s,Ur=a,Nr=i,Qe=o,P=c,Lr=J,be=l,be.splice(0,be.length,...m),Me=T,ve=new DataView(P.buffer,P.byteOffset,P.byteLength),ee}function Ro(){P=null,Nr=null,be=null}const Sc=new Array(147);for(let r=0;r<256;r++)Sc[r]=+("1e"+Math.floor(45.15-r*.30103));var Ci=new $s({useRecords:!1});const cv=Ci.unpack;Ci.unpackMultiple;Ci.unpack;let uv=new Float32Array(1);new Uint8Array(uv.buffer,0,4);let Ra;try{Ra=new TextEncoder}catch{}let zo,Qd;const ji=typeof Buffer<"u",pa=ji?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,eh=ji?Buffer:Uint8Array,Iu=ji?4294967296:2144337920;let _,Xn,Re,w=0,ft,De=null,lv;const dv=21760,hv=/[\u0080-\uFFFF]/,xn=Symbol("record-id");class pv extends $s{constructor(e){super(e),this.offset=0;let t,n,s,a,i=eh.prototype.utf8Write?function(d,O){return _.utf8Write(d,O,4294967295)}:Ra&&Ra.encodeInto?function(d,O){return Ra.encodeInto(d,_.subarray(O)).written}:!1,o=this;e||(e={});let c=e&&e.sequential,l=e.structures||e.saveStructures,m=e.maxSharedStructures;if(m==null&&(m=l?32:0),m>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let T=e.maxOwnStructures;T==null&&(T=l?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let J=m>32||T+m>64,ee=m+64,Ne=m+T+64;if(Ne>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let te=[],rr=0,nr=0;this.pack=this.encode=function(d,O){if(_||(_=new pa(8192),Re=_.dataView||(_.dataView=new DataView(_.buffer,0,8192)),w=0),ft=_.length-10,ft-w<2048?(_=new pa(_.length),Re=_.dataView||(_.dataView=new DataView(_.buffer,0,_.length)),ft=_.length-10,w=0):w=w+7&2147483640,t=w,O&bv&&(w+=O&255),a=o.structuredClone?new Map:null,o.bundleStrings&&typeof d!="string"?(De=[],De.size=1/0):De=null,s=o.structures,s){s.uninitialized&&(s=o._mergeStructures(o.getStructures()));let y=s.sharedLength||0;if(y>m)throw new Error("Shared structures is larger than maximum shared structures, try increasing maxSharedStructures to "+s.sharedLength);if(!s.transitions){s.transitions=Object.create(null);for(let g=0;g<y;g++){let k=s[g];if(!k)continue;let R,M=s.transitions;for(let I=0,ne=k.length;I<ne;I++){let K=k[I];R=M[K],R||(R=M[K]=Object.create(null)),M=R}M[xn]=g+64}this.lastNamedStructuresLength=y}c||(s.nextId=y+64)}n&&(n=!1);try{o.randomAccessStructure&&d&&d.constructor&&d.constructor===Object?qi(d):re(d);let y=De;if(De&&Cu(t,re,0),a&&a.idsToInsert){let g=a.idsToInsert.sort((I,ne)=>I.offset>ne.offset?1:-1),k=g.length,R=-1;for(;y&&k>0;){let I=g[--k].offset+t;I<y.stringsPosition+t&&R===-1&&(R=0),I>y.position+t?R>=0&&(R+=6):(R>=0&&(Re.setUint32(y.position+t,Re.getUint32(y.position+t)+R),R=-1),y=y.previous,k++)}R>=0&&y&&Re.setUint32(y.position+t,Re.getUint32(y.position+t)+R),w+=g.length*6,w>ft&&et(w),o.offset=w;let M=mv(_.subarray(t,w),g);return a=null,M}return o.offset=w,O&vv?(_.start=t,_.end=w,_):_.subarray(t,w)}finally{if(s&&(Fn(),n&&o.saveStructures)){let y=s.sharedLength||0,g=_.subarray(t,w),k=yv(s,o);return o.saveStructures(k,k.isCompatible)===!1?o.pack(d,O):(o.lastNamedStructuresLength=y,g)}O&wv&&(w=t)}};const Fn=()=>{nr<10&&nr++;let d=s.sharedLength||0;if(s.length>d&&!c&&(s.length=d),rr>1e4)s.transitions=null,nr=0,rr=0,te.length>0&&(te=[]);else if(te.length>0&&!c){for(let O=0,y=te.length;O<y;O++)te[O][xn]=0;te=[]}},Qr=d=>{var O=d.length;O<16?_[w++]=144|O:O<65536?(_[w++]=220,_[w++]=O>>8,_[w++]=O&255):(_[w++]=221,Re.setUint32(w,O),w+=4);for(let y=0;y<O;y++)re(d[y])},re=d=>{w>ft&&(_=et(w));var O=typeof d,y;if(O==="string"){let g=d.length;if(De&&g>=4&&g<4096){if((De.size+=g)>dv){let I,ne=(De[0]?De[0].length*3+De[1].length:0)+10;w+ne>ft&&(_=et(w+ne));let K;De.position?(K=De,_[w]=200,w+=3,_[w++]=98,I=w-t,w+=4,Cu(t,re,0),Re.setUint16(I+t-3,w-t-I)):(_[w++]=214,_[w++]=98,I=w-t,w+=4),De=["",""],De.previous=K,De.size=0,De.position=I}let M=hv.test(d);De[M?0:1]+=d,_[w++]=193,re(M?-g:g);return}let k;g<32?k=1:g<256?k=2:g<65536?k=3:k=5;let R=g*3;if(w+R>ft&&(_=et(w+R)),g<64||!i){let M,I,ne,K=w+k;for(M=0;M<g;M++)I=d.charCodeAt(M),I<128?_[K++]=I:I<2048?(_[K++]=I>>6|192,_[K++]=I&63|128):(I&64512)===55296&&((ne=d.charCodeAt(M+1))&64512)===56320?(I=65536+((I&1023)<<10)+(ne&1023),M++,_[K++]=I>>18|240,_[K++]=I>>12&63|128,_[K++]=I>>6&63|128,_[K++]=I&63|128):(_[K++]=I>>12|224,_[K++]=I>>6&63|128,_[K++]=I&63|128);y=K-w-k}else y=i(d,w+k);y<32?_[w++]=160|y:y<256?(k<2&&_.copyWithin(w+2,w+1,w+1+y),_[w++]=217,_[w++]=y):y<65536?(k<3&&_.copyWithin(w+3,w+2,w+2+y),_[w++]=218,_[w++]=y>>8,_[w++]=y&255):(k<5&&_.copyWithin(w+5,w+3,w+3+y),_[w++]=219,Re.setUint32(w,y),w+=4),w+=y}else if(O==="number")if(d>>>0===d)d<32||d<128&&this.useRecords===!1||d<64&&!this.randomAccessStructure?_[w++]=d:d<256?(_[w++]=204,_[w++]=d):d<65536?(_[w++]=205,_[w++]=d>>8,_[w++]=d&255):(_[w++]=206,Re.setUint32(w,d),w+=4);else if(d>>0===d)d>=-32?_[w++]=256+d:d>=-128?(_[w++]=208,_[w++]=d+256):d>=-32768?(_[w++]=209,Re.setInt16(w,d),w+=2):(_[w++]=210,Re.setInt32(w,d),w+=4);else{let g;if((g=this.useFloat32)>0&&d<4294967296&&d>=-2147483648){_[w++]=202,Re.setFloat32(w,d);let k;if(g<4||(k=d*Sc[(_[w]&127)<<1|_[w+1]>>7])>>0===k){w+=4;return}else w--}_[w++]=203,Re.setFloat64(w,d),w+=8}else if(O==="object"||O==="function")if(!d)_[w++]=192;else{if(a){let k=a.get(d);if(k){if(!k.id){let R=a.idsToInsert||(a.idsToInsert=[]);k.id=R.push(k)}_[w++]=214,_[w++]=112,Re.setUint32(w,k.id),w+=4;return}else a.set(d,{offset:w-t})}let g=d.constructor;if(g===Object)sr(d,!0);else if(g===Array)Qr(d);else if(g===Map)if(this.mapAsEmptyObject)_[w++]=128;else{y=d.size,y<16?_[w++]=128|y:y<65536?(_[w++]=222,_[w++]=y>>8,_[w++]=y&255):(_[w++]=223,Re.setUint32(w,y),w+=4);for(let[k,R]of d)re(k),re(R)}else{for(let k=0,R=zo.length;k<R;k++){let M=Qd[k];if(d instanceof M){let I=zo[k];if(I.write){I.type&&(_[w++]=212,_[w++]=I.type,_[w++]=0);let tt=I.write.call(this,d);tt===d?Array.isArray(d)?Qr(d):sr(d):re(tt);return}let ne=_,K=Re,Ke=w;_=null;let ht;try{ht=I.pack.call(this,d,tt=>(_=ne,ne=null,w+=tt,w>ft&&et(w),{target:_,targetView:Re,position:w-tt}),re)}finally{ne&&(_=ne,Re=K,w=Ke,ft=_.length-10)}ht&&(ht.length+w>ft&&et(ht.length+w),w=fv(ht,_,w,I.type));return}}if(Array.isArray(d))Qr(d);else{if(d.toJSON){const k=d.toJSON();if(k!==d)return re(k)}if(O==="function")return re(this.writeFunction&&this.writeFunction(d));sr(d,!d.hasOwnProperty)}}}else if(O==="boolean")_[w++]=d?195:194;else if(O==="bigint"){if(d<BigInt(1)<<BigInt(63)&&d>=-(BigInt(1)<<BigInt(63)))_[w++]=211,Re.setBigInt64(w,d);else if(d<BigInt(1)<<BigInt(64)&&d>0)_[w++]=207,Re.setBigUint64(w,d);else if(this.largeBigIntToFloat)_[w++]=203,Re.setFloat64(w,Number(d));else throw new RangeError(d+" was too large to fit in MessagePack 64-bit integer format, set largeBigIntToFloat to convert to float-64");w+=8}else if(O==="undefined")this.encodeUndefinedAsNil?_[w++]=192:(_[w++]=212,_[w++]=0,_[w++]=0);else throw new Error("Unknown type: "+O)},Wn=this.variableMapSize||this.coercibleKeyAsNumber?d=>{let O=Object.keys(d),y=O.length;y<16?_[w++]=128|y:y<65536?(_[w++]=222,_[w++]=y>>8,_[w++]=y&255):(_[w++]=223,Re.setUint32(w,y),w+=4);let g;if(this.coercibleKeyAsNumber)for(let k=0;k<y;k++){g=O[k];let R=Number(g);re(isNaN(R)?g:R),re(d[g])}else for(let k=0;k<y;k++)re(g=O[k]),re(d[g])}:(d,O)=>{_[w++]=222;let y=w-t;w+=2;let g=0;for(let k in d)(O||d.hasOwnProperty(k))&&(re(k),re(d[k]),g++);_[y+++t]=g>>8,_[y+t]=g&255},Yn=this.useRecords===!1?Wn:e.progressiveRecords&&!J?(d,O)=>{let y,g=s.transitions||(s.transitions=Object.create(null)),k=w++-t,R;for(let M in d)if(O||d.hasOwnProperty(M)){if(y=g[M],y)g=y;else{let I=Object.keys(d),ne=g;g=s.transitions;let K=0;for(let Ke=0,ht=I.length;Ke<ht;Ke++){let tt=I[Ke];y=g[tt],y||(y=g[tt]=Object.create(null),K++),g=y}k+t+1==w?(w--,en(g,I,K)):Gn(g,I,k,K),R=!0,g=ne[M]}re(d[M])}if(!R){let M=g[xn];M?_[k+t]=M:Gn(g,Object.keys(d),k,0)}}:(d,O)=>{let y,g=s.transitions||(s.transitions=Object.create(null)),k=0;for(let M in d)(O||d.hasOwnProperty(M))&&(y=g[M],y||(y=g[M]=Object.create(null),k++),g=y);let R=g[xn];R?R>=96&&J?(_[w++]=((R-=96)&31)+96,_[w++]=R>>5):_[w++]=R:en(g,g.__keys__||Object.keys(d),k);for(let M in d)(O||d.hasOwnProperty(M))&&re(d[M])},Jn=typeof this.useRecords=="function"&&this.useRecords,sr=Jn?(d,O)=>{Jn(d)?Yn(d,O):Wn(d,O)}:Yn,et=d=>{let O;if(d>16777216){if(d-t>Iu)throw new Error("Packed buffer would be larger than maximum buffer size");O=Math.min(Iu,Math.round(Math.max((d-t)*(d>67108864?1.25:2),4194304)/4096)*4096)}else O=(Math.max(d-t<<2,_.length-1)>>12)+1<<12;let y=new pa(O);return Re=y.dataView||(y.dataView=new DataView(y.buffer,0,O)),d=Math.min(d,_.length),_.copy?_.copy(y,0,t,d):y.set(_.slice(t,d)),w-=t,t=0,ft=y.length-10,_=y},en=(d,O,y)=>{let g=s.nextId;g||(g=64),g<ee&&this.shouldShareStructure&&!this.shouldShareStructure(O)?(g=s.nextOwnId,g<Ne||(g=ee),s.nextOwnId=g+1):(g>=Ne&&(g=ee),s.nextId=g+1);let k=O.highByte=g>=96&&J?g-96>>5:-1;d[xn]=g,d.__keys__=O,s[g-64]=O,g<ee?(O.isShared=!0,s.sharedLength=g-63,n=!0,k>=0?(_[w++]=(g&31)+96,_[w++]=k):_[w++]=g):(k>=0?(_[w++]=213,_[w++]=114,_[w++]=(g&31)+96,_[w++]=k):(_[w++]=212,_[w++]=114,_[w++]=g),y&&(rr+=nr*y),te.length>=T&&(te.shift()[xn]=0),te.push(d),re(O))},Gn=(d,O,y,g)=>{let k=_,R=w,M=ft,I=t;_=Xn,w=0,t=0,_||(Xn=_=new pa(8192)),ft=_.length-10,en(d,O,g),Xn=_;let ne=w;if(_=k,w=R,ft=M,t=I,ne>1){let K=w+ne-1;K>ft&&et(K);let Ke=y+t;_.copyWithin(Ke+ne,Ke+1,w),_.set(Xn.slice(0,ne),Ke),w=K}else _[y+t]=Xn[0]},qi=(d,O)=>{let y=lv(d,_,t,w,s,et,(g,k,R)=>{if(R)return n=!0;w=k;let M=_;return re(g),Fn(),M!==_?{position:w,targetView:Re,target:_}:w},this);if(y===0)return sr(d,!0);w=y}}useBuffer(e){_=e,Re=new DataView(_.buffer,_.byteOffset,_.byteLength),w=0}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}Qd=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Kd];zo=[{pack(r,e,t){let n=r.getTime()/1e3;if((this.useTimestamp32||r.getMilliseconds()===0)&&n>=0&&n<4294967296){let{target:s,targetView:a,position:i}=e(6);s[i++]=214,s[i++]=255,a.setUint32(i,n)}else if(n>0&&n<4294967296){let{target:s,targetView:a,position:i}=e(10);s[i++]=215,s[i++]=255,a.setUint32(i,r.getMilliseconds()*4e6+(n/1e3/4294967296>>0)),a.setUint32(i+4,n)}else if(isNaN(n)){if(this.onInvalidDate)return e(0),t(this.onInvalidDate());let{target:s,targetView:a,position:i}=e(3);s[i++]=212,s[i++]=255,s[i++]=255}else{let{target:s,targetView:a,position:i}=e(15);s[i++]=199,s[i++]=12,s[i++]=255,a.setUint32(i,r.getMilliseconds()*1e6),a.setBigInt64(i+4,BigInt(Math.floor(n)))}}},{pack(r,e,t){if(this.setAsEmptyObject)return e(0),t({});let n=Array.from(r),{target:s,position:a}=e(this.moreTypes?3:0);this.moreTypes&&(s[a++]=212,s[a++]=115,s[a++]=0),t(n)}},{pack(r,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=101,n[s++]=0),t([r.name,r.message])}},{pack(r,e,t){let{target:n,position:s}=e(this.moreTypes?3:0);this.moreTypes&&(n[s++]=212,n[s++]=120,n[s++]=0),t([r.source,r.flags])}},{pack(r,e){this.moreTypes?Zu(r,16,e):$u(ji?Buffer.from(r):new Uint8Array(r),e)}},{pack(r,e){let t=r.constructor;t!==eh&&this.moreTypes?Zu(r,Hd.indexOf(t.name),e):$u(r,e)}},{pack(r,e){let{target:t,position:n}=e(1);t[n]=193}}];function Zu(r,e,t,n){let s=r.byteLength;if(s+1<256){var{target:a,position:i}=t(4+s);a[i++]=199,a[i++]=s+1}else if(s+1<65536){var{target:a,position:i}=t(5+s);a[i++]=200,a[i++]=s+1>>8,a[i++]=s+1&255}else{var{target:a,position:i,targetView:o}=t(7+s);a[i++]=201,o.setUint32(i,s+1),i+=4}a[i++]=116,a[i++]=e,a.set(new Uint8Array(r.buffer,r.byteOffset,r.byteLength),i)}function $u(r,e){let t=r.byteLength;var n,s;if(t<256){var{target:n,position:s}=e(t+2);n[s++]=196,n[s++]=t}else if(t<65536){var{target:n,position:s}=e(t+3);n[s++]=197,n[s++]=t>>8,n[s++]=t&255}else{var{target:n,position:s,targetView:a}=e(t+5);n[s++]=198,a.setUint32(s,t),s+=4}n.set(r,s)}function fv(r,e,t,n){let s=r.length;switch(s){case 1:e[t++]=212;break;case 2:e[t++]=213;break;case 4:e[t++]=214;break;case 8:e[t++]=215;break;case 16:e[t++]=216;break;default:s<256?(e[t++]=199,e[t++]=s):s<65536?(e[t++]=200,e[t++]=s>>8,e[t++]=s&255):(e[t++]=201,e[t++]=s>>24,e[t++]=s>>16&255,e[t++]=s>>8&255,e[t++]=s&255)}return e[t++]=n,e.set(r,t),t+=s,t}function mv(r,e){let t,n=e.length*6,s=r.length-n;for(;t=e.pop();){let a=t.offset,i=t.id;r.copyWithin(a+n,a,s),n-=6;let o=a+n;r[o++]=214,r[o++]=105,r[o++]=i>>24,r[o++]=i>>16&255,r[o++]=i>>8&255,r[o++]=i&255,s=a}return r}function Cu(r,e,t){if(De.length>0){Re.setUint32(De.position+r,w+t-De.position-r),De.stringsPosition=w-r;let n=De;De=null,e(n[0]),e(n[1])}}function yv(r,e){return r.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},r}let th=new pv({useRecords:!1});const gv=th.pack;th.pack;const vv=512,wv=1024,bv=2048;class _v{constructor(){j(this,"contentType","application/msgpack")}encode(e){return gv(Bn.toSnake(e))}decode(e,t){const n=Bn.toCamel(cv(new Uint8Array(e)));return t!=null?t.parse(n):n}}class kv{constructor(){j(this,"contentType","application/json"),j(this,"decoder"),this.decoder=new TextDecoder}encode(e){const t=JSON.stringify(Bn.toSnake(e),(n,s)=>ArrayBuffer.isView(s)?Array.from(s):Fg(s)&&"encode_value"in s?typeof s.value=="bigint"?s.value.toString():s.value:typeof s=="bigint"?s.toString():s);return new TextEncoder().encode(t)}decode(e,t){const n=Bn.toCamel(JSON.parse(this.decoder.decode(e)));return t!=null?t.parse(n):n}static registerCustomType(){}}new _v,new kv;var Oe;(function(r){r.assertEqual=s=>s;function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{const a={};for(const i of s)a[i]=i;return a},r.getValidEnumValues=s=>{const a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(const o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{const a=[];for(const i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(const i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(Oe||(Oe={}));var Po;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Po||(Po={}));const L=Oe.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Pr=r=>{switch(typeof r){case"undefined":return L.undefined;case"string":return L.string;case"number":return isNaN(r)?L.nan:L.number;case"boolean":return L.boolean;case"function":return L.function;case"bigint":return L.bigint;case"symbol":return L.symbol;case"object":return Array.isArray(r)?L.array:r===null?L.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?L.promise:typeof Map<"u"&&r instanceof Map?L.map:typeof Set<"u"&&r instanceof Set?L.set:typeof Date<"u"&&r instanceof Date?L.date:L.object;default:return L.unknown}},C=Oe.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),Ov=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:");class Mt extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){const l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}toString(){return this.message}get message(){return JSON.stringify(this.issues,Oe.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){const t={},n=[];for(const s of this.issues)s.path.length>0?(t[s.path[0]]=t[s.path[0]]||[],t[s.path[0]].push(e(s))):n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}Mt.create=r=>new Mt(r);const Cs=(r,e)=>{let t;switch(r.code){case C.invalid_type:r.received===L.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case C.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,Oe.jsonStringifyReplacer)}`;break;case C.unrecognized_keys:t=`Unrecognized key(s) in object: ${Oe.joinValues(r.keys,", ")}`;break;case C.invalid_union:t="Invalid input";break;case C.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${Oe.joinValues(r.options)}`;break;case C.invalid_enum_value:t=`Invalid enum value. Expected ${Oe.joinValues(r.options)}, received '${r.received}'`;break;case C.invalid_arguments:t="Invalid function arguments";break;case C.invalid_return_type:t="Invalid function return type";break;case C.invalid_date:t="Invalid date";break;case C.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:Oe.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case C.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case C.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case C.custom:t="Invalid input";break;case C.invalid_intersection_types:t="Intersection results could not be merged";break;case C.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case C.not_finite:t="Number must be finite";break;default:t=e.defaultError,Oe.assertNever(r)}return{message:t}};let rh=Cs;function Tv(r){rh=r}function oi(){return rh}const ci=r=>{const{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};let o="";const c=n.filter(l=>!!l).slice().reverse();for(const l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:s.message||o}},xv=[];function q(r,e){const t=ci({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,oi(),Cs].filter(n=>!!n)});r.common.issues.push(t)}class lt{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const s of t){if(s.status==="aborted")return ce;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const s of t)n.push({key:await s.key,value:await s.value});return lt.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const s of t){const{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return ce;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const ce=Object.freeze({status:"aborted"}),nh=r=>({status:"dirty",value:r}),bt=r=>({status:"valid",value:r}),Mo=r=>r.status==="aborted",Uo=r=>r.status==="dirty",js=r=>r.status==="valid",ui=r=>typeof Promise<"u"&&r instanceof Promise;var Y;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(Y||(Y={}));class er{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ju=(r,e)=>{if(js(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new Mt(r.common.issues);return this._error=t,this._error}}};function de(r){if(!r)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(a,i)=>a.code!=="invalid_type"?{message:i.defaultError}:typeof i.data>"u"?{message:n??i.defaultError}:{message:t??i.defaultError},description:s}}class fe{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return Pr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Pr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new lt,ctx:{common:e.parent.common,data:e.data,parsedType:Pr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ui(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const s={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pr(e)},a=this._parseSync({data:e,path:s.path,parent:s});return ju(s,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Pr(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await(ui(s)?s:Promise.resolve(s));return ju(n,a)}refine(e,t){const n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{const i=e(s),o=()=>a.addIssue({code:C.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new Vt({schema:this,typeName:Q.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Er.create(this,this._def)}nullable(){return gn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Ut.create(this,this._def)}promise(){return qn.create(this,this._def)}or(e){return Ms.create([this,e],this._def)}and(e){return Us.create(this,e,this._def)}transform(e){return new Vt({...de(this._def),schema:this,typeName:Q.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new qs({...de(this._def),innerType:this,defaultValue:t,typeName:Q.ZodDefault})}brand(){return new ah({typeName:Q.ZodBranded,type:this,...de(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new pi({...de(this._def),innerType:this,catchValue:t,typeName:Q.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return ea.create(this,e)}readonly(){return mi.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Sv=/^c[^\s-]{8,}$/i,Nv=/^[a-z][a-z0-9]*$/,Ev=/^[0-9A-HJKMNP-TV-Z]{26}$/,Av=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,Iv=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Zv="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let to;const $v=/^(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))$/,Cv=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,jv=r=>r.precision?r.offset?new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}(([+-]\\d{2}(:?\\d{2})?)|Z)$`):new RegExp(`^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{${r.precision}}Z$`):r.precision===0?r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"):r.offset?new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?(([+-]\\d{2}(:?\\d{2})?)|Z)$"):new RegExp("^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}(\\.\\d+)?Z$");function Rv(r,e){return!!((e==="v4"||!e)&&$v.test(r)||(e==="v6"||!e)&&Cv.test(r))}class jt extends fe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==L.string){const s=this._getOrReturnCtx(e);return q(s,{code:C.invalid_type,expected:L.string,received:s.parsedType}),ce}const t=new lt;let n;for(const s of this._def.checks)if(s.kind==="min")e.data.length<s.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:C.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="max")e.data.length>s.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!1,message:s.message}),t.dirty());else if(s.kind==="length"){const a=e.data.length>s.value,i=e.data.length<s.value;(a||i)&&(n=this._getOrReturnCtx(e,n),a?q(n,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&q(n,{code:C.too_small,minimum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}),t.dirty())}else if(s.kind==="email")Iv.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"email",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")to||(to=new RegExp(Zv,"u")),to.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"emoji",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="uuid")Av.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"uuid",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid")Sv.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"cuid",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="cuid2")Nv.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"cuid2",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="ulid")Ev.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"ulid",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="url")try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),q(n,{validation:"url",code:C.invalid_string,message:s.message}),t.dirty()}else s.kind==="regex"?(s.regex.lastIndex=0,s.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"regex",code:C.invalid_string,message:s.message}),t.dirty())):s.kind==="trim"?e.data=e.data.trim():s.kind==="includes"?e.data.includes(s.value,s.position)||(n=this._getOrReturnCtx(e,n),q(n,{code:C.invalid_string,validation:{includes:s.value,position:s.position},message:s.message}),t.dirty()):s.kind==="toLowerCase"?e.data=e.data.toLowerCase():s.kind==="toUpperCase"?e.data=e.data.toUpperCase():s.kind==="startsWith"?e.data.startsWith(s.value)||(n=this._getOrReturnCtx(e,n),q(n,{code:C.invalid_string,validation:{startsWith:s.value},message:s.message}),t.dirty()):s.kind==="endsWith"?e.data.endsWith(s.value)||(n=this._getOrReturnCtx(e,n),q(n,{code:C.invalid_string,validation:{endsWith:s.value},message:s.message}),t.dirty()):s.kind==="datetime"?jv(s).test(e.data)||(n=this._getOrReturnCtx(e,n),q(n,{code:C.invalid_string,validation:"datetime",message:s.message}),t.dirty()):s.kind==="ip"?Rv(e.data,s.version)||(n=this._getOrReturnCtx(e,n),q(n,{validation:"ip",code:C.invalid_string,message:s.message}),t.dirty()):Oe.assertNever(s);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:C.invalid_string,...Y.errToObj(n)})}_addCheck(e){return new jt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...Y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...Y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...Y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...Y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...Y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...Y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...Y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...Y.errToObj(e)})}datetime(e){var t;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!1,...Y.errToObj(e==null?void 0:e.message)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...Y.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...Y.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...Y.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...Y.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...Y.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...Y.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...Y.errToObj(t)})}nonempty(e){return this.min(1,Y.errToObj(e))}trim(){return new jt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new jt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new jt({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get minLength(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}jt.create=r=>{var e;return new jt({checks:[],typeName:Q.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...de(r)})};function zv(r,e){const t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=parseInt(r.toFixed(s).replace(".","")),i=parseInt(e.toFixed(s).replace(".",""));return a%i/Math.pow(10,s)}class Wr extends fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==L.number){const s=this._getOrReturnCtx(e);return q(s,{code:C.invalid_type,expected:L.number,received:s.parsedType}),ce}let t;const n=new lt;for(const s of this._def.checks)s.kind==="int"?Oe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),q(t,{code:C.invalid_type,expected:"integer",received:"float",message:s.message}),n.dirty()):s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.too_small,minimum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.too_big,maximum:s.value,type:"number",inclusive:s.inclusive,exact:!1,message:s.message}),n.dirty()):s.kind==="multipleOf"?zv(e.data,s.value)!==0&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):s.kind==="finite"?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),q(t,{code:C.not_finite,message:s.message}),n.dirty()):Oe.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,n,s){return new Wr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Y.toString(s)}]})}_addCheck(e){return new Wr({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:Y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:Y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:Y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:Y.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&Oe.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Wr.create=r=>new Wr({checks:[],typeName:Q.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...de(r)});class Yr extends fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce&&(e.data=BigInt(e.data)),this._getType(e)!==L.bigint){const s=this._getOrReturnCtx(e);return q(s,{code:C.invalid_type,expected:L.bigint,received:s.parsedType}),ce}let t;const n=new lt;for(const s of this._def.checks)s.kind==="min"?(s.inclusive?e.data<s.value:e.data<=s.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.too_small,type:"bigint",minimum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="max"?(s.inclusive?e.data>s.value:e.data>=s.value)&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.too_big,type:"bigint",maximum:s.value,inclusive:s.inclusive,message:s.message}),n.dirty()):s.kind==="multipleOf"?e.data%s.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),q(t,{code:C.not_multiple_of,multipleOf:s.value,message:s.message}),n.dirty()):Oe.assertNever(s);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,Y.toString(t))}gt(e,t){return this.setLimit("min",e,!1,Y.toString(t))}lte(e,t){return this.setLimit("max",e,!0,Y.toString(t))}lt(e,t){return this.setLimit("max",e,!1,Y.toString(t))}setLimit(e,t,n,s){return new Yr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Y.toString(s)}]})}_addCheck(e){return new Yr({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:Y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:Y.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:Y.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}Yr.create=r=>{var e;return new Yr({checks:[],typeName:Q.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...de(r)})};class Rs extends fe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==L.boolean){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.boolean,received:t.parsedType}),ce}return bt(e.data)}}Rs.create=r=>new Rs({typeName:Q.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...de(r)});class mn extends fe{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==L.date){const s=this._getOrReturnCtx(e);return q(s,{code:C.invalid_type,expected:L.date,received:s.parsedType}),ce}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return q(s,{code:C.invalid_date}),ce}const t=new lt;let n;for(const s of this._def.checks)s.kind==="min"?e.data.getTime()<s.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:C.too_small,message:s.message,inclusive:!0,exact:!1,minimum:s.value,type:"date"}),t.dirty()):s.kind==="max"?e.data.getTime()>s.value&&(n=this._getOrReturnCtx(e,n),q(n,{code:C.too_big,message:s.message,inclusive:!0,exact:!1,maximum:s.value,type:"date"}),t.dirty()):Oe.assertNever(s);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new mn({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:Y.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:Y.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}mn.create=r=>new mn({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:Q.ZodDate,...de(r)});class li extends fe{_parse(e){if(this._getType(e)!==L.symbol){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.symbol,received:t.parsedType}),ce}return bt(e.data)}}li.create=r=>new li({typeName:Q.ZodSymbol,...de(r)});class zs extends fe{_parse(e){if(this._getType(e)!==L.undefined){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.undefined,received:t.parsedType}),ce}return bt(e.data)}}zs.create=r=>new zs({typeName:Q.ZodUndefined,...de(r)});class Ps extends fe{_parse(e){if(this._getType(e)!==L.null){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.null,received:t.parsedType}),ce}return bt(e.data)}}Ps.create=r=>new Ps({typeName:Q.ZodNull,...de(r)});class Vn extends fe{constructor(){super(...arguments),this._any=!0}_parse(e){return bt(e.data)}}Vn.create=r=>new Vn({typeName:Q.ZodAny,...de(r)});class on extends fe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return bt(e.data)}}on.create=r=>new on({typeName:Q.ZodUnknown,...de(r)});class Zr extends fe{_parse(e){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.never,received:t.parsedType}),ce}}Zr.create=r=>new Zr({typeName:Q.ZodNever,...de(r)});class di extends fe{_parse(e){if(this._getType(e)!==L.undefined){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.void,received:t.parsedType}),ce}return bt(e.data)}}di.create=r=>new di({typeName:Q.ZodVoid,...de(r)});class Ut extends fe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==L.array)return q(t,{code:C.invalid_type,expected:L.array,received:t.parsedType}),ce;if(s.exactLength!==null){const i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(q(t,{code:i?C.too_big:C.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(q(t,{code:C.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(q(t,{code:C.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new er(t,i,t.path,o)))).then(i=>lt.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new er(t,i,t.path,o)));return lt.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Ut({...this._def,minLength:{value:e,message:Y.toString(t)}})}max(e,t){return new Ut({...this._def,maxLength:{value:e,message:Y.toString(t)}})}length(e,t){return new Ut({...this._def,exactLength:{value:e,message:Y.toString(t)}})}nonempty(e){return this.min(1,e)}}Ut.create=(r,e)=>new Ut({type:r,minLength:null,maxLength:null,exactLength:null,typeName:Q.ZodArray,...de(e)});function En(r){if(r instanceof Be){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Er.create(En(n))}return new Be({...r._def,shape:()=>e})}else return r instanceof Ut?new Ut({...r._def,type:En(r.element)}):r instanceof Er?Er.create(En(r.unwrap())):r instanceof gn?gn.create(En(r.unwrap())):r instanceof tr?tr.create(r.items.map(e=>En(e))):r}class Be extends fe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=Oe.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==L.object){const c=this._getOrReturnCtx(e);return q(c,{code:C.invalid_type,expected:L.object,received:c.parsedType}),ce}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Zr&&this._def.unknownKeys==="strip"))for(const c in n.data)a.includes(c)||i.push(c);const o=[];for(const c of a){const l=s[c],m=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new er(n,m,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Zr){const c=this._def.unknownKeys;if(c==="passthrough")for(const l of i)o.push({key:{status:"valid",value:l},value:{status:"valid",value:n.data[l]}});else if(c==="strict")i.length>0&&(q(n,{code:C.unrecognized_keys,keys:i}),t.dirty());else if(c!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const c=this._def.catchall;for(const l of i){const m=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new er(n,m,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const m=await l.key;c.push({key:m,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>lt.mergeObjectSync(t,c)):lt.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return Y.errToObj,new Be({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var s,a,i,o;const c=(i=(a=(s=this._def).errorMap)===null||a===void 0?void 0:a.call(s,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.code==="unrecognized_keys"?{message:(o=Y.errToObj(e).message)!==null&&o!==void 0?o:c}:{message:c}}}:{}})}strip(){return new Be({...this._def,unknownKeys:"strip"})}passthrough(){return new Be({...this._def,unknownKeys:"passthrough"})}extend(e){return new Be({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Be({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:Q.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Be({...this._def,catchall:e})}pick(e){const t={};return Oe.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new Be({...this._def,shape:()=>t})}omit(e){const t={};return Oe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Be({...this._def,shape:()=>t})}deepPartial(){return En(this)}partial(e){const t={};return Oe.objectKeys(this.shape).forEach(n=>{const s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}),new Be({...this._def,shape:()=>t})}required(e){const t={};return Oe.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let s=this.shape[n];for(;s instanceof Er;)s=s._def.innerType;t[n]=s}}),new Be({...this._def,shape:()=>t})}keyof(){return sh(Oe.objectKeys(this.shape))}}Be.create=(r,e)=>new Be({shape:()=>r,unknownKeys:"strip",catchall:Zr.create(),typeName:Q.ZodObject,...de(e)});Be.strictCreate=(r,e)=>new Be({shape:()=>r,unknownKeys:"strict",catchall:Zr.create(),typeName:Q.ZodObject,...de(e)});Be.lazycreate=(r,e)=>new Be({shape:r,unknownKeys:"strip",catchall:Zr.create(),typeName:Q.ZodObject,...de(e)});class Ms extends fe{_parse(e){const{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(const o of a)if(o.result.status==="valid")return o.result;for(const o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new Mt(o.ctx.common.issues));return q(t,{code:C.invalid_union,unionErrors:i}),ce}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a;const i=[];for(const c of n){const l={...t,common:{...t.common,issues:[]},parent:null},m=c._parseSync({data:t.data,path:t.path,parent:l});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(c=>new Mt(c));return q(t,{code:C.invalid_union,unionErrors:o}),ce}}get options(){return this._def.options}}Ms.create=(r,e)=>new Ms({options:r,typeName:Q.ZodUnion,...de(e)});const za=r=>r instanceof Ls?za(r.schema):r instanceof Vt?za(r.innerType()):r instanceof Bs?[r.value]:r instanceof Jr?r.options:r instanceof Vs?Object.keys(r.enum):r instanceof qs?za(r._def.innerType):r instanceof zs?[void 0]:r instanceof Ps?[null]:null;class Ri extends fe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.object)return q(t,{code:C.invalid_type,expected:L.object,received:t.parsedType}),ce;const n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(q(t,{code:C.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),ce)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){const s=new Map;for(const a of t){const i=za(a.shape[e]);if(!i)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new Ri({typeName:Q.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...de(n)})}}function Do(r,e){const t=Pr(r),n=Pr(e);if(r===e)return{valid:!0,data:r};if(t===L.object&&n===L.object){const s=Oe.objectKeys(e),a=Oe.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(const o of a){const c=Do(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===L.array&&n===L.array){if(r.length!==e.length)return{valid:!1};const s=[];for(let a=0;a<r.length;a++){const i=r[a],o=e[a],c=Do(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===L.date&&n===L.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class Us extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Mo(a)||Mo(i))return ce;const o=Do(a.value,i.value);return o.valid?((Uo(a)||Uo(i))&&t.dirty(),{status:t.value,value:o.data}):(q(n,{code:C.invalid_intersection_types}),ce)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}Us.create=(r,e,t)=>new Us({left:r,right:e,typeName:Q.ZodIntersection,...de(t)});class tr extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.array)return q(n,{code:C.invalid_type,expected:L.array,received:n.parsedType}),ce;if(n.data.length<this._def.items.length)return q(n,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),ce;!this._def.rest&&n.data.length>this._def.items.length&&(q(n,{code:C.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const s=[...n.data].map((a,i)=>{const o=this._def.items[i]||this._def.rest;return o?o._parse(new er(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>lt.mergeArray(t,a)):lt.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new tr({...this._def,rest:e})}}tr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new tr({items:r,typeName:Q.ZodTuple,rest:null,...de(e)})};class Ds extends fe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.object)return q(n,{code:C.invalid_type,expected:L.object,received:n.parsedType}),ce;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new er(n,o,n.path,o)),value:i._parse(new er(n,n.data[o],n.path,o))});return n.common.async?lt.mergeObjectAsync(t,s):lt.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof fe?new Ds({keyType:e,valueType:t,typeName:Q.ZodRecord,...de(n)}):new Ds({keyType:jt.create(),valueType:e,typeName:Q.ZodRecord,...de(t)})}}class hi extends fe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.map)return q(n,{code:C.invalid_type,expected:L.map,received:n.parsedType}),ce;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new er(n,o,n.path,[l,"key"])),value:a._parse(new er(n,c,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const c of i){const l=await c.key,m=await c.value;if(l.status==="aborted"||m.status==="aborted")return ce;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,m=c.value;if(l.status==="aborted"||m.status==="aborted")return ce;(l.status==="dirty"||m.status==="dirty")&&t.dirty(),o.set(l.value,m.value)}return{status:t.value,value:o}}}}hi.create=(r,e,t)=>new hi({valueType:e,keyType:r,typeName:Q.ZodMap,...de(t)});class yn extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.set)return q(n,{code:C.invalid_type,expected:L.set,received:n.parsedType}),ce;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(q(n,{code:C.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(q(n,{code:C.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());const a=this._def.valueType;function i(c){const l=new Set;for(const m of c){if(m.status==="aborted")return ce;m.status==="dirty"&&t.dirty(),l.add(m.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new er(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new yn({...this._def,minSize:{value:e,message:Y.toString(t)}})}max(e,t){return new yn({...this._def,maxSize:{value:e,message:Y.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}yn.create=(r,e)=>new yn({valueType:r,minSize:null,maxSize:null,typeName:Q.ZodSet,...de(e)});class Cn extends fe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.function)return q(t,{code:C.invalid_type,expected:L.function,received:t.parsedType}),ce;function n(o,c){return ci({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,oi(),Cs].filter(l=>!!l),issueData:{code:C.invalid_arguments,argumentsError:c}})}function s(o,c){return ci({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,oi(),Cs].filter(l=>!!l),issueData:{code:C.invalid_return_type,returnTypeError:c}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof qn){const o=this;return bt(async function(...c){const l=new Mt([]),m=await o._def.args.parseAsync(c,a).catch(J=>{throw l.addIssue(n(c,J)),l}),T=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(T,a).catch(J=>{throw l.addIssue(s(T,J)),l})})}else{const o=this;return bt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Mt([n(c,l.error)]);const m=Reflect.apply(i,this,l.data),T=o._def.returns.safeParse(m,a);if(!T.success)throw new Mt([s(m,T.error)]);return T.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Cn({...this._def,args:tr.create(e).rest(on.create())})}returns(e){return new Cn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Cn({args:e||tr.create([]).rest(on.create()),returns:t||on.create(),typeName:Q.ZodFunction,...de(n)})}}class Ls extends fe{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}Ls.create=(r,e)=>new Ls({getter:r,typeName:Q.ZodLazy,...de(e)});class Bs extends fe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return q(t,{received:t.data,code:C.invalid_literal,expected:this._def.value}),ce}return{status:"valid",value:e.data}}get value(){return this._def.value}}Bs.create=(r,e)=>new Bs({value:r,typeName:Q.ZodLiteral,...de(e)});function sh(r,e){return new Jr({values:r,typeName:Q.ZodEnum,...de(e)})}class Jr extends fe{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{expected:Oe.joinValues(n),received:t.parsedType,code:C.invalid_type}),ce}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return q(t,{received:t.data,code:C.invalid_enum_value,options:n}),ce}return bt(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e){return Jr.create(e)}exclude(e){return Jr.create(this.options.filter(t=>!e.includes(t)))}}Jr.create=sh;class Vs extends fe{_parse(e){const t=Oe.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==L.string&&n.parsedType!==L.number){const s=Oe.objectValues(t);return q(n,{expected:Oe.joinValues(s),received:n.parsedType,code:C.invalid_type}),ce}if(t.indexOf(e.data)===-1){const s=Oe.objectValues(t);return q(n,{received:n.data,code:C.invalid_enum_value,options:s}),ce}return bt(e.data)}get enum(){return this._def.values}}Vs.create=(r,e)=>new Vs({values:r,typeName:Q.ZodNativeEnum,...de(e)});class qn extends fe{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.promise&&t.common.async===!1)return q(t,{code:C.invalid_type,expected:L.promise,received:t.parsedType}),ce;const n=t.parsedType===L.promise?t.data:Promise.resolve(t.data);return bt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}qn.create=(r,e)=>new qn({type:r,typeName:Q.ZodPromise,...de(e)});class Vt extends fe{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===Q.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{q(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){const i=s.transform(n.data,a);return n.common.issues.length?{status:"dirty",value:n.data}:n.common.async?Promise.resolve(i).then(o=>this._def.schema._parseAsync({data:o,path:n.path,parent:n})):this._def.schema._parseSync({data:i,path:n.path,parent:n})}if(s.type==="refinement"){const i=o=>{const c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?ce:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?ce:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!js(i))return i;const o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>js(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);Oe.assertNever(s)}}Vt.create=(r,e,t)=>new Vt({schema:r,typeName:Q.ZodEffects,effect:e,...de(t)});Vt.createWithPreprocess=(r,e,t)=>new Vt({schema:e,effect:{type:"preprocess",transform:r},typeName:Q.ZodEffects,...de(t)});class Er extends fe{_parse(e){return this._getType(e)===L.undefined?bt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Er.create=(r,e)=>new Er({innerType:r,typeName:Q.ZodOptional,...de(e)});class gn extends fe{_parse(e){return this._getType(e)===L.null?bt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}gn.create=(r,e)=>new gn({innerType:r,typeName:Q.ZodNullable,...de(e)});class qs extends fe{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===L.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}qs.create=(r,e)=>new qs({innerType:r,typeName:Q.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...de(e)});class pi extends fe{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ui(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new Mt(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Mt(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}pi.create=(r,e)=>new pi({innerType:r,typeName:Q.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...de(e)});class fi extends fe{_parse(e){if(this._getType(e)!==L.nan){const t=this._getOrReturnCtx(e);return q(t,{code:C.invalid_type,expected:L.nan,received:t.parsedType}),ce}return{status:"valid",value:e.data}}}fi.create=r=>new fi({typeName:Q.ZodNaN,...de(r)});const Pv=Symbol("zod_brand");class ah extends fe{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class ea extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const s=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ce:s.status==="dirty"?(t.dirty(),nh(s.value)):this._def.out._parseAsync({data:s.value,path:n.path,parent:n})})();{const s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?ce:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new ea({in:e,out:t,typeName:Q.ZodPipeline})}}class mi extends fe{_parse(e){const t=this._def.innerType._parse(e);return js(t)&&(t.value=Object.freeze(t.value)),t}}mi.create=(r,e)=>new mi({innerType:r,typeName:Q.ZodReadonly,...de(e)});const ih=(r,e={},t)=>r?Vn.create().superRefine((n,s)=>{var a,i;if(!r(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,c=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,l=typeof o=="string"?{message:o}:o;s.addIssue({code:"custom",...l,fatal:c})}}):Vn.create(),Mv={object:Be.lazycreate};var Q;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(Q||(Q={}));const Uv=(r,e={message:`Input not instance of ${r.name}`})=>ih(t=>t instanceof r,e),oh=jt.create,ch=Wr.create,Dv=fi.create,Lv=Yr.create,uh=Rs.create,Bv=mn.create,Vv=li.create,qv=zs.create,Kv=Ps.create,Fv=Vn.create,Wv=on.create,Yv=Zr.create,Jv=di.create,Gv=Ut.create,Hv=Be.create,Xv=Be.strictCreate,Qv=Ms.create,ew=Ri.create,tw=Us.create,rw=tr.create,nw=Ds.create,sw=hi.create,aw=yn.create,iw=Cn.create,ow=Ls.create,cw=Bs.create,uw=Jr.create,lw=Vs.create,dw=qn.create,Ru=Vt.create,hw=Er.create,pw=gn.create,fw=Vt.createWithPreprocess,mw=ea.create,yw=()=>oh().optional(),gw=()=>ch().optional(),vw=()=>uh().optional(),ww={string:r=>jt.create({...r,coerce:!0}),number:r=>Wr.create({...r,coerce:!0}),boolean:r=>Rs.create({...r,coerce:!0}),bigint:r=>Yr.create({...r,coerce:!0}),date:r=>mn.create({...r,coerce:!0})},bw=ce;var Or=Object.freeze({__proto__:null,defaultErrorMap:Cs,setErrorMap:Tv,getErrorMap:oi,makeIssue:ci,EMPTY_PATH:xv,addIssueToContext:q,ParseStatus:lt,INVALID:ce,DIRTY:nh,OK:bt,isAborted:Mo,isDirty:Uo,isValid:js,isAsync:ui,get util(){return Oe},get objectUtil(){return Po},ZodParsedType:L,getParsedType:Pr,ZodType:fe,ZodString:jt,ZodNumber:Wr,ZodBigInt:Yr,ZodBoolean:Rs,ZodDate:mn,ZodSymbol:li,ZodUndefined:zs,ZodNull:Ps,ZodAny:Vn,ZodUnknown:on,ZodNever:Zr,ZodVoid:di,ZodArray:Ut,ZodObject:Be,ZodUnion:Ms,ZodDiscriminatedUnion:Ri,ZodIntersection:Us,ZodTuple:tr,ZodRecord:Ds,ZodMap:hi,ZodSet:yn,ZodFunction:Cn,ZodLazy:Ls,ZodLiteral:Bs,ZodEnum:Jr,ZodNativeEnum:Vs,ZodPromise:qn,ZodEffects:Vt,ZodTransformer:Vt,ZodOptional:Er,ZodNullable:gn,ZodDefault:qs,ZodCatch:pi,ZodNaN:fi,BRAND:Pv,ZodBranded:ah,ZodPipeline:ea,ZodReadonly:mi,custom:ih,Schema:fe,ZodSchema:fe,late:Mv,get ZodFirstPartyTypeKind(){return Q},coerce:ww,any:Fv,array:Gv,bigint:Lv,boolean:uh,date:Bv,discriminatedUnion:ew,effect:Ru,enum:uw,function:iw,instanceof:Uv,intersection:tw,lazy:ow,literal:cw,map:sw,nan:Dv,nativeEnum:lw,never:Yv,null:Kv,nullable:pw,number:ch,object:Hv,oboolean:vw,onumber:gw,optional:hw,ostring:yw,pipeline:mw,preprocess:fw,promise:dw,record:nw,set:aw,strictObject:Xv,string:oh,symbol:Vv,transformer:Ru,tuple:rw,undefined:qv,union:Qv,unknown:Wv,void:Jv,NEVER:bw,ZodIssueCode:C,quotelessJson:Ov,ZodError:Mt});class ta extends Error{constructor(e,t){super(e),Ye(this,"discriminator","FreighterError"),Ye(this,"type"),this.type=t}}const _w=r=>{if(r==null||typeof r!="object")return!1;const e=r;if(e.discriminator!=="FreighterError")return!1;if(!("type"in e))throw new Error(`Freighter error is missing its type property: ${JSON.stringify(e)}`);return!0},Lo="unknown",zu="nil",zi="freighter",ra=Or.object({type:Or.string(),data:Or.string()});class kw{constructor(){Ye(this,"providers",[])}register(e){this.providers.push(e)}encode(e){if(e==null)return{type:zu,data:""};if(_w(e))for(const t of this.providers){const n=t.encode(e);if(n!=null)return n}return{type:Lo,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===zu)return null;if(e.type===Lo)return new Pu(e.data);for(const t of this.providers){const n=t.decode(e);if(n!=null)return n}return new Pu(e.data)}}const lh=new kw,dh=({encode:r,decode:e})=>lh.register({encode:r,decode:e}),Nc=r=>lh.decode(r);class Pu extends ta{constructor(e){super(e,Lo)}}class Ks extends ta{constructor(){super("EOF",zi)}}class yi extends ta{constructor(){super("StreamClosed",zi)}}class Fs extends ta{constructor(e={}){const{message:t="Unreachable",url:n=ev.UNKNOWN}=e;super(t,zi),Ye(this,"url"),this.url=n}}const Pa="freighter",Ow=r=>{if(r.type!==zi)return null;if(r instanceof Ks)return{type:Pa,data:"EOF"};if(r instanceof yi)return{type:Pa,data:"StreamClosed"};if(r instanceof Fs)return{type:Pa,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},Tw=r=>{if(r.type!==Pa)return null;switch(r.data){case"EOF":return new Ks;case"StreamClosed":return new yi;case"Unreachable":return new Fs;default:throw new Error(`Unknown error type: ${r.data}`)}};dh({encode:Ow,decode:Tw});class hh{constructor(){Ye(this,"middleware",[])}use(...e){this.middleware.push(...e)}async executeMiddleware(e,t){let n=0;const s=async a=>{if(n===this.middleware.length)return await t(a);const i=this.middleware[n];return n++,await i(a,s)};return await s(e)}}const ph="Content-Type",Mu=r=>{if(Vd.RUNTIME!=="node")return fetch;const e=require("node-fetch");if(r==="http")return e;const t=require("https"),n=new t.Agent({rejectUnauthorized:!1});return async(s,a)=>await e(s,{...a,agent:n})};class xw extends hh{constructor(e,t,n=!1){return super(),Ye(this,"endpoint"),Ye(this,"encoder"),Ye(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=Mu(this.endpoint.protocol),new Proxy(this,{get:(s,a,i)=>a==="endpoint"?this.endpoint:Reflect.get(s,a,i)})}get headers(){return{[ph]:this.encoder.contentType}}async send(e,t,n,s){t=n==null?void 0:n.parse(t);let a=null;const i=this.endpoint.child(e),o={};o.method="POST",o.body=this.encoder.encode(t??{});const[,c]=await this.executeMiddleware({target:i.toString(),protocol:this.endpoint.protocol,params:{},role:"client"},async l=>{const m={...l,params:{}};o.headers={...this.headers,...l.params};let T;try{T=await Mu(l.protocol)(l.target,o)}catch(ee){let Ne=ee;return Ne.message==="Load failed"&&(Ne=new Fs({url:i})),[m,Ne]}const J=await T.arrayBuffer();if(T!=null&&T.ok)return s!=null&&(a=this.encoder.decode(J,s)),[m,null];try{if(T.status!==400)return[m,new Error(T.statusText)];const ee=this.encoder.decode(J,ra),Ne=Nc(ee);return[m,Ne]}catch(ee){return[m,new Error(`[freighter] - failed to decode error: ${T.statusText}: ${ee.message}`)]}});return[a,c]}}const G=async(r,e,t,n,s)=>{const[a,i]=await r.send(e,t,n,s);if(i!=null)throw i;return a},Sw=()=>Vd.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),Nw=Or.object({type:Or.union([Or.literal("data"),Or.literal("close")]),payload:Or.unknown().optional(),error:Or.optional(ra)});class Ew{constructor(e,t,n,s){Ye(this,"encoder"),Ye(this,"reqSchema"),Ye(this,"resSchema"),Ye(this,"ws"),Ye(this,"serverClosed"),Ye(this,"sendClosed"),Ye(this,"receiveDataQueue",[]),Ye(this,"receiveCallbacksQueue",[]),this.encoder=t,this.reqSchema=n,this.resSchema=s,this.ws=e,this.sendClosed=!1,this.serverClosed=null,this.listenForMessages()}send(e){if(this.serverClosed!=null)return new Ks;if(this.sendClosed)throw new yi;return this.ws.send(this.encoder.encode({type:"data",payload:e})),null}async receive(){if(this.serverClosed!=null)return[null,this.serverClosed];const e=await this.receiveMsg();if(e.type==="close"){if(e.error==null)throw new Error("Message error must be defined");return this.serverClosed=Nc(e.error),[null,this.serverClosed]}return[this.resSchema.parse(e.payload),null]}received(){return this.receiveDataQueue.length!==0}closeSend(){if(this.sendClosed||this.serverClosed!=null)return;const e={type:"close"};try{this.ws.send(this.encoder.encode(e))}finally{this.sendClosed=!0}}async receiveMsg(){return this.receiveDataQueue.shift()??await new Promise((t,n)=>this.receiveCallbacksQueue.push({resolve:t,reject:n}))}listenForMessages(){this.ws.onmessage=e=>{const t=this.encoder.decode(e.data,Nw),n=this.receiveCallbacksQueue.shift();n!=null?n.resolve(t):this.receiveDataQueue.push(t)},this.ws.onclose=e=>{this.serverClosed=Cw(e)?new Ks:new yi}}}const Aw="freighterctx",Iw=1e3,Zw=1001,$w=[Iw,Zw],Cw=r=>$w.includes(r.code),fh=class mh extends hh{constructor(e,t,n=!1){super(),Ye(this,"baseUrl"),Ye(this,"encoder"),this.baseUrl=e.replace({protocol:n?"wss":"ws"}),this.encoder=t}async stream(e,t,n){const s=Sw();let a;const[,i]=await this.executeMiddleware({target:e,protocol:"websocket",params:{},role:"client"},async o=>{const c=s(this.buildURL(e,o)),l={...o,params:{}};c.binaryType=mh.MESSAGE_TYPE;const m=await this.wrapSocket(c,t,n);return m instanceof Error?[l,m]:(a=m,[l,null])});if(i!=null)throw i;return a}buildURL(e,t){const n=Qg({[ph]:this.encoder.contentType,...t.params},Aw);return this.baseUrl.child(e).toString()+n}async wrapSocket(e,t,n){return await new Promise(s=>{e.onopen=()=>{s(new Ew(e,this.encoder,t,n))},e.onerror=a=>{const i=a;s(new Error(i.message))}})}};Ye(fh,"MESSAGE_TYPE","arraybuffer");let jw=fh;const kr="sy.api.";var $r=(r=>(r.General=kr+"general",r.Parse=kr+"parse",r.Auth=kr+"auth",r.Unexpected=kr+"unexpected",r.Validation=kr+"validation",r.Query=kr+"query",r.Route=kr+"route",r))($r||{});class Gr extends ta{constructor(e){super(e,kr)}}class gt extends Gr{constructor(t){var e=(...fk)=>(super(...fk),h(this,"fields"),this);typeof t=="string"?(e(t),this.fields=[]):Array.isArray(t)?(e(t.map(n=>`${n.field}: ${n.message}`).join(`
12
+ `)),this.fields=t):(e(`${t.field}: ${t.message}`),this.fields=[t])}}class yh extends Gr{}class gh extends Gr{}class Ec extends Gr{}class vn extends Gr{constructor(e){super(`
13
13
  Unexpected error encountered:
14
14
 
15
15
  ${e}
16
16
 
17
17
  Please report this to the Synnax team.
18
- `)}}class qt extends Hr{}class Sw extends qt{}class Nw extends qt{}class ph extends Hr{constructor(t,n){super(t);h(this,"path");this.path=n}}class Ew extends Hr{}const Aw=r=>{if(!r.type.startsWith(kr))return null;switch(r.type){case $r.General:return new dh(r.data);case $r.Parse:return new hh(r.data);case $r.Auth:return new Ec(r.data);case $r.Unexpected:return new wn(r.data);case $r.Validation:return new gt(r.data);case $r.Query:return new qt(r.data);case $r.Route:return new ph(r.data,r.data);default:return new wn(r.data)}},Iw=()=>{throw new Error("Not implemented")};ih({encode:Iw,decode:Aw});const Zw=async(r,e)=>{const[t,n]=await e(r);return n==null?[t,n]:n instanceof Ws?[t,new Ws({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,n]},$w=u.z.object({leaseholder:u.z.number().optional(),keys:u.z.number().array().optional(),names:u.z.string().array().optional(),search:u.z.string().optional(),rangeKey:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional()}),Cw=u.z.object({channels:Qs.array()}),_i=class _i{constructor(e){h(this,"client");this.client=e}async search(e,t){return await this.execute({search:e,rangeKey:t})}async retrieve(e,t){const{variant:n,normalized:s}=Xr(e);return await this.execute({[n]:s,rangeKey:t})}async page(e,t,n){return await this.execute({offset:e,limit:t,rangeKey:n})}async execute(e){const[t,n]=await this.client.send(_i.ENDPOINT,e,$w,Cw);if(n!=null)throw n;return t.channels}};h(_i,"ENDPOINT","/channel/retrieve");let Ys=_i;class Ac{constructor(e){h(this,"cache");h(this,"namesToKeys");h(this,"wrapped");this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t}=Xr(e),n=[],s=[];if(t.forEach(i=>{const o=this.getFromCache(i);o!=null?n.push(o):s.push(i)}),s.length===0)return n;const a=await this.wrapped.retrieve(s);return this.updateCache(a),n.concat(a)}updateCache(e){e.forEach(t=>{this.cache.set(t.key,t),this.namesToKeys.set(t.name,t.key)})}getFromCache(e){const t=typeof e=="number"?e:this.namesToKeys.get(e);if(t!=null)return this.cache.get(t)}}const Xr=r=>{let e=Ne(r).filter(n=>n!==0),t="keys";return typeof e[0]=="string"&&(isNaN(parseInt(e[0]))?t="names":e=e.map(n=>parseInt(n))),{single:!Array.isArray(r),variant:t,normalized:e,actual:r}};class fh{constructor(e,t){h(this,"mu",new Um);h(this,"requests",new Map);h(this,"wrapped");h(this,"debouncedRun");this.wrapped=e,this.debouncedRun=om(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t,variant:n}=Xr(e);return n==="names"?await this.wrapped.retrieve(t):await new Promise((a,i)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:a,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,n)=>n.forEach(s=>e.add(s)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,s)=>n.resolve(t.filter(a=>s.includes(a.key))))}catch(t){this.requests.forEach(n=>n.reject(t))}finally{this.requests.clear()}})}}const mh=async(r,e)=>{const{normalized:t}=Xr(e),n=await r.retrieve(t),s=[];if(t.forEach(a=>{n.find(i=>i.name===a||i.key===a)==null&&s.push(a)}),s.length>0)throw new qt(`Could not find channels: ${JSON.stringify(s)}`);return n};class Ic{constructor({dataType:e,rate:t,name:n,leaseholder:s=0,key:a=0,isIndex:i=!1,index:o=0,frameClient:c,alias:l}){h(this,"_frameClient");h(this,"key");h(this,"name");h(this,"rate");h(this,"dataType");h(this,"leaseholder");h(this,"index");h(this,"isIndex");h(this,"alias");this.key=a,this.name=n,this.rate=new Ni(t??0),this.dataType=new ze(e),this.leaseholder=s,this.index=o,this.isIndex=i,this.alias=l,this._frameClient=c??null}get framer(){if(this._frameClient==null)throw new gt("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Qs.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex})}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(this.key,e,t)}}let yh=class{constructor(e,t,n,s){h(this,"frameClient");h(this,"retriever");h(this,"creator");h(this,"client");this.frameClient=e,this.retriever=t,this.client=n,this.creator=s}async create(e,t={}){const{retrieveIfNameExists:n=!1}=t,s=!Array.isArray(e);let a=Ne(e),i=[];if(n){const o=await this.retriever.retrieve(a.map(l=>l.name)),c=new Set(o.map(l=>l.name));a=a.filter(l=>!c.has(l.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.creator.create(a))),s?i[0]:i}async retrieve(e,t){const{single:n,actual:s,normalized:a}=Xr(e);if(a.length===0)return[];const i=this.sugar(await this.retriever.retrieve(e,t));if(!n)return i;if(i.length===0)throw new Sw(`channel matching ${s} not found`);if(i.length>1)throw new Nw(`multiple channels matching ${s} found`);return i[0]}async search(e,t){return this.sugar(await this.retriever.search(e,t))}newSearcherUnderRange(e){return new jw(this,e)}async page(e,t,n){return this.sugar(await this.retriever.page(e,t,n))}createDebouncedBatchRetriever(e=10){return new Ac(new fh(new Ys(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(n=>new Ic({...n,frameClient:t}))}};class jw{constructor(e,t){h(this,"client");h(this,"rangeKey");this.client=e,this.rangeKey=t}async search(e){return await this.client.search(e,this.rangeKey)}async page(e,t){return await this.client.page(e,t,this.rangeKey)}async retrieve(e){return await this.client.retrieve(e,this.rangeKey)}}const Rw=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:Ac,Channel:Ic,Client:yh,ClusterRetriever:Ys,Creator:Xa,DebouncedBatchRetriever:fh,analyzeParams:Xr,keyZ:Xs,newPayload:Ql,parseChannels:ed,payload:Qs,retrieveRequired:mh},Symbol.toStringTag,{value:"Module"})),zw=u.z.object({key:u.z.string(),username:u.z.string()}),Pw=r=>async(e,t)=>{try{const n=await r();e.params.Authorization=`Bearer ${n}`}catch(n){return[e,n]}return await t(e)},Mw=u.z.object({username:u.z.string(),password:u.z.string()}),Uw=u.z.object({token:u.z.string(),user:zw}),Dw="/auth/login";let Lw=class{constructor(e,t){h(this,"token");h(this,"client");h(this,"authenticating");h(this,"authenticated");h(this,"user");this.client=e,this.authenticated=!1,this.authenticate(t)}authenticate(e){this.authenticating=new Promise((t,n)=>{this.client.send(Dw,e,Mw,Uw).then(([s,a])=>{if(a!=null)return n(a);this.token=s==null?void 0:s.token,this.user=s==null?void 0:s.user,this.authenticated=!0,t()}).catch(n)})}middleware(){return Pw(async()=>{if(this.authenticated||await this.authenticating,this.token==null)throw new Ec("[auth] - attempting to authenticate without a token");return this.token})}};const Bw=["disconnected","connecting","connected","failed"],gh=u.z.enum(Bw),vh=u.z.object({status:gh,error:u.z.instanceof(Error).optional(),message:u.z.string().optional(),clusterKey:u.z.string()}),Vw=u.z.object({clusterKey:u.z.string()}),Uu={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},An=class An{constructor(e,t=Re.seconds(30),n){h(this,"_state");h(this,"pollFrequency",Re.seconds(30));h(this,"client");h(this,"name");h(this,"interval");h(this,"onChangeHandlers",[]);this._state={...Uu},this.client=e,this.pollFrequency=t,this.name=n,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var t;const e=this._state.status;try{const[n,s]=await this.client.send(An.ENDPOINT,{},u.z.object({}),Vw);if(s!=null)throw s;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(t=this.state.error)==null?void 0:t.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(n=>n(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};h(An,"ENDPOINT","/connectivity/check"),h(An,"DEFAULT",Uu),h(An,"connectionStateZ",vh);let Js=An;const qw=Object.freeze(Object.defineProperty({__proto__:null,Checker:Js,state:vh,status:gh},Symbol.toStringTag,{value:"Module"})),Cr=class Cr extends Number{};h(Cr,"Absolute",255),h(Cr,"Default",1),h(Cr,"z",u.z.union([u.z.instanceof(Cr),u.z.number().int().min(0).max(255).transform(e=>new Cr(e)),u.z.instanceof(Number).transform(e=>new Cr(e))]));let Gr=Cr;const Du=r=>{const e=Ne(r);return e.length===0?null:typeof e[0]=="number"?"key":"name"},Lu=(r,e)=>{const t=Ne(r);if(t.length===e.length)return;const n=Du(r);throw Du===null?new gt("[Frame] - channel keys or names must be provided when constructing a frame."):new gt(`[Frame] - ${n}s and arrays must be the same length.
19
- Got ${t.length} ${n}s and ${e.length} arrays.`)};class Je{constructor(e=[],t=[]){h(this,"columns",[]);h(this,"series",[]);if(e instanceof Je){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((s,a)=>this.push(a,...Ne(s)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const s=e,a=s.series.map(i=>bh(i));Lu(s.keys,a),s.keys.forEach((i,o)=>this.push(i,a[o]))}else Object.entries(e).forEach(([s,a])=>{const i=parseInt(s);if(isNaN(i))this.push(s,...Ne(a));else return this.push(i,...Ne(a))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const s=Ne(t),a=Ne(e);Lu(a,s),s.forEach((i,o)=>this.push(a[o],i));return}throw new gt(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
18
+ `)}}class qt extends Gr{}class Rw extends qt{}class zw extends qt{}class vh extends Gr{constructor(t,n){super(t);h(this,"path");this.path=n}}class Pw extends Gr{}const Mw=r=>{if(!r.type.startsWith(kr))return null;switch(r.type){case $r.General:return new yh(r.data);case $r.Parse:return new gh(r.data);case $r.Auth:return new Ec(r.data);case $r.Unexpected:return new vn(r.data);case $r.Validation:return new gt(r.data);case $r.Query:return new qt(r.data);case $r.Route:return new vh(r.data,r.data);default:return new vn(r.data)}},Uw=()=>{throw new Error("Not implemented")};dh({encode:Uw,decode:Mw});const Dw=async(r,e)=>{const[t,n]=await e(r);return n==null?[t,n]:n instanceof Fs?[t,new Fs({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,n]},Lw=u.z.object({leaseholder:u.z.number().optional(),keys:u.z.number().array().optional(),names:u.z.string().array().optional(),search:u.z.string().optional(),rangeKey:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional()}),Bw=u.z.object({channels:Hs.array()}),wi=class wi{constructor(e){h(this,"client");this.client=e}async search(e,t){return await this.execute({search:e,rangeKey:t})}async retrieve(e,t){const{variant:n,normalized:s}=Hr(e);return await this.execute({[n]:s,rangeKey:t})}async page(e,t,n){return await this.execute({offset:e,limit:t,rangeKey:n})}async execute(e){const[t,n]=await this.client.send(wi.ENDPOINT,e,Lw,Bw);if(n!=null)throw n;return t.channels}};h(wi,"ENDPOINT","/channel/retrieve");let Ws=wi;class Ac{constructor(e){h(this,"cache");h(this,"namesToKeys");h(this,"wrapped");this.cache=new Map,this.namesToKeys=new Map,this.wrapped=e}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t}=Hr(e),n=[],s=[];if(t.forEach(i=>{const o=this.getFromCache(i);o!=null?n.push(o):s.push(i)}),s.length===0)return n;const a=await this.wrapped.retrieve(s);return this.updateCache(a),n.concat(a)}updateCache(e){e.forEach(t=>{this.cache.set(t.key,t),this.namesToKeys.set(t.name,t.key)})}getFromCache(e){const t=typeof e=="number"?e:this.namesToKeys.get(e);if(t!=null)return this.cache.get(t)}}const Hr=r=>{let e=Se(r).filter(n=>n!==0),t="keys";return typeof e[0]=="string"&&(isNaN(parseInt(e[0]))?t="names":e=e.map(n=>parseInt(n))),{single:!Array.isArray(r),variant:t,normalized:e,actual:r}};class wh{constructor(e,t){h(this,"mu",new Ym);h(this,"requests",new Map);h(this,"wrapped");h(this,"debouncedRun");this.wrapped=e,this.debouncedRun=ym(()=>{this.run()},t)}async search(e,t){return await this.wrapped.search(e,t)}async page(e,t,n){return await this.wrapped.page(e,t,n)}async retrieve(e){const{normalized:t,variant:n}=Hr(e);return n==="names"?await this.wrapped.retrieve(t):await new Promise((a,i)=>{this.mu.runExclusive(()=>{this.requests.set(t,{resolve:a,reject:i}),this.debouncedRun()})})}async run(){await this.mu.runExclusive(async()=>{const e=new Set;this.requests.forEach((t,n)=>n.forEach(s=>e.add(s)));try{const t=await this.wrapped.retrieve(Array.from(e));this.requests.forEach((n,s)=>n.resolve(t.filter(a=>s.includes(a.key))))}catch(t){this.requests.forEach(n=>n.reject(t))}finally{this.requests.clear()}})}}const bh=async(r,e)=>{const{normalized:t}=Hr(e),n=await r.retrieve(t),s=[];if(t.forEach(a=>{n.find(i=>i.name===a||i.key===a)==null&&s.push(a)}),s.length>0)throw new qt(`Could not find channels: ${JSON.stringify(s)}`);return n};class Ic{constructor({dataType:e,rate:t,name:n,leaseholder:s=0,key:a=0,isIndex:i=!1,index:o=0,frameClient:c,alias:l}){h(this,"_frameClient");h(this,"key");h(this,"name");h(this,"rate");h(this,"dataType");h(this,"leaseholder");h(this,"index");h(this,"isIndex");h(this,"alias");this.key=a,this.name=n,this.rate=new xi(t??0),this.dataType=new Ee(e),this.leaseholder=s,this.index=o,this.isIndex=i,this.alias=l,this._frameClient=c??null}get framer(){if(this._frameClient==null)throw new gt("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Hs.parse({key:this.key,name:this.name,rate:this.rate.valueOf(),dataType:this.dataType.valueOf(),leaseholder:this.leaseholder,index:this.index,isIndex:this.isIndex})}async read(e){return await this.framer.read(e,this.key)}async write(e,t){return await this.framer.write(this.key,e,t)}}let _h=class{constructor(e,t,n,s){h(this,"frameClient");h(this,"retriever");h(this,"creator");h(this,"client");this.frameClient=e,this.retriever=t,this.client=n,this.creator=s}async create(e,t={}){const{retrieveIfNameExists:n=!1}=t,s=!Array.isArray(e);let a=Se(e),i=[];if(n){const o=await this.retriever.retrieve(a.map(l=>l.name)),c=new Set(o.map(l=>l.name));a=a.filter(l=>!c.has(l.name)),i=this.sugar(o)}return i=i.concat(this.sugar(await this.creator.create(a))),s?i[0]:i}async retrieve(e,t){const{single:n,actual:s,normalized:a}=Hr(e);if(a.length===0)return[];const i=this.sugar(await this.retriever.retrieve(e,t));if(!n)return i;if(i.length===0)throw new Rw(`channel matching ${s} not found`);if(i.length>1)throw new zw(`multiple channels matching ${s} found`);return i[0]}async search(e,t){return this.sugar(await this.retriever.search(e,t))}newSearcherUnderRange(e){return new Vw(this,e)}async page(e,t,n){return this.sugar(await this.retriever.page(e,t,n))}createDebouncedBatchRetriever(e=10){return new Ac(new wh(new Ws(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(n=>new Ic({...n,frameClient:t}))}};class Vw{constructor(e,t){h(this,"client");h(this,"rangeKey");this.client=e,this.rangeKey=t}async search(e){return await this.client.search(e,this.rangeKey)}async page(e,t){return await this.client.page(e,t,this.rangeKey)}async retrieve(e){return await this.client.retrieve(e,this.rangeKey)}}const qw=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:Ac,Channel:Ic,Client:_h,ClusterRetriever:Ws,Creator:Ga,DebouncedBatchRetriever:wh,analyzeParams:Hr,keyZ:Gs,newPayload:sd,parseChannels:ad,payload:Hs,retrieveRequired:bh},Symbol.toStringTag,{value:"Module"})),Kw=u.z.object({key:u.z.string(),username:u.z.string()}),Fw=r=>async(e,t)=>{try{const n=await r();e.params.Authorization=`Bearer ${n}`}catch(n){return[e,n]}return await t(e)},Ww=u.z.object({username:u.z.string(),password:u.z.string()}),Yw=u.z.object({token:u.z.string(),user:Kw}),Jw="/auth/login";let Gw=class{constructor(e,t){h(this,"token");h(this,"client");h(this,"authenticating");h(this,"authenticated");h(this,"user");this.client=e,this.authenticated=!1,this.authenticate(t)}authenticate(e){this.authenticating=new Promise((t,n)=>{this.client.send(Jw,e,Ww,Yw).then(([s,a])=>{if(a!=null)return n(a);this.token=s==null?void 0:s.token,this.user=s==null?void 0:s.user,this.authenticated=!0,t()}).catch(n)})}middleware(){return Fw(async()=>{if(this.authenticated||await this.authenticating,this.token==null)throw new Ec("[auth] - attempting to authenticate without a token");return this.token})}};const Hw=["disconnected","connecting","connected","failed"],kh=u.z.enum(Hw),Oh=u.z.object({status:kh,error:u.z.instanceof(Error).optional(),message:u.z.string().optional(),clusterKey:u.z.string()}),Xw=u.z.object({clusterKey:u.z.string()}),Uu={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},An=class An{constructor(e,t=ze.seconds(30),n){h(this,"_state");h(this,"pollFrequency",ze.seconds(30));h(this,"client");h(this,"name");h(this,"interval");h(this,"onChangeHandlers",[]);this._state={...Uu},this.client=e,this.pollFrequency=t,this.name=n,this.check(),this.startChecking()}stopChecking(){this.interval!=null&&clearInterval(this.interval)}async check(){var t;const e=this._state.status;try{const[n,s]=await this.client.send(An.ENDPOINT,{},u.z.object({}),Xw);if(s!=null)throw s;this._state.status="connected",this._state.message=`Connected to ${this.name??"cluster"}`,this._state.clusterKey=n.clusterKey}catch(n){this._state.status="failed",this._state.error=n,this._state.message=(t=this.state.error)==null?void 0:t.message}return this.onChangeHandlers.length>0&&e!==this._state.status&&this.onChangeHandlers.forEach(n=>n(this.state)),this.state}get state(){return{...this._state}}onChange(e){this.onChangeHandlers.push(e)}startChecking(){this.interval=setInterval(()=>{this.check()},this.pollFrequency.milliseconds)}};h(An,"ENDPOINT","/connectivity/check"),h(An,"DEFAULT",Uu),h(An,"connectionStateZ",Oh);let Ys=An;const Qw=Object.freeze(Object.defineProperty({__proto__:null,Checker:Ys,state:Oh,status:kh},Symbol.toStringTag,{value:"Module"})),Du=r=>{const e=Se(r);return e.length===0?null:typeof e[0]=="number"||!isNaN(parseInt(e[0]))?"key":"name"},Lu=(r,e)=>{const t=Se(r);if(t.length===e.length)return;const n=Du(r);throw Du===null?new gt("[Frame] - channel keys or names must be provided when constructing a frame."):new gt(`[Frame] - ${n}s and arrays must be the same length.
19
+ Got ${t.length} ${n}s and ${e.length} arrays.`)};class Je{constructor(e=[],t=[]){h(this,"columns",[]);h(this,"series",[]);if(e instanceof Je){this.columns=e.columns,this.series=e.series;return}if(e instanceof Map){e.forEach((s,a)=>this.push(a,...Se(s)));return}if(typeof e=="object"&&!Array.isArray(e)){if("keys"in e&&"series"in e){const s=e,a=s.series.map(i=>xh(i));Lu(s.keys,a),s.keys.forEach((i,o)=>this.push(i,a[o]))}else Object.entries(e).forEach(([s,a])=>{const i=parseInt(s);if(isNaN(i))this.push(s,...Se(a));else return this.push(i,...Se(a))});return}if(Array.isArray(e)||["string","number"].includes(typeof e)){const s=Se(t),a=Se(e);Lu(a,s),s.forEach((i,o)=>this.push(a[o],i));return}throw new gt(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
20
20
  payload, a list of lazy arrays, a lazy array, a map, or a record keyed by channel
21
- name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new wn("colType is not key");return this.columns??[]}get uniqueKeys(){return eu(this.keys)}get names(){if(this.colType==="key")throw new wn("colType is not name");return this.columns??[]}get uniqueNames(){return eu(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>_h(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return $t.ZERO;const n=Se.min(...this.series.map(a=>a.timeRange.start)),s=Se.max(...this.series.map(a=>a.timeRange.end));return new $t(n,s)}const t=this.get(e);return t==null?$t.ZERO:new $t(t[0].timeRange.start,t[t.length-1].timeRange.end)}latest(){return Object.fromEntries(this.columns.map((e,t)=>[e,this.series[t].at(-1)]).filter(([e,t])=>t!=null))}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):this.series.filter((t,n)=>this.columns[n]===e)}push(e,...t){if(e instanceof Je){if(this.colType!==null&&e.colType!==this.colType)throw new gt("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...t),typeof e=="string"&&this.colType==="key")throw new gt("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new gt("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new Je([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const t=new Je;return this.forEach((n,s,a)=>t.push(...e(n,s,a))),t}forEach(e){this.columns.forEach((t,n)=>{const s=this.series[n];e(t,s,n)})}filter(e){const t=new Je;return this.columns.forEach((n,s)=>{const a=this.series[s];e(n,a,s)&&t.push(n,a)}),t}get byteLength(){return new Ga(this.series.reduce((e,t)=>e.add(t.byteLength),Ga.ZERO))}get length(){return this.series.reduce((e,t)=>e+t.length,0)}}const wh=u.z.object({timeRange:$t.z.optional(),alignment:u.z.number().optional(),dataType:ze.z,data:u.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer)}),Ui=u.z.object({keys:u.z.union([u.z.null().transform(()=>[]),u.z.number().array().optional().default([])]),series:u.z.union([u.z.null().transform(()=>[]),wh.array().optional().default([])])}),bh=r=>{const{dataType:e,data:t,timeRange:n,alignment:s}=r;return new Zn({data:t,dataType:e,timeRange:n,glBufferUsage:"static",alignment:s})},_h=r=>({timeRange:r._timeRange,dataType:r.dataType,data:new Uint8Array(r.data.buffer),alignment:r.alignment});class Di{constructor(e){h(this,"adapter");h(this,"retriever");h(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new Di(e);return await n.update(t),n}async update(e){const{variant:t,normalized:n}=Xr(e);if(t==="keys"){this.adapter=null,this.keys=n;return}const s=await this.retriever.retrieve(n),a=new Map;this.adapter=a,n.forEach(i=>{const o=s.find(c=>c.name===i);if(o==null)throw new Error(`Channel ${i} not found`);a.set(o.key,o.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const t=this.adapter;return e.map((n,s)=>{if(typeof n=="number"){const a=t.get(n);if(a==null)throw new Error(`Channel ${n} not found`);return[a,s]}return[n,s]})}}class Zc{constructor(e){h(this,"adapter");h(this,"retriever");h(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new Zc(e);return await n.update(t),n}async update(e){const t=await mh(this.retriever,e);this.adapter=new Map(t.map(n=>[n.name,n.key])),this.keys=t.map(n=>n.key)}async fetchChannel(e){const t=await this.retriever.retrieve(e);if(t.length===0)throw new Error(`Channel ${e} not found`);return t[0]}async adapt(e,t){if(typeof e=="string"||typeof e=="number"){if(t==null)throw new gt(`
21
+ name. keys parameter must be a set of channel keys or channel names.`)}get colType(){return this.columns.length===0?null:typeof this.columns[0]=="string"?"name":"key"}get keys(){if(this.colType==="name")throw new vn("colType is not key");return this.columns??[]}get uniqueKeys(){return eu(this.keys)}get names(){if(this.colType==="key")throw new vn("colType is not name");return this.columns??[]}get uniqueNames(){return eu(this.names)}get uniqueColumns(){return this.colType==="key"?this.uniqueKeys:this.uniqueNames}toPayload(){return{series:this.series.map(e=>Sh(e)),keys:this.keys}}get isVertical(){return this.uniqueColumns.length===this.columns.length}get isHorizontal(){return this.uniqueColumns.length===1}get isSquare(){return this.isHorizontal&&this.isVertical}get isWeaklyAligned(){if(this.columns.length<=1)return!0;const e=this.timeRanges;return e.every(t=>t.equals(e[0]))}timeRange(e){if(e==null){if(this.columns.length===0)return Et.ZERO;const n=Ae.min(...this.series.map(a=>a.timeRange.start)),s=Ae.max(...this.series.map(a=>a.timeRange.end));return new Et(n,s)}const t=this.get(e);return t==null?Et.ZERO:t.timeRange}latest(){return this.at(-1)}get timeRanges(){return this.uniqueColumns.map(e=>this.timeRange(e))}get(e){return Array.isArray(e)?this.filter(t=>e.includes(t)):new Ul(this.series.filter((t,n)=>this.columns[n]===e))}push(e,...t){if(e instanceof Je){if(this.colType!==null&&e.colType!==this.colType)throw new gt("keyVariant must match");this.series.push(...e.series),this.columns.push(...e.columns)}else{if(this.series.push(...t),typeof e=="string"&&this.colType==="key")throw new gt("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new gt("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new Je([...this.columns,...e.columns],[...this.series,...e.series])}has(e){return typeof e=="string"&&this.colType==="key"||typeof e=="number"&&this.colType==="name"?!1:this.columns.includes(e)}map(e){const t=new Je;return this.forEach((n,s,a)=>t.push(...e(n,s,a))),t}forEach(e){this.columns.forEach((t,n)=>{const s=this.series[n];e(t,s,n)})}at(e,t=!1){const n={};return this.uniqueColumns.forEach(s=>{n[s]=this.get(s).at(e,t)}),n}filter(e){const t=new Je;return this.columns.forEach((n,s)=>{const a=this.series[s];e(n,a,s)&&t.push(n,a)}),t}get byteLength(){return new Ya(this.series.reduce((e,t)=>e.add(t.byteLength),Ya.ZERO))}get length(){return this.series.reduce((e,t)=>e+t.length,0)}}const Th=u.z.object({timeRange:Et.z.optional(),alignment:u.z.number().optional(),dataType:Ee.z,data:u.z.string().transform(r=>new Uint8Array(atob(r).split("").map(e=>e.charCodeAt(0))).buffer)}),Pi=u.z.object({keys:u.z.union([u.z.null().transform(()=>[]),u.z.number().array().optional().default([])]),series:u.z.union([u.z.null().transform(()=>[]),Th.array().optional().default([])])}),xh=r=>{const{dataType:e,data:t,timeRange:n,alignment:s}=r;return new Zn({data:t,dataType:e,timeRange:n,glBufferUsage:"static",alignment:s})},Sh=r=>({timeRange:r._timeRange,dataType:r.dataType,data:new Uint8Array(r.data.buffer),alignment:r.alignment});class Mi{constructor(e){h(this,"adapter");h(this,"retriever");h(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new Mi(e);return await n.update(t),n}async update(e){const{variant:t,normalized:n}=Hr(e);if(t==="keys"){this.adapter=null,this.keys=n;return}const s=await this.retriever.retrieve(n),a=new Map;this.adapter=a,n.forEach(i=>{const o=s.find(c=>c.name===i);if(o==null)throw new Error(`Channel ${i} not found`);a.set(o.key,o.name)}),this.keys=Array.from(this.adapter.keys())}adapt(e){if(this.adapter==null)return e;const t=this.adapter;return e.map((n,s)=>{if(typeof n=="number"){const a=t.get(n);if(a==null)throw new Error(`Channel ${n} not found`);return[a,s]}return[n,s]})}}class Zc{constructor(e){h(this,"adapter");h(this,"retriever");h(this,"keys");this.retriever=e,this.adapter=null,this.keys=[]}static async open(e,t){const n=new Zc(e);return await n.update(t),n}async update(e){const t=await bh(this.retriever,e);this.adapter=new Map(t.map(n=>[n.name,n.key])),this.keys=t.map(n=>n.key)}async fetchChannel(e){const t=await this.retriever.retrieve(e);if(t.length===0)throw new Error(`Channel ${e} not found`);return t[0]}async adapt(e,t){if(typeof e=="string"||typeof e=="number"){if(t==null)throw new gt(`
22
22
  Received a single channel name or key but no series.
23
23
  `);if(Array.isArray(t)){if(t.length>1)throw new gt(`
24
24
  Received a single channel name or key but multiple series.
@@ -30,8 +30,8 @@
30
30
  Received an array of channel names or keys but not enough series.
31
31
  `);const m=new Zn({data:t[c],dataType:l.dataType});i.push(l.key),o.push(m)}return new Je(i,o)}if(e instanceof Je||e instanceof Map){const i=new Je(e);if(this.adapter==null)return i;let o=[];return o=i.columns.map(c=>{var m;const l=typeof c=="string"?(m=this.adapter)==null?void 0:m.get(c):c;if(l==null)throw new gt(`
32
32
  Channel ${c} was not provided in the list of channels when opening the writer
33
- `);return l}),new Je(o,i.series)}const n=[],s=[],a=Object.entries(e);for(let i=0;i<a.length;i++){const[o,c]=a[i],l=await this.fetchChannel(o),m=new Zn({data:c,dataType:l.dataType});n.push(l.key),s.push(m)}return new Je(n,s)}}class $c{constructor(e,t){h(this,"name");h(this,"stream");this.stream=t,this.name=e}async receive(){const[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){this.stream.closeSend();const[e,t]=await this.stream.receive();if(e!=null)throw new wn(`${this.name} received unexpected response on closure.
34
- Please report this error to the Synnax team.`);if(t==null)throw new wn(`${this.name} received unexpected null error on closure.
33
+ `);return l}),new Je(o,i.series)}const n=[],s=[],a=Object.entries(e);for(let i=0;i<a.length;i++){const[o,c]=a[i],l=await this.fetchChannel(o),m=new Zn({data:c,dataType:l.dataType});n.push(l.key),s.push(m)}return new Je(n,s)}}class $c{constructor(e,t){h(this,"name");h(this,"stream");this.stream=t,this.name=e}async receive(){const[e,t]=await this.stream.receive();if(t!=null)throw t;return e}received(){return this.stream.received()}async closeAndAck(){this.stream.closeSend();const[e,t]=await this.stream.receive();if(e!=null)throw new vn(`${this.name} received unexpected response on closure.
34
+ Please report this error to the Synnax team.`);if(t==null)throw new vn(`${this.name} received unexpected null error on closure.
35
35
  Please report this error to Synnax team.
36
- `);if(!(t instanceof Fs))throw t}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Bo=new Re(-1);var Cc=(r=>(r[r.Open=0]="Open",r[r.Next=1]="Next",r[r.Prev=2]="Prev",r[r.SeekFirst=3]="SeekFirst",r[r.SeekLast=4]="SeekLast",r[r.SeekLE=5]="SeekLE",r[r.SeekGE=6]="SeekGE",r[r.Valid=7]="Valid",r[r.Error=8]="Error",r))(Cc||{}),kh=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(kh||{});const Kw=u.z.object({command:u.z.nativeEnum(Cc),span:Re.z.optional(),bounds:$t.z.optional(),stamp:Se.z.optional(),keys:u.z.number().array().optional()}),Fw=u.z.object({variant:u.z.nativeEnum(kh),ack:u.z.boolean(),command:u.z.nativeEnum(Cc),error:sa.optional().nullable(),frame:Ui.optional()}),as=class as{constructor(e,t){h(this,"stream");h(this,"adapter");h(this,"value");this.stream=new $c("Iterator",e),this.value=new Je,this.adapter=t}static async _open(e,t,n,s){const a=await Di.open(n,t),i=await s.stream(as.ENDPOINT,Kw,Fw),o=new as(i,a);return await o.execute({command:0,keys:a.keys,bounds:e}),o}async next(e=Bo){return await this.execute({command:1,span:new Re(e)})}async prev(e=Bo){return await this.execute({command:2,span:new Re(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new Se(e)})}async seekGE(e){return await this.execute({command:6,stamp:new Se(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new Ww(this)}async execute(e){for(this.stream.send(e),this.value=new Je;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new Je(t.frame)))}}};h(as,"ENDPOINT","/frame/iterate");let wi=as;class Ww{constructor(e){h(this,"iter");h(this,"open",!1);this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const Yw=u.z.object({start:Se.z.optional(),keys:u.z.number().array()}),Jw=u.z.object({frame:Ui,error:sa.optional().nullable()}),Gw="/frame/stream";class Li{constructor(e,t){h(this,"stream");h(this,"adapter");this.stream=new $c("Streamer",e),this.adapter=t}get keys(){return this.adapter.keys}static async _open(e,t,n,s){const a=await Di.open(n,t),i=await s.stream(Gw,Yw,Jw),o=new Li(i,a);return i.send({start:new Se(e),keys:a.keys}),o}async next(){try{return{done:!1,value:await this.read()}}catch{return{done:!0,value:void 0}}}async read(){return this.adapter.adapt(new Je((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}const jc=u.z.object({name:u.z.string(),key:u.z.string()}),Hw=u.z.object({subject:jc,resource:u.z.number(),authority:Gr.z}),Xw=(...r)=>e=>e.filter(t=>{let n=!1;return t.to!=null&&(n=r.includes(t.to.resource)),t.from!=null&&!n&&(n=r.includes(t.from.resource)),n}),Qw=r=>{var e,t;return r.to==null?`${(e=r.from)==null?void 0:e.resource} - ${(t=r.from)==null?void 0:t.subject.name} -> released`:r.from==null?`${r.to.resource} - released -> ${r.to.subject.name} (${r.to.authority.toString()})`:`${r.to.resource} - ${r.from.subject.name} -> ${r.to.subject.name} (${r.to.authority.toString()})`};class Rc{constructor(e){h(this,"states");h(this,"streamer");h(this,"ecd");h(this,"observer");h(this,"closePromise");this.states=new Map,this.ecd=new Xl.JSONEncoderDecoder,this.observer=new Ha.Observer,this.streamer=e,this.closePromise=this.stream()}subjects(){const e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}onChange(e){return this.observer.onChange(e)}async close(){this.streamer.close(),await this.closePromise}static async open(e){const t=await e.newStreamer("sy_node_1_control");return new Rc(t)}async stream(){for await(const e of this.streamer){const t=this.ecd.decode(e.series[0].buffer);this.merge(t),this.observer.notify(t.transfers)}}merge(e){e.transfers.forEach(t=>{t.from==null&&t.to==null&&console.warn("Invalid transfer: ",t),t.to==null?this.states.delete(t.from.resource):this.states.set(t.to.resource,t.to)})}}var zc=(r=>(r[r.Open=0]="Open",r[r.Write=1]="Write",r[r.Commit=2]="Commit",r[r.Error=3]="Error",r[r.SetAuthority=4]="SetAuthority",r[r.SetMode=5]="SetMode",r))(zc||{}),Gs=(r=>(r[r.PersistStream=1]="PersistStream",r[r.PersistOnly=2]="PersistOnly",r[r.StreamOnly=3]="StreamOnly",r))(Gs||{});const eb=u.z.object({start:Se.z.optional(),controlSubject:jc.optional(),keys:u.z.number().array().optional(),authorities:Gr.z.array().optional(),mode:u.z.nativeEnum(Gs).optional()}),tb=u.z.object({command:u.z.nativeEnum(zc),config:eb.optional(),frame:Ui.optional()}),rb=u.z.object({ack:u.z.boolean(),command:u.z.nativeEnum(zc),error:sa.optional().nullable()});var un;let Oh=(un=class{constructor(e,t){h(this,"stream");h(this,"adapter");this.stream=new $c("Writer",e),this.adapter=t}static async _open(e,t,{channels:n,authorities:s=Gr.Absolute,controlSubject:a,start:i,mode:o}){const c=await Zc.open(e,n),l=await t.stream(un.ENDPOINT,tb,rb),m=new un(l,c);return await m.execute({command:0,config:{start:new Se(i),keys:c.keys,controlSubject:a,authorities:Ne(s),mode:o}}),m}async write(e,t){const n=await this.adapter.adapt(e,t);return this.stream.send({command:1,frame:n.toPayload()}),!0}async setAuthority(e){return(await this.execute({command:4,config:{keys:Object.keys(e).map(n=>Number(n)),authorities:Object.values(e)}})).ack}async setMode(e){return(await this.execute({command:5,config:{mode:e}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const e=await this.execute({command:3});return e.error!=null?Nc(e.error):null}async close(){await this.stream.closeAndAck()}async execute(e){for(this.stream.send(e);;){const t=await this.stream.receive();if(t.command===e.command)return t;console.warn("writer received unexpected response",t)}}get errorAccumulated(){return this.stream.received()}},h(un,"ENDPOINT","/frame/write"),un),Th=class{constructor(e,t){h(this,"stream");h(this,"retriever");this.stream=e,this.retriever=t}async newIterator(e,t){return await wi._open(e,t,this.retriever,this.stream)}async newWriter({start:e,channels:t,controlSubject:n,authorities:s=Gr.Absolute,mode:a=Gs.PersistStream}){return await Oh._open(this.retriever,this.stream,{start:e??Se.now(),controlSubject:n,channels:t,authorities:s,mode:a})}async newStreamer(e,t=Se.now()){return await Li._open(t,e,this.retriever,this.stream)}async write(e,t,n){const s=await this.newWriter({start:t,channels:e,mode:Gs.PersistOnly});try{await s.write(e,n),await s.commit()}finally{await s.close()}}async read(e,t){const{single:n}=Xr(t),s=await this.readFrame(e,t);return n?s.series[0]:s}async readFrame(e,t){const n=await this.newIterator(e,t),s=new Je;try{for await(const a of n)s.push(a)}finally{await n.close()}return s}};const nb=Object.freeze(Object.defineProperty({__proto__:null,AUTO_SPAN:Bo,Client:Th,Frame:Je,Iterator:wi,Streamer:Li,Writer:Oh,WriterMode:Gs,frameZ:Ui,series:wh,seriesFromPayload:bh,seriesToPayload:_h},Symbol.toStringTag,{value:"Module"}));let xh=class{constructor(e,t,n){h(this,"tasks");h(this,"racks");h(this,"devices");this.tasks=e,this.racks=t,this.devices=n}};const sb=Object.freeze(Object.defineProperty({__proto__:null,Client:xh},Symbol.toStringTag,{value:"Module"})),aa=u.z.number(),Pc=u.z.object({key:aa,name:u.z.string()}),ab=Pc.partial({key:!0}),Mc=u.z.string(),Bi=u.z.object({key:Mc,rack:aa,name:u.z.string(),make:u.z.string(),model:u.z.string(),location:u.z.string(),properties:u.z.string()});class ia{constructor(e,t,n,s){h(this,"streamer");h(this,"decoder");h(this,"base");h(this,"closePromise");h(this,"deleteChannel");h(this,"setChannel");this.streamer=e,this.decoder=t,this.base=new Ha.Observer,this.closePromise=this.stream(),this.deleteChannel=s,this.setChannel=n}onChange(e){return this.base.onChange(e)}async close(){return this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer){const t=[];if(this.deleteChannel!=null){const n=e.get(this.deleteChannel);t.push(...n.flatMap(s=>this.decoder("delete",s)))}if(this.setChannel!=null){const n=e.get(this.setChannel);t.push(...n.flatMap(s=>this.decoder("set",s)))}this.base.notify(t)}}static async open(e,t,n,s){const a=await e.newStreamer([t,n]);return new ia(a,s,t,n)}}const ib="sy_device_set",ob="sy_device_delete";let Sh=class{constructor(e,t,n){h(this,"retriever");h(this,"writer");h(this,"frameClient");this.retriever=e,this.writer=t,this.frameClient=n}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t=await this.retriever.retrieve(Ne(e));return Array.isArray(e)?t:t[0]}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async delete(e){await this.writer.delete(e)}async openDeviceTracker(){return await ia.open(this.frameClient,ib,ob,cb)}};const cb=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(Bi).map(t=>({variant:r,key:t.key,value:t})),no="/hardware/device/retrieve",so=u.z.object({search:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional(),keys:Mc.array().optional()}),ao=u.z.object({devices:Bi.array()});let Nh=class{constructor(e){h(this,"client");this.client=e}async search(e){return(await G(this.client,no,{keys:[e]},so,ao)).devices}async page(e,t){return(await G(this.client,no,{offset:e,limit:t},so,ao)).devices}async retrieve(e){return(await G(this.client,no,{keys:e},so,ao)).devices}};const ub="/hardware/device/create",lb="/hardware/device/delete",db=u.z.object({devices:Bi.array()}),hb=u.z.object({devices:Bi.array()}),pb=u.z.object({keys:Mc.array()}),fb=u.z.object({});let Eh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await G(this.client,ub,{devices:e},db,hb)).devices}async delete(e){await G(this.client,lb,{keys:e},pb,fb)}};const mb=Object.freeze(Object.defineProperty({__proto__:null,Client:Sh,Retriever:Nh,Writer:Eh},Symbol.toStringTag,{value:"Module"}));let Ah=class{constructor(e,t,n,s,a){h(this,"retriever");h(this,"writer");h(this,"frameClient");h(this,"taskWriter");h(this,"taskRetriever");this.retriever=e,this.writer=t,this.frameClient=n,this.taskWriter=s,this.taskRetriever=a}async create(e){const t=await this.writer.create([e]);return this.sugar(t)[0]}async search(e){const t=await this.retriever.search(e);return this.sugar(t)}async page(e,t){const n=await this.retriever.page(e,t);return this.sugar(n)}async retrieve(e){const t=await this.retriever.retrieve(Ne(e));return Array.isArray(e)?this.sugar(t):this.sugar(t)[0]}sugar(e){return e.map(t=>new Ih(t.key,t.name,this.taskWriter,this.taskRetriever))}};class Ih{constructor(e,t,n,s){h(this,"key");h(this,"name");h(this,"writer");h(this,"tasks");this.key=e,this.name=t,this.writer=n,this.tasks=s}async listTasks(){return await this.tasks.retrieve({rack:this.key})}async retrieveTasks(){return[]}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),(await this.writer.create([e]))[0]}async deleteTask(e){await this.writer.delete([e])}}const yb="/hardware/rack/create",gb="/hardware/rack/delete",vb=u.z.object({racks:ab.array()}),wb=u.z.object({racks:Pc.array()}),bb=u.z.object({keys:aa.array()}),_b=u.z.object({});let Zh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await G(this.client,yb,{racks:e},vb,wb)).racks}async delete(e){await G(this.client,gb,{keys:e},bb,_b)}};const io="/hardware/rack/retrieve",oo=u.z.object({keys:aa.array().optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),co=u.z.object({racks:Pc.array()});let $h=class{constructor(e){h(this,"client");this.client=e}async page(e,t){return(await G(this.client,io,{offset:e,limit:t},oo,co)).racks}async search(e){return(await G(this.client,io,{search:e},oo,co)).racks}async retrieve(e){return(await G(this.client,io,{keys:e},oo,co)).racks}};const kb=Object.freeze(Object.defineProperty({__proto__:null,Client:Ah,Rack:Ih,Retriever:$h,Writer:Zh},Symbol.toStringTag,{value:"Module"}));let Ch=class{constructor(e,t){h(this,"retriever");h(this,"writer");this.retriever=e,this.writer=t}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t={};let n=!0;typeof e=="number"?t.rack=e:typeof e=="string"?(n=!1,t.keys=[e]):t.keys=Ne(e);const s=await this.retriever.retrieve(t);return n?s:s[0]}};const Uc=u.z.union([u.z.string(),u.z.bigint().transform(r=>r.toString()),u.z.number().transform(r=>r.toString())]),Dc=u.z.object({key:Uc,name:u.z.string(),type:u.z.string(),config:u.z.record(u.z.unknown()).or(u.z.string().transform(r=>JSON.parse(r)))}),Ob=Dc.omit({key:!0}).extend({key:Uc.transform(r=>r.toString()).optional(),config:u.z.unknown().transform(r=>JSON.stringify(r))}),uo=u.z.object({rack:aa.optional(),keys:u.z.string().array().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),lo=u.z.object({tasks:u.z.union([Dc.array(),u.z.null().transform(()=>[])])}),ho="/hardware/task/retrieve";let jh=class{constructor(e){h(this,"client");this.client=e}async retrieve(e){return(await G(this.client,ho,e,uo,lo)).tasks}async search(e){return(await G(this.client,ho,{keys:[e]},uo,lo)).tasks}async page(e,t){return(await G(this.client,ho,{offset:e,limit:t},uo,lo)).tasks}};const Tb="/hardware/task/create",xb="/hardware/task/delete",Sb=u.z.object({tasks:Ob.array()}),Nb=u.z.object({tasks:Dc.array()}),Eb=u.z.object({keys:Uc.array()}),Ab=u.z.object({});let Rh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await G(this.client,Tb,{tasks:e},Sb,Nb)).tasks}async delete(e){await G(this.client,xb,{keys:e},Eb,Ab)}};const Ib=Object.freeze(Object.defineProperty({__proto__:null,Client:Ch,Retriever:jh,Writer:Rh},Symbol.toStringTag,{value:"Module"}));class Zb{constructor(e,t){h(this,"key");h(this,"name");this.key=t,this.name=e}get ontologyID(){return new st({type:"group",key:this.key})}}const $b=u.z.string().uuid(),Cb=u.z.object({key:$b,name:u.z.string()}),zh=u.z.union([u.z.literal("label"),u.z.literal("builtin"),u.z.literal("cluster"),u.z.literal("channel"),u.z.literal("node"),u.z.literal("group"),u.z.literal("range"),u.z.literal("range-alias"),u.z.literal("user"),u.z.literal("workspace"),u.z.literal("pid"),u.z.literal("lineplot"),u.z.literal("rack")]),Dt=u.z.object({type:zh,key:u.z.string()}),Ph=u.z.string().transform(r=>{const[e,t]=r.split(":");return{type:e,key:t}}),Mh=u.z.union([Ph,Dt]),In=class In{constructor(e){h(this,"type");h(this,"key");if(e instanceof In)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[t,n]=e.split(":");this.type=t,this.key=n}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};h(In,"z",u.z.union([Mh,u.z.instanceof(In)]).transform(e=>new In(e)));let st=In;const jb=new st({type:"builtin",key:"root"}),Uh=u.z.object({type:u.z.number()}),Dh=u.z.object({type:zh,fields:u.z.record(Uh)}),Lh=u.z.object({id:st.z,name:u.z.string(),schema:Dh.optional(),data:u.z.record(u.z.unknown()).optional()}).transform(r=>({key:r.id.toString(),...r})),Rb=u.z.object({from:st.z,type:u.z.string(),to:st.z}),Vo=r=>{const[e,t,n]=r.split("->");return{from:new st(e),type:t,to:new st(n)}},zb=u.z.object({group:Cb}),Pb=u.z.object({parent:Dt,name:u.z.string()}),Mb=u.z.object({key:u.z.string(),name:u.z.string()}),Ub=u.z.object({keys:u.z.array(u.z.string())});var Gt;let Db=(Gt=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const[n,s]=await this.client.send(Gt.ENDPOINT,{parent:e,name:t},Pb,zb);if(s!=null)throw s;return n.group}async rename(e,t){const n={key:e,name:t},[,s]=await this.client.send(Gt.ENDPOINT_RENAME,n,Mb,u.z.object({}));if(s!=null)throw s}async delete(e){const t={keys:e},[,n]=await this.client.send(Gt.ENDPOINT_DELETE,t,Ub,u.z.object({}));if(n!=null)throw n}},h(Gt,"ENDPOINT","/ontology/create-group"),h(Gt,"ENDPOINT_RENAME","/ontology/rename-group"),h(Gt,"ENDPOINT_DELETE","/ontology/delete-group"),Gt),Lb=class{constructor(e){h(this,"creator");this.creator=new Db(e)}async create(e,t){return this.sugar(await this.creator.create(e,t))}async rename(e,t){return await this.creator.rename(e,t)}async delete(...e){return await this.creator.delete(e)}sugar(e){return new Zb(e.name,e.key)}};const Bb=u.z.object({ids:Dt.array().optional(),children:u.z.boolean().optional(),parents:u.z.boolean().optional(),includeSchema:u.z.boolean().optional(),includeFieldData:u.z.boolean().optional(),term:u.z.string().optional()}),Vb=u.z.object({resources:Lh.array()});var jn;let qb=(jn=class{constructor(e){h(this,"client");this.client=e}async search(e){return await this.execute({term:e})}async retrieve(e,t=!0,n=!0){return await this.execute({ids:Ne(e).map(s=>new st(s).payload),includeFieldData:n,includeSchema:t})}async retrieveChildren(e,t=!0,n=!0){return await this.execute({ids:Ne(e).map(s=>new st(s).payload),children:!0,includeSchema:t,includeFieldData:n})}async retrieveParents(e,t=!0,n=!0){return await this.execute({ids:Ne(e).map(s=>new st(s).payload),parents:!0,includeSchema:t,includeFieldData:n})}async execute(e){return(await G(this.client,jn.ENDPOINT,e,Bb,Vb)).resources}},h(jn,"ENDPOINT","/ontology/retrieve"),jn);const po={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},Bu=u.z.object({id:Dt,children:Dt.array()}),Kb=u.z.object({from:Dt,to:Dt,children:Dt.array()});let Fb=class{constructor(e){h(this,"client");this.client=e}async addChildren(e,...t){await G(this.client,po.ADD_CHILDREN,{id:e,children:t},Bu,u.z.object({}))}async removeChildren(e,...t){await G(this.client,po.REMOVE_CHILDREN,{id:e,children:t},Bu,u.z.object({}))}async moveChildren(e,t,...n){const s={from:e,to:t,children:n};await G(this.client,po.MOVE_CHILDREN,s,Kb,u.z.object({}))}};const Vu="sy_ontology_resource_set",qu="sy_ontology_resource_delete",Ku="sy_ontology_relationship_set",Fu="sy_ontology_relationship_delete";class Vi{constructor(e,t){h(this,"resourceObs");h(this,"relationshipObs");h(this,"relationships");h(this,"resources");h(this,"streamer");h(this,"retriever");h(this,"closePromise");this.relationshipObs=new Ha.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Ha.Observer,this.resources=this.resourceObs,this.retriever=t,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const t=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);t.concat(n).length>0&&this.resourceObs.notify(t.concat(n));const a=this.parseRelationshipSets(e),i=this.parseRelationshipDeletes(e);a.concat(i).length>0&&this.relationshipObs.notify(a.concat(i))}parseRelationshipSets(e){const t=e.get(Ku);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"set",key:Vo(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(Fu);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"delete",key:Vo(n)}))}async parseResourceSets(e){const t=e.get(Vu);if(t.length===0)return[];const n=t[0].toStrings().map(s=>new st(s));try{return(await this.retriever.retrieve(n)).map(a=>({variant:"set",key:a.id,value:a}))}catch(s){if(s instanceof qt)return console.warn(s),[];throw s}}parseResourceDeletes(e){const t=e.get(qu);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"delete",key:new st(n)}))}static async open(e,t){const n=await e.newStreamer([Vu,qu,Ku,Fu]);return new Vi(n,t)}}let Bh=class{constructor(e,t){h(this,"groups");h(this,"retriever");h(this,"writer");h(this,"framer");this.retriever=new qb(e),this.writer=new Fb(e),this.groups=new Lb(e),this.framer=t}async search(e){return await this.retriever.search(e)}async retrieve(e,t,n){const s=await this.retriever.retrieve(e,t,n);if(Array.isArray(e))return s;if(s.length===0)throw new qt(`No resource found with ID ${e.toString()}`);return s[0]}async page(e,t){return[]}async retrieveChildren(e,t,n){return await this.retriever.retrieveChildren(e,t,n)}async retrieveParents(e,t,n){return await this.retriever.retrieveParents(e,t,n)}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...n){return await this.writer.moveChildren(e,t,...n)}async openChangeTracker(){return await Vi.open(this.framer,this.retriever)}};const Wb=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:Vi,Client:Bh,ID:st,Root:jb,crudeIDZ:Mh,idZ:Dt,parseRelationship:Vo,relationshipSchemaZ:Rb,resourceSchemaZ:Lh,schemaFieldZ:Uh,schemaZ:Dh,stringIDZ:Ph},Symbol.toStringTag,{value:"Module"})),Kn=u.z.string().uuid(),oa=u.z.object({key:Kn,name:u.z.string().min(1),color:u.z.string()}),Yb=r=>new st({type:"label",key:r}),Jb=u.z.object({keys:Kn.array().optional(),for:Dt.optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),Gb=u.z.object({labels:oa.array().optional().default([])});var Rn;let Vh=(Rn=class{constructor(e){h(this,"client");this.client=e}async retrieve(e){const t=Ne(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,n]=await this.client.send(Rn.ENDPOINT,e,Jb,Gb);if(n!=null)throw n;return t.labels}},h(Rn,"ENDPOINT","/label/retrieve"),Rn);const qh=oa.extend({key:Kn.optional()}),Hb=u.z.object({labels:qh.array()}),Xb=u.z.object({labels:oa.array()}),Qb=u.z.object({keys:Kn.array()}),Kh=u.z.object({id:Dt,labels:Kn.array()}),e_=Kh,fo=u.z.object({}),t_="/label/create",r_="/label/delete",n_="/label/set",s_="/label/remove";let Fh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await G(this.client,t_,{labels:Ne(e)},Hb,Xb)).labels}async delete(e){await G(this.client,r_,{keys:Ne(e)},Qb,fo)}async set(e,t){await G(this.client,n_,{id:e,labels:t},Kh,fo)}async remove(e,t){await G(this.client,s_,{id:e,labels:t},e_,fo)}};const a_="sy_label_set",i_="sy_label_delete";let Wh=class{constructor(e,t){h(this,"retriever");h(this,"writer");h(this,"frameClient");this.writer=new Fh(e),this.retriever=new Vh(e),this.frameClient=t}async search(e){return await this.retriever.search(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async retrieveFor(e){return await this.retriever.retrieveFor(e)}async label(e,t){await this.writer.set(e,t)}async removeLabels(e,t){await this.writer.remove(e,t)}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async openChangeTracker(){return await ia.open(this.frameClient,a_,i_,o_)}};const o_=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON(oa).map(t=>({variant:r,key:t.key,value:t})),c_=Object.freeze(Object.defineProperty({__proto__:null,Client:Wh,Retriever:Vh,Writer:Fh,keyZ:Kn,labelZ:oa,newLabelPayloadZ:qh,ontologyID:Yb},Symbol.toStringTag,{value:"Module"})),dt=u.z.string().uuid(),ca=u.z.object({key:dt,name:u.z.string().min(1),timeRange:$t.z}),Yh=ca.extend({key:u.z.string().uuid().optional()}),Lc=r=>{const e=Ne(r);if(e.length===0)throw new Error("Range params must not be empty");const t=dt.safeParse(e[0]).success;return{single:!Array.isArray(r),variant:t?"keys":"names",normalized:e,actual:r}},u_=u.z.object({}),l_=u.z.object({range:ca}),d_=u.z.object({range:dt}),h_=u.z.object({range:dt}),p_=u.z.object({}),f_="/range/set-active",m_="/range/retrieve-active",y_="/range/clear-active";class g_{constructor(e){h(this,"client");this.client=e}async setActive(e){await G(this.client,f_,{range:e},d_,u_)}async retrieveActive(){const[e,t]=await this.client.send(m_,{},u.z.object({}),l_);if(t instanceof qt)return null;if(t!=null)throw t;return e.range}async clearActive(e){await G(this.client,y_,{range:e},h_,p_)}}const v_="sy_range_alias_set",w_="sy_range_alias_delete",b_=u.z.object({range:dt,aliases:u.z.string().array()}),__=u.z.object({aliases:u.z.record(u.z.string(),Xs)}),k_=u.z.object({range:dt,aliases:u.z.record(Xs.or(u.z.string()),u.z.string())}),O_=u.z.unknown(),T_=u.z.object({range:dt,channels:Xs.array()}),x_=u.z.unknown(),S_=u.z.object({range:dt}),N_=u.z.object({aliases:u.z.record(u.z.string(),u.z.string())}),Wt=class Wt{constructor(e,t,n){h(this,"frameClient");h(this,"cache",new Map);h(this,"client");h(this,"rangeKey");this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=t}async resolve(e){const t=[],n=typeof e=="string",s={};if(n){const i=this.cache.get(e);if(i!=null)return i;t.push(e)}else e.forEach(i=>{const o=this.cache.get(i);o!=null?s[i]=o:t.push(i)});if(t.length===0)return s;const a=await G(this.client,Wt.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},b_,__);return Object.entries(a.aliases).forEach(([i,o])=>this.cache.set(i,o)),n?a.aliases[t[0]]:{...s,...a.aliases}}async set(e){await G(this.client,Wt.SET_ENDPOINT,{range:this.rangeKey,aliases:e},k_,O_)}async list(){return(await G(this.client,Wt.LIST_ENDPOINT,{range:this.rangeKey},S_,N_)).aliases}async delete(e){await G(this.client,Wt.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},T_,x_)}async openChangeTracker(){return await ia.open(this.frameClient,v_,w_,I_(this.rangeKey))}};h(Wt,"SET_ENDPOINT","/range/alias/set"),h(Wt,"RESOLVE_ENDPOINT","/range/alias/resolve"),h(Wt,"LIST_ENDPOINT","/range/alias/list"),h(Wt,"DELETE_ENDPOINT","/range/alias/delete");let qo=Wt;const E_=u.z.object({range:dt,channel:Xs,alias:u.z.string()}),A_="---",I_=r=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(A_)[0]===r).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(E_).map(n=>({variant:e,key:n.alias,value:n})),Z_=u.z.object({range:dt,keys:u.z.string().array()}),$_=u.z.object({pairs:u.z.record(u.z.string(),u.z.string())}),C_=u.z.object({range:dt,pairs:u.z.record(u.z.string(),u.z.string())}),j_=u.z.object({range:dt,keys:u.z.string().array()}),jr=class jr{constructor(e,t){h(this,"rangeKey");h(this,"client");this.rangeKey=e,this.client=t}async get(e){const[t,n]=await this.client.send(jr.GET_ENDPOINT,{range:this.rangeKey,keys:Ne(e)},Z_,$_);if(n!=null)throw n;return Array.isArray(e)?t.pairs:t.pairs[e]}async set(e,t=""){await G(this.client,jr.SET_ENDPOINT,{range:this.rangeKey,pairs:zl(e)?e:{[e]:t}},C_,u.z.unknown())}async delete(e){await G(this.client,jr.DELETE_ENDPOINT,{range:this.rangeKey,keys:Ne(e)},j_,u.z.unknown())}};h(jr,"GET_ENDPOINT","/range/kv/get"),h(jr,"SET_ENDPOINT","/range/kv/set"),h(jr,"DELETE_ENDPOINT","/range/kv/delete");let Ko=jr;const mo=r=>new st({type:"range",key:r});class Jh{constructor(e,t=$t.ZERO,n,s,a,i,o,c){h(this,"key");h(this,"name");h(this,"kv");h(this,"timeRange");h(this,"channels");h(this,"aliaser");h(this,"frameClient");h(this,"labelClient");this.key=n,this.name=e,this.timeRange=t,this.frameClient=s,this.kv=a,this.aliaser=i,this.channels=o,this.labelClient=c}async setAlias(e,t){const n=await this.channels.retrieve(e);if(n.length===0)throw new qt(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(mo(this.key))}async addLabel(...e){await this.labelClient.label(mo(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(mo(this.key),e)}}let Gh=class{constructor(e,t,n,s,a,i){h(this,"frameClient");h(this,"retriever");h(this,"writer");h(this,"unaryClient");h(this,"channels");h(this,"active");h(this,"labelClient");this.frameClient=e,this.retriever=t,this.writer=n,this.unaryClient=s,this.channels=a,this.active=new g_(s),this.labelClient=i}async create(e){const t=!Array.isArray(e),n=this.sugar(await this.writer.create(Ne(e)));return t?n[0]:n}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(Ne(e))}async search(e){return this.sugar(await this.retriever.search(e))}async page(e,t){return[]}async retrieve(e){const{single:t,actual:n}=Lc(e),s=this.sugar(await this.retriever.retrieve(e));if(!t)return s;if(s.length===0)throw new qt(`range matching ${n} not found`);if(s.length>1)throw new qt(`multiple ranges matching ${n} found`);return s[0]}async setActive(e){await this.active.setActive(e)}async retrieveActive(){const e=await this.active.retrieveActive();return e==null?null:this.sugar([e])[0]}async clearActive(e){await this.active.clearActive(e)}sugar(e){return e.map(t=>new Jh(t.name,t.timeRange,t.key,this.frameClient,new Ko(t.key,this.unaryClient),new qo(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}};const R_=u.z.object({ranges:ca.array()}),z_=u.z.object({ranges:Yh.array()}),P_=u.z.object({keys:dt.array()}),M_=u.z.object({}),U_=u.z.object({key:dt,name:u.z.string()}),D_=u.z.object({}),L_="/range/create",B_="/range/delete",V_="/range/rename";let Hh=class{constructor(e){h(this,"client");this.client=e}async rename(e,t){await G(this.client,V_,{key:e,name:t},U_,D_)}async create(e){return(await G(this.client,L_,{ranges:e},z_,R_)).ranges}async delete(e){await G(this.client,B_,{keys:e},P_,M_)}};const q_=u.z.object({keys:dt.array().optional(),names:u.z.array(u.z.string()).optional(),term:u.z.string().optional()}),K_=u.z.object({ranges:u.z.array(ca)});let Xh=class{constructor(e){h(this,"ENDPOINT","/range/retrieve");h(this,"client");this.client=e}async retrieve(e){const{normalized:t,variant:n}=Lc(e);return await this.execute({[n]:t})}async search(e){return await this.execute({term:e})}async execute(e){const[t,n]=await this.client.send(this.ENDPOINT,e,q_,K_);if(n!=null)throw n;return t.ranges}};const F_=Object.freeze(Object.defineProperty({__proto__:null,Client:Gh,Range:Jh,Retriever:Xh,Writer:Hh,analyzeParams:Lc,keyZ:dt,newPayloadZ:Yh,payloadZ:ca},Symbol.toStringTag,{value:"Module"})),W_="/api/v1/";class Y_{constructor(e,t=!1){h(this,"url");h(this,"unary");h(this,"stream");h(this,"secure");this.secure=t,this.url=e.child(W_);const n=new Xl.JSONEncoderDecoder;this.unary=new yw(this.url,n,this.secure),this.stream=new xw(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Qr=u.z.string().uuid(),Bc=u.z.object({name:u.z.string(),key:Qr,layout:oc.or(u.z.string().transform(r=>JSON.parse(r)))}),Vc=Bc.omit({layout:!0}).extend({layout:u.z.string().transform(r=>JSON.parse(r))}),qc=u.z.string().uuid(),Kc=u.z.object({key:u.z.string(),name:u.z.string(),data:oc.or(u.z.string().transform(r=>JSON.parse(r)))}),J_=u.z.object({keys:u.z.string().array()}),G_=u.z.object({linePlots:Kc.array()});let H_=class{constructor(e){h(this,"ENDPOINT","/workspace/lineplot/retrieve");h(this,"client");this.client=e}async retrieve(e){const t=Ne(e);return(await G(this.client,this.ENDPOINT,{keys:t},J_,G_)).linePlots}};const X_=Kc.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),Q_=u.z.object({workspace:Qr,linePlots:X_.array()}),e1=u.z.object({linePlots:Kc.array()}),t1=u.z.object({keys:qc.array()}),r1=u.z.object({}),n1=u.z.object({key:qc,name:u.z.string()}),s1=u.z.object({}),a1=u.z.object({key:qc,data:u.z.string()}),i1=u.z.object({}),o1="/workspace/lineplot/create",c1="/workspace/lineplot/delete",u1="/workspace/lineplot/rename",l1="/workspace/lineplot/set-data";let d1=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await G(this.client,o1,{workspace:e,linePlots:[n]},Q_,e1)).linePlots[0]}async delete(e){const t=Ne(e);await G(this.client,c1,{keys:t},t1,r1)}async rename(e,t){await G(this.client,u1,{key:e,name:t},n1,s1)}async setData(e,t){await G(this.client,l1,{key:e,data:JSON.stringify(t)},a1,i1)}},h1=class{constructor(e){h(this,"writer");h(this,"retriever");this.writer=new d1(e),this.retriever=new H_(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}};const qi=u.z.string().uuid(),p1=u.z.object({key:u.z.string(),name:u.z.string(),data:oc.or(u.z.string().transform(r=>JSON.parse(r))),snapshot:u.z.boolean()}),Fc=u.z.object({key:u.z.string(),name:u.z.string(),snapshot:u.z.boolean(),data:u.z.string().transform(r=>JSON.parse(r))}),f1=u.z.object({keys:u.z.string().array()}),m1=u.z.object({pids:Fc.array()});let y1=class{constructor(e){h(this,"ENDPOINT","/workspace/pid/retrieve");h(this,"client");this.client=e}async retrieve(e){return(await G(this.client,this.ENDPOINT,{keys:Ne(e)},f1,m1)).pids}};const g1=p1.partial({key:!0,snapshot:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),v1=u.z.object({workspace:Qr,pids:g1.array()}),w1=u.z.object({pids:Fc.array()}),b1=u.z.object({keys:qi.array()}),_1=u.z.object({}),k1=u.z.object({key:qi,name:u.z.string()}),Wu=u.z.object({}),O1=u.z.object({key:qi,data:u.z.string()});u.z.object({});const T1=u.z.object({key:qi,name:u.z.string(),snapshot:u.z.boolean()}),x1=u.z.object({pid:Fc}),S1="/workspace/pid/create",N1="/workspace/pid/delete",E1="/workspace/pid/rename",A1="/workspace/pid/set-data",I1="/workspace/pid/copy";let Z1=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await G(this.client,S1,{workspace:e,pids:[n]},v1,w1)).pids[0]}async copy(e,t,n){return(await G(this.client,I1,{key:e,name:t,snapshot:n},T1,x1)).pid}async delete(e){const t=Ne(e);await G(this.client,N1,{keys:t},b1,_1)}async rename(e,t){await G(this.client,E1,{key:e,name:t},k1,Wu)}async setData(e,t){await G(this.client,A1,{key:e,data:JSON.stringify(t)},O1,Wu)}},$1=class{constructor(e){h(this,"writer");h(this,"retriever");this.writer=new Z1(e),this.retriever=new y1(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async copy(e,t,n){return await this.writer.copy(e,t,n)}};const C1=u.z.object({keys:Qr.array().optional(),search:u.z.string().optional(),author:u.z.string().uuid().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),j1=u.z.object({workspaces:Vc.array()}),ki=class ki{constructor(e){h(this,"client");this.client=e}async retrieve(e){const t=Ne(e);return await this.execute({keys:t})}async retrieveByAuthor(e){return await this.execute({author:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){return(await G(this.client,ki.ENDPOINT,e,C1,j1)).workspaces}};h(ki,"ENDPOINT","/workspace/retrieve");let Fo=ki;const R1=Bc.partial({key:!0}).transform(r=>({...r,layout:JSON.stringify(r.layout)})),z1=u.z.object({workspaces:R1.array()}),P1=u.z.object({workspaces:Vc.array()}),M1=u.z.object({keys:Qr.array()}),U1=u.z.object({}),D1=u.z.object({key:Qr,name:u.z.string()}),L1=u.z.object({}),B1=u.z.object({key:Qr,layout:u.z.string()}),V1=u.z.object({}),q1="/workspace/create",K1="/workspace/delete",F1="/workspace/rename",W1="/workspace/set-layout";class Y1{constructor(e){h(this,"client");this.client=e}async create(e){return(await G(this.client,q1,{workspaces:Ne(e)},z1,P1)).workspaces}async delete(e){await G(this.client,K1,{keys:Ne(e)},M1,U1)}async rename(e,t){await G(this.client,F1,{key:e,name:t},D1,L1)}async setLayout(e,t){await G(this.client,W1,{key:e,layout:JSON.stringify(t)},B1,V1)}}class Qh{constructor(e){h(this,"pid");h(this,"linePlot");h(this,"retriever");h(this,"writer");this.pid=new $1(e),this.linePlot=new h1(e),this.retriever=new Fo(e),this.writer=new Y1(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async rename(e,t){await this.writer.rename(e,t)}async setLayout(e,t){await this.writer.setLayout(e,t)}async delete(...e){await this.writer.delete(e)}}const J1=Object.freeze(Object.defineProperty({__proto__:null,Client:Qh,keyZ:Qr,workspaceRemoteZ:Vc,workspaceZ:Bc},Symbol.toStringTag,{value:"Module"})),ep=u.z.object({host:u.z.string().min(1),port:u.z.number().or(u.z.string()),username:u.z.string().optional(),password:u.z.string().optional(),connectivityPollFrequency:Re.z.default(Re.seconds(30)),secure:u.z.boolean().optional().default(!1),name:u.z.string().optional()});class tp{constructor(e){h(this,"createdAt");h(this,"props");h(this,"telem");h(this,"ranges");h(this,"channels");h(this,"auth");h(this,"connectivity");h(this,"ontology");h(this,"workspaces");h(this,"labels");h(this,"hardware");h(this,"transport");this.createdAt=Se.now(),this.props=ep.parse(e);const{host:t,port:n,username:s,password:a,connectivityPollFrequency:i,secure:o}=this.props;this.transport=new Y_(new lm({host:t,port:Number(n)}),o),this.transport.use(Zw),s!=null&&a!=null&&(this.auth=new Lw(this.transport.unary,{username:s,password:a}),this.transport.use(this.auth.middleware()));const c=new Ac(new Ys(this.transport.unary)),l=new Xa(this.transport.unary);this.telem=new Th(this.transport.stream,c),this.channels=new yh(this.telem,c,this.transport.unary,l),this.connectivity=new Js(this.transport.unary,i,e.name),this.ontology=new Bh(this.transport.unary,this.telem);const m=new Xh(this.transport.unary),T=new Hh(this.transport.unary);this.labels=new Wh(this.transport.unary,this.telem),this.ranges=new Gh(this.telem,m,T,this.transport.unary,c,this.labels),this.workspaces=new Qh(this.transport.unary);const J=new Sh(new Nh(this.transport.unary),new Eh(this.transport.unary),this.telem),ee=new jh(this.transport.unary),Ee=new Rh(this.transport.unary),te=new Ch(ee,Ee),rr=new Ah(new $h(this.transport.unary),new Zh(this.transport.unary),this.telem,Ee,ee);this.hardware=new xh(te,rr,J)}close(){this.connectivity.stopChecking()}}h(tp,"connectivity",Js);const G1=Object.freeze(Object.defineProperty({__proto__:null,Authority:Gr,StateTracker:Rc,filterTransfersByChannelKey:Xw,stateZ:Hw,subjectZ:jc,transferString:Qw},Symbol.toStringTag,{value:"Module"}));exports.AuthError=Ec;exports.Authority=Gr;exports.Channel=Ic;exports.ContiguityError=Ew;exports.DataType=ze;exports.Density=ot;exports.Frame=Je;exports.GeneralError=dh;exports.ParseError=hh;exports.QueryError=qt;exports.Rate=Ni;exports.RouteError=ph;exports.Series=Zn;exports.Synnax=tp;exports.TimeRange=$t;exports.TimeSpan=Re;exports.TimeStamp=Se;exports.UnexpectedError=wn;exports.ValidationError=gt;exports.channel=Rw;exports.connection=qw;exports.control=G1;exports.device=mb;exports.framer=nb;exports.hardware=sb;exports.label=c_;exports.ontology=Wb;exports.rack=kb;exports.ranger=F_;exports.synnaxPropsZ=ep;exports.task=Ib;exports.workspace=J1;
36
+ `);if(!(t instanceof Ks))throw t}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Bo=new ze(-1);var Cc=(r=>(r[r.Open=0]="Open",r[r.Next=1]="Next",r[r.Prev=2]="Prev",r[r.SeekFirst=3]="SeekFirst",r[r.SeekLast=4]="SeekLast",r[r.SeekLE=5]="SeekLE",r[r.SeekGE=6]="SeekGE",r[r.Valid=7]="Valid",r[r.Error=8]="Error",r))(Cc||{}),Nh=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(Nh||{});const eb=u.z.object({command:u.z.nativeEnum(Cc),span:ze.z.optional(),bounds:Et.z.optional(),stamp:Ae.z.optional(),keys:u.z.number().array().optional()}),tb=u.z.object({variant:u.z.nativeEnum(Nh),ack:u.z.boolean(),command:u.z.nativeEnum(Cc),error:ra.optional().nullable(),frame:Pi.optional()}),as=class as{constructor(e,t){h(this,"stream");h(this,"adapter");h(this,"value");this.stream=new $c("Iterator",e),this.value=new Je,this.adapter=t}static async _open(e,t,n,s){const a=await Mi.open(n,t),i=await s.stream(as.ENDPOINT,eb,tb),o=new as(i,a);return await o.execute({command:0,keys:a.keys,bounds:e}),o}async next(e=Bo){return await this.execute({command:1,span:new ze(e)})}async prev(e=Bo){return await this.execute({command:2,span:new ze(e)})}async seekFirst(){return await this.execute({command:3})}async seekLast(){return await this.execute({command:4})}async seekLE(e){return await this.execute({command:5,stamp:new Ae(e)})}async seekGE(e){return await this.execute({command:6,stamp:new Ae(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new rb(this)}async execute(e){for(this.stream.send(e),this.value=new Je;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new Je(t.frame)))}}};h(as,"ENDPOINT","/frame/iterate");let gi=as;class rb{constructor(e){h(this,"iter");h(this,"open",!1);this.iter=e}async next(){try{let e=!0;return this.open||(await this.iter.seekFirst()||(e=!1),this.open=!0),await this.iter.next()||(e=!1),e||await this.iter.close(),{done:!e,value:this.iter.value}}catch(e){throw await this.iter.close(),e}}}const nb=u.z.object({start:Ae.z.optional(),keys:u.z.number().array()}),sb=u.z.object({frame:Pi,error:ra.optional().nullable()}),ab="/frame/stream";class Ui{constructor(e,t){h(this,"stream");h(this,"adapter");this.stream=new $c("Streamer",e),this.adapter=t}get keys(){return this.adapter.keys}static async _open(e,t,{channels:n,from:s}){const a=await Mi.open(e,n),i=await t.stream(ab,nb,sb),o=new Ui(i,a);return i.send({start:new Ae(s),keys:a.keys}),o}async next(){try{return{done:!1,value:await this.read()}}catch{return{done:!0,value:void 0}}}async read(){return this.adapter.adapt(new Je((await this.stream.receive()).frame))}async update(e){await this.adapter.update(e),this.stream.send({keys:this.adapter.keys})}close(){this.stream.closeSend()}[Symbol.asyncIterator](){return this}}const Cr=class Cr extends Number{};h(Cr,"Absolute",255),h(Cr,"Default",1),h(Cr,"z",u.z.union([u.z.instanceof(Cr),u.z.number().int().min(0).max(255).transform(e=>new Cr(e)),u.z.instanceof(Number).transform(e=>new Cr(e))]));let wn=Cr;const jc=u.z.object({name:u.z.string(),key:u.z.string()}),ib=u.z.object({subject:jc,resource:u.z.number(),authority:wn.z}),ob=(...r)=>e=>e.filter(t=>{let n=!1;return t.to!=null&&(n=r.includes(t.to.resource)),t.from!=null&&!n&&(n=r.includes(t.from.resource)),n}),cb=r=>{var e,t;return r.to==null?`${(e=r.from)==null?void 0:e.resource} - ${(t=r.from)==null?void 0:t.subject.name} -> released`:r.from==null?`${r.to.resource} - released -> ${r.to.subject.name} (${r.to.authority.toString()})`:`${r.to.resource} - ${r.from.subject.name} -> ${r.to.subject.name} (${r.to.authority.toString()})`};class Rc{constructor(e){h(this,"states");h(this,"streamer");h(this,"ecd");h(this,"observer");h(this,"closePromise");this.states=new Map,this.ecd=new nd.JSONEncoderDecoder,this.observer=new Ja.Observer,this.streamer=e,this.closePromise=this.stream()}subjects(){const e=new Map;return this.states.forEach(t=>e.set(t.subject.key,t.subject)),Array.from(e.values())}onChange(e){return this.observer.onChange(e)}async close(){this.streamer.close(),await this.closePromise}static async open(e){const t=await e.openStreamer("sy_node_1_control");return new Rc(t)}async stream(){for await(const e of this.streamer){const t=this.ecd.decode(e.series[0].buffer);this.merge(t),this.observer.notify(t.transfers)}}merge(e){e.transfers.forEach(t=>{t.from==null&&t.to==null&&console.warn("Invalid transfer: ",t),t.to==null?this.states.delete(t.from.resource):this.states.set(t.to.resource,t.to)})}}var zc=(r=>(r[r.Open=0]="Open",r[r.Write=1]="Write",r[r.Commit=2]="Commit",r[r.Error=3]="Error",r[r.SetAuthority=4]="SetAuthority",r[r.SetMode=5]="SetMode",r))(zc||{}),Di=(r=>(r[r.PersistStream=1]="PersistStream",r[r.PersistOnly=2]="PersistOnly",r[r.StreamOnly=3]="StreamOnly",r))(Di||{});const ub=u.z.object({start:Ae.z.optional(),controlSubject:jc.optional(),keys:u.z.number().array().optional(),authorities:wn.z.array().optional(),mode:u.z.nativeEnum(Di).optional()}),lb=u.z.object({command:u.z.nativeEnum(zc),config:ub.optional(),frame:Pi.optional()}),db=u.z.object({ack:u.z.boolean(),command:u.z.nativeEnum(zc),error:ra.optional().nullable()});var cn;let Eh=(cn=class{constructor(e,t){h(this,"stream");h(this,"adapter");this.stream=new $c("Writer",e),this.adapter=t}static async _open(e,t,{channels:n,start:s=Ae.now(),authorities:a=wn.Absolute,controlSubject:i,mode:o=1}){const c=await Zc.open(e,n),l=await t.stream(cn.ENDPOINT,lb,db),m=new cn(l,c);return await m.execute({command:0,config:{start:new Ae(s),keys:c.keys,controlSubject:i,authorities:Se(a),mode:o}}),m}async write(e,t){const n=await this.adapter.adapt(e,t);return this.stream.send({command:1,frame:n.toPayload()}),!0}async setAuthority(e){return(await this.execute({command:4,config:{keys:Object.keys(e).map(n=>Number(n)),authorities:Object.values(e)}})).ack}async setMode(e){return(await this.execute({command:5,config:{mode:e}})).ack}async commit(){return this.errorAccumulated?!1:(await this.execute({command:2})).ack}async error(){this.stream.send({command:3});const e=await this.execute({command:3});return e.error!=null?Nc(e.error):null}async close(){await this.stream.closeAndAck()}async execute(e){for(this.stream.send(e);;){const t=await this.stream.receive();if(t.command===e.command)return t;console.warn("writer received unexpected response",t)}}get errorAccumulated(){return this.stream.received()}},h(cn,"ENDPOINT","/frame/write"),cn),Ah=class{constructor(e,t){h(this,"stream");h(this,"retriever");this.stream=e,this.retriever=t}async openIterator(e,t){return await gi._open(e,t,this.retriever,this.stream)}async openWriter(e){return await Eh._open(this.retriever,this.stream,e)}async openStreamer(e){const t=typeof e=="object";return(Array.isArray(e)||!t)&&(e={channels:e}),await Ui._open(this.retriever,this.stream,e)}async write(e,t,n){const s=await this.openWriter({start:t,channels:e,mode:Di.PersistOnly});try{await s.write(e,n),await s.commit()}finally{await s.close()}}async read(e,t){const{single:n}=Hr(t),s=await this.readFrame(e,t);return n?s.series[0]:s}async readFrame(e,t){const n=await this.openIterator(e,t),s=new Je;try{for await(const a of n)s.push(a)}finally{await n.close()}return s}};const hb=Object.freeze(Object.defineProperty({__proto__:null,AUTO_SPAN:Bo,Client:Ah,Frame:Je,Iterator:gi,Streamer:Ui,Writer:Eh,WriterMode:Di,frameZ:Pi,series:Th,seriesFromPayload:xh,seriesToPayload:Sh},Symbol.toStringTag,{value:"Module"}));let Ih=class{constructor(e,t,n){h(this,"tasks");h(this,"racks");h(this,"devices");this.tasks=e,this.racks=t,this.devices=n}};const pb=Object.freeze(Object.defineProperty({__proto__:null,Client:Ih},Symbol.toStringTag,{value:"Module"})),na=u.z.number(),Pc=u.z.object({key:na,name:u.z.string()}),fb=Pc.partial({key:!0}),Mc=u.z.string(),Li=u.z.object({key:Mc,rack:na,name:u.z.string(),make:u.z.string(),model:u.z.string(),location:u.z.string(),properties:u.z.string()});class sa{constructor(e,t,n,s){h(this,"streamer");h(this,"decoder");h(this,"base");h(this,"closePromise");h(this,"deleteChannel");h(this,"setChannel");this.streamer=e,this.decoder=t,this.base=new Ja.Observer,this.closePromise=this.stream(),this.deleteChannel=s,this.setChannel=n}onChange(e){return this.base.onChange(e)}async close(){return this.streamer.close(),await this.closePromise}async stream(){for await(const e of this.streamer){const t=[];if(this.deleteChannel!=null){const n=e.get(this.deleteChannel);t.push(...n.series.flatMap(s=>this.decoder("delete",s)))}if(this.setChannel!=null){const n=e.get(this.setChannel);t.push(...n.series.flatMap(s=>this.decoder("set",s)))}this.base.notify(t)}}static async open(e,t,n,s){const a=await e.openStreamer([t,n]);return new sa(a,s,t,n)}}const mb="sy_device_set",yb="sy_device_delete";let Zh=class{constructor(e,t,n){h(this,"retriever");h(this,"writer");h(this,"frameClient");this.retriever=e,this.writer=t,this.frameClient=n}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t=await this.retriever.retrieve(Se(e));return Array.isArray(e)?t:t[0]}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async delete(e){await this.writer.delete(e)}async openDeviceTracker(){return await sa.open(this.frameClient,mb,yb,gb)}};const gb=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(Li).map(t=>({variant:r,key:t.key,value:t})),ro="/hardware/device/retrieve",no=u.z.object({search:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional(),keys:Mc.array().optional()}),so=u.z.object({devices:Li.array()});let $h=class{constructor(e){h(this,"client");this.client=e}async search(e){return(await G(this.client,ro,{keys:[e]},no,so)).devices}async page(e,t){return(await G(this.client,ro,{offset:e,limit:t},no,so)).devices}async retrieve(e){return(await G(this.client,ro,{keys:e},no,so)).devices}};const vb="/hardware/device/create",wb="/hardware/device/delete",bb=u.z.object({devices:Li.array()}),_b=u.z.object({devices:Li.array()}),kb=u.z.object({keys:Mc.array()}),Ob=u.z.object({});let Ch=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await G(this.client,vb,{devices:e},bb,_b)).devices}async delete(e){await G(this.client,wb,{keys:e},kb,Ob)}};const Tb=Object.freeze(Object.defineProperty({__proto__:null,Client:Zh,Retriever:$h,Writer:Ch},Symbol.toStringTag,{value:"Module"}));let jh=class{constructor(e,t,n,s,a){h(this,"retriever");h(this,"writer");h(this,"frameClient");h(this,"taskWriter");h(this,"taskRetriever");this.retriever=e,this.writer=t,this.frameClient=n,this.taskWriter=s,this.taskRetriever=a}async create(e){const t=await this.writer.create([e]);return this.sugar(t)[0]}async search(e){const t=await this.retriever.search(e);return this.sugar(t)}async page(e,t){const n=await this.retriever.page(e,t);return this.sugar(n)}async retrieve(e){const t=await this.retriever.retrieve(Se(e));return Array.isArray(e)?this.sugar(t):this.sugar(t)[0]}sugar(e){return e.map(t=>new Rh(t.key,t.name,this.taskWriter,this.taskRetriever))}};class Rh{constructor(e,t,n,s){h(this,"key");h(this,"name");h(this,"writer");h(this,"tasks");this.key=e,this.name=t,this.writer=n,this.tasks=s}async listTasks(){return await this.tasks.retrieve({rack:this.key})}async retrieveTasks(){return[]}async createTask(e){return e.key=((BigInt(this.key)<<32n)+(BigInt(e.key??0)&0xffffffffn)).toString(),(await this.writer.create([e]))[0]}async deleteTask(e){await this.writer.delete([e])}}const xb="/hardware/rack/create",Sb="/hardware/rack/delete",Nb=u.z.object({racks:fb.array()}),Eb=u.z.object({racks:Pc.array()}),Ab=u.z.object({keys:na.array()}),Ib=u.z.object({});let zh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await G(this.client,xb,{racks:e},Nb,Eb)).racks}async delete(e){await G(this.client,Sb,{keys:e},Ab,Ib)}};const ao="/hardware/rack/retrieve",io=u.z.object({keys:na.array().optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),oo=u.z.object({racks:Pc.array()});let Ph=class{constructor(e){h(this,"client");this.client=e}async page(e,t){return(await G(this.client,ao,{offset:e,limit:t},io,oo)).racks}async search(e){return(await G(this.client,ao,{search:e},io,oo)).racks}async retrieve(e){return(await G(this.client,ao,{keys:e},io,oo)).racks}};const Zb=Object.freeze(Object.defineProperty({__proto__:null,Client:jh,Rack:Rh,Retriever:Ph,Writer:zh},Symbol.toStringTag,{value:"Module"}));let Mh=class{constructor(e,t){h(this,"retriever");h(this,"writer");this.retriever=e,this.writer=t}async search(e){return await this.retriever.search(e)}async page(e,t){return await this.retriever.page(e,t)}async create(e){return(await this.writer.create([e]))[0]}async retrieve(e){const t={};let n=!0;typeof e=="number"?t.rack=e:typeof e=="string"?(n=!1,t.keys=[e]):t.keys=Se(e);const s=await this.retriever.retrieve(t);return n?s:s[0]}};const Uc=u.z.union([u.z.string(),u.z.bigint().transform(r=>r.toString()),u.z.number().transform(r=>r.toString())]),Dc=u.z.object({key:Uc,name:u.z.string(),type:u.z.string(),config:u.z.record(u.z.unknown()).or(u.z.string().transform(r=>JSON.parse(r)))}),$b=Dc.omit({key:!0}).extend({key:Uc.transform(r=>r.toString()).optional(),config:u.z.unknown().transform(r=>JSON.stringify(r))}),co=u.z.object({rack:na.optional(),keys:u.z.string().array().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),uo=u.z.object({tasks:u.z.union([Dc.array(),u.z.null().transform(()=>[])])}),lo="/hardware/task/retrieve";let Uh=class{constructor(e){h(this,"client");this.client=e}async retrieve(e){return(await G(this.client,lo,e,co,uo)).tasks}async search(e){return(await G(this.client,lo,{keys:[e]},co,uo)).tasks}async page(e,t){return(await G(this.client,lo,{offset:e,limit:t},co,uo)).tasks}};const Cb="/hardware/task/create",jb="/hardware/task/delete",Rb=u.z.object({tasks:$b.array()}),zb=u.z.object({tasks:Dc.array()}),Pb=u.z.object({keys:Uc.array()}),Mb=u.z.object({});let Dh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await G(this.client,Cb,{tasks:e},Rb,zb)).tasks}async delete(e){await G(this.client,jb,{keys:e},Pb,Mb)}};const Ub=Object.freeze(Object.defineProperty({__proto__:null,Client:Mh,Retriever:Uh,Writer:Dh},Symbol.toStringTag,{value:"Module"}));class Db{constructor(e,t){h(this,"key");h(this,"name");this.key=t,this.name=e}get ontologyID(){return new st({type:"group",key:this.key})}}const Lb=u.z.string().uuid(),Bb=u.z.object({key:Lb,name:u.z.string()}),Lh=u.z.union([u.z.literal("label"),u.z.literal("builtin"),u.z.literal("cluster"),u.z.literal("channel"),u.z.literal("node"),u.z.literal("group"),u.z.literal("range"),u.z.literal("range-alias"),u.z.literal("user"),u.z.literal("workspace"),u.z.literal("pid"),u.z.literal("lineplot"),u.z.literal("rack")]),Dt=u.z.object({type:Lh,key:u.z.string()}),Bh=u.z.string().transform(r=>{const[e,t]=r.split(":");return{type:e,key:t}}),Vh=u.z.union([Bh,Dt]),In=class In{constructor(e){h(this,"type");h(this,"key");if(e instanceof In)this.type=e.type,this.key=e.key;else if(typeof e=="string"){const[t,n]=e.split(":");this.type=t,this.key=n}else this.type=e.type,this.key=e.key}toString(){return`${this.type}:${this.key}`}get payload(){return{type:this.type,key:this.key}}};h(In,"z",u.z.union([Vh,u.z.instanceof(In)]).transform(e=>new In(e)));let st=In;const Vb=new st({type:"builtin",key:"root"}),qh=u.z.object({type:u.z.number()}),Kh=u.z.object({type:Lh,fields:u.z.record(qh)}),Fh=u.z.object({id:st.z,name:u.z.string(),schema:Kh.optional(),data:u.z.record(u.z.unknown()).optional()}).transform(r=>({key:r.id.toString(),...r})),qb=u.z.object({from:st.z,type:u.z.string(),to:st.z}),Vo=r=>{const[e,t,n]=r.split("->");return{from:new st(e),type:t,to:new st(n)}},Kb=u.z.object({group:Bb}),Fb=u.z.object({parent:Dt,name:u.z.string()}),Wb=u.z.object({key:u.z.string(),name:u.z.string()}),Yb=u.z.object({keys:u.z.array(u.z.string())});var Gt;let Jb=(Gt=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const[n,s]=await this.client.send(Gt.ENDPOINT,{parent:e,name:t},Fb,Kb);if(s!=null)throw s;return n.group}async rename(e,t){const n={key:e,name:t},[,s]=await this.client.send(Gt.ENDPOINT_RENAME,n,Wb,u.z.object({}));if(s!=null)throw s}async delete(e){const t={keys:e},[,n]=await this.client.send(Gt.ENDPOINT_DELETE,t,Yb,u.z.object({}));if(n!=null)throw n}},h(Gt,"ENDPOINT","/ontology/create-group"),h(Gt,"ENDPOINT_RENAME","/ontology/rename-group"),h(Gt,"ENDPOINT_DELETE","/ontology/delete-group"),Gt),Gb=class{constructor(e){h(this,"creator");this.creator=new Jb(e)}async create(e,t){return this.sugar(await this.creator.create(e,t))}async rename(e,t){return await this.creator.rename(e,t)}async delete(...e){return await this.creator.delete(e)}sugar(e){return new Db(e.name,e.key)}};const Hb=u.z.object({ids:Dt.array().optional(),children:u.z.boolean().optional(),parents:u.z.boolean().optional(),includeSchema:u.z.boolean().optional(),includeFieldData:u.z.boolean().optional(),term:u.z.string().optional()}),Xb=u.z.object({resources:Fh.array()});var jn;let Qb=(jn=class{constructor(e){h(this,"client");this.client=e}async search(e){return await this.execute({term:e})}async retrieve(e,t=!0,n=!0){return await this.execute({ids:Se(e).map(s=>new st(s).payload),includeFieldData:n,includeSchema:t})}async retrieveChildren(e,t=!0,n=!0){return await this.execute({ids:Se(e).map(s=>new st(s).payload),children:!0,includeSchema:t,includeFieldData:n})}async retrieveParents(e,t=!0,n=!0){return await this.execute({ids:Se(e).map(s=>new st(s).payload),parents:!0,includeSchema:t,includeFieldData:n})}async execute(e){return(await G(this.client,jn.ENDPOINT,e,Hb,Xb)).resources}},h(jn,"ENDPOINT","/ontology/retrieve"),jn);const ho={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},Bu=u.z.object({id:Dt,children:Dt.array()}),e_=u.z.object({from:Dt,to:Dt,children:Dt.array()});let t_=class{constructor(e){h(this,"client");this.client=e}async addChildren(e,...t){await G(this.client,ho.ADD_CHILDREN,{id:e,children:t},Bu,u.z.object({}))}async removeChildren(e,...t){await G(this.client,ho.REMOVE_CHILDREN,{id:e,children:t},Bu,u.z.object({}))}async moveChildren(e,t,...n){const s={from:e,to:t,children:n};await G(this.client,ho.MOVE_CHILDREN,s,e_,u.z.object({}))}};const Vu="sy_ontology_resource_set",qu="sy_ontology_resource_delete",Ku="sy_ontology_relationship_set",Fu="sy_ontology_relationship_delete";class Bi{constructor(e,t){h(this,"resourceObs");h(this,"relationshipObs");h(this,"relationships");h(this,"resources");h(this,"streamer");h(this,"retriever");h(this,"closePromise");this.relationshipObs=new Ja.Observer,this.relationships=this.relationshipObs,this.resourceObs=new Ja.Observer,this.resources=this.resourceObs,this.retriever=t,this.streamer=e,this.closePromise=this.start()}async close(){this.streamer.close(),await this.closePromise}async start(){for await(const e of this.streamer)await this.update(e)}async update(e){const t=await this.parseResourceSets(e),n=this.parseResourceDeletes(e);t.concat(n).length>0&&this.resourceObs.notify(t.concat(n));const a=this.parseRelationshipSets(e),i=this.parseRelationshipDeletes(e);a.concat(i).length>0&&this.relationshipObs.notify(a.concat(i))}parseRelationshipSets(e){const t=e.get(Ku);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"set",key:Vo(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(Fu);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:Vo(n)}))}async parseResourceSets(e){const t=e.get(Vu);if(t.length===0)return[];const n=Array.from(t.as("string")).map(s=>new st(s));try{return(await this.retriever.retrieve(n)).map(a=>({variant:"set",key:a.id,value:a}))}catch(s){if(s instanceof qt)return console.warn(s),[];throw s}}parseResourceDeletes(e){const t=e.get(qu);return t.length===0?[]:Array.from(t.as("string")).map(n=>({variant:"delete",key:new st(n)}))}static async open(e,t){const n=await e.openStreamer([Vu,qu,Ku,Fu]);return new Bi(n,t)}}let Wh=class{constructor(e,t){h(this,"groups");h(this,"retriever");h(this,"writer");h(this,"framer");this.retriever=new Qb(e),this.writer=new t_(e),this.groups=new Gb(e),this.framer=t}async search(e){return await this.retriever.search(e)}async retrieve(e,t,n){const s=await this.retriever.retrieve(e,t,n);if(Array.isArray(e))return s;if(s.length===0)throw new qt(`No resource found with ID ${e.toString()}`);return s[0]}async page(e,t){return[]}async retrieveChildren(e,t,n){return await this.retriever.retrieveChildren(e,t,n)}async retrieveParents(e,t,n){return await this.retriever.retrieveParents(e,t,n)}async addChildren(e,...t){return await this.writer.addChildren(e,...t)}async removeChildren(e,...t){return await this.writer.removeChildren(e,...t)}async moveChildren(e,t,...n){return await this.writer.moveChildren(e,t,...n)}async openChangeTracker(){return await Bi.open(this.framer,this.retriever)}};const r_=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:Bi,Client:Wh,ID:st,Root:Vb,crudeIDZ:Vh,idZ:Dt,parseRelationship:Vo,relationshipSchemaZ:qb,resourceSchemaZ:Fh,schemaFieldZ:qh,schemaZ:Kh,stringIDZ:Bh},Symbol.toStringTag,{value:"Module"})),Kn=u.z.string().uuid(),aa=u.z.object({key:Kn,name:u.z.string().min(1),color:u.z.string()}),n_=r=>new st({type:"label",key:r}),s_=u.z.object({keys:Kn.array().optional(),for:Dt.optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),a_=u.z.object({labels:aa.array().optional().default([])});var Rn;let Yh=(Rn=class{constructor(e){h(this,"client");this.client=e}async retrieve(e){const t=Se(e);return await this.execute({keys:t})}async retrieveFor(e){return await this.execute({for:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){const[t,n]=await this.client.send(Rn.ENDPOINT,e,s_,a_);if(n!=null)throw n;return t.labels}},h(Rn,"ENDPOINT","/label/retrieve"),Rn);const Jh=aa.extend({key:Kn.optional()}),i_=u.z.object({labels:Jh.array()}),o_=u.z.object({labels:aa.array()}),c_=u.z.object({keys:Kn.array()}),Gh=u.z.object({id:Dt,labels:Kn.array()}),u_=Gh,po=u.z.object({}),l_="/label/create",d_="/label/delete",h_="/label/set",p_="/label/remove";let Hh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await G(this.client,l_,{labels:Se(e)},i_,o_)).labels}async delete(e){await G(this.client,d_,{keys:Se(e)},c_,po)}async set(e,t){await G(this.client,h_,{id:e,labels:t},Gh,po)}async remove(e,t){await G(this.client,p_,{id:e,labels:t},u_,po)}};const f_="sy_label_set",m_="sy_label_delete";let Xh=class{constructor(e,t){h(this,"retriever");h(this,"writer");h(this,"frameClient");this.writer=new Hh(e),this.retriever=new Yh(e),this.frameClient=t}async search(e){return await this.retriever.search(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async retrieveFor(e){return await this.retriever.retrieveFor(e)}async label(e,t){await this.writer.set(e,t)}async removeLabels(e,t){await this.writer.remove(e,t)}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async openChangeTracker(){return await sa.open(this.frameClient,f_,m_,y_)}};const y_=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON(aa).map(t=>({variant:r,key:t.key,value:t})),g_=Object.freeze(Object.defineProperty({__proto__:null,Client:Xh,Retriever:Yh,Writer:Hh,keyZ:Kn,labelZ:aa,newLabelPayloadZ:Jh,ontologyID:n_},Symbol.toStringTag,{value:"Module"})),dt=u.z.string().uuid(),ia=u.z.object({key:dt,name:u.z.string().min(1),timeRange:Et.z}),Qh=ia.extend({key:u.z.string().uuid().optional()}),Lc=r=>{const e=Se(r);if(e.length===0)throw new Error("Range params must not be empty");const t=dt.safeParse(e[0]).success;return{single:!Array.isArray(r),variant:t?"keys":"names",normalized:e,actual:r}},v_=u.z.object({}),w_=u.z.object({range:ia}),b_=u.z.object({range:dt}),__=u.z.object({range:dt}),k_=u.z.object({}),O_="/range/set-active",T_="/range/retrieve-active",x_="/range/clear-active";class S_{constructor(e){h(this,"client");this.client=e}async setActive(e){await G(this.client,O_,{range:e},b_,v_)}async retrieveActive(){const[e,t]=await this.client.send(T_,{},u.z.object({}),w_);if(t instanceof qt)return null;if(t!=null)throw t;return e.range}async clearActive(e){await G(this.client,x_,{range:e},__,k_)}}const N_="sy_range_alias_set",E_="sy_range_alias_delete",A_=u.z.object({range:dt,aliases:u.z.string().array()}),I_=u.z.object({aliases:u.z.record(u.z.string(),Gs)}),Z_=u.z.object({range:dt,aliases:u.z.record(Gs.or(u.z.string()),u.z.string())}),$_=u.z.unknown(),C_=u.z.object({range:dt,channels:Gs.array()}),j_=u.z.unknown(),R_=u.z.object({range:dt}),z_=u.z.object({aliases:u.z.record(u.z.string(),u.z.string())}),Wt=class Wt{constructor(e,t,n){h(this,"frameClient");h(this,"cache",new Map);h(this,"client");h(this,"rangeKey");this.rangeKey=e,this.cache=new Map,this.client=n,this.frameClient=t}async resolve(e){const t=[],n=typeof e=="string",s={};if(n){const i=this.cache.get(e);if(i!=null)return i;t.push(e)}else e.forEach(i=>{const o=this.cache.get(i);o!=null?s[i]=o:t.push(i)});if(t.length===0)return s;const a=await G(this.client,Wt.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},A_,I_);return Object.entries(a.aliases).forEach(([i,o])=>this.cache.set(i,o)),n?a.aliases[t[0]]:{...s,...a.aliases}}async set(e){await G(this.client,Wt.SET_ENDPOINT,{range:this.rangeKey,aliases:e},Z_,$_)}async list(){return(await G(this.client,Wt.LIST_ENDPOINT,{range:this.rangeKey},R_,z_)).aliases}async delete(e){await G(this.client,Wt.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},C_,j_)}async openChangeTracker(){return await sa.open(this.frameClient,N_,E_,U_(this.rangeKey))}};h(Wt,"SET_ENDPOINT","/range/alias/set"),h(Wt,"RESOLVE_ENDPOINT","/range/alias/resolve"),h(Wt,"LIST_ENDPOINT","/range/alias/list"),h(Wt,"DELETE_ENDPOINT","/range/alias/delete");let qo=Wt;const P_=u.z.object({range:dt,channel:Gs,alias:u.z.string()}),M_="---",U_=r=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(M_)[0]===r).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(P_).map(n=>({variant:e,key:n.alias,value:n})),D_=u.z.object({range:dt,keys:u.z.string().array()}),L_=u.z.object({pairs:u.z.record(u.z.string(),u.z.string())}),B_=u.z.object({range:dt,pairs:u.z.record(u.z.string(),u.z.string())}),V_=u.z.object({range:dt,keys:u.z.string().array()}),jr=class jr{constructor(e,t){h(this,"rangeKey");h(this,"client");this.rangeKey=e,this.client=t}async get(e){const[t,n]=await this.client.send(jr.GET_ENDPOINT,{range:this.rangeKey,keys:Se(e)},D_,L_);if(n!=null)throw n;return Array.isArray(e)?t.pairs:t.pairs[e]}async set(e,t=""){await G(this.client,jr.SET_ENDPOINT,{range:this.rangeKey,pairs:Ll(e)?e:{[e]:t}},B_,u.z.unknown())}async delete(e){await G(this.client,jr.DELETE_ENDPOINT,{range:this.rangeKey,keys:Se(e)},V_,u.z.unknown())}};h(jr,"GET_ENDPOINT","/range/kv/get"),h(jr,"SET_ENDPOINT","/range/kv/set"),h(jr,"DELETE_ENDPOINT","/range/kv/delete");let Ko=jr;const fo=r=>new st({type:"range",key:r});class ep{constructor(e,t=Et.ZERO,n,s,a,i,o,c){h(this,"key");h(this,"name");h(this,"kv");h(this,"timeRange");h(this,"channels");h(this,"aliaser");h(this,"frameClient");h(this,"labelClient");this.key=n,this.name=e,this.timeRange=t,this.frameClient=s,this.kv=a,this.aliaser=i,this.channels=o,this.labelClient=c}async setAlias(e,t){const n=await this.channels.retrieve(e);if(n.length===0)throw new qt(`Channel ${e} does not exist`);await this.aliaser.set({[n[0].key]:t})}async deleteAlias(...e){await this.aliaser.delete(e)}async listAliases(){return await this.aliaser.list()}async openAliasTracker(){return await this.aliaser.openChangeTracker()}async read(e){return await this.frameClient.read(this.timeRange,e)}async labels(){return await this.labelClient.retrieveFor(fo(this.key))}async addLabel(...e){await this.labelClient.label(fo(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(fo(this.key),e)}}let tp=class{constructor(e,t,n,s,a,i){h(this,"frameClient");h(this,"retriever");h(this,"writer");h(this,"unaryClient");h(this,"channels");h(this,"active");h(this,"labelClient");this.frameClient=e,this.retriever=t,this.writer=n,this.unaryClient=s,this.channels=a,this.active=new S_(s),this.labelClient=i}async create(e){const t=!Array.isArray(e),n=this.sugar(await this.writer.create(Se(e)));return t?n[0]:n}async rename(e,t){await this.writer.rename(e,t)}async delete(e){await this.writer.delete(Se(e))}async search(e){return this.sugar(await this.retriever.search(e))}async page(e,t){return[]}async retrieve(e){const{single:t,actual:n}=Lc(e),s=this.sugar(await this.retriever.retrieve(e));if(!t)return s;if(s.length===0)throw new qt(`range matching ${n} not found`);if(s.length>1)throw new qt(`multiple ranges matching ${n} found`);return s[0]}async setActive(e){await this.active.setActive(e)}async retrieveActive(){const e=await this.active.retrieveActive();return e==null?null:this.sugar([e])[0]}async clearActive(e){await this.active.clearActive(e)}sugar(e){return e.map(t=>new ep(t.name,t.timeRange,t.key,this.frameClient,new Ko(t.key,this.unaryClient),new qo(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}};const q_=u.z.object({ranges:ia.array()}),K_=u.z.object({ranges:Qh.array()}),F_=u.z.object({keys:dt.array()}),W_=u.z.object({}),Y_=u.z.object({key:dt,name:u.z.string()}),J_=u.z.object({}),G_="/range/create",H_="/range/delete",X_="/range/rename";let rp=class{constructor(e){h(this,"client");this.client=e}async rename(e,t){await G(this.client,X_,{key:e,name:t},Y_,J_)}async create(e){return(await G(this.client,G_,{ranges:e},K_,q_)).ranges}async delete(e){await G(this.client,H_,{keys:e},F_,W_)}};const Q_=u.z.object({keys:dt.array().optional(),names:u.z.array(u.z.string()).optional(),term:u.z.string().optional()}),e1=u.z.object({ranges:u.z.array(ia)});let np=class{constructor(e){h(this,"ENDPOINT","/range/retrieve");h(this,"client");this.client=e}async retrieve(e){const{normalized:t,variant:n}=Lc(e);return await this.execute({[n]:t})}async search(e){return await this.execute({term:e})}async execute(e){const[t,n]=await this.client.send(this.ENDPOINT,e,Q_,e1);if(n!=null)throw n;return t.ranges}};const t1=Object.freeze(Object.defineProperty({__proto__:null,Client:tp,Range:ep,Retriever:np,Writer:rp,analyzeParams:Lc,keyZ:dt,newPayloadZ:Qh,payloadZ:ia},Symbol.toStringTag,{value:"Module"})),r1="/api/v1/";class n1{constructor(e,t=!1){h(this,"url");h(this,"unary");h(this,"stream");h(this,"secure");this.secure=t,this.url=e.child(r1);const n=new nd.JSONEncoderDecoder;this.unary=new xw(this.url,n,this.secure),this.stream=new jw(this.url,n,this.secure)}use(...e){this.unary.use(...e),this.stream.use(...e)}}const Xr=u.z.string().uuid(),Bc=u.z.object({name:u.z.string(),key:Xr,layout:oc.or(u.z.string().transform(r=>JSON.parse(r)))}),Vc=Bc.omit({layout:!0}).extend({layout:u.z.string().transform(r=>JSON.parse(r))}),qc=u.z.string().uuid(),Kc=u.z.object({key:u.z.string(),name:u.z.string(),data:oc.or(u.z.string().transform(r=>JSON.parse(r)))}),s1=u.z.object({keys:u.z.string().array()}),a1=u.z.object({linePlots:Kc.array()});let i1=class{constructor(e){h(this,"ENDPOINT","/workspace/lineplot/retrieve");h(this,"client");this.client=e}async retrieve(e){const t=Se(e);return(await G(this.client,this.ENDPOINT,{keys:t},s1,a1)).linePlots}};const o1=Kc.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),c1=u.z.object({workspace:Xr,linePlots:o1.array()}),u1=u.z.object({linePlots:Kc.array()}),l1=u.z.object({keys:qc.array()}),d1=u.z.object({}),h1=u.z.object({key:qc,name:u.z.string()}),p1=u.z.object({}),f1=u.z.object({key:qc,data:u.z.string()}),m1=u.z.object({}),y1="/workspace/lineplot/create",g1="/workspace/lineplot/delete",v1="/workspace/lineplot/rename",w1="/workspace/lineplot/set-data";let b1=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await G(this.client,y1,{workspace:e,linePlots:[n]},c1,u1)).linePlots[0]}async delete(e){const t=Se(e);await G(this.client,g1,{keys:t},l1,d1)}async rename(e,t){await G(this.client,v1,{key:e,name:t},h1,p1)}async setData(e,t){await G(this.client,w1,{key:e,data:JSON.stringify(t)},f1,m1)}},_1=class{constructor(e){h(this,"writer");h(this,"retriever");this.writer=new b1(e),this.retriever=new i1(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}};const Vi=u.z.string().uuid(),k1=u.z.object({key:u.z.string(),name:u.z.string(),data:oc.or(u.z.string().transform(r=>JSON.parse(r))),snapshot:u.z.boolean()}),Fc=u.z.object({key:u.z.string(),name:u.z.string(),snapshot:u.z.boolean(),data:u.z.string().transform(r=>JSON.parse(r))}),O1=u.z.object({keys:u.z.string().array()}),T1=u.z.object({pids:Fc.array()});let x1=class{constructor(e){h(this,"ENDPOINT","/workspace/pid/retrieve");h(this,"client");this.client=e}async retrieve(e){return(await G(this.client,this.ENDPOINT,{keys:Se(e)},O1,T1)).pids}};const S1=k1.partial({key:!0,snapshot:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),N1=u.z.object({workspace:Xr,pids:S1.array()}),E1=u.z.object({pids:Fc.array()}),A1=u.z.object({keys:Vi.array()}),I1=u.z.object({}),Z1=u.z.object({key:Vi,name:u.z.string()}),Wu=u.z.object({}),$1=u.z.object({key:Vi,data:u.z.string()});u.z.object({});const C1=u.z.object({key:Vi,name:u.z.string(),snapshot:u.z.boolean()}),j1=u.z.object({pid:Fc}),R1="/workspace/pid/create",z1="/workspace/pid/delete",P1="/workspace/pid/rename",M1="/workspace/pid/set-data",U1="/workspace/pid/copy";let D1=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await G(this.client,R1,{workspace:e,pids:[n]},N1,E1)).pids[0]}async copy(e,t,n){return(await G(this.client,U1,{key:e,name:t,snapshot:n},C1,j1)).pid}async delete(e){const t=Se(e);await G(this.client,z1,{keys:t},A1,I1)}async rename(e,t){await G(this.client,P1,{key:e,name:t},Z1,Wu)}async setData(e,t){await G(this.client,M1,{key:e,data:JSON.stringify(t)},$1,Wu)}},L1=class{constructor(e){h(this,"writer");h(this,"retriever");this.writer=new D1(e),this.retriever=new x1(e)}async create(e,t){return await this.writer.create(e,t)}async rename(e,t){await this.writer.rename(e,t)}async setData(e,t){await this.writer.setData(e,t)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async delete(e){await this.writer.delete(e)}async copy(e,t,n){return await this.writer.copy(e,t,n)}};const B1=u.z.object({keys:Xr.array().optional(),search:u.z.string().optional(),author:u.z.string().uuid().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),V1=u.z.object({workspaces:Vc.array()}),bi=class bi{constructor(e){h(this,"client");this.client=e}async retrieve(e){const t=Se(e);return await this.execute({keys:t})}async retrieveByAuthor(e){return await this.execute({author:e})}async search(e){return await this.execute({search:e})}async page(e,t){return await this.execute({offset:e,limit:t})}async execute(e){return(await G(this.client,bi.ENDPOINT,e,B1,V1)).workspaces}};h(bi,"ENDPOINT","/workspace/retrieve");let Fo=bi;const q1=Bc.partial({key:!0}).transform(r=>({...r,layout:JSON.stringify(r.layout)})),K1=u.z.object({workspaces:q1.array()}),F1=u.z.object({workspaces:Vc.array()}),W1=u.z.object({keys:Xr.array()}),Y1=u.z.object({}),J1=u.z.object({key:Xr,name:u.z.string()}),G1=u.z.object({}),H1=u.z.object({key:Xr,layout:u.z.string()}),X1=u.z.object({}),Q1="/workspace/create",e0="/workspace/delete",t0="/workspace/rename",r0="/workspace/set-layout";class n0{constructor(e){h(this,"client");this.client=e}async create(e){return(await G(this.client,Q1,{workspaces:Se(e)},K1,F1)).workspaces}async delete(e){await G(this.client,e0,{keys:Se(e)},W1,Y1)}async rename(e,t){await G(this.client,t0,{key:e,name:t},J1,G1)}async setLayout(e,t){await G(this.client,r0,{key:e,layout:JSON.stringify(t)},H1,X1)}}class sp{constructor(e){h(this,"pid");h(this,"linePlot");h(this,"retriever");h(this,"writer");this.pid=new L1(e),this.linePlot=new _1(e),this.retriever=new Fo(e),this.writer=new n0(e)}async search(e){return await this.retriever.search(e)}async retrieveByAuthor(e){return await this.retriever.retrieveByAuthor(e)}async retrieve(e){const t=Array.isArray(e),n=await this.retriever.retrieve(e);return t?n:n[0]}async page(e,t){return await this.retriever.page(e,t)}async create(e){const t=Array.isArray(e),n=await this.writer.create(e);return t?n:n[0]}async rename(e,t){await this.writer.rename(e,t)}async setLayout(e,t){await this.writer.setLayout(e,t)}async delete(...e){await this.writer.delete(e)}}const s0=Object.freeze(Object.defineProperty({__proto__:null,Client:sp,keyZ:Xr,workspaceRemoteZ:Vc,workspaceZ:Bc},Symbol.toStringTag,{value:"Module"})),ap=u.z.object({host:u.z.string().min(1),port:u.z.number().or(u.z.string()),username:u.z.string().optional(),password:u.z.string().optional(),connectivityPollFrequency:ze.z.default(ze.seconds(30)),secure:u.z.boolean().optional().default(!1),name:u.z.string().optional()});class ip{constructor(e){h(this,"createdAt");h(this,"props");h(this,"telem");h(this,"ranges");h(this,"channels");h(this,"auth");h(this,"connectivity");h(this,"ontology");h(this,"workspaces");h(this,"labels");h(this,"hardware");h(this,"transport");this.createdAt=Ae.now(),this.props=ap.parse(e);const{host:t,port:n,username:s,password:a,connectivityPollFrequency:i,secure:o}=this.props;this.transport=new n1(new wm({host:t,port:Number(n)}),o),this.transport.use(Dw),s!=null&&a!=null&&(this.auth=new Gw(this.transport.unary,{username:s,password:a}),this.transport.use(this.auth.middleware()));const c=new Ac(new Ws(this.transport.unary)),l=new Ga(this.transport.unary);this.telem=new Ah(this.transport.stream,c),this.channels=new _h(this.telem,c,this.transport.unary,l),this.connectivity=new Ys(this.transport.unary,i,e.name),this.ontology=new Wh(this.transport.unary,this.telem);const m=new np(this.transport.unary),T=new rp(this.transport.unary);this.labels=new Xh(this.transport.unary,this.telem),this.ranges=new tp(this.telem,m,T,this.transport.unary,c,this.labels),this.workspaces=new sp(this.transport.unary);const J=new Zh(new $h(this.transport.unary),new Ch(this.transport.unary),this.telem),ee=new Uh(this.transport.unary),Ne=new Dh(this.transport.unary),te=new Mh(ee,Ne),rr=new jh(new Ph(this.transport.unary),new zh(this.transport.unary),this.telem,Ne,ee);this.hardware=new Ih(te,rr,J)}close(){this.connectivity.stopChecking()}}h(ip,"connectivity",Ys);const a0=Object.freeze(Object.defineProperty({__proto__:null,Authority:wn,StateTracker:Rc,filterTransfersByChannelKey:ob,stateZ:ib,subjectZ:jc,transferString:cb},Symbol.toStringTag,{value:"Module"}));exports.AuthError=Ec;exports.Authority=wn;exports.Channel=Ic;exports.ContiguityError=Pw;exports.DataType=Ee;exports.Density=ot;exports.Frame=Je;exports.GeneralError=yh;exports.MultiSeries=Ul;exports.ParseError=gh;exports.QueryError=qt;exports.Rate=xi;exports.RouteError=vh;exports.Series=Zn;exports.Synnax=ip;exports.TimeRange=Et;exports.TimeSpan=ze;exports.TimeStamp=Ae;exports.UnexpectedError=vn;exports.ValidationError=gt;exports.channel=qw;exports.connection=Qw;exports.control=a0;exports.device=Tb;exports.framer=hb;exports.hardware=pb;exports.label=g_;exports.ontology=r_;exports.rack=Zb;exports.ranger=t1;exports.synnaxPropsZ=ap;exports.task=Ub;exports.workspace=s0;
37
37
  //# sourceMappingURL=client.cjs.map