@synnaxlabs/client 0.17.1 → 0.17.3

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,21 +1,21 @@
1
- "use strict";var tp=Object.defineProperty;var rp=(r,e,t)=>e in r?tp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var h=(r,e,t)=>(rp(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("zod");var np=Object.defineProperty,sp=(r,e,t)=>e in r?np(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,S=(r,e,t)=>(sp(r,typeof e!="symbol"?e+"":e,t),t);let ap="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",ip=(r=21)=>{let e="",t=r;for(;t--;)e+=ap[Math.random()*64|0];return e};const op=r=>r!=null&&typeof r=="object"&&"toString"in r,cp=(r,e=!1)=>{const t=op(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?up(n):n},up=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 fo;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(fo||(fo={}));const D=_e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Cr=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}},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"]),lp=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 as=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===D.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=as;function dp(r){Yu=r}function Pa(){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}},hp=[];function B(r,e){const t=Ua({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Pa(),as].filter(n=>!!n)});r.common.issues.push(t)}class ot{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 ae;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 ot.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 ae;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 ae=Object.freeze({status:"aborted"}),Ju=r=>({status:"dirty",value:r}),gt=r=>({status:"valid",value:r}),mo=r=>r.status==="aborted",yo=r=>r.status==="dirty",is=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 Gt=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(is(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 Cr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Cr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ot,ctx:{common:e.parent.common,data:e.data,parsedType:Cr(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:Cr(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:Cr(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:G.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return _r.create(this,this._def)}nullable(){return hn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dn.create(this,this._def)}promise(){return Pn.create(this,this._def)}or(e){return hs.create([this,e],this._def)}and(e){return ps.create(this,e,this._def)}transform(e){return new Lt({...ue(this._def),schema:this,typeName:G.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new gs({...ue(this._def),innerType:this,defaultValue:t,typeName:G.ZodDefault})}brand(){return new nl({typeName:G.ZodBranded,type:this,...ue(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ka({...ue(this._def),innerType:this,catchValue:t,typeName:G.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Fo.create(this,e)}readonly(){return Fa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const pp=/^c[^\s-]{8,}$/i,fp=/^[a-z][a-z0-9]*$/,mp=/^[0-9A-HJKMNP-TV-Z]{26}$/,yp=/^[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,gp=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,vp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ki;const wp=/^(((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}))$/,bp=/^(([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})))$/,_p=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 kp(r,e){return!!((e==="v4"||!e)&&wp.test(r)||(e==="v6"||!e)&&bp.test(r))}let Rn=class Xn extends he{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==D.string){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:D.string,received:s.parsedType}),ae}const t=new ot;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")gp.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(vp,"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")yp.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")pp.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")fp.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")mp.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"?_p(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"?kp(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 Xn({...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 Xn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Xn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Xn({...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}};Rn.create=r=>{var e;return new Rn({checks:[],typeName:G.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ue(r)})};function Op(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 os=class go 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)!==D.number){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:D.number,received:s.parsedType}),ae}let t;const n=new ot;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"?Op(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 go({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:F.toString(s)}]})}_addCheck(e){return new go({...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)}};os.create=r=>new os({checks:[],typeName:G.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ue(r)});class Mr 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)!==D.bigint){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:D.bigint,received:s.parsedType}),ae}let t;const n=new ot;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 Mr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:F.toString(s)}]})}_addCheck(e){return new Mr({...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}}Mr.create=r=>{var e;return new Mr({checks:[],typeName:G.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ue(r)})};let cs=class extends he{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==D.boolean){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.boolean,received:t.parsedType}),ae}return gt(e.data)}};cs.create=r=>new cs({typeName:G.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ue(r)});let us=class Gu extends he{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==D.date){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:D.date,received:s.parsedType}),ae}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_date}),ae}const t=new ot;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}};us.create=r=>new us({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:G.ZodDate,...ue(r)});let Ma=class extends he{_parse(e){if(this._getType(e)!==D.symbol){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.symbol,received:t.parsedType}),ae}return gt(e.data)}};Ma.create=r=>new Ma({typeName:G.ZodSymbol,...ue(r)});let ls=class extends he{_parse(e){if(this._getType(e)!==D.undefined){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.undefined,received:t.parsedType}),ae}return gt(e.data)}};ls.create=r=>new ls({typeName:G.ZodUndefined,...ue(r)});let ds=class extends he{_parse(e){if(this._getType(e)!==D.null){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.null,received:t.parsedType}),ae}return gt(e.data)}};ds.create=r=>new ds({typeName:G.ZodNull,...ue(r)});let zn=class extends he{constructor(){super(...arguments),this._any=!0}_parse(e){return gt(e.data)}};zn.create=r=>new zn({typeName:G.ZodAny,...ue(r)});let on=class extends he{constructor(){super(...arguments),this._unknown=!0}_parse(e){return gt(e.data)}};on.create=r=>new on({typeName:G.ZodUnknown,...ue(r)});let Sr=class extends he{_parse(e){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.never,received:t.parsedType}),ae}};Sr.create=r=>new Sr({typeName:G.ZodNever,...ue(r)});let La=class extends he{_parse(e){if(this._getType(e)!==D.undefined){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.void,received:t.parsedType}),ae}return gt(e.data)}};La.create=r=>new La({typeName:G.ZodVoid,...ue(r)});let dn=class pa extends he{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==D.array)return B(t,{code:Z.invalid_type,expected:D.array,received:t.parsedType}),ae;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 Gt(t,i,t.path,o)))).then(i=>ot.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Gt(t,i,t.path,o)));return ot.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new pa({...this._def,minLength:{value:e,message:F.toString(t)}})}max(e,t){return new pa({...this._def,maxLength:{value:e,message:F.toString(t)}})}length(e,t){return new pa({...this._def,exactLength:{value:e,message:F.toString(t)}})}nonempty(e){return this.min(1,e)}};dn.create=(r,e)=>new dn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:G.ZodArray,...ue(e)});function Sn(r){if(r instanceof Nt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_r.create(Sn(n))}return new Nt({...r._def,shape:()=>e})}else return r instanceof dn?new dn({...r._def,type:Sn(r.element)}):r instanceof _r?_r.create(Sn(r.unwrap())):r instanceof hn?hn.create(Sn(r.unwrap())):r instanceof Lr?Lr.create(r.items.map(e=>Sn(e))):r}let Nt=class It 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)!==D.object){const c=this._getOrReturnCtx(e);return B(c,{code:Z.invalid_type,expected:D.object,received:c.parsedType}),ae}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Sr&&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],g=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Gt(n,g,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Sr){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 g=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Gt(n,g,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const g=await l.key;c.push({key:g,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>ot.mergeObjectSync(t,c)):ot.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return F.errToObj,new It({...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 It({...this._def,unknownKeys:"strip"})}passthrough(){return new It({...this._def,unknownKeys:"passthrough"})}extend(e){return new It({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new It({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:G.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new It({...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 It({...this._def,shape:()=>t})}omit(e){const t={};return _e.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new It({...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 It({...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 _r;)s=s._def.innerType;t[n]=s}}),new It({...this._def,shape:()=>t})}keyof(){return rl(_e.objectKeys(this.shape))}};Nt.create=(r,e)=>new Nt({shape:()=>r,unknownKeys:"strip",catchall:Sr.create(),typeName:G.ZodObject,...ue(e)});Nt.strictCreate=(r,e)=>new Nt({shape:()=>r,unknownKeys:"strict",catchall:Sr.create(),typeName:G.ZodObject,...ue(e)});Nt.lazycreate=(r,e)=>new Nt({shape:r,unknownKeys:"strip",catchall:Sr.create(),typeName:G.ZodObject,...ue(e)});let hs=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}),ae}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},g=c._parseSync({data:t.data,path:t.path,parent:l});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,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}),ae}}get options(){return this._def.options}};hs.create=(r,e)=>new hs({options:r,typeName:G.ZodUnion,...ue(e)});const fa=r=>r instanceof fs?fa(r.schema):r instanceof Lt?fa(r.innerType()):r instanceof ms?[r.value]:r instanceof Br?r.options:r instanceof ys?Object.keys(r.enum):r instanceof gs?fa(r._def.innerType):r instanceof ls?[void 0]:r instanceof ds?[null]:null;let Hu=class Xu extends he{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.object)return B(t,{code:Z.invalid_type,expected:D.object,received:t.parsedType}),ae;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]}),ae)}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=fa(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:G.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ue(n)})}};function vo(r,e){const t=Cr(r),n=Cr(e);if(r===e)return{valid:!0,data:r};if(t===D.object&&n===D.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=vo(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=vo(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}}let ps=class extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(mo(a)||mo(i))return ae;const o=vo(a.value,i.value);return o.valid?((yo(a)||yo(i))&&t.dirty(),{status:t.value,value:o.data}):(B(n,{code:Z.invalid_intersection_types}),ae)};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}))}};ps.create=(r,e,t)=>new ps({left:r,right:e,typeName:G.ZodIntersection,...ue(t)});let Lr=class Qu extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.array)return B(n,{code:Z.invalid_type,expected:D.array,received:n.parsedType}),ae;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"}),ae;!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 Gt(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>ot.mergeArray(t,a)):ot.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Qu({...this._def,rest:e})}};Lr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Lr({items:r,typeName:G.ZodTuple,rest:null,...ue(e)})};let el=class wo 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!==D.object)return B(n,{code:Z.invalid_type,expected:D.object,received:n.parsedType}),ae;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Gt(n,o,n.path,o)),value:i._parse(new Gt(n,n.data[o],n.path,o))});return n.common.async?ot.mergeObjectAsync(t,s):ot.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof he?new wo({keyType:e,valueType:t,typeName:G.ZodRecord,...ue(n)}):new wo({keyType:Rn.create(),valueType:e,typeName:G.ZodRecord,...ue(t)})}},Ba=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!==D.map)return B(n,{code:Z.invalid_type,expected:D.map,received:n.parsedType}),ae;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new Gt(n,o,n.path,[l,"key"])),value:a._parse(new Gt(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,g=await c.value;if(l.status==="aborted"||g.status==="aborted")return ae;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,g=c.value;if(l.status==="aborted"||g.status==="aborted")return ae;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}}}};Ba.create=(r,e,t)=>new Ba({valueType:e,keyType:r,typeName:G.ZodMap,...ue(t)});let Va=class bo extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.set)return B(n,{code:Z.invalid_type,expected:D.set,received:n.parsedType}),ae;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 g of c){if(g.status==="aborted")return ae;g.status==="dirty"&&t.dirty(),l.add(g.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Gt(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new bo({...this._def,minSize:{value:e,message:F.toString(t)}})}max(e,t){return new bo({...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)}};Va.create=(r,e)=>new Va({valueType:r,minSize:null,maxSize:null,typeName:G.ZodSet,...ue(e)});let tl=class ma extends he{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.function)return B(t,{code:Z.invalid_type,expected:D.function,received:t.parsedType}),ae;function n(o,c){return Ua({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pa(),as].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,Pa(),as].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 Pn){const o=this;return gt(async function(...c){const l=new Rt([]),g=await o._def.args.parseAsync(c,a).catch(Q=>{throw l.addIssue(n(c,Q)),l}),E=await Reflect.apply(i,this,g);return await o._def.returns._def.type.parseAsync(E,a).catch(Q=>{throw l.addIssue(s(E,Q)),l})})}else{const o=this;return gt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Rt([n(c,l.error)]);const g=Reflect.apply(i,this,l.data),E=o._def.returns.safeParse(g,a);if(!E.success)throw new Rt([s(g,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ma({...this._def,args:Lr.create(e).rest(on.create())})}returns(e){return new ma({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ma({args:e||Lr.create([]).rest(on.create()),returns:t||on.create(),typeName:G.ZodFunction,...ue(n)})}};class fs 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})}}fs.create=(r,e)=>new fs({getter:r,typeName:G.ZodLazy,...ue(e)});let ms=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}),ae}return{status:"valid",value:e.data}}get value(){return this._def.value}};ms.create=(r,e)=>new ms({value:r,typeName:G.ZodLiteral,...ue(e)});function rl(r,e){return new Br({values:r,typeName:G.ZodEnum,...ue(e)})}class Br 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}),ae}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}),ae}return gt(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 Br.create(e)}exclude(e){return Br.create(this.options.filter(t=>!e.includes(t)))}}Br.create=rl;let ys=class extends he{_parse(e){const t=_e.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==D.string&&n.parsedType!==D.number){const s=_e.objectValues(t);return B(n,{expected:_e.joinValues(s),received:n.parsedType,code:Z.invalid_type}),ae}if(t.indexOf(e.data)===-1){const s=_e.objectValues(t);return B(n,{received:n.data,code:Z.invalid_enum_value,options:s}),ae}return gt(e.data)}get enum(){return this._def.values}};ys.create=(r,e)=>new ys({values:r,typeName:G.ZodNativeEnum,...ue(e)});let Pn=class extends he{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.promise&&t.common.async===!1)return B(t,{code:Z.invalid_type,expected:D.promise,received:t.parsedType}),ae;const n=t.parsedType===D.promise?t.data:Promise.resolve(t.data);return gt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Pn.create=(r,e)=>new Pn({type:r,typeName:G.ZodPromise,...ue(e)});let Lt=class extends he{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===G.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"?ae:(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"?ae:(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(!is(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=>is(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:G.ZodEffects,effect:e,...ue(t)});Lt.createWithPreprocess=(r,e,t)=>new Lt({schema:e,effect:{type:"preprocess",transform:r},typeName:G.ZodEffects,...ue(t)});let _r=class extends he{_parse(e){return this._getType(e)===D.undefined?gt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};_r.create=(r,e)=>new _r({innerType:r,typeName:G.ZodOptional,...ue(e)});class hn extends he{_parse(e){return this._getType(e)===D.null?gt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}hn.create=(r,e)=>new hn({innerType:r,typeName:G.ZodNullable,...ue(e)});let gs=class extends he{_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}};gs.create=(r,e)=>new gs({innerType:r,typeName:G.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ue(e)});let Ka=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}};Ka.create=(r,e)=>new Ka({innerType:r,typeName:G.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ue(e)});let qa=class extends he{_parse(e){if(this._getType(e)!==D.nan){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.nan,received:t.parsedType}),ae}return{status:"valid",value:e.data}}};qa.create=r=>new qa({typeName:G.ZodNaN,...ue(r)});const Tp=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}},Fo=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"?ae: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"?ae: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:G.ZodPipeline})}},Fa=class extends he{_parse(e){const t=this._def.innerType._parse(e);return is(t)&&(t.value=Object.freeze(t.value)),t}};Fa.create=(r,e)=>new Fa({innerType:r,typeName:G.ZodReadonly,...ue(e)});const al=(r,e={},t)=>r?zn.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})}}):zn.create(),xp={object:Nt.lazycreate};var G;(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"})(G||(G={}));const Sp=(r,e={message:`Input not instance of ${r.name}`})=>al(t=>t instanceof r,e),il=Rn.create,ol=os.create,Np=qa.create,Ep=Mr.create,cl=cs.create,Ap=us.create,Ip=Ma.create,Zp=ls.create,$p=ds.create,Cp=zn.create,jp=on.create,Rp=Sr.create,zp=La.create,Pp=dn.create,Up=Nt.create,Dp=Nt.strictCreate,Mp=hs.create,Lp=Hu.create,Bp=ps.create,Vp=Lr.create,Kp=el.create,qp=Ba.create,Fp=Va.create,Wp=tl.create,Yp=fs.create,Jp=ms.create,Gp=Br.create,Hp=ys.create,Xp=Pn.create,Yc=Lt.create,Qp=_r.create,ef=hn.create,tf=Lt.createWithPreprocess,rf=Fo.create,nf=()=>il().optional(),sf=()=>ol().optional(),af=()=>cl().optional(),of={string:r=>Rn.create({...r,coerce:!0}),number:r=>os.create({...r,coerce:!0}),boolean:r=>cs.create({...r,coerce:!0}),bigint:r=>Mr.create({...r,coerce:!0}),date:r=>us.create({...r,coerce:!0})},cf=ae;var T=Object.freeze({__proto__:null,defaultErrorMap:as,setErrorMap:dp,getErrorMap:Pa,makeIssue:Ua,EMPTY_PATH:hp,addIssueToContext:B,ParseStatus:ot,INVALID:ae,DIRTY:Ju,OK:gt,isAborted:mo,isDirty:yo,isValid:is,isAsync:Da,get util(){return _e},get objectUtil(){return fo},ZodParsedType:D,getParsedType:Cr,ZodType:he,ZodString:Rn,ZodNumber:os,ZodBigInt:Mr,ZodBoolean:cs,ZodDate:us,ZodSymbol:Ma,ZodUndefined:ls,ZodNull:ds,ZodAny:zn,ZodUnknown:on,ZodNever:Sr,ZodVoid:La,ZodArray:dn,ZodObject:Nt,ZodUnion:hs,ZodDiscriminatedUnion:Hu,ZodIntersection:ps,ZodTuple:Lr,ZodRecord:el,ZodMap:Ba,ZodSet:Va,ZodFunction:tl,ZodLazy:fs,ZodLiteral:ms,ZodEnum:Br,ZodNativeEnum:ys,ZodPromise:Pn,ZodEffects:Lt,ZodTransformer:Lt,ZodOptional:_r,ZodNullable:hn,ZodDefault:gs,ZodCatch:Ka,ZodNaN:qa,BRAND:Tp,ZodBranded:nl,ZodPipeline:Fo,ZodReadonly:Fa,custom:al,Schema:he,ZodSchema:he,late:xp,get ZodFirstPartyTypeKind(){return G},coerce:of,any:Cp,array:Pp,bigint:Ep,boolean:cl,date:Ap,discriminatedUnion:Lp,effect:Yc,enum:Gp,function:Wp,instanceof:Sp,intersection:Bp,lazy:Yp,literal:Jp,map:qp,nan:Np,nativeEnum:Hp,never:Rp,null:$p,nullable:ef,number:ol,object:Up,oboolean:af,onumber:sf,optional:Qp,ostring:nf,pipeline:rf,preprocess:tf,promise:Xp,record:Kp,set:Fp,strictObject:Dp,string:il,symbol:Ip,transformer:Yc,tuple:Vp,undefined:Zp,union:Mp,unknown:jp,void:zp,NEVER:cf,ZodIssueCode:Z,quotelessJson:lp,ZodError:Rt});const Wo=T.tuple([T.number(),T.number()]),ul=T.object({width:T.number(),height:T.number()}),uf=T.object({signedWidth:T.number(),signedHeight:T.number()}),lf=["width","height"];T.enum(lf);const df=["start","center","end"],hf=["signedWidth","signedHeight"];T.enum(hf);const Wa=T.object({x:T.number(),y:T.number()}),pf=T.object({clientX:T.number(),clientY:T.number()}),ff=["x","y"],ll=T.enum(ff),dl=["top","right","bottom","left"];T.enum(dl);const mf=["left","right"],hl=T.enum(mf),yf=["top","bottom"],pl=T.enum(yf),fl=["center"],Jc=T.enum(fl),gf=[...dl,...fl],ml=T.enum(gf);T.enum(df);const vf=["first","last"];T.enum(vf);const wf=T.object({lower:T.number(),upper:T.number()});T.union([wf,Wo]);T.union([ll,ml]);T.union([ll,ml,T.instanceof(String)]);const ns=(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),bf(t)},bf=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var Et=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 _f(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=_f;var ki={};Object.defineProperty(ki,"__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-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}ki.default=kf;var Oi={};Object.defineProperty(Oi,"__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-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=Of;var Yo={};Object.defineProperty(Yo,"__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-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Yo.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){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)}Ho.default=Nf;var Xo={};Object.defineProperty(Xo,"__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().replace(/( ?)(\w+)( ?)/g,function(e,t,n,s){return t+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}Xo.default=Ef;var Ti={};Object.defineProperty(Ti,"__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():""}Ti.default=Af;var Qo={},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 If=Et&&Et.__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(Qo,"__esModule",{value:!0});var ar=bn;function ya(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=ya(s,e)):e.recursiveInArray&&ar.isArrayObject(s)&&(s=If(s).map(function(i){var o=i;if(ar.isValidObject(i))ar.belongToTypes(o,e.keepTypesOnRecursion)||(o=ya(i,e));else if(ar.isArrayObject(i)){var c=ya({key:i},e);o=c.key}return o}))),t[a]=s}),t}Qo.default=ya;var ec={},Zf=Et&&Et.__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 ir=bn;function ga(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=ga(s,e)):e.recursiveInArray&&ir.isArrayObject(s)&&(s=Zf(s).map(function(i){var o=i;if(ir.isValidObject(i))ir.belongToTypes(o,e.keepTypesOnRecursion)||(o=ga(i,e));else if(ir.isArrayObject(i)){var c=ga({key:i},e);o=c.key}return o}))),t[a]=s}),t}ec.default=ga;var tc={},$f=Et&&Et.__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 or=bn,Cf=_i;function va(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=Cf.default(n);e.recursive&&(or.isValidObject(s)?or.belongToTypes(s,e.keepTypesOnRecursion)||(s=va(s,e)):e.recursiveInArray&&or.isArrayObject(s)&&(s=$f(s).map(function(i){var o=i;if(or.isValidObject(i))or.belongToTypes(o,e.keepTypesOnRecursion)||(o=va(i,e));else if(or.isArrayObject(i)){var c=va({key:i},e);o=c.key}return o}))),t[a]=s}),t}tc.default=va;var rc={},jf=Et&&Et.__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 cr=bn,Rf=ki;function wa(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=Rf.default(n);e.recursive&&(cr.isValidObject(s)?cr.belongToTypes(s,e.keepTypesOnRecursion)||(s=wa(s,e)):e.recursiveInArray&&cr.isArrayObject(s)&&(s=jf(s).map(function(i){var o=i;if(cr.isValidObject(i))cr.belongToTypes(o,e.keepTypesOnRecursion)||(o=wa(i,e));else if(cr.isArrayObject(i)){var c=wa({key:i},e);o=c.key}return o}))),t[a]=s}),t}rc.default=wa;var nc={},zf=Et&&Et.__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 ur=bn,Pf=Oi;function ba(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=Pf.default(n);e.recursive&&(ur.isValidObject(s)?ur.belongToTypes(s,e.keepTypesOnRecursion)||(s=ba(s,e)):e.recursiveInArray&&ur.isArrayObject(s)&&(s=zf(s).map(function(i){var o=i;if(ur.isValidObject(i))ur.belongToTypes(o,e.keepTypesOnRecursion)||(o=ba(i,e));else if(ur.isArrayObject(i)){var c=ba({key:i},e);o=c.key}return o}))),t[a]=s}),t}nc.default=ba;var sc={},Uf=Et&&Et.__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 lr=bn,Df=Ti;function _a(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=_a(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=_a(i,e));else if(lr.isArrayObject(i)){var c=_a({key:i},e);o=c.key}return o}))),t[a]=s}),t}sc.default=_a;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=Yo;me.toDotCase=wl.default;var bl=Jo;me.toPathCase=bl.default;var _l=Go;me.toTextCase=_l.default;var kl=Ho;me.toSentenceCase=kl.default;var Ol=Xo;me.toHeaderCase=Ol.default;var Tl=Ti;me.toKebabCase=Tl.default;var xl=Qo;me.lowerKeys=xl.default;var Sl=ec;me.upperKeys=Sl.default;var Nl=tc;me.camelKeys=Nl.default;var El=rc;me.snakeKeys=El.default;var Al=nc;me.pascalKeys=Al.default;var Il=sc;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 Mf={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=Mf;var Cl=me;const jl={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Lf=r=>Cl.snakeKeys(r,jl),Bf=r=>Cl.camelKeys(r,jl);var Un;(r=>{r.toSnake=Lf,r.toCamel=Bf,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Un||(Un={}));T.object({x:hl.or(Jc),y:pl.or(Jc)});const Vf=T.object({x:hl,y:pl}),Kf=Object.freeze({x:"left",y:"top"}),qf=(r,e)=>r.x===e.x&&r.y===e.y,Gc=T.union([T.number(),Wa,Wo,ul,uf,pf]),Ff=(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},ia=T.union([T.number(),T.string()]);T.object({top:ia,left:ia,width:ia,height:ia});T.object({left:T.number(),top:T.number(),right:T.number(),bottom:T.number()});T.object({one:Wa,two:Wa,root:Vf});const ac=(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))},qi=r=>{const e=ac(r);return{lower:e.one.x,upper:e.two.x}},Fi=r=>{const e=ac(r);return{lower:e.one.y,upper:e.two.y}},Wf=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Yf=T.object({signedWidth:T.number(),signedHeight:T.number()});T.union([ul,Yf,Wa,Wo]);const Jf=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);T.object({offset:Gc,scale:Gc});const Gf=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Hf=r=>(e,t,n,s)=>[e,s?n/r:n*r],Xf=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 g=(n-s)*(l/c)+i;return[r,g]},Qf=r=>(e,t,n)=>[r,n],em=()=>(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)]},tm=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=Jf(n,s,a),[e,n]},_o=class Qn{constructor(){S(this,"ops",[]),S(this,"currBounds",null),S(this,"currType",null),S(this,"reversed",!1),this.ops=[]}static translate(e){return new Qn().translate(e)}static magnify(e){return new Qn().magnify(e)}static scale(e,t){return new Qn().scale(e,t)}translate(e){const t=this.new(),n=Gf(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Hf(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=ns(e,t),s=this.new(),a=Xf(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=ns(e,t),s=this.new(),a=tm(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=ns(e,t),s=this.new(),a=Qf(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=em();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 Qn;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}};S(_o,"IDENTITY",new _o);let Xc=_o;const Qc=class gr{constructor(e=new Xc,t=new Xc,n=null){S(this,"x"),S(this,"y"),S(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=Ff(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(Wf(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!qf(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(qi(e)),t.y=t.y.scale(Fi(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(qi(e)),t.y=this.y.reBound(Fi(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(qi(e)),t.y=this.y.clamp(Fi(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 ac(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};S(Qc,"IDENTITY",new Qc);const Rl=(r,e)=>{const t=new je(e);if(![Pe.DAY,Pe.HOUR,Pe.MINUTE,Pe.SECOND,Pe.MILLISECOND,Pe.MICROSECOND,Pe.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 je?new je(n):new Pe(n)},Ee=class ne{constructor(e,t="UTC"){if(S(this,"value"),S(this,"encodeValue",!0),e==null)this.value=ne.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*ne.MILLISECOND.valueOf();else if(typeof e=="string")this.value=ne.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=ne.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=ne.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=ne.MAX:e=ne.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 ne(BigInt(s.getTime())*ne.MILLISECOND.valueOf()).truncate(ne.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=ne.hours(parseInt(n??"00",10)).add(ne.minutes(parseInt(s??"00",10))).add(ne.seconds(parseInt(i??"00",10))).add(ne.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(ne.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return ne.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new ne(BigInt(n.getTime())*ne.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(ne.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 Pe(BigInt(new Date().getTimezoneOffset())*ne.MINUTE.valueOf())}static since(e){return new ne().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new ne(e).valueOf()}span(e){return this.range(e).span}range(e){return new Zt(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 ne(e).valueOf()}afterEq(e){return this.valueOf()>=new ne(e).valueOf()}before(e){return this.valueOf()<new ne(e).valueOf()}beforeEq(e){return this.valueOf()<=new ne(e).valueOf()}add(e){return new ne(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new ne(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/ne.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Rl(this,e)}get isToday(){return this.truncate(Pe.DAY).equals(ne.now().truncate(Pe.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new ne(new Date)}static max(...e){let t=ne.MIN;for(const n of e){const s=new ne(n);s.after(t)&&(t=s)}return t}static min(...e){let t=ne.MAX;for(const n of e){const s=new ne(n);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new ne(e)}static microseconds(e){return ne.nanoseconds(e*1e3)}static milliseconds(e){return ne.microseconds(e*1e3)}static seconds(e){return ne.milliseconds(e*1e3)}static minutes(e){return ne.seconds(e*60)}static hours(e){return ne.minutes(e*60)}static days(e){return ne.hours(e*24)}};S(Ee,"NANOSECOND",Ee.nanoseconds(1)),S(Ee,"MICROSECOND",Ee.microseconds(1)),S(Ee,"MILLISECOND",Ee.milliseconds(1)),S(Ee,"SECOND",Ee.seconds(1)),S(Ee,"MINUTE",Ee.minutes(1)),S(Ee,"HOUR",Ee.hours(1)),S(Ee,"DAY",Ee.days(1)),S(Ee,"MAX",new Ee((1n<<63n)-1n)),S(Ee,"MIN",new Ee(0)),S(Ee,"ZERO",new Ee(0)),S(Ee,"z",T.union([T.object({value:T.bigint()}).transform(r=>new Ee(r.value)),T.string().transform(r=>new Ee(BigInt(r))),T.instanceof(Number).transform(r=>new Ee(r)),T.number().transform(r=>new Ee(r)),T.instanceof(Ee)]));let je=Ee;const Ae=class Te{constructor(e){S(this,"value"),S(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),g=n.sub(t),E=s.sub(n),Q=a.sub(s),ce=i.sub(a),Se=o.sub(i);let ee="";return c.isZero||(ee+=`${c.days}d `),l.isZero||(ee+=`${l.hours}h `),g.isZero||(ee+=`${g.minutes}m `),E.isZero||(ee+=`${E.seconds}s `),Q.isZero||(ee+=`${Q.milliseconds}ms `),ce.isZero||(ee+=`${ce.microseconds}µs `),Se.isZero||(ee+=`${Se.nanoseconds}ns`),ee.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)}};S(Ae,"NANOSECOND",Ae.nanoseconds(1)),S(Ae,"MICROSECOND",Ae.microseconds(1)),S(Ae,"MILLISECOND",Ae.milliseconds(1)),S(Ae,"SECOND",Ae.seconds(1)),S(Ae,"MINUTE",Ae.minutes(1)),S(Ae,"HOUR",Ae.hours(1)),S(Ae,"DAY",Ae.days(1)),S(Ae,"MAX",new Ae((1n<<63n)-1n)),S(Ae,"MIN",new Ae(0)),S(Ae,"ZERO",new Ae(0)),S(Ae,"z",T.union([T.object({value:T.bigint()}).transform(r=>new Ae(r.value)),T.string().transform(r=>new Ae(BigInt(r))),T.instanceof(Number).transform(r=>new Ae(r)),T.number().transform(r=>new Ae(r)),T.instanceof(Ae)]));let Pe=Ae;const es=class ka extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new ka(e).valueOf()}get period(){return Pe.seconds(1/this.valueOf())}sampleCount(e){return new Pe(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new it(t).valueOf()}span(e){return Pe.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new ka(e)}static khz(e){return ka.hz(e*1e3)}};S(es,"z",T.union([T.number().transform(r=>new es(r)),T.instanceof(Number).transform(r=>new es(r)),T.instanceof(es)]));let xi=es;const et=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())}};S(et,"UNKNOWN",new et(0)),S(et,"BIT128",new et(16)),S(et,"BIT64",new et(8)),S(et,"BIT32",new et(4)),S(et,"BIT16",new et(2)),S(et,"BIT8",new et(1)),S(et,"z",T.union([T.number().transform(r=>new et(r)),T.instanceof(Number).transform(r=>new et(r)),T.instanceof(et)]));let it=et;const Kt=class Oa{constructor(e,t){S(this,"start"),S(this,"end"),this.start=new je(e),this.end=new je(t)}get span(){return new Pe(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 Oa(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 Oa?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Oa(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}};S(Kt,"MAX",new Kt(je.MIN,je.MAX)),S(Kt,"MIN",new Kt(je.MAX,je.MIN)),S(Kt,"ZERO",new Kt(je.ZERO,je.ZERO)),S(Kt,"z",T.union([T.object({start:je.z,end:je.z}).transform(r=>new Kt(r.start,r.end)),T.instanceof(Kt)]));let Zt=Kt;const N=class sn extends String{constructor(e){if(e instanceof sn||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=sn.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(sn.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=sn.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 density(){const e=sn.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 sn.BIG_INT_TYPES.some(e=>e.equals(this))}};S(N,"UNKNOWN",new N("unknown")),S(N,"FLOAT64",new N("float64")),S(N,"FLOAT32",new N("float32")),S(N,"INT64",new N("int64")),S(N,"INT32",new N("int32")),S(N,"INT16",new N("int16")),S(N,"INT8",new N("int8")),S(N,"UINT64",new N("uint64")),S(N,"UINT32",new N("uint32")),S(N,"UINT16",new N("uint16")),S(N,"UINT8",new N("uint8")),S(N,"TIMESTAMP",new N("timestamp")),S(N,"UUID",new N("uuid")),S(N,"STRING",new N("string")),S(N,"JSON",new N("json")),S(N,"ARRAY_CONSTRUCTORS",new Map([[N.UINT8.toString(),Uint8Array],[N.UINT16.toString(),Uint16Array],[N.UINT32.toString(),Uint32Array],[N.UINT64.toString(),BigUint64Array],[N.FLOAT32.toString(),Float32Array],[N.FLOAT64.toString(),Float64Array],[N.INT8.toString(),Int8Array],[N.INT16.toString(),Int16Array],[N.INT32.toString(),Int32Array],[N.INT64.toString(),BigInt64Array],[N.TIMESTAMP.toString(),BigInt64Array],[N.STRING.toString(),Uint8Array],[N.JSON.toString(),Uint8Array],[N.UUID.toString(),Uint8Array]])),S(N,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,N.UINT8],[Uint16Array.name,N.UINT16],[Uint32Array.name,N.UINT32],[BigUint64Array.name,N.UINT64],[Float32Array.name,N.FLOAT32],[Float64Array.name,N.FLOAT64],[Int8Array.name,N.INT8],[Int16Array.name,N.INT16],[Int32Array.name,N.INT32],[BigInt64Array.name,N.INT64]])),S(N,"DENSITIES",new Map([[N.UINT8.toString(),it.BIT8],[N.UINT16.toString(),it.BIT16],[N.UINT32.toString(),it.BIT32],[N.UINT64.toString(),it.BIT64],[N.FLOAT32.toString(),it.BIT32],[N.FLOAT64.toString(),it.BIT64],[N.INT8.toString(),it.BIT8],[N.INT16.toString(),it.BIT16],[N.INT32.toString(),it.BIT32],[N.INT64.toString(),it.BIT64],[N.TIMESTAMP.toString(),it.BIT64],[N.STRING.toString(),it.UNKNOWN],[N.JSON.toString(),it.UNKNOWN],[N.UUID.toString(),it.BIT128]])),S(N,"ALL",[N.UNKNOWN,N.FLOAT64,N.FLOAT32,N.INT64,N.INT32,N.INT16,N.INT8,N.UINT64,N.UINT32,N.UINT16,N.UINT8,N.TIMESTAMP,N.UUID,N.STRING,N.JSON]),S(N,"BIG_INT_TYPES",[N.INT64,N.UINT64,N.TIMESTAMP]),S(N,"z",T.union([T.string().transform(r=>new N(r)),T.instanceof(N)]));let rt=N;const st=class qe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return qe.bytes(this.valueOf()+e.valueOf())}sub(e){return qe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new qe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return qe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/qe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/qe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/qe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/qe.TERABYTE.valueOf()}toString(){const e=this.truncate(qe.TERABYTE),t=this.truncate(qe.GIGABYTE),n=this.truncate(qe.MEGABYTE),s=this.truncate(qe.KILOBYTE),a=this.truncate(qe.BYTE),i=e,o=t.sub(e),c=n.sub(t),l=s.sub(n),g=a.sub(s);let E="";return i.isZero||(E+=`${i.terabytes}TB `),o.isZero||(E+=`${o.gigabytes}GB `),c.isZero||(E+=`${c.megabytes}MB `),l.isZero||(E+=`${l.kilobytes}KB `),(!g.isZero||E==="")&&(E+=`${g.valueOf()}B`),E.trim()}static bytes(e=1){return new qe(e)}static kilobytes(e=1){return qe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return qe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return qe.megabytes(e.valueOf()*1e3)}static terabytes(e){return qe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};S(st,"BYTE",new st(1)),S(st,"KILOBYTE",st.kilobytes(1)),S(st,"MEGABYTE",st.megabytes(1)),S(st,"GIGABYTE",st.gigabytes(1)),S(st,"TERABYTE",st.terabytes(1)),S(st,"ZERO",new st(0)),S(st,"z",T.union([T.number().transform(r=>new st(r)),T.instanceof(st)]));let Ya=st;T.union([T.instanceof(Uint8Array),T.instanceof(Uint16Array),T.instanceof(Uint32Array),T.instanceof(BigUint64Array),T.instanceof(Float32Array),T.instanceof(Float64Array),T.instanceof(Int8Array),T.instanceof(Int16Array),T.instanceof(Int32Array),T.instanceof(BigInt64Array)]);const rm=(r,e,t,n=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!r.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(n):ts(t,-n),tn=-1;let ic=class Ar{constructor({data:e,dataType:t,timeRange:n,sampleOffset:s=0,glBufferUsage:a="static",alignment:i=0,key:o=ip()}){if(S(this,"key",""),S(this,"dataType"),S(this,"sampleOffset"),S(this,"gl"),S(this,"_data"),S(this,"_timeRange"),S(this,"alignment",0),S(this,"_min"),S(this,"_max"),S(this,"writePos",tn),S(this,"_refCount",0),t==null&&!(e instanceof ArrayBuffer))this.dataType=new rt(e);else if(t!=null)this.dataType=new rt(t);else throw new Error("must provide a data type when constructing a Series from a buffer");this.key=o,this.alignment=i,this.sampleOffset=s??0,this._data=e,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 rt(t).Array(e),a=new Ar({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 Ar({data:a,dataType:rt.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(e.join(`
1
+ "use strict";var tp=Object.defineProperty;var rp=(r,e,t)=>e in r?tp(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var h=(r,e,t)=>(rp(r,typeof e!="symbol"?e+"":e,t),t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("zod");var np=Object.defineProperty,sp=(r,e,t)=>e in r?np(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,S=(r,e,t)=>(sp(r,typeof e!="symbol"?e+"":e,t),t);let ap="_-0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ",ip=(r=21)=>{let e="",t=r;for(;t--;)e+=ap[Math.random()*64|0];return e};const op=r=>r!=null&&typeof r=="object"&&"toString"in r,cp=(r,e=!1)=>{const t=op(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?up(n):n},up=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 fo;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(fo||(fo={}));const D=_e.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Cr=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}},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"]),lp=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 as=(r,e)=>{let t;switch(r.code){case Z.invalid_type:r.received===D.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=as;function dp(r){Yu=r}function Pa(){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}},hp=[];function B(r,e){const t=Ua({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Pa(),as].filter(n=>!!n)});r.common.issues.push(t)}class ot{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 ae;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 ot.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 ae;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 ae=Object.freeze({status:"aborted"}),Ju=r=>({status:"dirty",value:r}),gt=r=>({status:"valid",value:r}),mo=r=>r.status==="aborted",yo=r=>r.status==="dirty",is=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 Gt=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(is(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 Cr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Cr(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ot,ctx:{common:e.parent.common,data:e.data,parsedType:Cr(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:Cr(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:Cr(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:G.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return _r.create(this,this._def)}nullable(){return hn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return dn.create(this,this._def)}promise(){return Pn.create(this,this._def)}or(e){return hs.create([this,e],this._def)}and(e){return ps.create(this,e,this._def)}transform(e){return new Lt({...ue(this._def),schema:this,typeName:G.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new gs({...ue(this._def),innerType:this,defaultValue:t,typeName:G.ZodDefault})}brand(){return new nl({typeName:G.ZodBranded,type:this,...ue(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new Ka({...ue(this._def),innerType:this,catchValue:t,typeName:G.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Fo.create(this,e)}readonly(){return Fa.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const pp=/^c[^\s-]{8,}$/i,fp=/^[a-z][a-z0-9]*$/,mp=/^[0-9A-HJKMNP-TV-Z]{26}$/,yp=/^[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,gp=/^(?!\.)(?!.*\.\.)([A-Z0-9_+-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,vp="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ki;const wp=/^(((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}))$/,bp=/^(([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})))$/,_p=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 kp(r,e){return!!((e==="v4"||!e)&&wp.test(r)||(e==="v6"||!e)&&bp.test(r))}let Rn=class Xn extends he{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==D.string){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:D.string,received:s.parsedType}),ae}const t=new ot;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")gp.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(vp,"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")yp.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")pp.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")fp.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")mp.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"?_p(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"?kp(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 Xn({...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 Xn({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Xn({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Xn({...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}};Rn.create=r=>{var e;return new Rn({checks:[],typeName:G.ZodString,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ue(r)})};function Op(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 os=class go 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)!==D.number){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:D.number,received:s.parsedType}),ae}let t;const n=new ot;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"?Op(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 go({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:F.toString(s)}]})}_addCheck(e){return new go({...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)}};os.create=r=>new os({checks:[],typeName:G.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...ue(r)});class Mr 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)!==D.bigint){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:D.bigint,received:s.parsedType}),ae}let t;const n=new ot;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 Mr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:F.toString(s)}]})}_addCheck(e){return new Mr({...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}}Mr.create=r=>{var e;return new Mr({checks:[],typeName:G.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...ue(r)})};let cs=class extends he{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==D.boolean){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.boolean,received:t.parsedType}),ae}return gt(e.data)}};cs.create=r=>new cs({typeName:G.ZodBoolean,coerce:(r==null?void 0:r.coerce)||!1,...ue(r)});let us=class Gu extends he{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==D.date){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_type,expected:D.date,received:s.parsedType}),ae}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return B(s,{code:Z.invalid_date}),ae}const t=new ot;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}};us.create=r=>new us({checks:[],coerce:(r==null?void 0:r.coerce)||!1,typeName:G.ZodDate,...ue(r)});let Ma=class extends he{_parse(e){if(this._getType(e)!==D.symbol){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.symbol,received:t.parsedType}),ae}return gt(e.data)}};Ma.create=r=>new Ma({typeName:G.ZodSymbol,...ue(r)});let ls=class extends he{_parse(e){if(this._getType(e)!==D.undefined){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.undefined,received:t.parsedType}),ae}return gt(e.data)}};ls.create=r=>new ls({typeName:G.ZodUndefined,...ue(r)});let ds=class extends he{_parse(e){if(this._getType(e)!==D.null){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.null,received:t.parsedType}),ae}return gt(e.data)}};ds.create=r=>new ds({typeName:G.ZodNull,...ue(r)});let zn=class extends he{constructor(){super(...arguments),this._any=!0}_parse(e){return gt(e.data)}};zn.create=r=>new zn({typeName:G.ZodAny,...ue(r)});let on=class extends he{constructor(){super(...arguments),this._unknown=!0}_parse(e){return gt(e.data)}};on.create=r=>new on({typeName:G.ZodUnknown,...ue(r)});let Sr=class extends he{_parse(e){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.never,received:t.parsedType}),ae}};Sr.create=r=>new Sr({typeName:G.ZodNever,...ue(r)});let La=class extends he{_parse(e){if(this._getType(e)!==D.undefined){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.void,received:t.parsedType}),ae}return gt(e.data)}};La.create=r=>new La({typeName:G.ZodVoid,...ue(r)});let dn=class pa extends he{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==D.array)return B(t,{code:Z.invalid_type,expected:D.array,received:t.parsedType}),ae;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 Gt(t,i,t.path,o)))).then(i=>ot.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Gt(t,i,t.path,o)));return ot.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new pa({...this._def,minLength:{value:e,message:F.toString(t)}})}max(e,t){return new pa({...this._def,maxLength:{value:e,message:F.toString(t)}})}length(e,t){return new pa({...this._def,exactLength:{value:e,message:F.toString(t)}})}nonempty(e){return this.min(1,e)}};dn.create=(r,e)=>new dn({type:r,minLength:null,maxLength:null,exactLength:null,typeName:G.ZodArray,...ue(e)});function Sn(r){if(r instanceof Nt){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=_r.create(Sn(n))}return new Nt({...r._def,shape:()=>e})}else return r instanceof dn?new dn({...r._def,type:Sn(r.element)}):r instanceof _r?_r.create(Sn(r.unwrap())):r instanceof hn?hn.create(Sn(r.unwrap())):r instanceof Lr?Lr.create(r.items.map(e=>Sn(e))):r}let Nt=class It 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)!==D.object){const c=this._getOrReturnCtx(e);return B(c,{code:Z.invalid_type,expected:D.object,received:c.parsedType}),ae}const{status:t,ctx:n}=this._processInputParams(e),{shape:s,keys:a}=this._getCached(),i=[];if(!(this._def.catchall instanceof Sr&&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],g=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Gt(n,g,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Sr){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 g=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Gt(n,g,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const g=await l.key;c.push({key:g,value:await l.value,alwaysSet:l.alwaysSet})}return c}).then(c=>ot.mergeObjectSync(t,c)):ot.mergeObjectSync(t,o)}get shape(){return this._def.shape()}strict(e){return F.errToObj,new It({...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 It({...this._def,unknownKeys:"strip"})}passthrough(){return new It({...this._def,unknownKeys:"passthrough"})}extend(e){return new It({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new It({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:G.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new It({...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 It({...this._def,shape:()=>t})}omit(e){const t={};return _e.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new It({...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 It({...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 _r;)s=s._def.innerType;t[n]=s}}),new It({...this._def,shape:()=>t})}keyof(){return rl(_e.objectKeys(this.shape))}};Nt.create=(r,e)=>new Nt({shape:()=>r,unknownKeys:"strip",catchall:Sr.create(),typeName:G.ZodObject,...ue(e)});Nt.strictCreate=(r,e)=>new Nt({shape:()=>r,unknownKeys:"strict",catchall:Sr.create(),typeName:G.ZodObject,...ue(e)});Nt.lazycreate=(r,e)=>new Nt({shape:r,unknownKeys:"strip",catchall:Sr.create(),typeName:G.ZodObject,...ue(e)});let hs=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}),ae}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},g=c._parseSync({data:t.data,path:t.path,parent:l});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,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}),ae}}get options(){return this._def.options}};hs.create=(r,e)=>new hs({options:r,typeName:G.ZodUnion,...ue(e)});const fa=r=>r instanceof fs?fa(r.schema):r instanceof Lt?fa(r.innerType()):r instanceof ms?[r.value]:r instanceof Br?r.options:r instanceof ys?Object.keys(r.enum):r instanceof gs?fa(r._def.innerType):r instanceof ls?[void 0]:r instanceof ds?[null]:null;let Hu=class Xu extends he{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.object)return B(t,{code:Z.invalid_type,expected:D.object,received:t.parsedType}),ae;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]}),ae)}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=fa(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:G.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...ue(n)})}};function vo(r,e){const t=Cr(r),n=Cr(e);if(r===e)return{valid:!0,data:r};if(t===D.object&&n===D.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=vo(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=vo(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}}let ps=class extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(mo(a)||mo(i))return ae;const o=vo(a.value,i.value);return o.valid?((yo(a)||yo(i))&&t.dirty(),{status:t.value,value:o.data}):(B(n,{code:Z.invalid_intersection_types}),ae)};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}))}};ps.create=(r,e,t)=>new ps({left:r,right:e,typeName:G.ZodIntersection,...ue(t)});let Lr=class Qu extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.array)return B(n,{code:Z.invalid_type,expected:D.array,received:n.parsedType}),ae;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"}),ae;!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 Gt(n,a,n.path,i)):null}).filter(a=>!!a);return n.common.async?Promise.all(s).then(a=>ot.mergeArray(t,a)):ot.mergeArray(t,s)}get items(){return this._def.items}rest(e){return new Qu({...this._def,rest:e})}};Lr.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Lr({items:r,typeName:G.ZodTuple,rest:null,...ue(e)})};let el=class wo 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!==D.object)return B(n,{code:Z.invalid_type,expected:D.object,received:n.parsedType}),ae;const s=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)s.push({key:a._parse(new Gt(n,o,n.path,o)),value:i._parse(new Gt(n,n.data[o],n.path,o))});return n.common.async?ot.mergeObjectAsync(t,s):ot.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof he?new wo({keyType:e,valueType:t,typeName:G.ZodRecord,...ue(n)}):new wo({keyType:Rn.create(),valueType:e,typeName:G.ZodRecord,...ue(t)})}},Ba=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!==D.map)return B(n,{code:Z.invalid_type,expected:D.map,received:n.parsedType}),ae;const s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new Gt(n,o,n.path,[l,"key"])),value:a._parse(new Gt(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,g=await c.value;if(l.status==="aborted"||g.status==="aborted")return ae;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,g=c.value;if(l.status==="aborted"||g.status==="aborted")return ae;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}}}};Ba.create=(r,e,t)=>new Ba({valueType:e,keyType:r,typeName:G.ZodMap,...ue(t)});let Va=class bo extends he{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==D.set)return B(n,{code:Z.invalid_type,expected:D.set,received:n.parsedType}),ae;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 g of c){if(g.status==="aborted")return ae;g.status==="dirty"&&t.dirty(),l.add(g.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Gt(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new bo({...this._def,minSize:{value:e,message:F.toString(t)}})}max(e,t){return new bo({...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)}};Va.create=(r,e)=>new Va({valueType:r,minSize:null,maxSize:null,typeName:G.ZodSet,...ue(e)});let tl=class ma extends he{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.function)return B(t,{code:Z.invalid_type,expected:D.function,received:t.parsedType}),ae;function n(o,c){return Ua({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pa(),as].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,Pa(),as].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 Pn){const o=this;return gt(async function(...c){const l=new Rt([]),g=await o._def.args.parseAsync(c,a).catch(Q=>{throw l.addIssue(n(c,Q)),l}),E=await Reflect.apply(i,this,g);return await o._def.returns._def.type.parseAsync(E,a).catch(Q=>{throw l.addIssue(s(E,Q)),l})})}else{const o=this;return gt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Rt([n(c,l.error)]);const g=Reflect.apply(i,this,l.data),E=o._def.returns.safeParse(g,a);if(!E.success)throw new Rt([s(g,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new ma({...this._def,args:Lr.create(e).rest(on.create())})}returns(e){return new ma({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new ma({args:e||Lr.create([]).rest(on.create()),returns:t||on.create(),typeName:G.ZodFunction,...ue(n)})}};class fs 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})}}fs.create=(r,e)=>new fs({getter:r,typeName:G.ZodLazy,...ue(e)});let ms=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}),ae}return{status:"valid",value:e.data}}get value(){return this._def.value}};ms.create=(r,e)=>new ms({value:r,typeName:G.ZodLiteral,...ue(e)});function rl(r,e){return new Br({values:r,typeName:G.ZodEnum,...ue(e)})}class Br 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}),ae}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}),ae}return gt(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 Br.create(e)}exclude(e){return Br.create(this.options.filter(t=>!e.includes(t)))}}Br.create=rl;let ys=class extends he{_parse(e){const t=_e.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==D.string&&n.parsedType!==D.number){const s=_e.objectValues(t);return B(n,{expected:_e.joinValues(s),received:n.parsedType,code:Z.invalid_type}),ae}if(t.indexOf(e.data)===-1){const s=_e.objectValues(t);return B(n,{received:n.data,code:Z.invalid_enum_value,options:s}),ae}return gt(e.data)}get enum(){return this._def.values}};ys.create=(r,e)=>new ys({values:r,typeName:G.ZodNativeEnum,...ue(e)});let Pn=class extends he{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==D.promise&&t.common.async===!1)return B(t,{code:Z.invalid_type,expected:D.promise,received:t.parsedType}),ae;const n=t.parsedType===D.promise?t.data:Promise.resolve(t.data);return gt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};Pn.create=(r,e)=>new Pn({type:r,typeName:G.ZodPromise,...ue(e)});let Lt=class extends he{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===G.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"?ae:(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"?ae:(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(!is(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=>is(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:G.ZodEffects,effect:e,...ue(t)});Lt.createWithPreprocess=(r,e,t)=>new Lt({schema:e,effect:{type:"preprocess",transform:r},typeName:G.ZodEffects,...ue(t)});let _r=class extends he{_parse(e){return this._getType(e)===D.undefined?gt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};_r.create=(r,e)=>new _r({innerType:r,typeName:G.ZodOptional,...ue(e)});class hn extends he{_parse(e){return this._getType(e)===D.null?gt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}hn.create=(r,e)=>new hn({innerType:r,typeName:G.ZodNullable,...ue(e)});let gs=class extends he{_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}};gs.create=(r,e)=>new gs({innerType:r,typeName:G.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...ue(e)});let Ka=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}};Ka.create=(r,e)=>new Ka({innerType:r,typeName:G.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...ue(e)});let qa=class extends he{_parse(e){if(this._getType(e)!==D.nan){const t=this._getOrReturnCtx(e);return B(t,{code:Z.invalid_type,expected:D.nan,received:t.parsedType}),ae}return{status:"valid",value:e.data}}};qa.create=r=>new qa({typeName:G.ZodNaN,...ue(r)});const Tp=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}},Fo=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"?ae: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"?ae: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:G.ZodPipeline})}},Fa=class extends he{_parse(e){const t=this._def.innerType._parse(e);return is(t)&&(t.value=Object.freeze(t.value)),t}};Fa.create=(r,e)=>new Fa({innerType:r,typeName:G.ZodReadonly,...ue(e)});const al=(r,e={},t)=>r?zn.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})}}):zn.create(),xp={object:Nt.lazycreate};var G;(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"})(G||(G={}));const Sp=(r,e={message:`Input not instance of ${r.name}`})=>al(t=>t instanceof r,e),il=Rn.create,ol=os.create,Np=qa.create,Ep=Mr.create,cl=cs.create,Ap=us.create,Ip=Ma.create,Zp=ls.create,$p=ds.create,Cp=zn.create,jp=on.create,Rp=Sr.create,zp=La.create,Pp=dn.create,Up=Nt.create,Dp=Nt.strictCreate,Mp=hs.create,Lp=Hu.create,Bp=ps.create,Vp=Lr.create,Kp=el.create,qp=Ba.create,Fp=Va.create,Wp=tl.create,Yp=fs.create,Jp=ms.create,Gp=Br.create,Hp=ys.create,Xp=Pn.create,Yc=Lt.create,Qp=_r.create,ef=hn.create,tf=Lt.createWithPreprocess,rf=Fo.create,nf=()=>il().optional(),sf=()=>ol().optional(),af=()=>cl().optional(),of={string:r=>Rn.create({...r,coerce:!0}),number:r=>os.create({...r,coerce:!0}),boolean:r=>cs.create({...r,coerce:!0}),bigint:r=>Mr.create({...r,coerce:!0}),date:r=>us.create({...r,coerce:!0})},cf=ae;var T=Object.freeze({__proto__:null,defaultErrorMap:as,setErrorMap:dp,getErrorMap:Pa,makeIssue:Ua,EMPTY_PATH:hp,addIssueToContext:B,ParseStatus:ot,INVALID:ae,DIRTY:Ju,OK:gt,isAborted:mo,isDirty:yo,isValid:is,isAsync:Da,get util(){return _e},get objectUtil(){return fo},ZodParsedType:D,getParsedType:Cr,ZodType:he,ZodString:Rn,ZodNumber:os,ZodBigInt:Mr,ZodBoolean:cs,ZodDate:us,ZodSymbol:Ma,ZodUndefined:ls,ZodNull:ds,ZodAny:zn,ZodUnknown:on,ZodNever:Sr,ZodVoid:La,ZodArray:dn,ZodObject:Nt,ZodUnion:hs,ZodDiscriminatedUnion:Hu,ZodIntersection:ps,ZodTuple:Lr,ZodRecord:el,ZodMap:Ba,ZodSet:Va,ZodFunction:tl,ZodLazy:fs,ZodLiteral:ms,ZodEnum:Br,ZodNativeEnum:ys,ZodPromise:Pn,ZodEffects:Lt,ZodTransformer:Lt,ZodOptional:_r,ZodNullable:hn,ZodDefault:gs,ZodCatch:Ka,ZodNaN:qa,BRAND:Tp,ZodBranded:nl,ZodPipeline:Fo,ZodReadonly:Fa,custom:al,Schema:he,ZodSchema:he,late:xp,get ZodFirstPartyTypeKind(){return G},coerce:of,any:Cp,array:Pp,bigint:Ep,boolean:cl,date:Ap,discriminatedUnion:Lp,effect:Yc,enum:Gp,function:Wp,instanceof:Sp,intersection:Bp,lazy:Yp,literal:Jp,map:qp,nan:Np,nativeEnum:Hp,never:Rp,null:$p,nullable:ef,number:ol,object:Up,oboolean:af,onumber:sf,optional:Qp,ostring:nf,pipeline:rf,preprocess:tf,promise:Xp,record:Kp,set:Fp,strictObject:Dp,string:il,symbol:Ip,transformer:Yc,tuple:Vp,undefined:Zp,union:Mp,unknown:jp,void:zp,NEVER:cf,ZodIssueCode:Z,quotelessJson:lp,ZodError:Rt});const Wo=T.tuple([T.number(),T.number()]),ul=T.object({width:T.number(),height:T.number()}),uf=T.object({signedWidth:T.number(),signedHeight:T.number()}),lf=["width","height"];T.enum(lf);const df=["start","center","end"],hf=["signedWidth","signedHeight"];T.enum(hf);const Wa=T.object({x:T.number(),y:T.number()}),pf=T.object({clientX:T.number(),clientY:T.number()}),ff=["x","y"],ll=T.enum(ff),dl=["top","right","bottom","left"];T.enum(dl);const mf=["left","right"],hl=T.enum(mf),yf=["top","bottom"],pl=T.enum(yf),fl=["center"],Jc=T.enum(fl),gf=[...dl,...fl],ml=T.enum(gf);T.enum(df);const vf=["first","last"];T.enum(vf);const wf=T.object({lower:T.number(),upper:T.number()});T.union([wf,Wo]);T.union([ll,ml]);T.union([ll,ml,T.instanceof(String)]);const ns=(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),bf(t)},bf=r=>r.lower>r.upper?{lower:r.upper,upper:r.lower}:r;var Et=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 _f(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=_f;var ki={};Object.defineProperty(ki,"__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-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,"_").toLowerCase():""}ki.default=kf;var Oi={};Object.defineProperty(Oi,"__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-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=Of;var Yo={};Object.defineProperty(Yo,"__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-z])([A-Z])/g,function(e,t,n){return t+"_"+n.toLowerCase()}).replace(/[^A-Za-z0-9]+|_+/g,".").toLowerCase():""}Yo.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){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)}Ho.default=Nf;var Xo={};Object.defineProperty(Xo,"__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().replace(/( ?)(\w+)( ?)/g,function(e,t,n,s){return t+n.charAt(0).toUpperCase()+n.slice(1)+s}):""}Xo.default=Ef;var Ti={};Object.defineProperty(Ti,"__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():""}Ti.default=Af;var Qo={},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 If=Et&&Et.__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(Qo,"__esModule",{value:!0});var ar=bn;function ya(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=ya(s,e)):e.recursiveInArray&&ar.isArrayObject(s)&&(s=If(s).map(function(i){var o=i;if(ar.isValidObject(i))ar.belongToTypes(o,e.keepTypesOnRecursion)||(o=ya(i,e));else if(ar.isArrayObject(i)){var c=ya({key:i},e);o=c.key}return o}))),t[a]=s}),t}Qo.default=ya;var ec={},Zf=Et&&Et.__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 ir=bn;function ga(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=ga(s,e)):e.recursiveInArray&&ir.isArrayObject(s)&&(s=Zf(s).map(function(i){var o=i;if(ir.isValidObject(i))ir.belongToTypes(o,e.keepTypesOnRecursion)||(o=ga(i,e));else if(ir.isArrayObject(i)){var c=ga({key:i},e);o=c.key}return o}))),t[a]=s}),t}ec.default=ga;var tc={},$f=Et&&Et.__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 or=bn,Cf=_i;function va(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=Cf.default(n);e.recursive&&(or.isValidObject(s)?or.belongToTypes(s,e.keepTypesOnRecursion)||(s=va(s,e)):e.recursiveInArray&&or.isArrayObject(s)&&(s=$f(s).map(function(i){var o=i;if(or.isValidObject(i))or.belongToTypes(o,e.keepTypesOnRecursion)||(o=va(i,e));else if(or.isArrayObject(i)){var c=va({key:i},e);o=c.key}return o}))),t[a]=s}),t}tc.default=va;var rc={},jf=Et&&Et.__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 cr=bn,Rf=ki;function wa(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=Rf.default(n);e.recursive&&(cr.isValidObject(s)?cr.belongToTypes(s,e.keepTypesOnRecursion)||(s=wa(s,e)):e.recursiveInArray&&cr.isArrayObject(s)&&(s=jf(s).map(function(i){var o=i;if(cr.isValidObject(i))cr.belongToTypes(o,e.keepTypesOnRecursion)||(o=wa(i,e));else if(cr.isArrayObject(i)){var c=wa({key:i},e);o=c.key}return o}))),t[a]=s}),t}rc.default=wa;var nc={},zf=Et&&Et.__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 ur=bn,Pf=Oi;function ba(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=Pf.default(n);e.recursive&&(ur.isValidObject(s)?ur.belongToTypes(s,e.keepTypesOnRecursion)||(s=ba(s,e)):e.recursiveInArray&&ur.isArrayObject(s)&&(s=zf(s).map(function(i){var o=i;if(ur.isValidObject(i))ur.belongToTypes(o,e.keepTypesOnRecursion)||(o=ba(i,e));else if(ur.isArrayObject(i)){var c=ba({key:i},e);o=c.key}return o}))),t[a]=s}),t}nc.default=ba;var sc={},Uf=Et&&Et.__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 lr=bn,Df=Ti;function _a(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=_a(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=_a(i,e));else if(lr.isArrayObject(i)){var c=_a({key:i},e);o=c.key}return o}))),t[a]=s}),t}sc.default=_a;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=Yo;me.toDotCase=wl.default;var bl=Jo;me.toPathCase=bl.default;var _l=Go;me.toTextCase=_l.default;var kl=Ho;me.toSentenceCase=kl.default;var Ol=Xo;me.toHeaderCase=Ol.default;var Tl=Ti;me.toKebabCase=Tl.default;var xl=Qo;me.lowerKeys=xl.default;var Sl=ec;me.upperKeys=Sl.default;var Nl=tc;me.camelKeys=Nl.default;var El=rc;me.snakeKeys=El.default;var Al=nc;me.pascalKeys=Al.default;var Il=sc;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 Mf={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=Mf;var Cl=me;const jl={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},Lf=r=>Cl.snakeKeys(r,jl),Bf=r=>Cl.camelKeys(r,jl);var Un;(r=>{r.toSnake=Lf,r.toCamel=Bf,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Un||(Un={}));T.object({x:hl.or(Jc),y:pl.or(Jc)});const Vf=T.object({x:hl,y:pl}),Kf=Object.freeze({x:"left",y:"top"}),qf=(r,e)=>r.x===e.x&&r.y===e.y,Gc=T.union([T.number(),Wa,Wo,ul,uf,pf]),Ff=(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},ia=T.union([T.number(),T.string()]);T.object({top:ia,left:ia,width:ia,height:ia});T.object({left:T.number(),top:T.number(),right:T.number(),bottom:T.number()});T.object({one:Wa,two:Wa,root:Vf});const ac=(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))},qi=r=>{const e=ac(r);return{lower:e.one.x,upper:e.two.x}},Fi=r=>{const e=ac(r);return{lower:e.one.y,upper:e.two.y}},Wf=r=>typeof r!="object"||r==null?!1:"one"in r&&"two"in r&&"root"in r,Yf=T.object({signedWidth:T.number(),signedHeight:T.number()});T.union([ul,Yf,Wa,Wo]);const Jf=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);T.object({offset:Gc,scale:Gc});const Gf=r=>(e,t,n,s)=>t==="dimension"?[e,n]:[e,s?n-r:n+r],Hf=r=>(e,t,n,s)=>[e,s?n/r:n*r],Xf=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 g=(n-s)*(l/c)+i;return[r,g]},Qf=r=>(e,t,n)=>[r,n],em=()=>(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)]},tm=r=>(e,t,n)=>{const{lower:s,upper:a}=r;return n=Jf(n,s,a),[e,n]},_o=class Qn{constructor(){S(this,"ops",[]),S(this,"currBounds",null),S(this,"currType",null),S(this,"reversed",!1),this.ops=[]}static translate(e){return new Qn().translate(e)}static magnify(e){return new Qn().magnify(e)}static scale(e,t){return new Qn().scale(e,t)}translate(e){const t=this.new(),n=Gf(e);return n.type="translate",t.ops.push(n),t}magnify(e){const t=this.new(),n=Hf(e);return n.type="magnify",t.ops.push(n),t}scale(e,t){const n=ns(e,t),s=this.new(),a=Xf(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=ns(e,t),s=this.new(),a=tm(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=ns(e,t),s=this.new(),a=Qf(n);return a.type="re-bound",s.ops.push(a),s}invert(){const e=em();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 Qn;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}};S(_o,"IDENTITY",new _o);let Xc=_o;const Qc=class gr{constructor(e=new Xc,t=new Xc,n=null){S(this,"x"),S(this,"y"),S(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=Ff(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(Wf(e)){const n=this.currRoot;return t.currRoot=e.root,n!=null&&!qf(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(qi(e)),t.y=t.y.scale(Fi(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(qi(e)),t.y=this.y.reBound(Fi(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(qi(e)),t.y=this.y.clamp(Fi(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 ac(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};S(Qc,"IDENTITY",new Qc);const Rl=(r,e)=>{const t=new je(e);if(![Pe.DAY,Pe.HOUR,Pe.MINUTE,Pe.SECOND,Pe.MILLISECOND,Pe.MICROSECOND,Pe.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 je?new je(n):new Pe(n)},Ee=class ne{constructor(e,t="UTC"){if(S(this,"value"),S(this,"encodeValue",!0),e==null)this.value=ne.now().valueOf();else if(e instanceof Date)this.value=BigInt(e.getTime())*ne.MILLISECOND.valueOf();else if(typeof e=="string")this.value=ne.parseDateTimeString(e,t).valueOf();else if(Array.isArray(e))this.value=ne.parseDate(e);else{let n=BigInt(0);e instanceof Number&&(e=e.valueOf()),t==="local"&&(n=ne.utcOffset.valueOf()),typeof e=="number"&&(isFinite(e)?e=Math.trunc(e):(isNaN(e)&&(e=0),e===1/0?e=ne.MAX:e=ne.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 ne(BigInt(s.getTime())*ne.MILLISECOND.valueOf()).truncate(ne.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=ne.hours(parseInt(n??"00",10)).add(ne.minutes(parseInt(s??"00",10))).add(ne.seconds(parseInt(i??"00",10))).add(ne.milliseconds(parseInt(o??"00",10)));return t==="local"&&(c=c.add(ne.utcOffset)),c.valueOf()}static parseDateTimeString(e,t="UTC"){if(!e.includes("/")&&!e.includes("-"))return ne.parseTimeString(e,t);const n=new Date(e);return e.includes(":")||n.setUTCHours(0,0,0,0),new ne(BigInt(n.getTime())*ne.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(ne.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 Pe(BigInt(new Date().getTimezoneOffset())*ne.MINUTE.valueOf())}static since(e){return new ne().span(e)}date(){return new Date(this.milliseconds())}equals(e){return this.valueOf()===new ne(e).valueOf()}span(e){return this.range(e).span}range(e){return new Zt(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 ne(e).valueOf()}afterEq(e){return this.valueOf()>=new ne(e).valueOf()}before(e){return this.valueOf()<new ne(e).valueOf()}beforeEq(e){return this.valueOf()<=new ne(e).valueOf()}add(e){return new ne(this.valueOf()+BigInt(e.valueOf()))}sub(e){return new ne(this.valueOf()-BigInt(e.valueOf()))}milliseconds(){return Number(this.valueOf()/ne.MILLISECOND.valueOf())}toString(){return this.date().toISOString()}remainder(e){return Rl(this,e)}get isToday(){return this.truncate(Pe.DAY).equals(ne.now().truncate(Pe.DAY))}truncate(e){return this.sub(this.remainder(e))}static now(){return new ne(new Date)}static max(...e){let t=ne.MIN;for(const n of e){const s=new ne(n);s.after(t)&&(t=s)}return t}static min(...e){let t=ne.MAX;for(const n of e){const s=new ne(n);s.before(t)&&(t=s)}return t}static nanoseconds(e){return new ne(e)}static microseconds(e){return ne.nanoseconds(e*1e3)}static milliseconds(e){return ne.microseconds(e*1e3)}static seconds(e){return ne.milliseconds(e*1e3)}static minutes(e){return ne.seconds(e*60)}static hours(e){return ne.minutes(e*60)}static days(e){return ne.hours(e*24)}};S(Ee,"NANOSECOND",Ee.nanoseconds(1)),S(Ee,"MICROSECOND",Ee.microseconds(1)),S(Ee,"MILLISECOND",Ee.milliseconds(1)),S(Ee,"SECOND",Ee.seconds(1)),S(Ee,"MINUTE",Ee.minutes(1)),S(Ee,"HOUR",Ee.hours(1)),S(Ee,"DAY",Ee.days(1)),S(Ee,"MAX",new Ee((1n<<63n)-1n)),S(Ee,"MIN",new Ee(0)),S(Ee,"ZERO",new Ee(0)),S(Ee,"z",T.union([T.object({value:T.bigint()}).transform(r=>new Ee(r.value)),T.string().transform(r=>new Ee(BigInt(r))),T.instanceof(Number).transform(r=>new Ee(r)),T.number().transform(r=>new Ee(r)),T.instanceof(Ee)]));let je=Ee;const Ae=class Te{constructor(e){S(this,"value"),S(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),g=n.sub(t),E=s.sub(n),Q=a.sub(s),ce=i.sub(a),Ne=o.sub(i);let ee="";return c.isZero||(ee+=`${c.days}d `),l.isZero||(ee+=`${l.hours}h `),g.isZero||(ee+=`${g.minutes}m `),E.isZero||(ee+=`${E.seconds}s `),Q.isZero||(ee+=`${Q.milliseconds}ms `),ce.isZero||(ee+=`${ce.microseconds}µs `),Ne.isZero||(ee+=`${Ne.nanoseconds}ns`),ee.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)}};S(Ae,"NANOSECOND",Ae.nanoseconds(1)),S(Ae,"MICROSECOND",Ae.microseconds(1)),S(Ae,"MILLISECOND",Ae.milliseconds(1)),S(Ae,"SECOND",Ae.seconds(1)),S(Ae,"MINUTE",Ae.minutes(1)),S(Ae,"HOUR",Ae.hours(1)),S(Ae,"DAY",Ae.days(1)),S(Ae,"MAX",new Ae((1n<<63n)-1n)),S(Ae,"MIN",new Ae(0)),S(Ae,"ZERO",new Ae(0)),S(Ae,"z",T.union([T.object({value:T.bigint()}).transform(r=>new Ae(r.value)),T.string().transform(r=>new Ae(BigInt(r))),T.instanceof(Number).transform(r=>new Ae(r)),T.number().transform(r=>new Ae(r)),T.instanceof(Ae)]));let Pe=Ae;const es=class ka extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new ka(e).valueOf()}get period(){return Pe.seconds(1/this.valueOf())}sampleCount(e){return new Pe(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new it(t).valueOf()}span(e){return Pe.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new ka(e)}static khz(e){return ka.hz(e*1e3)}};S(es,"z",T.union([T.number().transform(r=>new es(r)),T.instanceof(Number).transform(r=>new es(r)),T.instanceof(es)]));let xi=es;const et=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())}};S(et,"UNKNOWN",new et(0)),S(et,"BIT128",new et(16)),S(et,"BIT64",new et(8)),S(et,"BIT32",new et(4)),S(et,"BIT16",new et(2)),S(et,"BIT8",new et(1)),S(et,"z",T.union([T.number().transform(r=>new et(r)),T.instanceof(Number).transform(r=>new et(r)),T.instanceof(et)]));let it=et;const Kt=class Oa{constructor(e,t){S(this,"start"),S(this,"end"),this.start=new je(e),this.end=new je(t)}get span(){return new Pe(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 Oa(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 Oa?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Oa(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}};S(Kt,"MAX",new Kt(je.MIN,je.MAX)),S(Kt,"MIN",new Kt(je.MAX,je.MIN)),S(Kt,"ZERO",new Kt(je.ZERO,je.ZERO)),S(Kt,"z",T.union([T.object({start:je.z,end:je.z}).transform(r=>new Kt(r.start,r.end)),T.instanceof(Kt)]));let Zt=Kt;const N=class sn extends String{constructor(e){if(e instanceof sn||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=sn.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(sn.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=sn.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 density(){const e=sn.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 sn.BIG_INT_TYPES.some(e=>e.equals(this))}};S(N,"UNKNOWN",new N("unknown")),S(N,"FLOAT64",new N("float64")),S(N,"FLOAT32",new N("float32")),S(N,"INT64",new N("int64")),S(N,"INT32",new N("int32")),S(N,"INT16",new N("int16")),S(N,"INT8",new N("int8")),S(N,"UINT64",new N("uint64")),S(N,"UINT32",new N("uint32")),S(N,"UINT16",new N("uint16")),S(N,"UINT8",new N("uint8")),S(N,"TIMESTAMP",new N("timestamp")),S(N,"UUID",new N("uuid")),S(N,"STRING",new N("string")),S(N,"JSON",new N("json")),S(N,"ARRAY_CONSTRUCTORS",new Map([[N.UINT8.toString(),Uint8Array],[N.UINT16.toString(),Uint16Array],[N.UINT32.toString(),Uint32Array],[N.UINT64.toString(),BigUint64Array],[N.FLOAT32.toString(),Float32Array],[N.FLOAT64.toString(),Float64Array],[N.INT8.toString(),Int8Array],[N.INT16.toString(),Int16Array],[N.INT32.toString(),Int32Array],[N.INT64.toString(),BigInt64Array],[N.TIMESTAMP.toString(),BigInt64Array],[N.STRING.toString(),Uint8Array],[N.JSON.toString(),Uint8Array],[N.UUID.toString(),Uint8Array]])),S(N,"ARRAY_CONSTRUCTOR_DATA_TYPES",new Map([[Uint8Array.name,N.UINT8],[Uint16Array.name,N.UINT16],[Uint32Array.name,N.UINT32],[BigUint64Array.name,N.UINT64],[Float32Array.name,N.FLOAT32],[Float64Array.name,N.FLOAT64],[Int8Array.name,N.INT8],[Int16Array.name,N.INT16],[Int32Array.name,N.INT32],[BigInt64Array.name,N.INT64]])),S(N,"DENSITIES",new Map([[N.UINT8.toString(),it.BIT8],[N.UINT16.toString(),it.BIT16],[N.UINT32.toString(),it.BIT32],[N.UINT64.toString(),it.BIT64],[N.FLOAT32.toString(),it.BIT32],[N.FLOAT64.toString(),it.BIT64],[N.INT8.toString(),it.BIT8],[N.INT16.toString(),it.BIT16],[N.INT32.toString(),it.BIT32],[N.INT64.toString(),it.BIT64],[N.TIMESTAMP.toString(),it.BIT64],[N.STRING.toString(),it.UNKNOWN],[N.JSON.toString(),it.UNKNOWN],[N.UUID.toString(),it.BIT128]])),S(N,"ALL",[N.UNKNOWN,N.FLOAT64,N.FLOAT32,N.INT64,N.INT32,N.INT16,N.INT8,N.UINT64,N.UINT32,N.UINT16,N.UINT8,N.TIMESTAMP,N.UUID,N.STRING,N.JSON]),S(N,"BIG_INT_TYPES",[N.INT64,N.UINT64,N.TIMESTAMP]),S(N,"z",T.union([T.string().transform(r=>new N(r)),T.instanceof(N)]));let rt=N;const st=class qe extends Number{constructor(e){super(e.valueOf())}largerThan(e){return this.valueOf()>e.valueOf()}smallerThan(e){return this.valueOf()<e.valueOf()}add(e){return qe.bytes(this.valueOf()+e.valueOf())}sub(e){return qe.bytes(this.valueOf()-e.valueOf())}truncate(e){return new qe(Math.trunc(this.valueOf()/e.valueOf())*e.valueOf())}remainder(e){return qe.bytes(this.valueOf()%e.valueOf())}get gigabytes(){return this.valueOf()/qe.GIGABYTE.valueOf()}get megabytes(){return this.valueOf()/qe.MEGABYTE.valueOf()}get kilobytes(){return this.valueOf()/qe.KILOBYTE.valueOf()}get terabytes(){return this.valueOf()/qe.TERABYTE.valueOf()}toString(){const e=this.truncate(qe.TERABYTE),t=this.truncate(qe.GIGABYTE),n=this.truncate(qe.MEGABYTE),s=this.truncate(qe.KILOBYTE),a=this.truncate(qe.BYTE),i=e,o=t.sub(e),c=n.sub(t),l=s.sub(n),g=a.sub(s);let E="";return i.isZero||(E+=`${i.terabytes}TB `),o.isZero||(E+=`${o.gigabytes}GB `),c.isZero||(E+=`${c.megabytes}MB `),l.isZero||(E+=`${l.kilobytes}KB `),(!g.isZero||E==="")&&(E+=`${g.valueOf()}B`),E.trim()}static bytes(e=1){return new qe(e)}static kilobytes(e=1){return qe.bytes(e.valueOf()*1e3)}static megabytes(e=1){return qe.kilobytes(e.valueOf()*1e3)}static gigabytes(e=1){return qe.megabytes(e.valueOf()*1e3)}static terabytes(e){return qe.gigabytes(e.valueOf()*1e3)}get isZero(){return this.valueOf()===0}};S(st,"BYTE",new st(1)),S(st,"KILOBYTE",st.kilobytes(1)),S(st,"MEGABYTE",st.megabytes(1)),S(st,"GIGABYTE",st.gigabytes(1)),S(st,"TERABYTE",st.terabytes(1)),S(st,"ZERO",new st(0)),S(st,"z",T.union([T.number().transform(r=>new st(r)),T.instanceof(st)]));let Ya=st;T.union([T.instanceof(Uint8Array),T.instanceof(Uint16Array),T.instanceof(Uint32Array),T.instanceof(BigUint64Array),T.instanceof(Float32Array),T.instanceof(Float64Array),T.instanceof(Int8Array),T.instanceof(Int16Array),T.instanceof(Int32Array),T.instanceof(BigInt64Array)]);const rm=(r,e,t,n=0)=>r.usesBigInt&&!e.usesBigInt?Number(t)-Number(n):!r.usesBigInt&&e.usesBigInt?BigInt(t)-BigInt(n):ts(t,-n),tn=-1;let ic=class Ar{constructor({data:e,dataType:t,timeRange:n,sampleOffset:s=0,glBufferUsage:a="static",alignment:i=0,key:o=ip()}){if(S(this,"key",""),S(this,"dataType"),S(this,"sampleOffset"),S(this,"gl"),S(this,"_data"),S(this,"_timeRange"),S(this,"alignment",0),S(this,"_min"),S(this,"_max"),S(this,"writePos",tn),S(this,"_refCount",0),t==null&&!(e instanceof ArrayBuffer))this.dataType=new rt(e);else if(t!=null)this.dataType=new rt(t);else throw new Error("must provide a data type when constructing a Series from a buffer");this.key=o,this.alignment=i,this.sampleOffset=s??0,this._data=e,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 rt(t).Array(e),a=new Ar({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 Ar({data:a,dataType:rt.TIMESTAMP,timeRange:s})}get refCount(){return this._refCount}static fromStrings(e,t){const n=new TextEncoder().encode(e.join(`
2
2
  `)+`
3
3
  `);return new Ar({data:n,dataType:rt.STRING,timeRange:t})}static fromJSON(e,t){const n=new TextEncoder().encode(e.map(s=>JSON.stringify(s)).join(`
4
4
  `)+`
5
5
  `);return new Ar({data:n,dataType:rt.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.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(rt.STRING))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
6
6
  `).slice(0,-1)}toUUIDs(){if(!this.dataType.equals(rt.UUID))throw new Error("cannot convert non-uuid series to uuids");const e=rt.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(rt.JSON))throw new Error("cannot convert non-string series to strings");return new TextDecoder().decode(this.buffer).split(`
7
- `).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.writePos===tn?this.data.length:this.writePos}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]=rm(this.dataType,e,this.data[s],t);return new Ar({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(rt.TIMESTAMP))this._max=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._max=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._max=e.reduce((t,n)=>t>n?t:n)}return this._max}get max(){return this.writePos===0?-1/0:(this._max==null&&(this._max=this.calcRawMax()),ts(this._max,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(rt.TIMESTAMP))this._min=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._min=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._min=e.reduce((t,n)=>t<n?t:n)}return this._min}get min(){return this.writePos===0?1/0:(this._min==null&&(this._min=this.calcRawMin()),ts(this._min,this.sampleOffset))}get bounds(){return ns(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._min!=null){const t=e._min??e.calcRawMin();t<this._min&&(this._min=t)}if(this._max!=null){const t=e._max??e.calcRawMax();t>this._max&&(this._max=t)}}enrich(){this.max,this.min}get range(){return ts(this.max,-this.min)}at(e,t){e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t)throw new Error(`[series] - no value at index ${e}`);return}return ts(n,this.sampleOffset)}binarySearch(e){let t=0,n=this.length-1;const s=cp(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(rt.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}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 ns(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 Ar({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+e})}reAlign(e){return new Ar({data:this.buffer,dataType:this.dataType,timeRange:Zt.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};const ts=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:Number(r)+Number(e),oc=T.record(T.union([T.number(),T.string(),T.symbol()]),T.unknown()),zl=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),nm=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";nm();const sm=["MacOS","Windows","Linux","Docker"];T.enum(sm);const am=(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)],im=(...r)=>r.map(Pl).join(""),Pl=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),om=r=>r.endsWith("/")?r.slice(0,-1):r;var kn;let cm=(kn=class{constructor({host:r,port:e,protocol:t="",pathPrefix:n=""}){S(this,"protocol"),S(this,"host"),S(this,"port"),S(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:im(this.path,r)})}toString(){return om(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},S(kn,"UNKNOWN",new kn({host:"unknown",port:0})),kn);const Ne=r=>Array.isArray(r)?r:[r];var ko;try{ko=new TextDecoder}catch{}var z,xt,p=0,Re={},we,zr,Ot=0,Wt=0,Ge,kr,_t=[],ge,tu={useRecords:!1,mapsAsObjects:!0};let Ul=class{};const Dl=new Ul;Dl.name="MessagePack 0xC1";var Ur=!1,Ml=2,ru;try{new Function("")}catch{Ml=1/0}let Ll=class Oo{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(()=>(xo(),this?this.unpack(e,t):Oo.prototype.unpack.call(tu,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(xt=t.end||e.length,p=t.start||0):(p=0,xt=t>-1?t:e.length),Wt=0,zr=null,Ge=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 Oo){if(Re=this,this.structures)return we=this.structures,oa(t);(!we||we.length>0)&&(we=[])}else Re=tu,(!we||we.length>0)&&(we=[]);return oa(t)}unpackMultiple(e,t){let n,s=0;try{Ur=!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(oa(),s,p)===!1)return}else{for(n=[i];p<a;)s=p,n.push(oa());return n}}catch(a){throw a.lastPosition=s,a.values=n,a}finally{Ur=!1,xo()}}_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 oa(r){try{if(!Re.trusted&&!Ur){let t=we.sharedLength||0;t<we.length&&(we.length=t)}let e;if(Re.randomAccessStructure&&z[p]<64&&z[p]>=32&&ru?(e=ru(z,p,xt,Re),z=null,!(r&&r.lazy)&&e&&(e=e.toJSON()),p=xt):e=Be(),Ge&&(p=Ge.postBundlePosition,Ge=null),Ur&&(we.restoreStructures=null),p==xt)we&&we.restoreStructures&&nu(),we=null,z=null,kr&&(kr=null);else{if(p>xt)throw new Error("Unexpected end of MessagePack data");if(!Ur){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(),xo(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||p>xt)&&(e.incomplete=!0),e}}function nu(){for(let r in we.restoreStructures)we[r]=we.restoreStructures[r];we.restoreStructures=null}function Be(){let r=z[p++];if(r<160)if(r<128){if(r<64)return r;{let e=we[r&63]||Re.getStructures&&Bl()[r&63];return e?(e.read||(e.read=cc(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,Re.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Kl();n==="__proto__"&&(n="__proto_"),e[n]=Be()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Be(),Be());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Be();return Re.freezeData?Object.freeze(e):e}else if(r<192){let e=r-160;if(Wt>=p)return zr.slice(p-Ot,(p+=e)-Ot);if(Wt==0&&xt<140){let t=e<16?uc(e):Vl(e);if(t!=null)return t}return To(e)}else{let e;switch(r){case 192:return null;case 193:return Ge?(e=Be(),e>0?Ge[1].slice(Ge.position1,Ge.position1+=e):Ge[0].slice(Ge.position0,Ge.position0-=e)):Dl;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 Wi(e);case 197:return e=ge.getUint16(p),p+=2,Wi(e);case 198:return e=ge.getUint32(p),p+=4,Wi(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),Re.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 Re.int64AsType==="number"?(e=ge.getUint32(p)*4294967296,e+=ge.getUint32(p+4)):Re.int64AsType==="string"?e=ge.getBigUint64(p).toString():Re.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 Re.int64AsType==="number"?(e=ge.getInt32(p)*4294967296,e+=ge.getUint32(p+4)):Re.int64AsType==="string"?e=ge.getBigInt64(p).toString():Re.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=_t[e];if(t)return t.read?(p++,t.read(Be())):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++],Wt>=p?zr.slice(p-Ot,(p+=e)-Ot):lm(e);case 218:return e=ge.getUint16(p),p+=2,Wt>=p?zr.slice(p-Ot,(p+=e)-Ot):dm(e);case 219:return e=ge.getUint32(p),p+=4,Wt>=p?zr.slice(p-Ot,(p+=e)-Ot):hm(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 um=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function cc(r,e){function t(){if(t.count++>Ml){let s=r.read=new Function("r","return function(){return "+(Re.freezeData?"Object.freeze":"")+"({"+r.map(a=>a==="__proto__"?"__proto_:r()":um.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"})}")(Be);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]=Be()}return Re.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,Re.getStructures()));return we=Re._mergeStructures(r,we)}var To=Ys,lm=Ys,dm=Ys,hm=Ys;function Ys(r){let e;if(r<16&&(e=uc(r)))return e;if(r>64&&ko)return ko.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+=Ye.apply(String,n),n.length=0)}return n.length>0&&(e+=Ye.apply(String,n)),e}function au(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Be();return Re.freezeData?Object.freeze(e):e}function iu(r){if(Re.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Kl();n==="__proto__"&&(n="__proto_"),e[n]=Be()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Be(),Be());return e}}var Ye=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 Ye.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 Ye(e)}}else{let e=z[p++],t=z[p++];if((e&128)>0||(t&128)>0){p-=2;return}if(r<3)return Ye(e,t);let n=z[p++];if((n&128)>0){p-=3;return}return Ye(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 Ye(e,t,n,s);{let a=z[p++];if((a&128)>0){p-=5;return}return Ye(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 Ye(e,t,n,s,a,i);let o=z[p++];if((o&128)>0){p-=7;return}return Ye(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 Ye(e,t,n,s,a,i,o,c);{let l=z[p++];if((l&128)>0){p-=9;return}return Ye(e,t,n,s,a,i,o,c,l)}}else if(r<12){let l=z[p++],g=z[p++];if((l&128)>0||(g&128)>0){p-=10;return}if(r<11)return Ye(e,t,n,s,a,i,o,c,l,g);let E=z[p++];if((E&128)>0){p-=11;return}return Ye(e,t,n,s,a,i,o,c,l,g,E)}else{let l=z[p++],g=z[p++],E=z[p++],Q=z[p++];if((l&128)>0||(g&128)>0||(E&128)>0||(Q&128)>0){p-=12;return}if(r<14){if(r===12)return Ye(e,t,n,s,a,i,o,c,l,g,E,Q);{let ce=z[p++];if((ce&128)>0){p-=13;return}return Ye(e,t,n,s,a,i,o,c,l,g,E,Q,ce)}}else{let ce=z[p++],Se=z[p++];if((ce&128)>0||(Se&128)>0){p-=14;return}if(r<15)return Ye(e,t,n,s,a,i,o,c,l,g,E,Q,ce,Se);let ee=z[p++];if((ee&128)>0){p-=15;return}return Ye(e,t,n,s,a,i,o,c,l,g,E,Q,ce,Se,ee)}}}}}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 Ys(e)}function Wi(r){return Re.copyBuffers?Uint8Array.prototype.slice.call(z,p,p+=r):z.subarray(p,p+=r)}function rn(r){let e=z[p++];if(_t[e]){let t;return _t[e](z.subarray(p,t=p+=r),n=>{p=n;try{return Be()}finally{p=t}})}else throw new Error("Unknown extension type "+e)}var cu=new Array(4096);function Kl(){let r=z[p++];if(r>=160&&r<192){if(r=r-160,Wt>=p)return zr.slice(p-Ot,(p+=r)-Ot);if(!(Wt==0&&xt<180))return To(r)}else return p--,Be().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=To(r)}const uu=(r,e)=>{let t=Be().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||Ur)&&((we.restoreStructures||(we.restoreStructures=[]))[r]=s),we[r]=t,t.read=cc(t,n),t.read()};_t[0]=()=>{};_t[0].noBuffer=!0;let pm={Error,TypeError,ReferenceError};_t[101]=()=>{let r=Be();return(pm[r[0]]||Error)(r[1])};_t[105]=r=>{let e=ge.getUint32(p-4);kr||(kr=new Map);let t=z[p],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};kr.set(e,s);let a=Be();return s.used?Object.assign(n,a):(s.target=a,a)};_t[112]=r=>{let e=ge.getUint32(p-4),t=kr.get(e);return t.used=!0,t.target};_t[115]=()=>new Set(Be());const ql=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");let fm=typeof globalThis=="object"?globalThis:window;_t[116]=r=>{let e=r[0],t=ql[e];if(!t)throw new Error("Could not find typed array for code "+e);return new fm[t](Uint8Array.prototype.slice.call(r,1).buffer)};_t[120]=()=>{let r=Be();return new RegExp(r[0],r[1])};const mm=[];_t[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=p;return p+=e-r.length,Ge=mm,Ge=[ou(),ou()],Ge.position0=0,Ge.position1=0,Ge.postBundlePosition=p,p=t,Be()};_t[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=xt,t=p,n=Ot,s=Wt,a=zr,i=kr,o=Ge,c=new Uint8Array(z.slice(0,xt)),l=we,g=we.slice(0,we.length),E=Re,Q=Ur,ce=r();return xt=e,p=t,Ot=n,Wt=s,zr=a,kr=i,Ge=o,z=c,Ur=Q,we=l,we.splice(0,we.length,...g),Re=E,ge=new DataView(z.buffer,z.byteOffset,z.byteLength),ce}function xo(){z=null,kr=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 Ll({useRecords:!1});const ym=Si.unpack;Si.unpackMultiple;Si.unpack;let gm=new Float32Array(1);new Uint8Array(gm.buffer,0,4);let Ta;try{Ta=new TextEncoder}catch{}let So,Wl;const Ni=typeof Buffer<"u",ca=Ni?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,Yl=Ni?Buffer:Uint8Array,lu=Ni?4294967296:2144337920;let b,Gn,Ie,v=0,ht,Ue=null,vm;const wm=21760,bm=/[\u0080-\uFFFF]/,On=Symbol("record-id");let _m=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)}:Ta&&Ta.encodeInto?function(d,O){return Ta.encodeInto(d,b.subarray(O)).written}:!1,o=this;e||(e={});let c=e&&e.sequential,l=e.structures||e.saveStructures,g=e.maxSharedStructures;if(g==null&&(g=l?32:0),g>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let E=e.maxOwnStructures;E==null&&(E=l?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let Q=g>32||E+g>64,ce=g+64,Se=g+E+64;if(Se>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let ee=[],rr=0,nr=0;this.pack=this.encode=function(d,O){if(b||(b=new ca(8192),Ie=b.dataView||(b.dataView=new DataView(b.buffer,0,8192)),v=0),ht=b.length-10,ht-v<2048?(b=new ca(b.length),Ie=b.dataView||(b.dataView=new DataView(b.buffer,0,b.length)),ht=b.length-10,v=0):v=v+7&2147483640,t=v,O&Em&&(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 m=s.sharedLength||0;if(m>g)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 y=0;y<m;y++){let k=s[y];if(!k)continue;let R,U=s.transitions;for(let I=0,re=k.length;I<re;I++){let q=k[I];R=U[q],R||(R=U[q]=Object.create(null)),U=R}U[On]=y+64}this.lastNamedStructuresLength=m}c||(s.nextId=m+64)}n&&(n=!1);try{o.randomAccessStructure&&d&&d.constructor&&d.constructor===Object?Vi(d):te(d);let m=Ue;if(Ue&&pu(t,te,0),a&&a.idsToInsert){let y=a.idsToInsert.sort((I,re)=>I.offset>re.offset?1:-1),k=y.length,R=-1;for(;m&&k>0;){let I=y[--k].offset+t;I<m.stringsPosition+t&&R===-1&&(R=0),I>m.position+t?R>=0&&(R+=6):(R>=0&&(Ie.setUint32(m.position+t,Ie.getUint32(m.position+t)+R),R=-1),m=m.previous,k++)}R>=0&&m&&Ie.setUint32(m.position+t,Ie.getUint32(m.position+t)+R),v+=y.length*6,v>ht&&Xe(v),o.offset=v;let U=Om(b.subarray(t,v),y);return a=null,U}return o.offset=v,O&Sm?(b.start=t,b.end=v,b):b.subarray(t,v)}finally{if(s&&(qn(),n&&o.saveStructures)){let m=s.sharedLength||0,y=b.subarray(t,v),k=Tm(s,o);return o.saveStructures(k,k.isCompatible)===!1?o.pack(d,O):(o.lastNamedStructuresLength=m,y)}O&Nm&&(v=t)}};const qn=()=>{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,ee.length>0&&(ee=[]);else if(ee.length>0&&!c){for(let O=0,m=ee.length;O<m;O++)ee[O][On]=0;ee=[]}},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,Ie.setUint32(v,O),v+=4);for(let m=0;m<O;m++)te(d[m])},te=d=>{v>ht&&(b=Xe(v));var O=typeof d,m;if(O==="string"){let y=d.length;if(Ue&&y>=4&&y<4096){if((Ue.size+=y)>wm){let I,re=(Ue[0]?Ue[0].length*3+Ue[1].length:0)+10;v+re>ht&&(b=Xe(v+re));let q;Ue.position?(q=Ue,b[v]=200,v+=3,b[v++]=98,I=v-t,v+=4,pu(t,te,0),Ie.setUint16(I+t-3,v-t-I)):(b[v++]=214,b[v++]=98,I=v-t,v+=4),Ue=["",""],Ue.previous=q,Ue.size=0,Ue.position=I}let U=bm.test(d);Ue[U?0:1]+=d,b[v++]=193,te(U?-y:y);return}let k;y<32?k=1:y<256?k=2:y<65536?k=3:k=5;let R=y*3;if(v+R>ht&&(b=Xe(v+R)),y<64||!i){let U,I,re,q=v+k;for(U=0;U<y;U++)I=d.charCodeAt(U),I<128?b[q++]=I:I<2048?(b[q++]=I>>6|192,b[q++]=I&63|128):(I&64512)===55296&&((re=d.charCodeAt(U+1))&64512)===56320?(I=65536+((I&1023)<<10)+(re&1023),U++,b[q++]=I>>18|240,b[q++]=I>>12&63|128,b[q++]=I>>6&63|128,b[q++]=I&63|128):(b[q++]=I>>12|224,b[q++]=I>>6&63|128,b[q++]=I&63|128);m=q-v-k}else m=i(d,v+k);m<32?b[v++]=160|m:m<256?(k<2&&b.copyWithin(v+2,v+1,v+1+m),b[v++]=217,b[v++]=m):m<65536?(k<3&&b.copyWithin(v+3,v+2,v+2+m),b[v++]=218,b[v++]=m>>8,b[v++]=m&255):(k<5&&b.copyWithin(v+5,v+3,v+3+m),b[v++]=219,Ie.setUint32(v,m),v+=4),v+=m}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,Ie.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,Ie.setInt16(v,d),v+=2):(b[v++]=210,Ie.setInt32(v,d),v+=4);else{let y;if((y=this.useFloat32)>0&&d<4294967296&&d>=-2147483648){b[v++]=202,Ie.setFloat32(v,d);let k;if(y<4||(k=d*lc[(b[v]&127)<<1|b[v+1]>>7])>>0===k){v+=4;return}else v--}b[v++]=203,Ie.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,Ie.setUint32(v,k.id),v+=4;return}else a.set(d,{offset:v-t})}let y=d.constructor;if(y===Object)sr(d,!0);else if(y===Array)Qr(d);else if(y===Map)if(this.mapAsEmptyObject)b[v++]=128;else{m=d.size,m<16?b[v++]=128|m:m<65536?(b[v++]=222,b[v++]=m>>8,b[v++]=m&255):(b[v++]=223,Ie.setUint32(v,m),v+=4);for(let[k,R]of d)te(k),te(R)}else{for(let k=0,R=So.length;k<R;k++){let U=Wl[k];if(d instanceof U){let I=So[k];if(I.write){I.type&&(b[v++]=212,b[v++]=I.type,b[v++]=0);let Qe=I.write.call(this,d);Qe===d?Array.isArray(d)?Qr(d):sr(d):te(Qe);return}let re=b,q=Ie,Ke=v;b=null;let dt;try{dt=I.pack.call(this,d,Qe=>(b=re,re=null,v+=Qe,v>ht&&Xe(v),{target:b,targetView:Ie,position:v-Qe}),te)}finally{re&&(b=re,Ie=q,v=Ke,ht=b.length-10)}dt&&(dt.length+v>ht&&Xe(dt.length+v),v=km(dt,b,v,I.type));return}}if(Array.isArray(d))Qr(d);else{if(d.toJSON){const k=d.toJSON();if(k!==d)return te(k)}if(O==="function")return te(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,Ie.setBigInt64(v,d);else if(d<BigInt(1)<<BigInt(64)&&d>0)b[v++]=207,Ie.setBigUint64(v,d);else if(this.largeBigIntToFloat)b[v++]=203,Ie.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)},Fn=this.variableMapSize||this.coercibleKeyAsNumber?d=>{let O=Object.keys(d),m=O.length;m<16?b[v++]=128|m:m<65536?(b[v++]=222,b[v++]=m>>8,b[v++]=m&255):(b[v++]=223,Ie.setUint32(v,m),v+=4);let y;if(this.coercibleKeyAsNumber)for(let k=0;k<m;k++){y=O[k];let R=Number(y);te(isNaN(R)?y:R),te(d[y])}else for(let k=0;k<m;k++)te(y=O[k]),te(d[y])}:(d,O)=>{b[v++]=222;let m=v-t;v+=2;let y=0;for(let k in d)(O||d.hasOwnProperty(k))&&(te(k),te(d[k]),y++);b[m+++t]=y>>8,b[m+t]=y&255},Wn=this.useRecords===!1?Fn:e.progressiveRecords&&!Q?(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=v++-t,R;for(let U in d)if(O||d.hasOwnProperty(U)){if(m=y[U],m)y=m;else{let I=Object.keys(d),re=y;y=s.transitions;let q=0;for(let Ke=0,dt=I.length;Ke<dt;Ke++){let Qe=I[Ke];m=y[Qe],m||(m=y[Qe]=Object.create(null),q++),y=m}k+t+1==v?(v--,en(y,I,q)):Jn(y,I,k,q),R=!0,y=re[U]}te(d[U])}if(!R){let U=y[On];U?b[k+t]=U:Jn(y,Object.keys(d),k,0)}}:(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=0;for(let U in d)(O||d.hasOwnProperty(U))&&(m=y[U],m||(m=y[U]=Object.create(null),k++),y=m);let R=y[On];R?R>=96&&Q?(b[v++]=((R-=96)&31)+96,b[v++]=R>>5):b[v++]=R:en(y,y.__keys__||Object.keys(d),k);for(let U in d)(O||d.hasOwnProperty(U))&&te(d[U])},Yn=typeof this.useRecords=="function"&&this.useRecords,sr=Yn?(d,O)=>{Yn(d)?Wn(d,O):Fn(d,O)}:Wn,Xe=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 m=new ca(O);return Ie=m.dataView||(m.dataView=new DataView(m.buffer,0,O)),d=Math.min(d,b.length),b.copy?b.copy(m,0,t,d):m.set(b.slice(t,d)),v-=t,t=0,ht=m.length-10,b=m},en=(d,O,m)=>{let y=s.nextId;y||(y=64),y<ce&&this.shouldShareStructure&&!this.shouldShareStructure(O)?(y=s.nextOwnId,y<Se||(y=ce),s.nextOwnId=y+1):(y>=Se&&(y=ce),s.nextId=y+1);let k=O.highByte=y>=96&&Q?y-96>>5:-1;d[On]=y,d.__keys__=O,s[y-64]=O,y<ce?(O.isShared=!0,s.sharedLength=y-63,n=!0,k>=0?(b[v++]=(y&31)+96,b[v++]=k):b[v++]=y):(k>=0?(b[v++]=213,b[v++]=114,b[v++]=(y&31)+96,b[v++]=k):(b[v++]=212,b[v++]=114,b[v++]=y),m&&(rr+=nr*m),ee.length>=E&&(ee.shift()[On]=0),ee.push(d),te(O))},Jn=(d,O,m,y)=>{let k=b,R=v,U=ht,I=t;b=Gn,v=0,t=0,b||(Gn=b=new ca(8192)),ht=b.length-10,en(d,O,y),Gn=b;let re=v;if(b=k,v=R,ht=U,t=I,re>1){let q=v+re-1;q>ht&&Xe(q);let Ke=m+t;b.copyWithin(Ke+re,Ke+1,v),b.set(Gn.slice(0,re),Ke),v=q}else b[m+t]=Gn[0]},Vi=(d,O)=>{let m=vm(d,b,t,v,s,Xe,(y,k,R)=>{if(R)return n=!0;v=k;let U=b;return te(y),qn(),U!==b?{position:v,targetView:Ie,target:b}:v},this);if(m===0)return sr(d,!0);v=m}}useBuffer(e){b=e,Ie=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,Ul];So=[{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!==Yl&&this.moreTypes?du(r,ql.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 km(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 Om(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){Ie.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 Tm(r,e){return r.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},r}let Jl=new _m({useRecords:!1});const xm=Jl.pack;Jl.pack;const Sm=512,Nm=1024,Em=2048;let Gl=class{constructor(){S(this,"contentType","application/msgpack")}encode(e){return xm(Un.toSnake(e))}decode(e,t){const n=Un.toCamel(ym(new Uint8Array(e)));return t!=null?t.parse(n):n}},Hl=class{constructor(){S(this,"contentType","application/json"),S(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 Am=[new Gl,new Hl],Xl=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:Am,JSONEncoderDecoder:Hl,MsgpackEncoderDecoder:Gl},Symbol.toStringTag,{value:"Module"}));let Im=class{constructor(e){S(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:Im},Symbol.toStringTag,{value:"Module"})),Js=u.z.number(),Gs=u.z.object({name:u.z.string(),key:u.z.number(),rate:xi.z,dataType:rt.z,leaseholder:u.z.number(),index:u.z.number(),isIndex:u.z.boolean(),alias:u.z.string().optional()}),Ql=Gs.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()}),ed=r=>r.map(e=>({name:e.name,dataType:e.dataType,rate:e.rate??0,leaseholder:e.leaseholder,index:e.index,isIndex:e.isIndex})),Zm=u.z.object({channels:Ql.array()}),$m=u.z.object({channels:Gs.array()}),vi=class vi{constructor(e){h(this,"client");this.client=e}async create(e){const t={channels:ed(e)},[n,s]=await this.client.send(vi.ENDPOINT,t,Zm,$m);if(s!=null)throw s;return n.channels}};h(vi,"ENDPOINT","/channel/create");let Ga=vi;const Cm=new Error("request for lock canceled");var jm=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(g){try{l(n.next(g))}catch(E){i(E)}}function c(g){try{l(n.throw(g))}catch(E){i(E)}}function l(g){g.done?a(g.value):s(g.value).then(o,c)}l((n=n.apply(r,e||[])).next())})};class Rm{constructor(e,t=Cm){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 jm(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 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(g){try{l(n.next(g))}catch(E){i(E)}}function c(g){try{l(n.throw(g))}catch(E){i(E)}}function l(g){g.done?a(g.value):s(g.value).then(o,c)}l((n=n.apply(r,e||[])).next())})};class Pm{constructor(e){this._semaphore=new Rm(1,e)}acquire(){return zm(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()}}const Um=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()}),Dm=u.z.object({channels:Gs.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}=Gr(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,Um,Dm);if(n!=null)throw n;return t.channels}};h(wi,"ENDPOINT","/channel/retrieve");let vs=wi;class dc{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}=Gr(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 Gr=r=>{const e=Ne(r).filter(t=>t!=0);return{single:!Array.isArray(r),variant:typeof e[0]=="number"?"keys":"names",normalized:e,actual:r}};class td{constructor(e,t){h(this,"mu",new Pm);h(this,"requests",new Map);h(this,"wrapped");h(this,"debouncedRun");this.wrapped=e,this.debouncedRun=am(()=>{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}=Gr(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()}})}}var Mm=Object.defineProperty,Lm=(r,e,t)=>e in r?Mm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,We=(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 No;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(No||(No={}));const M=ke.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jr=r=>{switch(typeof r){case"undefined":return M.undefined;case"string":return M.string;case"number":return isNaN(r)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":return Array.isArray(r)?M.array:r===null?M.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?M.promise:typeof Map<"u"&&r instanceof Map?M.map:typeof Set<"u"&&r instanceof Set?M.set:typeof Date<"u"&&r instanceof Date?M.date:M.object;default:return M.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"]),Km=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 ws=(r,e)=>{let t;switch(r.code){case $.invalid_type:r.received===M.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 rd=ws;function qm(r){rd=r}function Ha(){return rd}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}},Fm=[];function V(r,e){const t=Xa({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ha(),ws].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"}),nd=r=>({status:"dirty",value:r}),vt=r=>({status:"valid",value:r}),Eo=r=>r.status==="aborted",Ao=r=>r.status==="dirty",bs=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 Ht{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(bs(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 jr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:jr(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:jr(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:jr(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:jr(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:H.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Or.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 Mn.create(this,this._def)}or(e){return Ts.create([this,e],this._def)}and(e){return xs.create(this,e,this._def)}transform(e){return new Bt({...le(this._def),schema:this,typeName:H.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Is({...le(this._def),innerType:this,defaultValue:t,typeName:H.ZodDefault})}brand(){return new ad({typeName:H.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:H.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Hs.create(this,e)}readonly(){return ai.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 Yi;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 $t extends pe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==M.string){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:M.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),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")Yi||(Yi=new RegExp(Xm,"u")),Yi.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 $t({...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 $t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $t({...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}}$t.create=r=>{var e;return new $t({checks:[],typeName:H.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 Vr 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)!==M.number){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:M.number,received:s.parsedType}),ie}let t;const n=new ct;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 Vr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:W.toString(s)}]})}_addCheck(e){return new Vr({...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)}}Vr.create=r=>new Vr({checks:[],typeName:H.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)!==M.bigint){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:M.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),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:H.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...le(r)})};class _s extends pe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==M.boolean){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.boolean,received:t.parsedType}),ie}return vt(e.data)}}_s.create=r=>new _s({typeName:H.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)!==M.date){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:M.date,received:s.parsedType}),ie}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return V(s,{code:$.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),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:H.ZodDate,...le(r)});class ei extends pe{_parse(e){if(this._getType(e)!==M.symbol){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.symbol,received:t.parsedType}),ie}return vt(e.data)}}ei.create=r=>new ei({typeName:H.ZodSymbol,...le(r)});class ks extends pe{_parse(e){if(this._getType(e)!==M.undefined){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.undefined,received:t.parsedType}),ie}return vt(e.data)}}ks.create=r=>new ks({typeName:H.ZodUndefined,...le(r)});class Os extends pe{_parse(e){if(this._getType(e)!==M.null){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.null,received:t.parsedType}),ie}return vt(e.data)}}Os.create=r=>new Os({typeName:H.ZodNull,...le(r)});class Dn extends pe{constructor(){super(...arguments),this._any=!0}_parse(e){return vt(e.data)}}Dn.create=r=>new Dn({typeName:H.ZodAny,...le(r)});class cn extends pe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return vt(e.data)}}cn.create=r=>new cn({typeName:H.ZodUnknown,...le(r)});class Nr extends pe{_parse(e){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.never,received:t.parsedType}),ie}}Nr.create=r=>new Nr({typeName:H.ZodNever,...le(r)});class ti extends pe{_parse(e){if(this._getType(e)!==M.undefined){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.void,received:t.parsedType}),ie}return vt(e.data)}}ti.create=r=>new ti({typeName:H.ZodVoid,...le(r)});class Pt extends pe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==M.array)return V(t,{code:$.invalid_type,expected:M.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)&&(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 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 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:H.ZodArray,...le(e)});function Nn(r){if(r instanceof Me){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Or.create(Nn(n))}return new Me({...r._def,shape:()=>e})}else return r instanceof Pt?new Pt({...r._def,type:Nn(r.element)}):r instanceof Or?Or.create(Nn(r.unwrap())):r instanceof mn?mn.create(Nn(r.unwrap())):r instanceof Xt?Xt.create(r.items.map(e=>Nn(e))):r}class Me 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)!==M.object){const c=this._getOrReturnCtx(e);return V(c,{code:$.invalid_type,expected:M.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 Nr&&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],g=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Ht(n,g,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Nr){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 g=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Ht(n,g,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const g=await l.key;c.push({key:g,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 W.errToObj,new Me({...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 Me({...this._def,unknownKeys:"strip"})}passthrough(){return new Me({...this._def,unknownKeys:"passthrough"})}extend(e){return new Me({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Me({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 Me({...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 Me({...this._def,shape:()=>t})}omit(e){const t={};return ke.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Me({...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 Me({...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 Or;)s=s._def.innerType;t[n]=s}}),new Me({...this._def,shape:()=>t})}keyof(){return sd(ke.objectKeys(this.shape))}}Me.create=(r,e)=>new Me({shape:()=>r,unknownKeys:"strip",catchall:Nr.create(),typeName:H.ZodObject,...le(e)});Me.strictCreate=(r,e)=>new Me({shape:()=>r,unknownKeys:"strict",catchall:Nr.create(),typeName:H.ZodObject,...le(e)});Me.lazycreate=(r,e)=>new Me({shape:r,unknownKeys:"strip",catchall:Nr.create(),typeName:H.ZodObject,...le(e)});class Ts 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}),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},g=c._parseSync({data:t.data,path:t.path,parent:l});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,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}),ie}}get options(){return this._def.options}}Ts.create=(r,e)=>new Ts({options:r,typeName:H.ZodUnion,...le(e)});const xa=r=>r instanceof Ns?xa(r.schema):r instanceof Bt?xa(r.innerType()):r instanceof Es?[r.value]:r instanceof qr?r.options:r instanceof As?Object.keys(r.enum):r instanceof Is?xa(r._def.innerType):r instanceof ks?[void 0]:r instanceof Os?[null]:null;class Ei extends pe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.object)return V(t,{code:$.invalid_type,expected:M.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}):(V(t,{code:$.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=xa(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:H.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...le(n)})}}function Io(r,e){const t=jr(r),n=jr(e);if(r===e)return{valid:!0,data:r};if(t===M.object&&n===M.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=Io(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===M.array&&n===M.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=Io(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===M.date&&n===M.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class xs extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Eo(a)||Eo(i))return ie;const o=Io(a.value,i.value);return o.valid?((Ao(a)||Ao(i))&&t.dirty(),{status:t.value,value:o.data}):(V(n,{code:$.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}))}}xs.create=(r,e,t)=>new xs({left:r,right:e,typeName:H.ZodIntersection,...le(t)});class Xt extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==M.array)return V(n,{code:$.invalid_type,expected:M.array,received:n.parsedType}),ie;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"}),ie;!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 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 Xt({...this._def,rest:e})}}Xt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Xt({items:r,typeName:H.ZodTuple,rest:null,...le(e)})};class Ss 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!==M.object)return V(n,{code:$.invalid_type,expected:M.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 pe?new Ss({keyType:e,valueType:t,typeName:H.ZodRecord,...le(n)}):new Ss({keyType:$t.create(),valueType:e,typeName:H.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!==M.map)return V(n,{code:$.invalid_type,expected:M.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,g=await c.value;if(l.status==="aborted"||g.status==="aborted")return ie;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,g=c.value;if(l.status==="aborted"||g.status==="aborted")return ie;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}}}}ri.create=(r,e,t)=>new ri({valueType:e,keyType:r,typeName:H.ZodMap,...le(t)});class fn extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==M.set)return V(n,{code:$.invalid_type,expected:M.set,received:n.parsedType}),ie;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 g of c){if(g.status==="aborted")return ie;g.status==="dirty"&&t.dirty(),l.add(g.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 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:H.ZodSet,...le(e)});class Zn extends pe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.function)return V(t,{code:$.invalid_type,expected:M.function,received:t.parsedType}),ie;function n(o,c){return Xa({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ha(),ws].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(),ws].filter(l=>!!l),issueData:{code:$.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 zt([]),g=await o._def.args.parseAsync(c,a).catch(Q=>{throw l.addIssue(n(c,Q)),l}),E=await Reflect.apply(i,this,g);return await o._def.returns._def.type.parseAsync(E,a).catch(Q=>{throw l.addIssue(s(E,Q)),l})})}else{const o=this;return vt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new zt([n(c,l.error)]);const g=Reflect.apply(i,this,l.data),E=o._def.returns.safeParse(g,a);if(!E.success)throw new zt([s(g,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Zn({...this._def,args:Xt.create(e).rest(cn.create())})}returns(e){return new Zn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Zn({args:e||Xt.create([]).rest(cn.create()),returns:t||cn.create(),typeName:H.ZodFunction,...le(n)})}}class Ns 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})}}Ns.create=(r,e)=>new Ns({getter:r,typeName:H.ZodLazy,...le(e)});class Es 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}),ie}return{status:"valid",value:e.data}}get value(){return this._def.value}}Es.create=(r,e)=>new Es({value:r,typeName:H.ZodLiteral,...le(e)});function sd(r,e){return new qr({values:r,typeName:H.ZodEnum,...le(e)})}class qr 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}),ie}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}),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 qr.create(e)}exclude(e){return qr.create(this.options.filter(t=>!e.includes(t)))}}qr.create=sd;class As extends pe{_parse(e){const t=ke.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==M.string&&n.parsedType!==M.number){const s=ke.objectValues(t);return V(n,{expected:ke.joinValues(s),received:n.parsedType,code:$.invalid_type}),ie}if(t.indexOf(e.data)===-1){const s=ke.objectValues(t);return V(n,{received:n.data,code:$.invalid_enum_value,options:s}),ie}return vt(e.data)}get enum(){return this._def.values}}As.create=(r,e)=>new As({values:r,typeName:H.ZodNativeEnum,...le(e)});class Mn extends pe{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.promise&&t.common.async===!1)return V(t,{code:$.invalid_type,expected:M.promise,received:t.parsedType}),ie;const n=t.parsedType===M.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,...le(e)});class Bt extends pe{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=>{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"?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(!bs(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=>bs(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:H.ZodEffects,effect:e,...le(t)});Bt.createWithPreprocess=(r,e,t)=>new Bt({schema:e,effect:{type:"preprocess",transform:r},typeName:H.ZodEffects,...le(t)});class Or extends pe{_parse(e){return this._getType(e)===M.undefined?vt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Or.create=(r,e)=>new Or({innerType:r,typeName:H.ZodOptional,...le(e)});class mn extends pe{_parse(e){return this._getType(e)===M.null?vt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mn.create=(r,e)=>new mn({innerType:r,typeName:H.ZodNullable,...le(e)});class Is extends pe{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===M.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Is.create=(r,e)=>new Is({innerType:r,typeName:H.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:H.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...le(e)});class si extends pe{_parse(e){if(this._getType(e)!==M.nan){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.nan,received:t.parsedType}),ie}return{status:"valid",value:e.data}}}si.create=r=>new si({typeName:H.ZodNaN,...le(r)});const sy=Symbol("zod_brand");class ad 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 Hs 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"?ie:s.status==="dirty"?(t.dirty(),nd(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 Hs({in:e,out:t,typeName:H.ZodPipeline})}}class ai extends pe{_parse(e){const t=this._def.innerType._parse(e);return bs(t)&&(t.value=Object.freeze(t.value)),t}}ai.create=(r,e)=>new ai({innerType:r,typeName:H.ZodReadonly,...le(e)});const id=(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:Me.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 iy=(r,e={message:`Input not instance of ${r.name}`})=>id(t=>t instanceof r,e),od=$t.create,cd=Vr.create,oy=si.create,cy=Kr.create,ud=_s.create,uy=pn.create,ly=ei.create,dy=ks.create,hy=Os.create,py=Dn.create,fy=cn.create,my=Nr.create,yy=ti.create,gy=Pt.create,vy=Me.create,wy=Me.strictCreate,by=Ts.create,_y=Ei.create,ky=xs.create,Oy=Xt.create,Ty=Ss.create,xy=ri.create,Sy=fn.create,Ny=Zn.create,Ey=Ns.create,Ay=Es.create,Iy=qr.create,Zy=As.create,$y=Mn.create,mu=Bt.create,Cy=Or.create,jy=mn.create,Ry=Bt.createWithPreprocess,zy=Hs.create,Py=()=>od().optional(),Uy=()=>cd().optional(),Dy=()=>ud().optional(),My={string:r=>$t.create({...r,coerce:!0}),number:r=>Vr.create({...r,coerce:!0}),boolean:r=>_s.create({...r,coerce:!0}),bigint:r=>Kr.create({...r,coerce:!0}),date:r=>pn.create({...r,coerce:!0})},Ly=ie;var x=Object.freeze({__proto__:null,defaultErrorMap:ws,setErrorMap:qm,getErrorMap:Ha,makeIssue:Xa,EMPTY_PATH:Fm,addIssueToContext:V,ParseStatus:ct,INVALID:ie,DIRTY:nd,OK:vt,isAborted:Eo,isDirty:Ao,isValid:bs,isAsync:Qa,get util(){return ke},get objectUtil(){return No},ZodParsedType:M,getParsedType:jr,ZodType:pe,ZodString:$t,ZodNumber:Vr,ZodBigInt:Kr,ZodBoolean:_s,ZodDate:pn,ZodSymbol:ei,ZodUndefined:ks,ZodNull:Os,ZodAny:Dn,ZodUnknown:cn,ZodNever:Nr,ZodVoid:ti,ZodArray:Pt,ZodObject:Me,ZodUnion:Ts,ZodDiscriminatedUnion:Ei,ZodIntersection:xs,ZodTuple:Xt,ZodRecord:Ss,ZodMap:ri,ZodSet:fn,ZodFunction:Zn,ZodLazy:Ns,ZodLiteral:Es,ZodEnum:qr,ZodNativeEnum:As,ZodPromise:Mn,ZodEffects:Bt,ZodTransformer:Bt,ZodOptional:Or,ZodNullable:mn,ZodDefault:Is,ZodCatch:ni,ZodNaN:si,BRAND:sy,ZodBranded:ad,ZodPipeline:Hs,ZodReadonly:ai,custom:id,Schema:pe,ZodSchema:pe,late:ay,get ZodFirstPartyTypeKind(){return H},coerce:My,any:py,array:gy,bigint:cy,boolean:ud,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:cd,object:vy,oboolean:Dy,onumber:Uy,optional:Cy,ostring:Py,pipeline:zy,preprocess:Ry,promise:$y,record:Ty,set:Sy,strictObject:wy,string:od,symbol:ly,transformer:mu,tuple:Oy,undefined:dy,union:by,unknown:fy,void:yy,NEVER:Ly,ZodIssueCode:$,quotelessJson:Km,ZodError:zt});const hc=x.tuple([x.number(),x.number()]),ld=x.object({width:x.number(),height:x.number()}),By=x.object({signedWidth:x.number(),signedHeight:x.number()}),Vy=["width","height"];x.enum(Vy);const Ky=["start","center","end"],qy=["signedWidth","signedHeight"];x.enum(qy);const ii=x.object({x:x.number(),y:x.number()}),Fy=x.object({clientX:x.number(),clientY:x.number()}),Wy=["x","y"],dd=x.enum(Wy),hd=["top","right","bottom","left"];x.enum(hd);const Yy=["left","right"],pd=x.enum(Yy),Jy=["top","bottom"],fd=x.enum(Jy),md=["center"],yu=x.enum(md),Gy=[...hd,...md],yd=x.enum(Gy);x.enum(Ky);const Hy=["first","last"];x.enum(Hy);const Xy=x.object({lower:x.number(),upper:x.number()});x.union([Xy,hc]);x.union([dd,yd]);x.union([dd,yd,x.instanceof(String)]);const Ji=(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 At=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 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()}):""}Ai.default=eg;var Ii={};Object.defineProperty(Ii,"__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():""}Ii.default=tg;var Zi={};Object.defineProperty(Zi,"__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()}):""}Zi.default=rg;var pc={};Object.defineProperty(pc,"__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():""}pc.default=ng;var fc={};Object.defineProperty(fc,"__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():""}fc.default=sg;var mc={};Object.defineProperty(mc,"__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():""}mc.default=ag;var yc={};Object.defineProperty(yc,"__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)}yc.default=ig;var gc={};Object.defineProperty(gc,"__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}):""}gc.default=og;var $i={};Object.defineProperty($i,"__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():""}$i.default=cg;var vc={},_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=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(vc,"__esModule",{value:!0});var dr=_n;function Sa(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=Sa(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=Sa(i,e));else if(dr.isArrayObject(i)){var c=Sa({key:i},e);o=c.key}return o}))),t[a]=s}),t}vc.default=Sa;var wc={},lg=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(wc,"__esModule",{value:!0});var hr=_n;function Na(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=Na(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=Na(i,e));else if(hr.isArrayObject(i)){var c=Na({key:i},e);o=c.key}return o}))),t[a]=s}),t}wc.default=Na;var bc={},dg=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(bc,"__esModule",{value:!0});var pr=_n,hg=Ai;function Ea(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=Ea(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=Ea(i,e));else if(pr.isArrayObject(i)){var c=Ea({key:i},e);o=c.key}return o}))),t[a]=s}),t}bc.default=Ea;var _c={},pg=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(_c,"__esModule",{value:!0});var fr=_n,fg=Ii;function Aa(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=Aa(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=Aa(i,e));else if(fr.isArrayObject(i)){var c=Aa({key:i},e);o=c.key}return o}))),t[a]=s}),t}_c.default=Aa;var kc={},mg=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(kc,"__esModule",{value:!0});var mr=_n,yg=Zi;function Ia(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=Ia(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=Ia(i,e));else if(mr.isArrayObject(i)){var c=Ia({key:i},e);o=c.key}return o}))),t[a]=s}),t}kc.default=Ia;var Oc={},gg=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(Oc,"__esModule",{value:!0});var yr=_n,vg=$i;function Za(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=Za(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=Za(i,e));else if(yr.isArrayObject(i)){var c=Za({key:i},e);o=c.key}return o}))),t[a]=s}),t}Oc.default=Za;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 gd=Ai;ye.toCamelCase=gd.default;var vd=Ii;ye.toSnakeCase=vd.default;var wd=Zi;ye.toPascalCase=wd.default;var bd=pc;ye.toDotCase=bd.default;var _d=fc;ye.toPathCase=_d.default;var kd=mc;ye.toTextCase=kd.default;var Od=yc;ye.toSentenceCase=Od.default;var Td=gc;ye.toHeaderCase=Td.default;var xd=$i;ye.toKebabCase=xd.default;var Sd=vc;ye.lowerKeys=Sd.default;var Nd=wc;ye.upperKeys=Nd.default;var Ed=bc;ye.camelKeys=Ed.default;var Ad=_c;ye.snakeKeys=Ad.default;var Id=kc;ye.pascalKeys=Id.default;var Zd=Oc;ye.kebabKeys=Zd.default;var $d=function(r){return String(r||"").toLowerCase()};ye.toLowerCase=$d;var Cd=function(r){return String(r||"").toUpperCase()};ye.toUpperCase=Cd;var wg={toCamelCase:gd.default,toSnakeCase:vd.default,toPascalCase:wd.default,toDotCase:bd.default,toPathCase:_d.default,toTextCase:kd.default,toSentenceCase:Od.default,toHeaderCase:Td.default,toKebabCase:xd.default,toUpperCase:Cd,toLowerCase:$d,lowerKeys:Sd.default,upperKeys:Nd.default,camelKeys:Ed.default,snakeKeys:Ad.default,pascalKeys:Id.default,kebabKeys:Zd.default};ye.default=wg;var jd=ye;const Rd={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},bg=r=>jd.snakeKeys(r,Rd),_g=r=>jd.camelKeys(r,Rd);var Ln;(r=>{r.toSnake=bg,r.toCamel=_g,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Ln||(Ln={}));x.object({x:pd.or(yu),y:fd.or(yu)});const kg=x.object({x:pd,y:fd}),Og=Object.freeze({x:"left",y:"top"}),Tg=(r,e)=>r.x===e.x&&r.y===e.y,gu=x.union([x.number(),ii,hc,ld,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},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:ii,two:ii,root:kg});const Tc=(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))},Gi=r=>{const e=Tc(r);return{lower:e.one.x,upper:e.two.x}},Hi=r=>{const e=Tc(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=x.object({signedWidth:x.number(),signedHeight:x.number()});x.union([ld,Ng,ii,hc]);const Eg=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);x.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 g=(n-s)*(l/c)+i;return[r,g]},$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]},Zo=class rs{constructor(){j(this,"ops",[]),j(this,"currBounds",null),j(this,"currType",null),j(this,"reversed",!1),this.ops=[]}static translate(e){return new rs().translate(e)}static magnify(e){return new rs().magnify(e)}static scale(e,t){return new rs().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=Ji(e,t),s=this.new(),a=Zg(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=Ji(e,t),s=this.new(),a=jg(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=Ji(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 rs;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(Zo,"IDENTITY",new Zo);let wu=Zo;const bu=class vr{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 vr().translate(e,t)}static translateX(e){return new vr().translateX(e)}static translateY(e){return new vr().translateY(e)}static clamp(e){return new vr().clamp(e)}static magnify(e){return new vr().magnify(e)}static scale(e){return new vr().scale(e)}static reBound(e){return new vr().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(Gi(e)),t.y=t.y.scale(Hi(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(Gi(e)),t.y=this.y.reBound(Hi(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Gi(e)),t.y=this.y.clamp(Hi(e)),t}copy(){const e=new vr;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 Tc(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};j(bu,"IDENTITY",new bu);const zd=(r,e)=>{const t=new bt(e);if(![mt.DAY,mt.HOUR,mt.MINUTE,mt.SECOND,mt.MILLISECOND,mt.MICROSECOND,mt.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 bt?new bt(n):new mt(n)},Ze=class se{constructor(e,t="UTC"){if(j(this,"value"),j(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 mt(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 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 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 zd(this,e)}get isToday(){return this.truncate(mt.DAY).equals(se.now().truncate(mt.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)}};j(Ze,"NANOSECOND",Ze.nanoseconds(1)),j(Ze,"MICROSECOND",Ze.microseconds(1)),j(Ze,"MILLISECOND",Ze.milliseconds(1)),j(Ze,"SECOND",Ze.seconds(1)),j(Ze,"MINUTE",Ze.minutes(1)),j(Ze,"HOUR",Ze.hours(1)),j(Ze,"DAY",Ze.days(1)),j(Ze,"MAX",new Ze((1n<<63n)-1n)),j(Ze,"MIN",new Ze(0)),j(Ze,"ZERO",new Ze(0)),j(Ze,"z",x.union([x.object({value:x.bigint()}).transform(r=>new Ze(r.value)),x.string().transform(r=>new Ze(BigInt(r))),x.instanceof(Number).transform(r=>new Ze(r)),x.number().transform(r=>new Ze(r)),x.instanceof(Ze)]));let bt=Ze;const $e=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 zd(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),g=n.sub(t),E=s.sub(n),Q=a.sub(s),ce=i.sub(a),Se=o.sub(i);let ee="";return c.isZero||(ee+=`${c.days}d `),l.isZero||(ee+=`${l.hours}h `),g.isZero||(ee+=`${g.minutes}m `),E.isZero||(ee+=`${E.seconds}s `),Q.isZero||(ee+=`${Q.milliseconds}ms `),ce.isZero||(ee+=`${ce.microseconds}µs `),Se.isZero||(ee+=`${Se.nanoseconds}ns`),ee.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($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",x.union([x.object({value:x.bigint()}).transform(r=>new $e(r.value)),x.string().transform(r=>new $e(BigInt(r))),x.instanceof(Number).transform(r=>new $e(r)),x.number().transform(r=>new $e(r)),x.instanceof($e)]));let mt=$e;const la=class $a extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new $a(e).valueOf()}get period(){return mt.seconds(1/this.valueOf())}sampleCount(e){return new mt(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ft(t).valueOf()}span(e){return mt.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new $a(e)}static khz(e){return $a.hz(e*1e3)}};j(la,"z",x.union([x.number().transform(r=>new la(r)),x.instanceof(Number).transform(r=>new la(r)),x.instanceof(la)]));const tt=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(tt,"UNKNOWN",new tt(0)),j(tt,"BIT128",new tt(16)),j(tt,"BIT64",new tt(8)),j(tt,"BIT32",new tt(4)),j(tt,"BIT16",new tt(2)),j(tt,"BIT8",new tt(1)),j(tt,"z",x.union([x.number().transform(r=>new tt(r)),x.instanceof(Number).transform(r=>new tt(r)),x.instanceof(tt)]));let ft=tt;const qt=class Ca{constructor(e,t){j(this,"start"),j(this,"end"),this.start=new bt(e),this.end=new bt(t)}get span(){return new mt(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 Ca(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 Ca?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Ca(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(qt,"MAX",new qt(bt.MIN,bt.MAX)),j(qt,"MIN",new qt(bt.MAX,bt.MIN)),j(qt,"ZERO",new qt(bt.ZERO,bt.ZERO)),j(qt,"z",x.union([x.object({start:bt.z,end:bt.z}).transform(r=>new qt(r.start,r.end)),x.instanceof(qt)]));let Rg=qt;const A=class an extends String{constructor(e){if(e instanceof an||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=an.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(an.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=an.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 density(){const e=an.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 an.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,"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(),ft.BIT8],[A.UINT16.toString(),ft.BIT16],[A.UINT32.toString(),ft.BIT32],[A.UINT64.toString(),ft.BIT64],[A.FLOAT32.toString(),ft.BIT32],[A.FLOAT64.toString(),ft.BIT64],[A.INT8.toString(),ft.BIT8],[A.INT16.toString(),ft.BIT16],[A.INT32.toString(),ft.BIT32],[A.INT64.toString(),ft.BIT64],[A.TIMESTAMP.toString(),ft.BIT64],[A.STRING.toString(),ft.UNKNOWN],[A.JSON.toString(),ft.UNKNOWN],[A.UUID.toString(),ft.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",x.union([x.string().transform(r=>new A(r)),x.instanceof(A)]));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),g=a.sub(s);let E="";return i.isZero||(E+=`${i.terabytes}TB `),o.isZero||(E+=`${o.gigabytes}GB `),c.isZero||(E+=`${c.megabytes}MB `),l.isZero||(E+=`${l.kilobytes}KB `),(!g.isZero||E==="")&&(E+=`${g.valueOf()}B`),E.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}};j(at,"BYTE",new at(1)),j(at,"KILOBYTE",at.kilobytes(1)),j(at,"MEGABYTE",at.megabytes(1)),j(at,"GIGABYTE",at.gigabytes(1)),j(at,"TERABYTE",at.terabytes(1)),j(at,"ZERO",new at(0)),j(at,"z",x.union([x.number().transform(r=>new at(r)),x.instanceof(at)]));let zg=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)]);x.record(x.union([x.number(),x.string(),x.symbol()]),x.unknown());const Pg=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),Pd=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Ug=Pd(),Ud=["MacOS","Windows","Linux","Docker"],Dg=x.enum(Ud);let Xi;const Mg=()=>{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??Xi??(Xi=Mg(),Xi??t)},Dd=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Ud,RUNTIME:Ug,detect:Pd,getOS:Lg,osZ:Dg},Symbol.toStringTag,{value:"Module"})),Bg=(...r)=>r.map(Md).join(""),Md=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Vg=r=>r.endsWith("/")?r.slice(0,-1):r,Kg=(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 qg=(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=Md(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 $o;try{$o=new TextDecoder}catch{}var P,St,f=0,ze={},be,Pr,Tt=0,Yt=0,He,Tr,kt=[],ve,_u={useRecords:!1,mapsAsObjects:!0};class Ld{}const Bd=new Ld;Bd.name="MessagePack 0xC1";var Dr=!1,Vd=2,ku;try{new Function("")}catch{Vd=1/0}class Zs{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 Yd(()=>(jo(),this?this.unpack(e,t):Zs.prototype.unpack.call(_u,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,f=t.start||0):(f=0,St=t>-1?t:e.length),Yt=0,Pr=null,He=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 Zs){if(ze=this,this.structures)return be=this.structures,da(t);(!be||be.length>0)&&(be=[])}else ze=_u,(!be||be.length>0)&&(be=[]);return da(t)}unpackMultiple(e,t){let n,s=0;try{Dr=!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(da(),s,f)===!1)return}else{for(n=[i];f<a;)s=f,n.push(da());return n}}catch(a){throw a.lastPosition=s,a.values=n,a}finally{Dr=!1,jo()}}_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 da(r){try{if(!ze.trusted&&!Dr){let t=be.sharedLength||0;t<be.length&&(be.length=t)}let e;if(ze.randomAccessStructure&&P[f]<64&&P[f]>=32&&ku?(e=ku(P,f,St,ze),P=null,!(r&&r.lazy)&&e&&(e=e.toJSON()),f=St):e=Ve(),He&&(f=He.postBundlePosition,He=null),Dr&&(be.restoreStructures=null),f==St)be&&be.restoreStructures&&Ou(),be=null,P=null,Tr&&(Tr=null);else{if(f>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 be&&be.restoreStructures&&Ou(),jo(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||f>St)&&(e.incomplete=!0),e}}function Ou(){for(let r in be.restoreStructures)be[r]=be.restoreStructures[r];be.restoreStructures=null}function Ve(){let r=P[f++];if(r<160)if(r<128){if(r<64)return r;{let e=be[r&63]||ze.getStructures&&Kd()[r&63];return e?(e.read||(e.read=xc(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,ze.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Fd();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 ze.freezeData?Object.freeze(e):e}else if(r<192){let e=r-160;if(Yt>=f)return Pr.slice(f-Tt,(f+=e)-Tt);if(Yt==0&&St<140){let t=e<16?Sc(e):qd(e);if(t!=null)return t}return Co(e)}else{let e;switch(r){case 192:return null;case 193:return He?(e=Ve(),e>0?He[1].slice(He.position1,He.position1+=e):He[0].slice(He.position0,He.position0-=e)):Bd;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 Qi(e);case 197:return e=ve.getUint16(f),f+=2,Qi(e);case 198:return e=ve.getUint32(f),f+=4,Qi(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),ze.useFloat32>2){let t=Nc[(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 ze.int64AsType==="number"?(e=ve.getUint32(f)*4294967296,e+=ve.getUint32(f+4)):ze.int64AsType==="string"?e=ve.getBigUint64(f).toString():ze.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 ze.int64AsType==="number"?(e=ve.getInt32(f)*4294967296,e+=ve.getUint32(f+4)):ze.int64AsType==="string"?e=ve.getBigInt64(f).toString():ze.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=kt[e];if(t)return t.read?(f++,t.read(Ve())):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++],Yt>=f?Pr.slice(f-Tt,(f+=e)-Tt):Wg(e);case 218:return e=ve.getUint16(f),f+=2,Yt>=f?Pr.slice(f-Tt,(f+=e)-Tt):Yg(e);case 219:return e=ve.getUint32(f),f+=4,Yt>=f?Pr.slice(f-Tt,(f+=e)-Tt):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 xc(r,e){function t(){if(t.count++>Vd){let s=r.read=new Function("r","return function(){return "+(ze.freezeData?"Object.freeze":"")+"({"+r.map(a=>a==="__proto__"?"__proto_:r()":Fg.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"})}")(Ve);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]=Ve()}return ze.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]||Kd()[n];if(!s)throw new Error("Record id is not defined for "+n);return s.read||(s.read=xc(s,r)),s.read()};function Kd(){let r=Yd(()=>(P=null,ze.getStructures()));return be=ze._mergeStructures(r,be)}var Co=Xs,Wg=Xs,Yg=Xs,Jg=Xs;function Xs(r){let e;if(r<16&&(e=Sc(r)))return e;if(r>64&&$o)return $o.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+=Je.apply(String,n),n.length=0)}return n.length>0&&(e+=Je.apply(String,n)),e}function xu(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Ve();return ze.freezeData?Object.freeze(e):e}function Su(r){if(ze.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Fd();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 Je=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 Je.apply(String,t)}function Sc(r){if(r<4)if(r<2){if(r===0)return"";{let e=P[f++];if((e&128)>1){f-=1;return}return Je(e)}}else{let e=P[f++],t=P[f++];if((e&128)>0||(t&128)>0){f-=2;return}if(r<3)return Je(e,t);let n=P[f++];if((n&128)>0){f-=3;return}return Je(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 Je(e,t,n,s);{let a=P[f++];if((a&128)>0){f-=5;return}return Je(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 Je(e,t,n,s,a,i);let o=P[f++];if((o&128)>0){f-=7;return}return Je(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 Je(e,t,n,s,a,i,o,c);{let l=P[f++];if((l&128)>0){f-=9;return}return Je(e,t,n,s,a,i,o,c,l)}}else if(r<12){let l=P[f++],g=P[f++];if((l&128)>0||(g&128)>0){f-=10;return}if(r<11)return Je(e,t,n,s,a,i,o,c,l,g);let E=P[f++];if((E&128)>0){f-=11;return}return Je(e,t,n,s,a,i,o,c,l,g,E)}else{let l=P[f++],g=P[f++],E=P[f++],Q=P[f++];if((l&128)>0||(g&128)>0||(E&128)>0||(Q&128)>0){f-=12;return}if(r<14){if(r===12)return Je(e,t,n,s,a,i,o,c,l,g,E,Q);{let ce=P[f++];if((ce&128)>0){f-=13;return}return Je(e,t,n,s,a,i,o,c,l,g,E,Q,ce)}}else{let ce=P[f++],Se=P[f++];if((ce&128)>0||(Se&128)>0){f-=14;return}if(r<15)return Je(e,t,n,s,a,i,o,c,l,g,E,Q,ce,Se);let ee=P[f++];if((ee&128)>0){f-=15;return}return Je(e,t,n,s,a,i,o,c,l,g,E,Q,ce,Se,ee)}}}}}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 Xs(e)}function Qi(r){return ze.copyBuffers?Uint8Array.prototype.slice.call(P,f,f+=r):P.subarray(f,f+=r)}function nn(r){let e=P[f++];if(kt[e]){let t;return kt[e](P.subarray(f,t=f+=r),n=>{f=n;try{return Ve()}finally{f=t}})}else throw new Error("Unknown extension type "+e)}var Eu=new Array(4096);function Fd(){let r=P[f++];if(r>=160&&r<192){if(r=r-160,Yt>=f)return Pr.slice(f-Tt,(f+=r)-Tt);if(!(Yt==0&&St<180))return Co(r)}else return f--,Ve().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?Sc(r):qd(r);return o!=null?t.string=o:t.string=Co(r)}const Au=(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=be[r];return s&&(s.isShared||Dr)&&((be.restoreStructures||(be.restoreStructures=[]))[r]=s),be[r]=t,t.read=xc(t,n),t.read()};kt[0]=()=>{};kt[0].noBuffer=!0;let Gg={Error,TypeError,ReferenceError};kt[101]=()=>{let r=Ve();return(Gg[r[0]]||Error)(r[1])};kt[105]=r=>{let e=ve.getUint32(f-4);Tr||(Tr=new Map);let t=P[f],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};Tr.set(e,s);let a=Ve();return s.used?Object.assign(n,a):(s.target=a,a)};kt[112]=r=>{let e=ve.getUint32(f-4),t=Tr.get(e);return t.used=!0,t.target};kt[115]=()=>new Set(Ve());const Wd=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");let Hg=typeof globalThis=="object"?globalThis:window;kt[116]=r=>{let e=r[0],t=Wd[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)};kt[120]=()=>{let r=Ve();return new RegExp(r[0],r[1])};const Xg=[];kt[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=f;return f+=e-r.length,He=Xg,He=[Nu(),Nu()],He.position0=0,He.position1=0,He.postBundlePosition=f,f=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 Yd(r){let e=St,t=f,n=Tt,s=Yt,a=Pr,i=Tr,o=He,c=new Uint8Array(P.slice(0,St)),l=be,g=be.slice(0,be.length),E=ze,Q=Dr,ce=r();return St=e,f=t,Tt=n,Yt=s,Pr=a,Tr=i,He=o,P=c,Dr=Q,be=l,be.splice(0,be.length,...g),ze=E,ve=new DataView(P.buffer,P.byteOffset,P.byteLength),ce}function jo(){P=null,Tr=null,be=null}const Nc=new Array(147);for(let r=0;r<256;r++)Nc[r]=+("1e"+Math.floor(45.15-r*.30103));var Ci=new Zs({useRecords:!1});const Qg=Ci.unpack;Ci.unpackMultiple;Ci.unpack;let ev=new Float32Array(1);new Uint8Array(ev.buffer,0,4);let ja;try{ja=new TextEncoder}catch{}let Ro,Jd;const ji=typeof Buffer<"u",ha=ji?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,Gd=ji?Buffer:Uint8Array,Iu=ji?4294967296:2144337920;let _,Hn,Ce,w=0,pt,De=null,tv;const rv=21760,nv=/[\u0080-\uFFFF]/,xn=Symbol("record-id");class sv extends Zs{constructor(e){super(e),this.offset=0;let t,n,s,a,i=Gd.prototype.utf8Write?function(d,O){return _.utf8Write(d,O,4294967295)}:ja&&ja.encodeInto?function(d,O){return ja.encodeInto(d,_.subarray(O)).written}:!1,o=this;e||(e={});let c=e&&e.sequential,l=e.structures||e.saveStructures,g=e.maxSharedStructures;if(g==null&&(g=l?32:0),g>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let E=e.maxOwnStructures;E==null&&(E=l?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let Q=g>32||E+g>64,ce=g+64,Se=g+E+64;if(Se>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let ee=[],rr=0,nr=0;this.pack=this.encode=function(d,O){if(_||(_=new ha(8192),Ce=_.dataView||(_.dataView=new DataView(_.buffer,0,8192)),w=0),pt=_.length-10,pt-w<2048?(_=new ha(_.length),Ce=_.dataView||(_.dataView=new DataView(_.buffer,0,_.length)),pt=_.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 m=s.sharedLength||0;if(m>g)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 y=0;y<m;y++){let k=s[y];if(!k)continue;let R,U=s.transitions;for(let I=0,re=k.length;I<re;I++){let q=k[I];R=U[q],R||(R=U[q]=Object.create(null)),U=R}U[xn]=y+64}this.lastNamedStructuresLength=m}c||(s.nextId=m+64)}n&&(n=!1);try{o.randomAccessStructure&&d&&d.constructor&&d.constructor===Object?Vi(d):te(d);let m=De;if(De&&Cu(t,te,0),a&&a.idsToInsert){let y=a.idsToInsert.sort((I,re)=>I.offset>re.offset?1:-1),k=y.length,R=-1;for(;m&&k>0;){let I=y[--k].offset+t;I<m.stringsPosition+t&&R===-1&&(R=0),I>m.position+t?R>=0&&(R+=6):(R>=0&&(Ce.setUint32(m.position+t,Ce.getUint32(m.position+t)+R),R=-1),m=m.previous,k++)}R>=0&&m&&Ce.setUint32(m.position+t,Ce.getUint32(m.position+t)+R),w+=y.length*6,w>pt&&Xe(w),o.offset=w;let U=iv(_.subarray(t,w),y);return a=null,U}return o.offset=w,O&uv?(_.start=t,_.end=w,_):_.subarray(t,w)}finally{if(s&&(qn(),n&&o.saveStructures)){let m=s.sharedLength||0,y=_.subarray(t,w),k=ov(s,o);return o.saveStructures(k,k.isCompatible)===!1?o.pack(d,O):(o.lastNamedStructuresLength=m,y)}O&lv&&(w=t)}};const qn=()=>{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,ee.length>0&&(ee=[]);else if(ee.length>0&&!c){for(let O=0,m=ee.length;O<m;O++)ee[O][xn]=0;ee=[]}},Qr=d=>{var O=d.length;O<16?_[w++]=144|O:O<65536?(_[w++]=220,_[w++]=O>>8,_[w++]=O&255):(_[w++]=221,Ce.setUint32(w,O),w+=4);for(let m=0;m<O;m++)te(d[m])},te=d=>{w>pt&&(_=Xe(w));var O=typeof d,m;if(O==="string"){let y=d.length;if(De&&y>=4&&y<4096){if((De.size+=y)>rv){let I,re=(De[0]?De[0].length*3+De[1].length:0)+10;w+re>pt&&(_=Xe(w+re));let q;De.position?(q=De,_[w]=200,w+=3,_[w++]=98,I=w-t,w+=4,Cu(t,te,0),Ce.setUint16(I+t-3,w-t-I)):(_[w++]=214,_[w++]=98,I=w-t,w+=4),De=["",""],De.previous=q,De.size=0,De.position=I}let U=nv.test(d);De[U?0:1]+=d,_[w++]=193,te(U?-y:y);return}let k;y<32?k=1:y<256?k=2:y<65536?k=3:k=5;let R=y*3;if(w+R>pt&&(_=Xe(w+R)),y<64||!i){let U,I,re,q=w+k;for(U=0;U<y;U++)I=d.charCodeAt(U),I<128?_[q++]=I:I<2048?(_[q++]=I>>6|192,_[q++]=I&63|128):(I&64512)===55296&&((re=d.charCodeAt(U+1))&64512)===56320?(I=65536+((I&1023)<<10)+(re&1023),U++,_[q++]=I>>18|240,_[q++]=I>>12&63|128,_[q++]=I>>6&63|128,_[q++]=I&63|128):(_[q++]=I>>12|224,_[q++]=I>>6&63|128,_[q++]=I&63|128);m=q-w-k}else m=i(d,w+k);m<32?_[w++]=160|m:m<256?(k<2&&_.copyWithin(w+2,w+1,w+1+m),_[w++]=217,_[w++]=m):m<65536?(k<3&&_.copyWithin(w+3,w+2,w+2+m),_[w++]=218,_[w++]=m>>8,_[w++]=m&255):(k<5&&_.copyWithin(w+5,w+3,w+3+m),_[w++]=219,Ce.setUint32(w,m),w+=4),w+=m}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,Ce.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,Ce.setInt16(w,d),w+=2):(_[w++]=210,Ce.setInt32(w,d),w+=4);else{let y;if((y=this.useFloat32)>0&&d<4294967296&&d>=-2147483648){_[w++]=202,Ce.setFloat32(w,d);let k;if(y<4||(k=d*Nc[(_[w]&127)<<1|_[w+1]>>7])>>0===k){w+=4;return}else w--}_[w++]=203,Ce.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,Ce.setUint32(w,k.id),w+=4;return}else a.set(d,{offset:w-t})}let y=d.constructor;if(y===Object)sr(d,!0);else if(y===Array)Qr(d);else if(y===Map)if(this.mapAsEmptyObject)_[w++]=128;else{m=d.size,m<16?_[w++]=128|m:m<65536?(_[w++]=222,_[w++]=m>>8,_[w++]=m&255):(_[w++]=223,Ce.setUint32(w,m),w+=4);for(let[k,R]of d)te(k),te(R)}else{for(let k=0,R=Ro.length;k<R;k++){let U=Jd[k];if(d instanceof U){let I=Ro[k];if(I.write){I.type&&(_[w++]=212,_[w++]=I.type,_[w++]=0);let Qe=I.write.call(this,d);Qe===d?Array.isArray(d)?Qr(d):sr(d):te(Qe);return}let re=_,q=Ce,Ke=w;_=null;let dt;try{dt=I.pack.call(this,d,Qe=>(_=re,re=null,w+=Qe,w>pt&&Xe(w),{target:_,targetView:Ce,position:w-Qe}),te)}finally{re&&(_=re,Ce=q,w=Ke,pt=_.length-10)}dt&&(dt.length+w>pt&&Xe(dt.length+w),w=av(dt,_,w,I.type));return}}if(Array.isArray(d))Qr(d);else{if(d.toJSON){const k=d.toJSON();if(k!==d)return te(k)}if(O==="function")return te(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,Ce.setBigInt64(w,d);else if(d<BigInt(1)<<BigInt(64)&&d>0)_[w++]=207,Ce.setBigUint64(w,d);else if(this.largeBigIntToFloat)_[w++]=203,Ce.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)},Fn=this.variableMapSize||this.coercibleKeyAsNumber?d=>{let O=Object.keys(d),m=O.length;m<16?_[w++]=128|m:m<65536?(_[w++]=222,_[w++]=m>>8,_[w++]=m&255):(_[w++]=223,Ce.setUint32(w,m),w+=4);let y;if(this.coercibleKeyAsNumber)for(let k=0;k<m;k++){y=O[k];let R=Number(y);te(isNaN(R)?y:R),te(d[y])}else for(let k=0;k<m;k++)te(y=O[k]),te(d[y])}:(d,O)=>{_[w++]=222;let m=w-t;w+=2;let y=0;for(let k in d)(O||d.hasOwnProperty(k))&&(te(k),te(d[k]),y++);_[m+++t]=y>>8,_[m+t]=y&255},Wn=this.useRecords===!1?Fn:e.progressiveRecords&&!Q?(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=w++-t,R;for(let U in d)if(O||d.hasOwnProperty(U)){if(m=y[U],m)y=m;else{let I=Object.keys(d),re=y;y=s.transitions;let q=0;for(let Ke=0,dt=I.length;Ke<dt;Ke++){let Qe=I[Ke];m=y[Qe],m||(m=y[Qe]=Object.create(null),q++),y=m}k+t+1==w?(w--,en(y,I,q)):Jn(y,I,k,q),R=!0,y=re[U]}te(d[U])}if(!R){let U=y[xn];U?_[k+t]=U:Jn(y,Object.keys(d),k,0)}}:(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=0;for(let U in d)(O||d.hasOwnProperty(U))&&(m=y[U],m||(m=y[U]=Object.create(null),k++),y=m);let R=y[xn];R?R>=96&&Q?(_[w++]=((R-=96)&31)+96,_[w++]=R>>5):_[w++]=R:en(y,y.__keys__||Object.keys(d),k);for(let U in d)(O||d.hasOwnProperty(U))&&te(d[U])},Yn=typeof this.useRecords=="function"&&this.useRecords,sr=Yn?(d,O)=>{Yn(d)?Wn(d,O):Fn(d,O)}:Wn,Xe=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 m=new ha(O);return Ce=m.dataView||(m.dataView=new DataView(m.buffer,0,O)),d=Math.min(d,_.length),_.copy?_.copy(m,0,t,d):m.set(_.slice(t,d)),w-=t,t=0,pt=m.length-10,_=m},en=(d,O,m)=>{let y=s.nextId;y||(y=64),y<ce&&this.shouldShareStructure&&!this.shouldShareStructure(O)?(y=s.nextOwnId,y<Se||(y=ce),s.nextOwnId=y+1):(y>=Se&&(y=ce),s.nextId=y+1);let k=O.highByte=y>=96&&Q?y-96>>5:-1;d[xn]=y,d.__keys__=O,s[y-64]=O,y<ce?(O.isShared=!0,s.sharedLength=y-63,n=!0,k>=0?(_[w++]=(y&31)+96,_[w++]=k):_[w++]=y):(k>=0?(_[w++]=213,_[w++]=114,_[w++]=(y&31)+96,_[w++]=k):(_[w++]=212,_[w++]=114,_[w++]=y),m&&(rr+=nr*m),ee.length>=E&&(ee.shift()[xn]=0),ee.push(d),te(O))},Jn=(d,O,m,y)=>{let k=_,R=w,U=pt,I=t;_=Hn,w=0,t=0,_||(Hn=_=new ha(8192)),pt=_.length-10,en(d,O,y),Hn=_;let re=w;if(_=k,w=R,pt=U,t=I,re>1){let q=w+re-1;q>pt&&Xe(q);let Ke=m+t;_.copyWithin(Ke+re,Ke+1,w),_.set(Hn.slice(0,re),Ke),w=q}else _[m+t]=Hn[0]},Vi=(d,O)=>{let m=tv(d,_,t,w,s,Xe,(y,k,R)=>{if(R)return n=!0;w=k;let U=_;return te(y),qn(),U!==_?{position:w,targetView:Ce,target:_}:w},this);if(m===0)return sr(d,!0);w=m}}useBuffer(e){_=e,Ce=new DataView(_.buffer,_.byteOffset,_.byteLength),w=0}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}Jd=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Ld];Ro=[{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!==Gd&&this.moreTypes?Zu(r,Wd.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){Ce.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 Hd=new sv({useRecords:!1});const cv=Hd.pack;Hd.pack;const uv=512,lv=1024,dv=2048;class hv{constructor(){j(this,"contentType","application/msgpack")}encode(e){return cv(Ln.toSnake(e))}decode(e,t){const n=Ln.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(Ln.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=Ln.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 zo;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(zo||(zo={}));const L=Oe.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 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 Ut 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()}}Ut.create=r=>new Ut(r);const $s=(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 Xd=$s;function mv(r){Xd=r}function oi(){return Xd}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}},yv=[];function K(r,e){const t=ci({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,oi(),$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"}),Qd=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),Po=r=>r.status==="aborted",Uo=r=>r.status==="dirty",Cs=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 Qt{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(Cs(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 Ut(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 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 ut,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(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:Rr(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:Rr(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:X.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xr.create(this,this._def)}nullable(){return vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Dt.create(this,this._def)}promise(){return Vn.create(this,this._def)}or(e){return Ps.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:X.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Vs({...de(this._def),innerType:this,defaultValue:t,typeName:X.ZodDefault})}brand(){return new th({typeName:X.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:X.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Qs.create(this,e)}readonly(){return mi.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 eo;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 Ct extends fe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==L.string){const s=this._getOrReturnCtx(e);return K(s,{code:C.invalid_type,expected:L.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),K(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),K(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?K(n,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&K(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),K(n,{validation:"email",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")eo||(eo=new RegExp(kv,"u")),eo.test(e.data)||(n=this._getOrReturnCtx(e,n),K(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),K(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),K(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),K(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),K(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),K(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),K(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),K(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),K(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),K(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),K(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),K(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 Ct({...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 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,...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 Fr 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 K(s,{code:C.invalid_type,expected:L.number,received:s.parsedType}),oe}let t;const n=new ut;for(const s of this._def.checks)s.kind==="int"?Oe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),K(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),K(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),K(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),K(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),K(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 Fr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Y.toString(s)}]})}_addCheck(e){return new Fr({...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)}}Fr.create=r=>new Fr({checks:[],typeName:X.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...de(r)});class Wr 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 K(s,{code:C.invalid_type,expected:L.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),K(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),K(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),K(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 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]})}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}}Wr.create=r=>{var e;return new Wr({checks:[],typeName:X.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...de(r)})};class js extends fe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==L.boolean){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.boolean,received:t.parsedType}),oe}return wt(e.data)}}js.create=r=>new js({typeName:X.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 K(s,{code:C.invalid_type,expected:L.date,received:s.parsedType}),oe}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return K(s,{code:C.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),K(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),K(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:X.ZodDate,...de(r)});class li extends fe{_parse(e){if(this._getType(e)!==L.symbol){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.symbol,received:t.parsedType}),oe}return wt(e.data)}}li.create=r=>new li({typeName:X.ZodSymbol,...de(r)});class Rs extends fe{_parse(e){if(this._getType(e)!==L.undefined){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.undefined,received:t.parsedType}),oe}return wt(e.data)}}Rs.create=r=>new Rs({typeName:X.ZodUndefined,...de(r)});class zs extends fe{_parse(e){if(this._getType(e)!==L.null){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.null,received:t.parsedType}),oe}return wt(e.data)}}zs.create=r=>new zs({typeName:X.ZodNull,...de(r)});class Bn extends fe{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}Bn.create=r=>new Bn({typeName:X.ZodAny,...de(r)});class un extends fe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}un.create=r=>new un({typeName:X.ZodUnknown,...de(r)});class Er extends fe{_parse(e){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.never,received:t.parsedType}),oe}}Er.create=r=>new Er({typeName:X.ZodNever,...de(r)});class di extends fe{_parse(e){if(this._getType(e)!==L.undefined){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.void,received:t.parsedType}),oe}return wt(e.data)}}di.create=r=>new di({typeName:X.ZodVoid,...de(r)});class Dt extends fe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==L.array)return K(t,{code:C.invalid_type,expected:L.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)&&(K(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&&(K(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&&(K(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 Qt(t,i,t.path,o)))).then(i=>ut.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Qt(t,i,t.path,o)));return ut.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Dt({...this._def,minLength:{value:e,message:Y.toString(t)}})}max(e,t){return new Dt({...this._def,maxLength:{value:e,message:Y.toString(t)}})}length(e,t){return new Dt({...this._def,exactLength:{value:e,message:Y.toString(t)}})}nonempty(e){return this.min(1,e)}}Dt.create=(r,e)=>new Dt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:X.ZodArray,...de(e)});function En(r){if(r instanceof Le){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(En(n))}return new Le({...r._def,shape:()=>e})}else return r instanceof Dt?new Dt({...r._def,type:En(r.element)}):r instanceof xr?xr.create(En(r.unwrap())):r instanceof vn?vn.create(En(r.unwrap())):r instanceof er?er.create(r.items.map(e=>En(e))):r}class Le 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 K(c,{code:C.invalid_type,expected:L.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 Er&&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],g=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Qt(n,g,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Er){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&&(K(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 g=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Qt(n,g,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const g=await l.key;c.push({key:g,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 Y.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=Y.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 Oe.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 Oe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Le({...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 Le({...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 xr;)s=s._def.innerType;t[n]=s}}),new Le({...this._def,shape:()=>t})}keyof(){return eh(Oe.objectKeys(this.shape))}}Le.create=(r,e)=>new Le({shape:()=>r,unknownKeys:"strip",catchall:Er.create(),typeName:X.ZodObject,...de(e)});Le.strictCreate=(r,e)=>new Le({shape:()=>r,unknownKeys:"strict",catchall:Er.create(),typeName:X.ZodObject,...de(e)});Le.lazycreate=(r,e)=>new Le({shape:r,unknownKeys:"strip",catchall:Er.create(),typeName:X.ZodObject,...de(e)});class Ps 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 Ut(o.ctx.common.issues));return K(t,{code:C.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},g=c._parseSync({data:t.data,path:t.path,parent:l});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,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 Ut(c));return K(t,{code:C.invalid_union,unionErrors:o}),oe}}get options(){return this._def.options}}Ps.create=(r,e)=>new Ps({options:r,typeName:X.ZodUnion,...de(e)});const Ra=r=>r instanceof Ms?Ra(r.schema):r instanceof Vt?Ra(r.innerType()):r instanceof Ls?[r.value]:r instanceof Yr?r.options:r instanceof Bs?Object.keys(r.enum):r instanceof Vs?Ra(r._def.innerType):r instanceof Rs?[void 0]:r instanceof zs?[null]:null;class Ri extends fe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.object)return K(t,{code:C.invalid_type,expected:L.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}):(K(t,{code:C.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=Ra(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:X.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...de(n)})}}function Do(r,e){const t=Rr(r),n=Rr(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(Po(a)||Po(i))return oe;const o=Do(a.value,i.value);return o.valid?((Uo(a)||Uo(i))&&t.dirty(),{status:t.value,value:o.data}):(K(n,{code:C.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}))}}Us.create=(r,e,t)=>new Us({left:r,right:e,typeName:X.ZodIntersection,...de(t)});class er extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.array)return K(n,{code:C.invalid_type,expected:L.array,received:n.parsedType}),oe;if(n.data.length<this._def.items.length)return K(n,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),oe;!this._def.rest&&n.data.length>this._def.items.length&&(K(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 Qt(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 er({...this._def,rest:e})}}er.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new er({items:r,typeName:X.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 K(n,{code:C.invalid_type,expected:L.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 Qt(n,o,n.path,o)),value:i._parse(new Qt(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 fe?new Ds({keyType:e,valueType:t,typeName:X.ZodRecord,...de(n)}):new Ds({keyType:Ct.create(),valueType:e,typeName:X.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 K(n,{code:C.invalid_type,expected:L.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 Qt(n,o,n.path,[l,"key"])),value:a._parse(new Qt(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,g=await c.value;if(l.status==="aborted"||g.status==="aborted")return oe;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,g=c.value;if(l.status==="aborted"||g.status==="aborted")return oe;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}}}}hi.create=(r,e,t)=>new hi({valueType:e,keyType:r,typeName:X.ZodMap,...de(t)});class gn extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.set)return K(n,{code:C.invalid_type,expected:L.set,received:n.parsedType}),oe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(K(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&&(K(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 g of c){if(g.status==="aborted")return oe;g.status==="dirty"&&t.dirty(),l.add(g.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Qt(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:X.ZodSet,...de(e)});class $n extends fe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.function)return K(t,{code:C.invalid_type,expected:L.function,received:t.parsedType}),oe;function n(o,c){return ci({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,oi(),$s].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(),$s].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 Vn){const o=this;return wt(async function(...c){const l=new Ut([]),g=await o._def.args.parseAsync(c,a).catch(Q=>{throw l.addIssue(n(c,Q)),l}),E=await Reflect.apply(i,this,g);return await o._def.returns._def.type.parseAsync(E,a).catch(Q=>{throw l.addIssue(s(E,Q)),l})})}else{const o=this;return wt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Ut([n(c,l.error)]);const g=Reflect.apply(i,this,l.data),E=o._def.returns.safeParse(g,a);if(!E.success)throw new Ut([s(g,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new $n({...this._def,args:er.create(e).rest(un.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||er.create([]).rest(un.create()),returns:t||un.create(),typeName:X.ZodFunction,...de(n)})}}class Ms 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})}}Ms.create=(r,e)=>new Ms({getter:r,typeName:X.ZodLazy,...de(e)});class Ls extends fe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return K(t,{received:t.data,code:C.invalid_literal,expected:this._def.value}),oe}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ls.create=(r,e)=>new Ls({value:r,typeName:X.ZodLiteral,...de(e)});function eh(r,e){return new Yr({values:r,typeName:X.ZodEnum,...de(e)})}class Yr extends fe{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{expected:Oe.joinValues(n),received:t.parsedType,code:C.invalid_type}),oe}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{received:t.data,code:C.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 Yr.create(e)}exclude(e){return Yr.create(this.options.filter(t=>!e.includes(t)))}}Yr.create=eh;class Bs 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 K(n,{expected:Oe.joinValues(s),received:n.parsedType,code:C.invalid_type}),oe}if(t.indexOf(e.data)===-1){const s=Oe.objectValues(t);return K(n,{received:n.data,code:C.invalid_enum_value,options:s}),oe}return wt(e.data)}get enum(){return this._def.values}}Bs.create=(r,e)=>new Bs({values:r,typeName:X.ZodNativeEnum,...de(e)});class Vn 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 K(t,{code:C.invalid_type,expected:L.promise,received:t.parsedType}),oe;const n=t.parsedType===L.promise?t.data:Promise.resolve(t.data);return wt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Vn.create=(r,e)=>new Vn({type:r,typeName:X.ZodPromise,...de(e)});class Vt extends fe{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=>{K(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(!Cs(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=>Cs(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:X.ZodEffects,effect:e,...de(t)});Vt.createWithPreprocess=(r,e,t)=>new Vt({schema:e,effect:{type:"preprocess",transform:r},typeName:X.ZodEffects,...de(t)});class xr extends fe{_parse(e){return this._getType(e)===L.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}xr.create=(r,e)=>new xr({innerType:r,typeName:X.ZodOptional,...de(e)});class vn extends fe{_parse(e){return this._getType(e)===L.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}vn.create=(r,e)=>new vn({innerType:r,typeName:X.ZodNullable,...de(e)});class Vs 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}}Vs.create=(r,e)=>new Vs({innerType:r,typeName:X.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 Ut(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ut(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}pi.create=(r,e)=>new pi({innerType:r,typeName:X.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 K(t,{code:C.invalid_type,expected:L.nan,received:t.parsedType}),oe}return{status:"valid",value:e.data}}}fi.create=r=>new fi({typeName:X.ZodNaN,...de(r)});const Ev=Symbol("zod_brand");class th 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 Qs 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"?oe:s.status==="dirty"?(t.dirty(),Qd(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 Qs({in:e,out:t,typeName:X.ZodPipeline})}}class mi extends fe{_parse(e){const t=this._def.innerType._parse(e);return Cs(t)&&(t.value=Object.freeze(t.value)),t}}mi.create=(r,e)=>new mi({innerType:r,typeName:X.ZodReadonly,...de(e)});const rh=(r,e={},t)=>r?Bn.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})}}):Bn.create(),Av={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 Iv=(r,e={message:`Input not instance of ${r.name}`})=>rh(t=>t instanceof r,e),nh=Ct.create,sh=Fr.create,Zv=fi.create,$v=Wr.create,ah=js.create,Cv=yn.create,jv=li.create,Rv=Rs.create,zv=zs.create,Pv=Bn.create,Uv=un.create,Dv=Er.create,Mv=di.create,Lv=Dt.create,Bv=Le.create,Vv=Le.strictCreate,Kv=Ps.create,qv=Ri.create,Fv=Us.create,Wv=er.create,Yv=Ds.create,Jv=hi.create,Gv=gn.create,Hv=$n.create,Xv=Ms.create,Qv=Ls.create,ew=Yr.create,tw=Bs.create,rw=Vn.create,Ru=Vt.create,nw=xr.create,sw=vn.create,aw=Vt.createWithPreprocess,iw=Qs.create,ow=()=>nh().optional(),cw=()=>sh().optional(),uw=()=>ah().optional(),lw={string:r=>Ct.create({...r,coerce:!0}),number:r=>Fr.create({...r,coerce:!0}),boolean:r=>js.create({...r,coerce:!0}),bigint:r=>Wr.create({...r,coerce:!0}),date:r=>yn.create({...r,coerce:!0})},dw=oe;var br=Object.freeze({__proto__:null,defaultErrorMap:$s,setErrorMap:mv,getErrorMap:oi,makeIssue:ci,EMPTY_PATH:yv,addIssueToContext:K,ParseStatus:ut,INVALID:oe,DIRTY:Qd,OK:wt,isAborted:Po,isDirty:Uo,isValid:Cs,isAsync:ui,get util(){return Oe},get objectUtil(){return zo},ZodParsedType:L,getParsedType:Rr,ZodType:fe,ZodString:Ct,ZodNumber:Fr,ZodBigInt:Wr,ZodBoolean:js,ZodDate:yn,ZodSymbol:li,ZodUndefined:Rs,ZodNull:zs,ZodAny:Bn,ZodUnknown:un,ZodNever:Er,ZodVoid:di,ZodArray:Dt,ZodObject:Le,ZodUnion:Ps,ZodDiscriminatedUnion:Ri,ZodIntersection:Us,ZodTuple:er,ZodRecord:Ds,ZodMap:hi,ZodSet:gn,ZodFunction:$n,ZodLazy:Ms,ZodLiteral:Ls,ZodEnum:Yr,ZodNativeEnum:Bs,ZodPromise:Vn,ZodEffects:Vt,ZodTransformer:Vt,ZodOptional:xr,ZodNullable:vn,ZodDefault:Vs,ZodCatch:pi,ZodNaN:fi,BRAND:Ev,ZodBranded:th,ZodPipeline:Qs,ZodReadonly:mi,custom:rh,Schema:fe,ZodSchema:fe,late:Av,get ZodFirstPartyTypeKind(){return X},coerce:lw,any:Pv,array:Lv,bigint:$v,boolean:ah,date:Cv,discriminatedUnion:qv,effect:Ru,enum:ew,function:Hv,instanceof:Iv,intersection:Fv,lazy:Xv,literal:Qv,map:Jv,nan:Zv,nativeEnum:tw,never:Dv,null:zv,nullable:sw,number:sh,object:Bv,oboolean:uw,onumber:cw,optional:nw,ostring:ow,pipeline:iw,preprocess:aw,promise:rw,record:Yv,set:Gv,strictObject:Vv,string:nh,symbol:jv,transformer:Ru,tuple:Wv,undefined:Rv,union:Kv,unknown:Uv,void:Mv,NEVER:dw,ZodIssueCode:C,quotelessJson:fv,ZodError:Ut});class ea extends Error{constructor(e,t){super(e),We(this,"discriminator","FreighterError"),We(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},Mo="unknown",zu="nil",zi="freighter",ta=br.object({type:br.string(),data:br.string()});class pw{constructor(){We(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:Mo,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===zu)return null;if(e.type===Mo)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 ih=new pw,oh=({encode:r,decode:e})=>ih.register({encode:r,decode:e}),Ec=r=>ih.decode(r);class Pu extends ea{constructor(e){super(e,Mo)}}class Ks extends ea{constructor(){super("EOF",zi)}}class yi extends ea{constructor(){super("StreamClosed",zi)}}class qs extends ea{constructor(e={}){const{message:t="Unreachable",url:n=qg.UNKNOWN}=e;super(t,zi),We(this,"url"),this.url=n}}const za="freighter",fw=r=>{if(r.type!==zi)return null;if(r instanceof Ks)return{type:za,data:"EOF"};if(r instanceof yi)return{type:za,data:"StreamClosed"};if(r instanceof qs)return{type:za,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},mw=r=>{if(r.type!==za)return null;switch(r.data){case"EOF":return new Ks;case"StreamClosed":return new yi;case"Unreachable":return new qs;default:throw new Error(`Unknown error type: ${r.data}`)}};oh({encode:fw,decode:mw});class ch{constructor(){We(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 uh="Content-Type",Uu=r=>{if(Dd.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 ch{constructor(e,t,n=!1){return super(),We(this,"endpoint"),We(this,"encoder"),We(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=Uu(this.endpoint.protocol),new Proxy(this,{get:(s,a,i)=>a==="endpoint"?this.endpoint:Reflect.get(s,a,i)})}get headers(){return{[uh]: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 g={...l,params:{}};o.headers={...this.headers,...l.params};let E;try{E=await Uu(l.protocol)(l.target,o)}catch(ce){let Se=ce;return Se.message==="Load failed"&&(Se=new qs({url:i})),[g,Se]}const Q=await E.arrayBuffer();if(E!=null&&E.ok)return s!=null&&(a=this.encoder.decode(Q,s)),[g,null];try{if(E.status!==400)return[g,new Error(E.statusText)];const ce=this.encoder.decode(Q,ta),Se=Ec(ce);return[g,Se]}catch(ce){return[g,new Error(`[freighter] - failed to decode error: ${E.statusText}: ${ce.message}`)]}});return[a,c]}}const J=async(r,e,t,n,s)=>{const[a,i]=await r.send(e,t,n,s);if(i!=null)throw i;return a},gw=()=>Dd.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),vw=br.object({type:br.union([br.literal("data"),br.literal("close")]),payload:br.unknown().optional(),error:br.optional(ta)});class ww{constructor(e,t,n,s){We(this,"encoder"),We(this,"reqSchema"),We(this,"resSchema"),We(this,"ws"),We(this,"serverClosed"),We(this,"sendClosed"),We(this,"receiveDataQueue",[]),We(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=Ec(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 Ks:new yi}}}const bw="freighterctx",_w=1e3,kw=1001,Ow=[_w,kw],Tw=r=>Ow.includes(r.code),lh=class dh extends ch{constructor(e,t,n=!1){super(),We(this,"baseUrl"),We(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=dh.MESSAGE_TYPE;const g=await this.wrapSocket(c,t,n);return g instanceof Error?[l,g]:(a=g,[l,null])});if(i!=null)throw i;return a}buildURL(e,t){const n=Kg({[uh]: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))}})}};We(lh,"MESSAGE_TYPE","arraybuffer");let xw=lh;const wr="sy.api.";var Ir=(r=>(r.General=wr+"general",r.Parse=wr+"parse",r.Auth=wr+"auth",r.Unexpected=wr+"unexpected",r.Validation=wr+"validation",r.Query=wr+"query",r.Route=wr+"route",r))(Ir||{});class Hr extends ea{constructor(e){super(e,wr)}}class jt extends Hr{constructor(t){var e=(...tk)=>(super(...tk),h(this,"fields"),this);typeof t=="string"?(e(t),this.fields=[]):Array.isArray(t)?(e(t.map(n=>`${n.field}: ${n.message}`).join(`
7
+ `).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.writePos===tn?this.data.length:this.writePos}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]=rm(this.dataType,e,this.data[s],t);return new Ar({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(rt.TIMESTAMP))this._max=this.data[this.data.length-1];else if(this.dataType.usesBigInt){const e=this.data;this._max=e.reduce((t,n)=>t>n?t:n)}else{const e=this.data;this._max=e.reduce((t,n)=>t>n?t:n)}return this._max}get max(){return this.writePos===0?-1/0:(this._max==null&&(this._max=this.calcRawMax()),ts(this._max,this.sampleOffset))}calcRawMin(){if(this.length===0)return 1/0;if(this.dataType.equals(rt.TIMESTAMP))this._min=this.data[0];else if(this.dataType.usesBigInt){const e=this.data;this._min=e.reduce((t,n)=>t<n?t:n)}else{const e=this.data;this._min=e.reduce((t,n)=>t<n?t:n)}return this._min}get min(){return this.writePos===0?1/0:(this._min==null&&(this._min=this.calcRawMin()),ts(this._min,this.sampleOffset))}get bounds(){return ns(Number(this.min),Number(this.max))}maybeRecomputeMinMax(e){if(this._min!=null){const t=e._min??e.calcRawMin();t<this._min&&(this._min=t)}if(this._max!=null){const t=e._max??e.calcRawMax();t>this._max&&(this._max=t)}}enrich(){this.max,this.min}get range(){return ts(this.max,-this.min)}at(e,t){e<0&&(e=this.length+e);const n=this.data[e];if(n==null){if(t)throw new Error(`[series] - no value at index ${e}`);return}return ts(n,this.sampleOffset)}binarySearch(e){let t=0,n=this.length-1;const s=cp(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(rt.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}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 ns(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 Ar({data:n,dataType:this.dataType,timeRange:this._timeRange,sampleOffset:this.sampleOffset,glBufferUsage:this.gl.bufferUsage,alignment:this.alignment+e})}reAlign(e){return new Ar({data:this.buffer,dataType:this.dataType,timeRange:Zt.ZERO,sampleOffset:this.sampleOffset,glBufferUsage:"static",alignment:e})}};const ts=(r,e)=>typeof r=="bigint"&&typeof e=="bigint"||typeof r=="number"&&typeof e=="number"?r+e:Number(r)+Number(e),oc=T.record(T.union([T.number(),T.string(),T.symbol()]),T.unknown()),zl=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),nm=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser";nm();const sm=["MacOS","Windows","Linux","Docker"];T.enum(sm);const am=(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)],im=(...r)=>r.map(Pl).join(""),Pl=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),om=r=>r.endsWith("/")?r.slice(0,-1):r;var kn;let cm=(kn=class{constructor({host:r,port:e,protocol:t="",pathPrefix:n=""}){S(this,"protocol"),S(this,"host"),S(this,"port"),S(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:im(this.path,r)})}toString(){return om(`${this.protocol}://${this.host}:${this.port}/${this.path}`)}},S(kn,"UNKNOWN",new kn({host:"unknown",port:0})),kn);const Se=r=>Array.isArray(r)?r:[r];var ko;try{ko=new TextDecoder}catch{}var z,xt,p=0,Re={},we,zr,Ot=0,Wt=0,Ge,kr,_t=[],ge,tu={useRecords:!1,mapsAsObjects:!0};let Ul=class{};const Dl=new Ul;Dl.name="MessagePack 0xC1";var Ur=!1,Ml=2,ru;try{new Function("")}catch{Ml=1/0}let Ll=class Oo{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(()=>(xo(),this?this.unpack(e,t):Oo.prototype.unpack.call(tu,e,t)));!e.buffer&&e.constructor===ArrayBuffer&&(e=typeof Buffer<"u"?Buffer.from(e):new Uint8Array(e)),typeof t=="object"?(xt=t.end||e.length,p=t.start||0):(p=0,xt=t>-1?t:e.length),Wt=0,zr=null,Ge=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 Oo){if(Re=this,this.structures)return we=this.structures,oa(t);(!we||we.length>0)&&(we=[])}else Re=tu,(!we||we.length>0)&&(we=[]);return oa(t)}unpackMultiple(e,t){let n,s=0;try{Ur=!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(oa(),s,p)===!1)return}else{for(n=[i];p<a;)s=p,n.push(oa());return n}}catch(a){throw a.lastPosition=s,a.values=n,a}finally{Ur=!1,xo()}}_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 oa(r){try{if(!Re.trusted&&!Ur){let t=we.sharedLength||0;t<we.length&&(we.length=t)}let e;if(Re.randomAccessStructure&&z[p]<64&&z[p]>=32&&ru?(e=ru(z,p,xt,Re),z=null,!(r&&r.lazy)&&e&&(e=e.toJSON()),p=xt):e=Be(),Ge&&(p=Ge.postBundlePosition,Ge=null),Ur&&(we.restoreStructures=null),p==xt)we&&we.restoreStructures&&nu(),we=null,z=null,kr&&(kr=null);else{if(p>xt)throw new Error("Unexpected end of MessagePack data");if(!Ur){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(),xo(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||p>xt)&&(e.incomplete=!0),e}}function nu(){for(let r in we.restoreStructures)we[r]=we.restoreStructures[r];we.restoreStructures=null}function Be(){let r=z[p++];if(r<160)if(r<128){if(r<64)return r;{let e=we[r&63]||Re.getStructures&&Bl()[r&63];return e?(e.read||(e.read=cc(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,Re.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Kl();n==="__proto__"&&(n="__proto_"),e[n]=Be()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Be(),Be());return e}else{r-=144;let e=new Array(r);for(let t=0;t<r;t++)e[t]=Be();return Re.freezeData?Object.freeze(e):e}else if(r<192){let e=r-160;if(Wt>=p)return zr.slice(p-Ot,(p+=e)-Ot);if(Wt==0&&xt<140){let t=e<16?uc(e):Vl(e);if(t!=null)return t}return To(e)}else{let e;switch(r){case 192:return null;case 193:return Ge?(e=Be(),e>0?Ge[1].slice(Ge.position1,Ge.position1+=e):Ge[0].slice(Ge.position0,Ge.position0-=e)):Dl;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 Wi(e);case 197:return e=ge.getUint16(p),p+=2,Wi(e);case 198:return e=ge.getUint32(p),p+=4,Wi(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),Re.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 Re.int64AsType==="number"?(e=ge.getUint32(p)*4294967296,e+=ge.getUint32(p+4)):Re.int64AsType==="string"?e=ge.getBigUint64(p).toString():Re.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 Re.int64AsType==="number"?(e=ge.getInt32(p)*4294967296,e+=ge.getUint32(p+4)):Re.int64AsType==="string"?e=ge.getBigInt64(p).toString():Re.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=_t[e];if(t)return t.read?(p++,t.read(Be())):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++],Wt>=p?zr.slice(p-Ot,(p+=e)-Ot):lm(e);case 218:return e=ge.getUint16(p),p+=2,Wt>=p?zr.slice(p-Ot,(p+=e)-Ot):dm(e);case 219:return e=ge.getUint32(p),p+=4,Wt>=p?zr.slice(p-Ot,(p+=e)-Ot):hm(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 um=/^[a-zA-Z_$][a-zA-Z\d_$]*$/;function cc(r,e){function t(){if(t.count++>Ml){let s=r.read=new Function("r","return function(){return "+(Re.freezeData?"Object.freeze":"")+"({"+r.map(a=>a==="__proto__"?"__proto_:r()":um.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"})}")(Be);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]=Be()}return Re.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,Re.getStructures()));return we=Re._mergeStructures(r,we)}var To=Ys,lm=Ys,dm=Ys,hm=Ys;function Ys(r){let e;if(r<16&&(e=uc(r)))return e;if(r>64&&ko)return ko.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+=Ye.apply(String,n),n.length=0)}return n.length>0&&(e+=Ye.apply(String,n)),e}function au(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Be();return Re.freezeData?Object.freeze(e):e}function iu(r){if(Re.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Kl();n==="__proto__"&&(n="__proto_"),e[n]=Be()}return e}else{let e=new Map;for(let t=0;t<r;t++)e.set(Be(),Be());return e}}var Ye=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 Ye.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 Ye(e)}}else{let e=z[p++],t=z[p++];if((e&128)>0||(t&128)>0){p-=2;return}if(r<3)return Ye(e,t);let n=z[p++];if((n&128)>0){p-=3;return}return Ye(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 Ye(e,t,n,s);{let a=z[p++];if((a&128)>0){p-=5;return}return Ye(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 Ye(e,t,n,s,a,i);let o=z[p++];if((o&128)>0){p-=7;return}return Ye(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 Ye(e,t,n,s,a,i,o,c);{let l=z[p++];if((l&128)>0){p-=9;return}return Ye(e,t,n,s,a,i,o,c,l)}}else if(r<12){let l=z[p++],g=z[p++];if((l&128)>0||(g&128)>0){p-=10;return}if(r<11)return Ye(e,t,n,s,a,i,o,c,l,g);let E=z[p++];if((E&128)>0){p-=11;return}return Ye(e,t,n,s,a,i,o,c,l,g,E)}else{let l=z[p++],g=z[p++],E=z[p++],Q=z[p++];if((l&128)>0||(g&128)>0||(E&128)>0||(Q&128)>0){p-=12;return}if(r<14){if(r===12)return Ye(e,t,n,s,a,i,o,c,l,g,E,Q);{let ce=z[p++];if((ce&128)>0){p-=13;return}return Ye(e,t,n,s,a,i,o,c,l,g,E,Q,ce)}}else{let ce=z[p++],Ne=z[p++];if((ce&128)>0||(Ne&128)>0){p-=14;return}if(r<15)return Ye(e,t,n,s,a,i,o,c,l,g,E,Q,ce,Ne);let ee=z[p++];if((ee&128)>0){p-=15;return}return Ye(e,t,n,s,a,i,o,c,l,g,E,Q,ce,Ne,ee)}}}}}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 Ys(e)}function Wi(r){return Re.copyBuffers?Uint8Array.prototype.slice.call(z,p,p+=r):z.subarray(p,p+=r)}function rn(r){let e=z[p++];if(_t[e]){let t;return _t[e](z.subarray(p,t=p+=r),n=>{p=n;try{return Be()}finally{p=t}})}else throw new Error("Unknown extension type "+e)}var cu=new Array(4096);function Kl(){let r=z[p++];if(r>=160&&r<192){if(r=r-160,Wt>=p)return zr.slice(p-Ot,(p+=r)-Ot);if(!(Wt==0&&xt<180))return To(r)}else return p--,Be().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=To(r)}const uu=(r,e)=>{let t=Be().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||Ur)&&((we.restoreStructures||(we.restoreStructures=[]))[r]=s),we[r]=t,t.read=cc(t,n),t.read()};_t[0]=()=>{};_t[0].noBuffer=!0;let pm={Error,TypeError,ReferenceError};_t[101]=()=>{let r=Be();return(pm[r[0]]||Error)(r[1])};_t[105]=r=>{let e=ge.getUint32(p-4);kr||(kr=new Map);let t=z[p],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};kr.set(e,s);let a=Be();return s.used?Object.assign(n,a):(s.target=a,a)};_t[112]=r=>{let e=ge.getUint32(p-4),t=kr.get(e);return t.used=!0,t.target};_t[115]=()=>new Set(Be());const ql=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");let fm=typeof globalThis=="object"?globalThis:window;_t[116]=r=>{let e=r[0],t=ql[e];if(!t)throw new Error("Could not find typed array for code "+e);return new fm[t](Uint8Array.prototype.slice.call(r,1).buffer)};_t[120]=()=>{let r=Be();return new RegExp(r[0],r[1])};const mm=[];_t[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=p;return p+=e-r.length,Ge=mm,Ge=[ou(),ou()],Ge.position0=0,Ge.position1=0,Ge.postBundlePosition=p,p=t,Be()};_t[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=xt,t=p,n=Ot,s=Wt,a=zr,i=kr,o=Ge,c=new Uint8Array(z.slice(0,xt)),l=we,g=we.slice(0,we.length),E=Re,Q=Ur,ce=r();return xt=e,p=t,Ot=n,Wt=s,zr=a,kr=i,Ge=o,z=c,Ur=Q,we=l,we.splice(0,we.length,...g),Re=E,ge=new DataView(z.buffer,z.byteOffset,z.byteLength),ce}function xo(){z=null,kr=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 Ll({useRecords:!1});const ym=Si.unpack;Si.unpackMultiple;Si.unpack;let gm=new Float32Array(1);new Uint8Array(gm.buffer,0,4);let Ta;try{Ta=new TextEncoder}catch{}let So,Wl;const Ni=typeof Buffer<"u",ca=Ni?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,Yl=Ni?Buffer:Uint8Array,lu=Ni?4294967296:2144337920;let b,Gn,Ie,v=0,ht,Ue=null,vm;const wm=21760,bm=/[\u0080-\uFFFF]/,On=Symbol("record-id");let _m=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)}:Ta&&Ta.encodeInto?function(d,O){return Ta.encodeInto(d,b.subarray(O)).written}:!1,o=this;e||(e={});let c=e&&e.sequential,l=e.structures||e.saveStructures,g=e.maxSharedStructures;if(g==null&&(g=l?32:0),g>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let E=e.maxOwnStructures;E==null&&(E=l?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let Q=g>32||E+g>64,ce=g+64,Ne=g+E+64;if(Ne>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let ee=[],rr=0,nr=0;this.pack=this.encode=function(d,O){if(b||(b=new ca(8192),Ie=b.dataView||(b.dataView=new DataView(b.buffer,0,8192)),v=0),ht=b.length-10,ht-v<2048?(b=new ca(b.length),Ie=b.dataView||(b.dataView=new DataView(b.buffer,0,b.length)),ht=b.length-10,v=0):v=v+7&2147483640,t=v,O&Em&&(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 m=s.sharedLength||0;if(m>g)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 y=0;y<m;y++){let k=s[y];if(!k)continue;let R,U=s.transitions;for(let I=0,re=k.length;I<re;I++){let q=k[I];R=U[q],R||(R=U[q]=Object.create(null)),U=R}U[On]=y+64}this.lastNamedStructuresLength=m}c||(s.nextId=m+64)}n&&(n=!1);try{o.randomAccessStructure&&d&&d.constructor&&d.constructor===Object?Vi(d):te(d);let m=Ue;if(Ue&&pu(t,te,0),a&&a.idsToInsert){let y=a.idsToInsert.sort((I,re)=>I.offset>re.offset?1:-1),k=y.length,R=-1;for(;m&&k>0;){let I=y[--k].offset+t;I<m.stringsPosition+t&&R===-1&&(R=0),I>m.position+t?R>=0&&(R+=6):(R>=0&&(Ie.setUint32(m.position+t,Ie.getUint32(m.position+t)+R),R=-1),m=m.previous,k++)}R>=0&&m&&Ie.setUint32(m.position+t,Ie.getUint32(m.position+t)+R),v+=y.length*6,v>ht&&Xe(v),o.offset=v;let U=Om(b.subarray(t,v),y);return a=null,U}return o.offset=v,O&Sm?(b.start=t,b.end=v,b):b.subarray(t,v)}finally{if(s&&(qn(),n&&o.saveStructures)){let m=s.sharedLength||0,y=b.subarray(t,v),k=Tm(s,o);return o.saveStructures(k,k.isCompatible)===!1?o.pack(d,O):(o.lastNamedStructuresLength=m,y)}O&Nm&&(v=t)}};const qn=()=>{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,ee.length>0&&(ee=[]);else if(ee.length>0&&!c){for(let O=0,m=ee.length;O<m;O++)ee[O][On]=0;ee=[]}},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,Ie.setUint32(v,O),v+=4);for(let m=0;m<O;m++)te(d[m])},te=d=>{v>ht&&(b=Xe(v));var O=typeof d,m;if(O==="string"){let y=d.length;if(Ue&&y>=4&&y<4096){if((Ue.size+=y)>wm){let I,re=(Ue[0]?Ue[0].length*3+Ue[1].length:0)+10;v+re>ht&&(b=Xe(v+re));let q;Ue.position?(q=Ue,b[v]=200,v+=3,b[v++]=98,I=v-t,v+=4,pu(t,te,0),Ie.setUint16(I+t-3,v-t-I)):(b[v++]=214,b[v++]=98,I=v-t,v+=4),Ue=["",""],Ue.previous=q,Ue.size=0,Ue.position=I}let U=bm.test(d);Ue[U?0:1]+=d,b[v++]=193,te(U?-y:y);return}let k;y<32?k=1:y<256?k=2:y<65536?k=3:k=5;let R=y*3;if(v+R>ht&&(b=Xe(v+R)),y<64||!i){let U,I,re,q=v+k;for(U=0;U<y;U++)I=d.charCodeAt(U),I<128?b[q++]=I:I<2048?(b[q++]=I>>6|192,b[q++]=I&63|128):(I&64512)===55296&&((re=d.charCodeAt(U+1))&64512)===56320?(I=65536+((I&1023)<<10)+(re&1023),U++,b[q++]=I>>18|240,b[q++]=I>>12&63|128,b[q++]=I>>6&63|128,b[q++]=I&63|128):(b[q++]=I>>12|224,b[q++]=I>>6&63|128,b[q++]=I&63|128);m=q-v-k}else m=i(d,v+k);m<32?b[v++]=160|m:m<256?(k<2&&b.copyWithin(v+2,v+1,v+1+m),b[v++]=217,b[v++]=m):m<65536?(k<3&&b.copyWithin(v+3,v+2,v+2+m),b[v++]=218,b[v++]=m>>8,b[v++]=m&255):(k<5&&b.copyWithin(v+5,v+3,v+3+m),b[v++]=219,Ie.setUint32(v,m),v+=4),v+=m}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,Ie.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,Ie.setInt16(v,d),v+=2):(b[v++]=210,Ie.setInt32(v,d),v+=4);else{let y;if((y=this.useFloat32)>0&&d<4294967296&&d>=-2147483648){b[v++]=202,Ie.setFloat32(v,d);let k;if(y<4||(k=d*lc[(b[v]&127)<<1|b[v+1]>>7])>>0===k){v+=4;return}else v--}b[v++]=203,Ie.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,Ie.setUint32(v,k.id),v+=4;return}else a.set(d,{offset:v-t})}let y=d.constructor;if(y===Object)sr(d,!0);else if(y===Array)Qr(d);else if(y===Map)if(this.mapAsEmptyObject)b[v++]=128;else{m=d.size,m<16?b[v++]=128|m:m<65536?(b[v++]=222,b[v++]=m>>8,b[v++]=m&255):(b[v++]=223,Ie.setUint32(v,m),v+=4);for(let[k,R]of d)te(k),te(R)}else{for(let k=0,R=So.length;k<R;k++){let U=Wl[k];if(d instanceof U){let I=So[k];if(I.write){I.type&&(b[v++]=212,b[v++]=I.type,b[v++]=0);let Qe=I.write.call(this,d);Qe===d?Array.isArray(d)?Qr(d):sr(d):te(Qe);return}let re=b,q=Ie,Ke=v;b=null;let dt;try{dt=I.pack.call(this,d,Qe=>(b=re,re=null,v+=Qe,v>ht&&Xe(v),{target:b,targetView:Ie,position:v-Qe}),te)}finally{re&&(b=re,Ie=q,v=Ke,ht=b.length-10)}dt&&(dt.length+v>ht&&Xe(dt.length+v),v=km(dt,b,v,I.type));return}}if(Array.isArray(d))Qr(d);else{if(d.toJSON){const k=d.toJSON();if(k!==d)return te(k)}if(O==="function")return te(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,Ie.setBigInt64(v,d);else if(d<BigInt(1)<<BigInt(64)&&d>0)b[v++]=207,Ie.setBigUint64(v,d);else if(this.largeBigIntToFloat)b[v++]=203,Ie.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)},Fn=this.variableMapSize||this.coercibleKeyAsNumber?d=>{let O=Object.keys(d),m=O.length;m<16?b[v++]=128|m:m<65536?(b[v++]=222,b[v++]=m>>8,b[v++]=m&255):(b[v++]=223,Ie.setUint32(v,m),v+=4);let y;if(this.coercibleKeyAsNumber)for(let k=0;k<m;k++){y=O[k];let R=Number(y);te(isNaN(R)?y:R),te(d[y])}else for(let k=0;k<m;k++)te(y=O[k]),te(d[y])}:(d,O)=>{b[v++]=222;let m=v-t;v+=2;let y=0;for(let k in d)(O||d.hasOwnProperty(k))&&(te(k),te(d[k]),y++);b[m+++t]=y>>8,b[m+t]=y&255},Wn=this.useRecords===!1?Fn:e.progressiveRecords&&!Q?(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=v++-t,R;for(let U in d)if(O||d.hasOwnProperty(U)){if(m=y[U],m)y=m;else{let I=Object.keys(d),re=y;y=s.transitions;let q=0;for(let Ke=0,dt=I.length;Ke<dt;Ke++){let Qe=I[Ke];m=y[Qe],m||(m=y[Qe]=Object.create(null),q++),y=m}k+t+1==v?(v--,en(y,I,q)):Jn(y,I,k,q),R=!0,y=re[U]}te(d[U])}if(!R){let U=y[On];U?b[k+t]=U:Jn(y,Object.keys(d),k,0)}}:(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=0;for(let U in d)(O||d.hasOwnProperty(U))&&(m=y[U],m||(m=y[U]=Object.create(null),k++),y=m);let R=y[On];R?R>=96&&Q?(b[v++]=((R-=96)&31)+96,b[v++]=R>>5):b[v++]=R:en(y,y.__keys__||Object.keys(d),k);for(let U in d)(O||d.hasOwnProperty(U))&&te(d[U])},Yn=typeof this.useRecords=="function"&&this.useRecords,sr=Yn?(d,O)=>{Yn(d)?Wn(d,O):Fn(d,O)}:Wn,Xe=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 m=new ca(O);return Ie=m.dataView||(m.dataView=new DataView(m.buffer,0,O)),d=Math.min(d,b.length),b.copy?b.copy(m,0,t,d):m.set(b.slice(t,d)),v-=t,t=0,ht=m.length-10,b=m},en=(d,O,m)=>{let y=s.nextId;y||(y=64),y<ce&&this.shouldShareStructure&&!this.shouldShareStructure(O)?(y=s.nextOwnId,y<Ne||(y=ce),s.nextOwnId=y+1):(y>=Ne&&(y=ce),s.nextId=y+1);let k=O.highByte=y>=96&&Q?y-96>>5:-1;d[On]=y,d.__keys__=O,s[y-64]=O,y<ce?(O.isShared=!0,s.sharedLength=y-63,n=!0,k>=0?(b[v++]=(y&31)+96,b[v++]=k):b[v++]=y):(k>=0?(b[v++]=213,b[v++]=114,b[v++]=(y&31)+96,b[v++]=k):(b[v++]=212,b[v++]=114,b[v++]=y),m&&(rr+=nr*m),ee.length>=E&&(ee.shift()[On]=0),ee.push(d),te(O))},Jn=(d,O,m,y)=>{let k=b,R=v,U=ht,I=t;b=Gn,v=0,t=0,b||(Gn=b=new ca(8192)),ht=b.length-10,en(d,O,y),Gn=b;let re=v;if(b=k,v=R,ht=U,t=I,re>1){let q=v+re-1;q>ht&&Xe(q);let Ke=m+t;b.copyWithin(Ke+re,Ke+1,v),b.set(Gn.slice(0,re),Ke),v=q}else b[m+t]=Gn[0]},Vi=(d,O)=>{let m=vm(d,b,t,v,s,Xe,(y,k,R)=>{if(R)return n=!0;v=k;let U=b;return te(y),qn(),U!==b?{position:v,targetView:Ie,target:b}:v},this);if(m===0)return sr(d,!0);v=m}}useBuffer(e){b=e,Ie=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,Ul];So=[{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!==Yl&&this.moreTypes?du(r,ql.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 km(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 Om(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){Ie.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 Tm(r,e){return r.isCompatible=t=>{let n=!t||(e.lastNamedStructuresLength||0)===t.length;return n||e._mergeStructures(t),n},r}let Jl=new _m({useRecords:!1});const xm=Jl.pack;Jl.pack;const Sm=512,Nm=1024,Em=2048;let Gl=class{constructor(){S(this,"contentType","application/msgpack")}encode(e){return xm(Un.toSnake(e))}decode(e,t){const n=Un.toCamel(ym(new Uint8Array(e)));return t!=null?t.parse(n):n}},Hl=class{constructor(){S(this,"contentType","application/json"),S(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 Am=[new Gl,new Hl],Xl=Object.freeze(Object.defineProperty({__proto__:null,ENCODERS:Am,JSONEncoderDecoder:Hl,MsgpackEncoderDecoder:Gl},Symbol.toStringTag,{value:"Module"}));let Im=class{constructor(e){S(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:Im},Symbol.toStringTag,{value:"Module"})),Js=u.z.number(),Gs=u.z.object({name:u.z.string(),key:u.z.number(),rate:xi.z,dataType:rt.z,leaseholder:u.z.number(),index:u.z.number(),isIndex:u.z.boolean(),alias:u.z.string().optional()}),Ql=Gs.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()}),ed=r=>r.map(e=>({name:e.name,dataType:e.dataType,rate:e.rate??0,leaseholder:e.leaseholder,index:e.index,isIndex:e.isIndex})),Zm=u.z.object({channels:Ql.array()}),$m=u.z.object({channels:Gs.array()}),vi=class vi{constructor(e){h(this,"client");this.client=e}async create(e){const t={channels:ed(e)},[n,s]=await this.client.send(vi.ENDPOINT,t,Zm,$m);if(s!=null)throw s;return n.channels}};h(vi,"ENDPOINT","/channel/create");let Ga=vi;const Cm=new Error("request for lock canceled");var jm=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(g){try{l(n.next(g))}catch(E){i(E)}}function c(g){try{l(n.throw(g))}catch(E){i(E)}}function l(g){g.done?a(g.value):s(g.value).then(o,c)}l((n=n.apply(r,e||[])).next())})};class Rm{constructor(e,t=Cm){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 jm(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 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(g){try{l(n.next(g))}catch(E){i(E)}}function c(g){try{l(n.throw(g))}catch(E){i(E)}}function l(g){g.done?a(g.value):s(g.value).then(o,c)}l((n=n.apply(r,e||[])).next())})};class Pm{constructor(e){this._semaphore=new Rm(1,e)}acquire(){return zm(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()}}const Um=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()}),Dm=u.z.object({channels:Gs.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}=Gr(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,Um,Dm);if(n!=null)throw n;return t.channels}};h(wi,"ENDPOINT","/channel/retrieve");let vs=wi;class dc{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}=Gr(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 Gr=r=>{const e=Se(r).filter(t=>t!=0);return{single:!Array.isArray(r),variant:typeof e[0]=="number"?"keys":"names",normalized:e,actual:r}};class td{constructor(e,t){h(this,"mu",new Pm);h(this,"requests",new Map);h(this,"wrapped");h(this,"debouncedRun");this.wrapped=e,this.debouncedRun=am(()=>{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}=Gr(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()}})}}var Mm=Object.defineProperty,Lm=(r,e,t)=>e in r?Mm(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,We=(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 No;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(No||(No={}));const M=ke.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),jr=r=>{switch(typeof r){case"undefined":return M.undefined;case"string":return M.string;case"number":return isNaN(r)?M.nan:M.number;case"boolean":return M.boolean;case"function":return M.function;case"bigint":return M.bigint;case"symbol":return M.symbol;case"object":return Array.isArray(r)?M.array:r===null?M.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?M.promise:typeof Map<"u"&&r instanceof Map?M.map:typeof Set<"u"&&r instanceof Set?M.set:typeof Date<"u"&&r instanceof Date?M.date:M.object;default:return M.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"]),Km=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 ws=(r,e)=>{let t;switch(r.code){case $.invalid_type:r.received===M.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 rd=ws;function qm(r){rd=r}function Ha(){return rd}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}},Fm=[];function V(r,e){const t=Xa({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,Ha(),ws].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"}),nd=r=>({status:"dirty",value:r}),vt=r=>({status:"valid",value:r}),Eo=r=>r.status==="aborted",Ao=r=>r.status==="dirty",bs=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 Ht{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(bs(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 jr(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:jr(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:jr(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:jr(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:jr(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:H.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return Or.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 Mn.create(this,this._def)}or(e){return Ts.create([this,e],this._def)}and(e){return xs.create(this,e,this._def)}transform(e){return new Bt({...le(this._def),schema:this,typeName:H.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Is({...le(this._def),innerType:this,defaultValue:t,typeName:H.ZodDefault})}brand(){return new ad({typeName:H.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:H.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Hs.create(this,e)}readonly(){return ai.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 Yi;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 $t extends pe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==M.string){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:M.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),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")Yi||(Yi=new RegExp(Xm,"u")),Yi.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 $t({...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 $t({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new $t({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new $t({...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}}$t.create=r=>{var e;return new $t({checks:[],typeName:H.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 Vr 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)!==M.number){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:M.number,received:s.parsedType}),ie}let t;const n=new ct;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 Vr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:W.toString(s)}]})}_addCheck(e){return new Vr({...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)}}Vr.create=r=>new Vr({checks:[],typeName:H.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)!==M.bigint){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:M.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),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:H.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...le(r)})};class _s extends pe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==M.boolean){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.boolean,received:t.parsedType}),ie}return vt(e.data)}}_s.create=r=>new _s({typeName:H.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)!==M.date){const s=this._getOrReturnCtx(e);return V(s,{code:$.invalid_type,expected:M.date,received:s.parsedType}),ie}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return V(s,{code:$.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),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:H.ZodDate,...le(r)});class ei extends pe{_parse(e){if(this._getType(e)!==M.symbol){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.symbol,received:t.parsedType}),ie}return vt(e.data)}}ei.create=r=>new ei({typeName:H.ZodSymbol,...le(r)});class ks extends pe{_parse(e){if(this._getType(e)!==M.undefined){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.undefined,received:t.parsedType}),ie}return vt(e.data)}}ks.create=r=>new ks({typeName:H.ZodUndefined,...le(r)});class Os extends pe{_parse(e){if(this._getType(e)!==M.null){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.null,received:t.parsedType}),ie}return vt(e.data)}}Os.create=r=>new Os({typeName:H.ZodNull,...le(r)});class Dn extends pe{constructor(){super(...arguments),this._any=!0}_parse(e){return vt(e.data)}}Dn.create=r=>new Dn({typeName:H.ZodAny,...le(r)});class cn extends pe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return vt(e.data)}}cn.create=r=>new cn({typeName:H.ZodUnknown,...le(r)});class Nr extends pe{_parse(e){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.never,received:t.parsedType}),ie}}Nr.create=r=>new Nr({typeName:H.ZodNever,...le(r)});class ti extends pe{_parse(e){if(this._getType(e)!==M.undefined){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.void,received:t.parsedType}),ie}return vt(e.data)}}ti.create=r=>new ti({typeName:H.ZodVoid,...le(r)});class Pt extends pe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==M.array)return V(t,{code:$.invalid_type,expected:M.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)&&(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 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 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:H.ZodArray,...le(e)});function Nn(r){if(r instanceof Me){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=Or.create(Nn(n))}return new Me({...r._def,shape:()=>e})}else return r instanceof Pt?new Pt({...r._def,type:Nn(r.element)}):r instanceof Or?Or.create(Nn(r.unwrap())):r instanceof mn?mn.create(Nn(r.unwrap())):r instanceof Xt?Xt.create(r.items.map(e=>Nn(e))):r}class Me 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)!==M.object){const c=this._getOrReturnCtx(e);return V(c,{code:$.invalid_type,expected:M.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 Nr&&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],g=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Ht(n,g,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Nr){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 g=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Ht(n,g,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const g=await l.key;c.push({key:g,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 W.errToObj,new Me({...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 Me({...this._def,unknownKeys:"strip"})}passthrough(){return new Me({...this._def,unknownKeys:"passthrough"})}extend(e){return new Me({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Me({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 Me({...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 Me({...this._def,shape:()=>t})}omit(e){const t={};return ke.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Me({...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 Me({...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 Or;)s=s._def.innerType;t[n]=s}}),new Me({...this._def,shape:()=>t})}keyof(){return sd(ke.objectKeys(this.shape))}}Me.create=(r,e)=>new Me({shape:()=>r,unknownKeys:"strip",catchall:Nr.create(),typeName:H.ZodObject,...le(e)});Me.strictCreate=(r,e)=>new Me({shape:()=>r,unknownKeys:"strict",catchall:Nr.create(),typeName:H.ZodObject,...le(e)});Me.lazycreate=(r,e)=>new Me({shape:r,unknownKeys:"strip",catchall:Nr.create(),typeName:H.ZodObject,...le(e)});class Ts 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}),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},g=c._parseSync({data:t.data,path:t.path,parent:l});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,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}),ie}}get options(){return this._def.options}}Ts.create=(r,e)=>new Ts({options:r,typeName:H.ZodUnion,...le(e)});const xa=r=>r instanceof Ns?xa(r.schema):r instanceof Bt?xa(r.innerType()):r instanceof Es?[r.value]:r instanceof qr?r.options:r instanceof As?Object.keys(r.enum):r instanceof Is?xa(r._def.innerType):r instanceof ks?[void 0]:r instanceof Os?[null]:null;class Ei extends pe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.object)return V(t,{code:$.invalid_type,expected:M.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}):(V(t,{code:$.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=xa(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:H.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...le(n)})}}function Io(r,e){const t=jr(r),n=jr(e);if(r===e)return{valid:!0,data:r};if(t===M.object&&n===M.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=Io(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===M.array&&n===M.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=Io(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===M.date&&n===M.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}class xs extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(Eo(a)||Eo(i))return ie;const o=Io(a.value,i.value);return o.valid?((Ao(a)||Ao(i))&&t.dirty(),{status:t.value,value:o.data}):(V(n,{code:$.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}))}}xs.create=(r,e,t)=>new xs({left:r,right:e,typeName:H.ZodIntersection,...le(t)});class Xt extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==M.array)return V(n,{code:$.invalid_type,expected:M.array,received:n.parsedType}),ie;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"}),ie;!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 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 Xt({...this._def,rest:e})}}Xt.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Xt({items:r,typeName:H.ZodTuple,rest:null,...le(e)})};class Ss 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!==M.object)return V(n,{code:$.invalid_type,expected:M.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 pe?new Ss({keyType:e,valueType:t,typeName:H.ZodRecord,...le(n)}):new Ss({keyType:$t.create(),valueType:e,typeName:H.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!==M.map)return V(n,{code:$.invalid_type,expected:M.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,g=await c.value;if(l.status==="aborted"||g.status==="aborted")return ie;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,g=c.value;if(l.status==="aborted"||g.status==="aborted")return ie;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}}}}ri.create=(r,e,t)=>new ri({valueType:e,keyType:r,typeName:H.ZodMap,...le(t)});class fn extends pe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==M.set)return V(n,{code:$.invalid_type,expected:M.set,received:n.parsedType}),ie;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 g of c){if(g.status==="aborted")return ie;g.status==="dirty"&&t.dirty(),l.add(g.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 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:H.ZodSet,...le(e)});class Zn extends pe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.function)return V(t,{code:$.invalid_type,expected:M.function,received:t.parsedType}),ie;function n(o,c){return Xa({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Ha(),ws].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(),ws].filter(l=>!!l),issueData:{code:$.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 zt([]),g=await o._def.args.parseAsync(c,a).catch(Q=>{throw l.addIssue(n(c,Q)),l}),E=await Reflect.apply(i,this,g);return await o._def.returns._def.type.parseAsync(E,a).catch(Q=>{throw l.addIssue(s(E,Q)),l})})}else{const o=this;return vt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new zt([n(c,l.error)]);const g=Reflect.apply(i,this,l.data),E=o._def.returns.safeParse(g,a);if(!E.success)throw new zt([s(g,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Zn({...this._def,args:Xt.create(e).rest(cn.create())})}returns(e){return new Zn({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Zn({args:e||Xt.create([]).rest(cn.create()),returns:t||cn.create(),typeName:H.ZodFunction,...le(n)})}}class Ns 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})}}Ns.create=(r,e)=>new Ns({getter:r,typeName:H.ZodLazy,...le(e)});class Es 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}),ie}return{status:"valid",value:e.data}}get value(){return this._def.value}}Es.create=(r,e)=>new Es({value:r,typeName:H.ZodLiteral,...le(e)});function sd(r,e){return new qr({values:r,typeName:H.ZodEnum,...le(e)})}class qr 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}),ie}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}),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 qr.create(e)}exclude(e){return qr.create(this.options.filter(t=>!e.includes(t)))}}qr.create=sd;class As extends pe{_parse(e){const t=ke.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==M.string&&n.parsedType!==M.number){const s=ke.objectValues(t);return V(n,{expected:ke.joinValues(s),received:n.parsedType,code:$.invalid_type}),ie}if(t.indexOf(e.data)===-1){const s=ke.objectValues(t);return V(n,{received:n.data,code:$.invalid_enum_value,options:s}),ie}return vt(e.data)}get enum(){return this._def.values}}As.create=(r,e)=>new As({values:r,typeName:H.ZodNativeEnum,...le(e)});class Mn extends pe{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==M.promise&&t.common.async===!1)return V(t,{code:$.invalid_type,expected:M.promise,received:t.parsedType}),ie;const n=t.parsedType===M.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,...le(e)});class Bt extends pe{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=>{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"?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(!bs(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=>bs(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:H.ZodEffects,effect:e,...le(t)});Bt.createWithPreprocess=(r,e,t)=>new Bt({schema:e,effect:{type:"preprocess",transform:r},typeName:H.ZodEffects,...le(t)});class Or extends pe{_parse(e){return this._getType(e)===M.undefined?vt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}Or.create=(r,e)=>new Or({innerType:r,typeName:H.ZodOptional,...le(e)});class mn extends pe{_parse(e){return this._getType(e)===M.null?vt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}mn.create=(r,e)=>new mn({innerType:r,typeName:H.ZodNullable,...le(e)});class Is extends pe{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===M.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}Is.create=(r,e)=>new Is({innerType:r,typeName:H.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:H.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...le(e)});class si extends pe{_parse(e){if(this._getType(e)!==M.nan){const t=this._getOrReturnCtx(e);return V(t,{code:$.invalid_type,expected:M.nan,received:t.parsedType}),ie}return{status:"valid",value:e.data}}}si.create=r=>new si({typeName:H.ZodNaN,...le(r)});const sy=Symbol("zod_brand");class ad 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 Hs 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"?ie:s.status==="dirty"?(t.dirty(),nd(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 Hs({in:e,out:t,typeName:H.ZodPipeline})}}class ai extends pe{_parse(e){const t=this._def.innerType._parse(e);return bs(t)&&(t.value=Object.freeze(t.value)),t}}ai.create=(r,e)=>new ai({innerType:r,typeName:H.ZodReadonly,...le(e)});const id=(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:Me.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 iy=(r,e={message:`Input not instance of ${r.name}`})=>id(t=>t instanceof r,e),od=$t.create,cd=Vr.create,oy=si.create,cy=Kr.create,ud=_s.create,uy=pn.create,ly=ei.create,dy=ks.create,hy=Os.create,py=Dn.create,fy=cn.create,my=Nr.create,yy=ti.create,gy=Pt.create,vy=Me.create,wy=Me.strictCreate,by=Ts.create,_y=Ei.create,ky=xs.create,Oy=Xt.create,Ty=Ss.create,xy=ri.create,Sy=fn.create,Ny=Zn.create,Ey=Ns.create,Ay=Es.create,Iy=qr.create,Zy=As.create,$y=Mn.create,mu=Bt.create,Cy=Or.create,jy=mn.create,Ry=Bt.createWithPreprocess,zy=Hs.create,Py=()=>od().optional(),Uy=()=>cd().optional(),Dy=()=>ud().optional(),My={string:r=>$t.create({...r,coerce:!0}),number:r=>Vr.create({...r,coerce:!0}),boolean:r=>_s.create({...r,coerce:!0}),bigint:r=>Kr.create({...r,coerce:!0}),date:r=>pn.create({...r,coerce:!0})},Ly=ie;var x=Object.freeze({__proto__:null,defaultErrorMap:ws,setErrorMap:qm,getErrorMap:Ha,makeIssue:Xa,EMPTY_PATH:Fm,addIssueToContext:V,ParseStatus:ct,INVALID:ie,DIRTY:nd,OK:vt,isAborted:Eo,isDirty:Ao,isValid:bs,isAsync:Qa,get util(){return ke},get objectUtil(){return No},ZodParsedType:M,getParsedType:jr,ZodType:pe,ZodString:$t,ZodNumber:Vr,ZodBigInt:Kr,ZodBoolean:_s,ZodDate:pn,ZodSymbol:ei,ZodUndefined:ks,ZodNull:Os,ZodAny:Dn,ZodUnknown:cn,ZodNever:Nr,ZodVoid:ti,ZodArray:Pt,ZodObject:Me,ZodUnion:Ts,ZodDiscriminatedUnion:Ei,ZodIntersection:xs,ZodTuple:Xt,ZodRecord:Ss,ZodMap:ri,ZodSet:fn,ZodFunction:Zn,ZodLazy:Ns,ZodLiteral:Es,ZodEnum:qr,ZodNativeEnum:As,ZodPromise:Mn,ZodEffects:Bt,ZodTransformer:Bt,ZodOptional:Or,ZodNullable:mn,ZodDefault:Is,ZodCatch:ni,ZodNaN:si,BRAND:sy,ZodBranded:ad,ZodPipeline:Hs,ZodReadonly:ai,custom:id,Schema:pe,ZodSchema:pe,late:ay,get ZodFirstPartyTypeKind(){return H},coerce:My,any:py,array:gy,bigint:cy,boolean:ud,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:cd,object:vy,oboolean:Dy,onumber:Uy,optional:Cy,ostring:Py,pipeline:zy,preprocess:Ry,promise:$y,record:Ty,set:Sy,strictObject:wy,string:od,symbol:ly,transformer:mu,tuple:Oy,undefined:dy,union:by,unknown:fy,void:yy,NEVER:Ly,ZodIssueCode:$,quotelessJson:Km,ZodError:zt});const hc=x.tuple([x.number(),x.number()]),ld=x.object({width:x.number(),height:x.number()}),By=x.object({signedWidth:x.number(),signedHeight:x.number()}),Vy=["width","height"];x.enum(Vy);const Ky=["start","center","end"],qy=["signedWidth","signedHeight"];x.enum(qy);const ii=x.object({x:x.number(),y:x.number()}),Fy=x.object({clientX:x.number(),clientY:x.number()}),Wy=["x","y"],dd=x.enum(Wy),hd=["top","right","bottom","left"];x.enum(hd);const Yy=["left","right"],pd=x.enum(Yy),Jy=["top","bottom"],fd=x.enum(Jy),md=["center"],yu=x.enum(md),Gy=[...hd,...md],yd=x.enum(Gy);x.enum(Ky);const Hy=["first","last"];x.enum(Hy);const Xy=x.object({lower:x.number(),upper:x.number()});x.union([Xy,hc]);x.union([dd,yd]);x.union([dd,yd,x.instanceof(String)]);const Ji=(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 At=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 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()}):""}Ai.default=eg;var Ii={};Object.defineProperty(Ii,"__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():""}Ii.default=tg;var Zi={};Object.defineProperty(Zi,"__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()}):""}Zi.default=rg;var pc={};Object.defineProperty(pc,"__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():""}pc.default=ng;var fc={};Object.defineProperty(fc,"__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():""}fc.default=sg;var mc={};Object.defineProperty(mc,"__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():""}mc.default=ag;var yc={};Object.defineProperty(yc,"__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)}yc.default=ig;var gc={};Object.defineProperty(gc,"__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}):""}gc.default=og;var $i={};Object.defineProperty($i,"__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():""}$i.default=cg;var vc={},_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=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(vc,"__esModule",{value:!0});var dr=_n;function Sa(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=Sa(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=Sa(i,e));else if(dr.isArrayObject(i)){var c=Sa({key:i},e);o=c.key}return o}))),t[a]=s}),t}vc.default=Sa;var wc={},lg=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(wc,"__esModule",{value:!0});var hr=_n;function Na(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=Na(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=Na(i,e));else if(hr.isArrayObject(i)){var c=Na({key:i},e);o=c.key}return o}))),t[a]=s}),t}wc.default=Na;var bc={},dg=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(bc,"__esModule",{value:!0});var pr=_n,hg=Ai;function Ea(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=Ea(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=Ea(i,e));else if(pr.isArrayObject(i)){var c=Ea({key:i},e);o=c.key}return o}))),t[a]=s}),t}bc.default=Ea;var _c={},pg=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(_c,"__esModule",{value:!0});var fr=_n,fg=Ii;function Aa(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=Aa(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=Aa(i,e));else if(fr.isArrayObject(i)){var c=Aa({key:i},e);o=c.key}return o}))),t[a]=s}),t}_c.default=Aa;var kc={},mg=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(kc,"__esModule",{value:!0});var mr=_n,yg=Zi;function Ia(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=Ia(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=Ia(i,e));else if(mr.isArrayObject(i)){var c=Ia({key:i},e);o=c.key}return o}))),t[a]=s}),t}kc.default=Ia;var Oc={},gg=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(Oc,"__esModule",{value:!0});var yr=_n,vg=$i;function Za(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=Za(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=Za(i,e));else if(yr.isArrayObject(i)){var c=Za({key:i},e);o=c.key}return o}))),t[a]=s}),t}Oc.default=Za;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 gd=Ai;ye.toCamelCase=gd.default;var vd=Ii;ye.toSnakeCase=vd.default;var wd=Zi;ye.toPascalCase=wd.default;var bd=pc;ye.toDotCase=bd.default;var _d=fc;ye.toPathCase=_d.default;var kd=mc;ye.toTextCase=kd.default;var Od=yc;ye.toSentenceCase=Od.default;var Td=gc;ye.toHeaderCase=Td.default;var xd=$i;ye.toKebabCase=xd.default;var Sd=vc;ye.lowerKeys=Sd.default;var Nd=wc;ye.upperKeys=Nd.default;var Ed=bc;ye.camelKeys=Ed.default;var Ad=_c;ye.snakeKeys=Ad.default;var Id=kc;ye.pascalKeys=Id.default;var Zd=Oc;ye.kebabKeys=Zd.default;var $d=function(r){return String(r||"").toLowerCase()};ye.toLowerCase=$d;var Cd=function(r){return String(r||"").toUpperCase()};ye.toUpperCase=Cd;var wg={toCamelCase:gd.default,toSnakeCase:vd.default,toPascalCase:wd.default,toDotCase:bd.default,toPathCase:_d.default,toTextCase:kd.default,toSentenceCase:Od.default,toHeaderCase:Td.default,toKebabCase:xd.default,toUpperCase:Cd,toLowerCase:$d,lowerKeys:Sd.default,upperKeys:Nd.default,camelKeys:Ed.default,snakeKeys:Ad.default,pascalKeys:Id.default,kebabKeys:Zd.default};ye.default=wg;var jd=ye;const Rd={recursive:!0,recursiveInArray:!0,keepTypesOnRecursion:[Number,String,Uint8Array]},bg=r=>jd.snakeKeys(r,Rd),_g=r=>jd.camelKeys(r,Rd);var Ln;(r=>{r.toSnake=bg,r.toCamel=_g,r.capitalize=e=>e[0].toUpperCase()+e.slice(1)})(Ln||(Ln={}));x.object({x:pd.or(yu),y:fd.or(yu)});const kg=x.object({x:pd,y:fd}),Og=Object.freeze({x:"left",y:"top"}),Tg=(r,e)=>r.x===e.x&&r.y===e.y,gu=x.union([x.number(),ii,hc,ld,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},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:ii,two:ii,root:kg});const Tc=(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))},Gi=r=>{const e=Tc(r);return{lower:e.one.x,upper:e.two.x}},Hi=r=>{const e=Tc(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=x.object({signedWidth:x.number(),signedHeight:x.number()});x.union([ld,Ng,ii,hc]);const Eg=(r,e,t)=>(e!=null&&(r=Math.max(r,e)),t!=null&&(r=Math.min(r,t)),r);x.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 g=(n-s)*(l/c)+i;return[r,g]},$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]},Zo=class rs{constructor(){j(this,"ops",[]),j(this,"currBounds",null),j(this,"currType",null),j(this,"reversed",!1),this.ops=[]}static translate(e){return new rs().translate(e)}static magnify(e){return new rs().magnify(e)}static scale(e,t){return new rs().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=Ji(e,t),s=this.new(),a=Zg(n);return a.type="scale",s.ops.push(a),s}clamp(e,t){const n=Ji(e,t),s=this.new(),a=jg(n);return a.type="clamp",s.ops.push(a),s}reBound(e,t){const n=Ji(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 rs;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(Zo,"IDENTITY",new Zo);let wu=Zo;const bu=class vr{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 vr().translate(e,t)}static translateX(e){return new vr().translateX(e)}static translateY(e){return new vr().translateY(e)}static clamp(e){return new vr().clamp(e)}static magnify(e){return new vr().magnify(e)}static scale(e){return new vr().scale(e)}static reBound(e){return new vr().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(Gi(e)),t.y=t.y.scale(Hi(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(Gi(e)),t.y=this.y.reBound(Hi(e)),t}clamp(e){const t=this.copy();return t.x=this.x.clamp(Gi(e)),t.y=this.y.clamp(Hi(e)),t}copy(){const e=new vr;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 Tc(this.pos(e.one),this.pos(e.two),0,0,this.currRoot??e.root)}};j(bu,"IDENTITY",new bu);const zd=(r,e)=>{const t=new bt(e);if(![mt.DAY,mt.HOUR,mt.MINUTE,mt.SECOND,mt.MILLISECOND,mt.MICROSECOND,mt.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 bt?new bt(n):new mt(n)},Ze=class se{constructor(e,t="UTC"){if(j(this,"value"),j(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 mt(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 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 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 zd(this,e)}get isToday(){return this.truncate(mt.DAY).equals(se.now().truncate(mt.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)}};j(Ze,"NANOSECOND",Ze.nanoseconds(1)),j(Ze,"MICROSECOND",Ze.microseconds(1)),j(Ze,"MILLISECOND",Ze.milliseconds(1)),j(Ze,"SECOND",Ze.seconds(1)),j(Ze,"MINUTE",Ze.minutes(1)),j(Ze,"HOUR",Ze.hours(1)),j(Ze,"DAY",Ze.days(1)),j(Ze,"MAX",new Ze((1n<<63n)-1n)),j(Ze,"MIN",new Ze(0)),j(Ze,"ZERO",new Ze(0)),j(Ze,"z",x.union([x.object({value:x.bigint()}).transform(r=>new Ze(r.value)),x.string().transform(r=>new Ze(BigInt(r))),x.instanceof(Number).transform(r=>new Ze(r)),x.number().transform(r=>new Ze(r)),x.instanceof(Ze)]));let bt=Ze;const $e=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 zd(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),g=n.sub(t),E=s.sub(n),Q=a.sub(s),ce=i.sub(a),Ne=o.sub(i);let ee="";return c.isZero||(ee+=`${c.days}d `),l.isZero||(ee+=`${l.hours}h `),g.isZero||(ee+=`${g.minutes}m `),E.isZero||(ee+=`${E.seconds}s `),Q.isZero||(ee+=`${Q.milliseconds}ms `),ce.isZero||(ee+=`${ce.microseconds}µs `),Ne.isZero||(ee+=`${Ne.nanoseconds}ns`),ee.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($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",x.union([x.object({value:x.bigint()}).transform(r=>new $e(r.value)),x.string().transform(r=>new $e(BigInt(r))),x.instanceof(Number).transform(r=>new $e(r)),x.number().transform(r=>new $e(r)),x.instanceof($e)]));let mt=$e;const la=class $a extends Number{constructor(e){e instanceof Number?super(e.valueOf()):super(e)}toString(){return`${this.valueOf()} Hz`}equals(e){return this.valueOf()===new $a(e).valueOf()}get period(){return mt.seconds(1/this.valueOf())}sampleCount(e){return new mt(e).seconds*this.valueOf()}byteCount(e,t){return this.sampleCount(e)*new ft(t).valueOf()}span(e){return mt.seconds(e/this.valueOf())}byteSpan(e,t){return this.span(e.valueOf()/t.valueOf())}static hz(e){return new $a(e)}static khz(e){return $a.hz(e*1e3)}};j(la,"z",x.union([x.number().transform(r=>new la(r)),x.instanceof(Number).transform(r=>new la(r)),x.instanceof(la)]));const tt=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(tt,"UNKNOWN",new tt(0)),j(tt,"BIT128",new tt(16)),j(tt,"BIT64",new tt(8)),j(tt,"BIT32",new tt(4)),j(tt,"BIT16",new tt(2)),j(tt,"BIT8",new tt(1)),j(tt,"z",x.union([x.number().transform(r=>new tt(r)),x.instanceof(Number).transform(r=>new tt(r)),x.instanceof(tt)]));let ft=tt;const qt=class Ca{constructor(e,t){j(this,"start"),j(this,"end"),this.start=new bt(e),this.end=new bt(t)}get span(){return new mt(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 Ca(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 Ca?this.contains(e.start)&&this.contains(e.end):this.start.beforeEq(e)&&this.end.after(e)}boundBy(e){const t=new Ca(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(qt,"MAX",new qt(bt.MIN,bt.MAX)),j(qt,"MIN",new qt(bt.MAX,bt.MIN)),j(qt,"ZERO",new qt(bt.ZERO,bt.ZERO)),j(qt,"z",x.union([x.object({start:bt.z,end:bt.z}).transform(r=>new qt(r.start,r.end)),x.instanceof(qt)]));let Rg=qt;const A=class an extends String{constructor(e){if(e instanceof an||typeof e=="string"||typeof e.valueOf()=="string"){super(e.valueOf());return}else{const t=an.ARRAY_CONSTRUCTOR_DATA_TYPES.get(e.constructor.name);if(t!=null){super(t.valueOf());return}}throw super(an.UNKNOWN.valueOf()),new Error(`unable to find data type for ${e.toString()}`)}get Array(){const e=an.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 density(){const e=an.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 an.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,"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(),ft.BIT8],[A.UINT16.toString(),ft.BIT16],[A.UINT32.toString(),ft.BIT32],[A.UINT64.toString(),ft.BIT64],[A.FLOAT32.toString(),ft.BIT32],[A.FLOAT64.toString(),ft.BIT64],[A.INT8.toString(),ft.BIT8],[A.INT16.toString(),ft.BIT16],[A.INT32.toString(),ft.BIT32],[A.INT64.toString(),ft.BIT64],[A.TIMESTAMP.toString(),ft.BIT64],[A.STRING.toString(),ft.UNKNOWN],[A.JSON.toString(),ft.UNKNOWN],[A.UUID.toString(),ft.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",x.union([x.string().transform(r=>new A(r)),x.instanceof(A)]));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),g=a.sub(s);let E="";return i.isZero||(E+=`${i.terabytes}TB `),o.isZero||(E+=`${o.gigabytes}GB `),c.isZero||(E+=`${c.megabytes}MB `),l.isZero||(E+=`${l.kilobytes}KB `),(!g.isZero||E==="")&&(E+=`${g.valueOf()}B`),E.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}};j(at,"BYTE",new at(1)),j(at,"KILOBYTE",at.kilobytes(1)),j(at,"MEGABYTE",at.megabytes(1)),j(at,"GIGABYTE",at.gigabytes(1)),j(at,"TERABYTE",at.terabytes(1)),j(at,"ZERO",new at(0)),j(at,"z",x.union([x.number().transform(r=>new at(r)),x.instanceof(at)]));let zg=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)]);x.record(x.union([x.number(),x.string(),x.symbol()]),x.unknown());const Pg=r=>r!=null&&typeof r=="object"&&!Array.isArray(r),Pd=()=>typeof process<"u"&&process.versions!=null&&process.versions.node!=null?"node":typeof window>"u"||window.document===void 0?"webworker":"browser",Ug=Pd(),Ud=["MacOS","Windows","Linux","Docker"],Dg=x.enum(Ud);let Xi;const Mg=()=>{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??Xi??(Xi=Mg(),Xi??t)},Dd=Object.freeze(Object.defineProperty({__proto__:null,OPERATING_SYSTEMS:Ud,RUNTIME:Ug,detect:Pd,getOS:Lg,osZ:Dg},Symbol.toStringTag,{value:"Module"})),Bg=(...r)=>r.map(Md).join(""),Md=r=>(r.endsWith("/")||(r+="/"),r.startsWith("/")&&(r=r.slice(1)),r),Vg=r=>r.endsWith("/")?r.slice(0,-1):r,Kg=(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 qg=(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=Md(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 $o;try{$o=new TextDecoder}catch{}var P,St,f=0,ze={},be,Pr,Tt=0,Yt=0,He,Tr,kt=[],ve,_u={useRecords:!1,mapsAsObjects:!0};class Ld{}const Bd=new Ld;Bd.name="MessagePack 0xC1";var Dr=!1,Vd=2,ku;try{new Function("")}catch{Vd=1/0}class Zs{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 Yd(()=>(jo(),this?this.unpack(e,t):Zs.prototype.unpack.call(_u,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,f=t.start||0):(f=0,St=t>-1?t:e.length),Yt=0,Pr=null,He=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 Zs){if(ze=this,this.structures)return be=this.structures,da(t);(!be||be.length>0)&&(be=[])}else ze=_u,(!be||be.length>0)&&(be=[]);return da(t)}unpackMultiple(e,t){let n,s=0;try{Dr=!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(da(),s,f)===!1)return}else{for(n=[i];f<a;)s=f,n.push(da());return n}}catch(a){throw a.lastPosition=s,a.values=n,a}finally{Dr=!1,jo()}}_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 da(r){try{if(!ze.trusted&&!Dr){let t=be.sharedLength||0;t<be.length&&(be.length=t)}let e;if(ze.randomAccessStructure&&P[f]<64&&P[f]>=32&&ku?(e=ku(P,f,St,ze),P=null,!(r&&r.lazy)&&e&&(e=e.toJSON()),f=St):e=Ve(),He&&(f=He.postBundlePosition,He=null),Dr&&(be.restoreStructures=null),f==St)be&&be.restoreStructures&&Ou(),be=null,P=null,Tr&&(Tr=null);else{if(f>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 be&&be.restoreStructures&&Ou(),jo(),(e instanceof RangeError||e.message.startsWith("Unexpected end of buffer")||f>St)&&(e.incomplete=!0),e}}function Ou(){for(let r in be.restoreStructures)be[r]=be.restoreStructures[r];be.restoreStructures=null}function Ve(){let r=P[f++];if(r<160)if(r<128){if(r<64)return r;{let e=be[r&63]||ze.getStructures&&Kd()[r&63];return e?(e.read||(e.read=xc(e,r&63)),e.read()):r}}else if(r<144)if(r-=128,ze.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Fd();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 ze.freezeData?Object.freeze(e):e}else if(r<192){let e=r-160;if(Yt>=f)return Pr.slice(f-Tt,(f+=e)-Tt);if(Yt==0&&St<140){let t=e<16?Sc(e):qd(e);if(t!=null)return t}return Co(e)}else{let e;switch(r){case 192:return null;case 193:return He?(e=Ve(),e>0?He[1].slice(He.position1,He.position1+=e):He[0].slice(He.position0,He.position0-=e)):Bd;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 Qi(e);case 197:return e=ve.getUint16(f),f+=2,Qi(e);case 198:return e=ve.getUint32(f),f+=4,Qi(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),ze.useFloat32>2){let t=Nc[(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 ze.int64AsType==="number"?(e=ve.getUint32(f)*4294967296,e+=ve.getUint32(f+4)):ze.int64AsType==="string"?e=ve.getBigUint64(f).toString():ze.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 ze.int64AsType==="number"?(e=ve.getInt32(f)*4294967296,e+=ve.getUint32(f+4)):ze.int64AsType==="string"?e=ve.getBigInt64(f).toString():ze.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=kt[e];if(t)return t.read?(f++,t.read(Ve())):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++],Yt>=f?Pr.slice(f-Tt,(f+=e)-Tt):Wg(e);case 218:return e=ve.getUint16(f),f+=2,Yt>=f?Pr.slice(f-Tt,(f+=e)-Tt):Yg(e);case 219:return e=ve.getUint32(f),f+=4,Yt>=f?Pr.slice(f-Tt,(f+=e)-Tt):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 xc(r,e){function t(){if(t.count++>Vd){let s=r.read=new Function("r","return function(){return "+(ze.freezeData?"Object.freeze":"")+"({"+r.map(a=>a==="__proto__"?"__proto_:r()":Fg.test(a)?a+":r()":"["+JSON.stringify(a)+"]:r()").join(",")+"})}")(Ve);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]=Ve()}return ze.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]||Kd()[n];if(!s)throw new Error("Record id is not defined for "+n);return s.read||(s.read=xc(s,r)),s.read()};function Kd(){let r=Yd(()=>(P=null,ze.getStructures()));return be=ze._mergeStructures(r,be)}var Co=Xs,Wg=Xs,Yg=Xs,Jg=Xs;function Xs(r){let e;if(r<16&&(e=Sc(r)))return e;if(r>64&&$o)return $o.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+=Je.apply(String,n),n.length=0)}return n.length>0&&(e+=Je.apply(String,n)),e}function xu(r){let e=new Array(r);for(let t=0;t<r;t++)e[t]=Ve();return ze.freezeData?Object.freeze(e):e}function Su(r){if(ze.mapsAsObjects){let e={};for(let t=0;t<r;t++){let n=Fd();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 Je=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 Je.apply(String,t)}function Sc(r){if(r<4)if(r<2){if(r===0)return"";{let e=P[f++];if((e&128)>1){f-=1;return}return Je(e)}}else{let e=P[f++],t=P[f++];if((e&128)>0||(t&128)>0){f-=2;return}if(r<3)return Je(e,t);let n=P[f++];if((n&128)>0){f-=3;return}return Je(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 Je(e,t,n,s);{let a=P[f++];if((a&128)>0){f-=5;return}return Je(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 Je(e,t,n,s,a,i);let o=P[f++];if((o&128)>0){f-=7;return}return Je(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 Je(e,t,n,s,a,i,o,c);{let l=P[f++];if((l&128)>0){f-=9;return}return Je(e,t,n,s,a,i,o,c,l)}}else if(r<12){let l=P[f++],g=P[f++];if((l&128)>0||(g&128)>0){f-=10;return}if(r<11)return Je(e,t,n,s,a,i,o,c,l,g);let E=P[f++];if((E&128)>0){f-=11;return}return Je(e,t,n,s,a,i,o,c,l,g,E)}else{let l=P[f++],g=P[f++],E=P[f++],Q=P[f++];if((l&128)>0||(g&128)>0||(E&128)>0||(Q&128)>0){f-=12;return}if(r<14){if(r===12)return Je(e,t,n,s,a,i,o,c,l,g,E,Q);{let ce=P[f++];if((ce&128)>0){f-=13;return}return Je(e,t,n,s,a,i,o,c,l,g,E,Q,ce)}}else{let ce=P[f++],Ne=P[f++];if((ce&128)>0||(Ne&128)>0){f-=14;return}if(r<15)return Je(e,t,n,s,a,i,o,c,l,g,E,Q,ce,Ne);let ee=P[f++];if((ee&128)>0){f-=15;return}return Je(e,t,n,s,a,i,o,c,l,g,E,Q,ce,Ne,ee)}}}}}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 Xs(e)}function Qi(r){return ze.copyBuffers?Uint8Array.prototype.slice.call(P,f,f+=r):P.subarray(f,f+=r)}function nn(r){let e=P[f++];if(kt[e]){let t;return kt[e](P.subarray(f,t=f+=r),n=>{f=n;try{return Ve()}finally{f=t}})}else throw new Error("Unknown extension type "+e)}var Eu=new Array(4096);function Fd(){let r=P[f++];if(r>=160&&r<192){if(r=r-160,Yt>=f)return Pr.slice(f-Tt,(f+=r)-Tt);if(!(Yt==0&&St<180))return Co(r)}else return f--,Ve().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?Sc(r):qd(r);return o!=null?t.string=o:t.string=Co(r)}const Au=(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=be[r];return s&&(s.isShared||Dr)&&((be.restoreStructures||(be.restoreStructures=[]))[r]=s),be[r]=t,t.read=xc(t,n),t.read()};kt[0]=()=>{};kt[0].noBuffer=!0;let Gg={Error,TypeError,ReferenceError};kt[101]=()=>{let r=Ve();return(Gg[r[0]]||Error)(r[1])};kt[105]=r=>{let e=ve.getUint32(f-4);Tr||(Tr=new Map);let t=P[f],n;t>=144&&t<160||t==220||t==221?n=[]:n={};let s={target:n};Tr.set(e,s);let a=Ve();return s.used?Object.assign(n,a):(s.target=a,a)};kt[112]=r=>{let e=ve.getUint32(f-4),t=Tr.get(e);return t.used=!0,t.target};kt[115]=()=>new Set(Ve());const Wd=["Int8","Uint8","Uint8Clamped","Int16","Uint16","Int32","Uint32","Float32","Float64","BigInt64","BigUint64"].map(r=>r+"Array");let Hg=typeof globalThis=="object"?globalThis:window;kt[116]=r=>{let e=r[0],t=Wd[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)};kt[120]=()=>{let r=Ve();return new RegExp(r[0],r[1])};const Xg=[];kt[98]=r=>{let e=(r[0]<<24)+(r[1]<<16)+(r[2]<<8)+r[3],t=f;return f+=e-r.length,He=Xg,He=[Nu(),Nu()],He.position0=0,He.position1=0,He.postBundlePosition=f,f=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 Yd(r){let e=St,t=f,n=Tt,s=Yt,a=Pr,i=Tr,o=He,c=new Uint8Array(P.slice(0,St)),l=be,g=be.slice(0,be.length),E=ze,Q=Dr,ce=r();return St=e,f=t,Tt=n,Yt=s,Pr=a,Tr=i,He=o,P=c,Dr=Q,be=l,be.splice(0,be.length,...g),ze=E,ve=new DataView(P.buffer,P.byteOffset,P.byteLength),ce}function jo(){P=null,Tr=null,be=null}const Nc=new Array(147);for(let r=0;r<256;r++)Nc[r]=+("1e"+Math.floor(45.15-r*.30103));var Ci=new Zs({useRecords:!1});const Qg=Ci.unpack;Ci.unpackMultiple;Ci.unpack;let ev=new Float32Array(1);new Uint8Array(ev.buffer,0,4);let ja;try{ja=new TextEncoder}catch{}let Ro,Jd;const ji=typeof Buffer<"u",ha=ji?function(r){return Buffer.allocUnsafeSlow(r)}:Uint8Array,Gd=ji?Buffer:Uint8Array,Iu=ji?4294967296:2144337920;let _,Hn,Ce,w=0,pt,De=null,tv;const rv=21760,nv=/[\u0080-\uFFFF]/,xn=Symbol("record-id");class sv extends Zs{constructor(e){super(e),this.offset=0;let t,n,s,a,i=Gd.prototype.utf8Write?function(d,O){return _.utf8Write(d,O,4294967295)}:ja&&ja.encodeInto?function(d,O){return ja.encodeInto(d,_.subarray(O)).written}:!1,o=this;e||(e={});let c=e&&e.sequential,l=e.structures||e.saveStructures,g=e.maxSharedStructures;if(g==null&&(g=l?32:0),g>8160)throw new Error("Maximum maxSharedStructure is 8160");e.structuredClone&&e.moreTypes==null&&(this.moreTypes=!0);let E=e.maxOwnStructures;E==null&&(E=l?32:64),!this.structures&&e.useRecords!=!1&&(this.structures=[]);let Q=g>32||E+g>64,ce=g+64,Ne=g+E+64;if(Ne>8256)throw new Error("Maximum maxSharedStructure + maxOwnStructure is 8192");let ee=[],rr=0,nr=0;this.pack=this.encode=function(d,O){if(_||(_=new ha(8192),Ce=_.dataView||(_.dataView=new DataView(_.buffer,0,8192)),w=0),pt=_.length-10,pt-w<2048?(_=new ha(_.length),Ce=_.dataView||(_.dataView=new DataView(_.buffer,0,_.length)),pt=_.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 m=s.sharedLength||0;if(m>g)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 y=0;y<m;y++){let k=s[y];if(!k)continue;let R,U=s.transitions;for(let I=0,re=k.length;I<re;I++){let q=k[I];R=U[q],R||(R=U[q]=Object.create(null)),U=R}U[xn]=y+64}this.lastNamedStructuresLength=m}c||(s.nextId=m+64)}n&&(n=!1);try{o.randomAccessStructure&&d&&d.constructor&&d.constructor===Object?Vi(d):te(d);let m=De;if(De&&Cu(t,te,0),a&&a.idsToInsert){let y=a.idsToInsert.sort((I,re)=>I.offset>re.offset?1:-1),k=y.length,R=-1;for(;m&&k>0;){let I=y[--k].offset+t;I<m.stringsPosition+t&&R===-1&&(R=0),I>m.position+t?R>=0&&(R+=6):(R>=0&&(Ce.setUint32(m.position+t,Ce.getUint32(m.position+t)+R),R=-1),m=m.previous,k++)}R>=0&&m&&Ce.setUint32(m.position+t,Ce.getUint32(m.position+t)+R),w+=y.length*6,w>pt&&Xe(w),o.offset=w;let U=iv(_.subarray(t,w),y);return a=null,U}return o.offset=w,O&uv?(_.start=t,_.end=w,_):_.subarray(t,w)}finally{if(s&&(qn(),n&&o.saveStructures)){let m=s.sharedLength||0,y=_.subarray(t,w),k=ov(s,o);return o.saveStructures(k,k.isCompatible)===!1?o.pack(d,O):(o.lastNamedStructuresLength=m,y)}O&lv&&(w=t)}};const qn=()=>{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,ee.length>0&&(ee=[]);else if(ee.length>0&&!c){for(let O=0,m=ee.length;O<m;O++)ee[O][xn]=0;ee=[]}},Qr=d=>{var O=d.length;O<16?_[w++]=144|O:O<65536?(_[w++]=220,_[w++]=O>>8,_[w++]=O&255):(_[w++]=221,Ce.setUint32(w,O),w+=4);for(let m=0;m<O;m++)te(d[m])},te=d=>{w>pt&&(_=Xe(w));var O=typeof d,m;if(O==="string"){let y=d.length;if(De&&y>=4&&y<4096){if((De.size+=y)>rv){let I,re=(De[0]?De[0].length*3+De[1].length:0)+10;w+re>pt&&(_=Xe(w+re));let q;De.position?(q=De,_[w]=200,w+=3,_[w++]=98,I=w-t,w+=4,Cu(t,te,0),Ce.setUint16(I+t-3,w-t-I)):(_[w++]=214,_[w++]=98,I=w-t,w+=4),De=["",""],De.previous=q,De.size=0,De.position=I}let U=nv.test(d);De[U?0:1]+=d,_[w++]=193,te(U?-y:y);return}let k;y<32?k=1:y<256?k=2:y<65536?k=3:k=5;let R=y*3;if(w+R>pt&&(_=Xe(w+R)),y<64||!i){let U,I,re,q=w+k;for(U=0;U<y;U++)I=d.charCodeAt(U),I<128?_[q++]=I:I<2048?(_[q++]=I>>6|192,_[q++]=I&63|128):(I&64512)===55296&&((re=d.charCodeAt(U+1))&64512)===56320?(I=65536+((I&1023)<<10)+(re&1023),U++,_[q++]=I>>18|240,_[q++]=I>>12&63|128,_[q++]=I>>6&63|128,_[q++]=I&63|128):(_[q++]=I>>12|224,_[q++]=I>>6&63|128,_[q++]=I&63|128);m=q-w-k}else m=i(d,w+k);m<32?_[w++]=160|m:m<256?(k<2&&_.copyWithin(w+2,w+1,w+1+m),_[w++]=217,_[w++]=m):m<65536?(k<3&&_.copyWithin(w+3,w+2,w+2+m),_[w++]=218,_[w++]=m>>8,_[w++]=m&255):(k<5&&_.copyWithin(w+5,w+3,w+3+m),_[w++]=219,Ce.setUint32(w,m),w+=4),w+=m}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,Ce.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,Ce.setInt16(w,d),w+=2):(_[w++]=210,Ce.setInt32(w,d),w+=4);else{let y;if((y=this.useFloat32)>0&&d<4294967296&&d>=-2147483648){_[w++]=202,Ce.setFloat32(w,d);let k;if(y<4||(k=d*Nc[(_[w]&127)<<1|_[w+1]>>7])>>0===k){w+=4;return}else w--}_[w++]=203,Ce.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,Ce.setUint32(w,k.id),w+=4;return}else a.set(d,{offset:w-t})}let y=d.constructor;if(y===Object)sr(d,!0);else if(y===Array)Qr(d);else if(y===Map)if(this.mapAsEmptyObject)_[w++]=128;else{m=d.size,m<16?_[w++]=128|m:m<65536?(_[w++]=222,_[w++]=m>>8,_[w++]=m&255):(_[w++]=223,Ce.setUint32(w,m),w+=4);for(let[k,R]of d)te(k),te(R)}else{for(let k=0,R=Ro.length;k<R;k++){let U=Jd[k];if(d instanceof U){let I=Ro[k];if(I.write){I.type&&(_[w++]=212,_[w++]=I.type,_[w++]=0);let Qe=I.write.call(this,d);Qe===d?Array.isArray(d)?Qr(d):sr(d):te(Qe);return}let re=_,q=Ce,Ke=w;_=null;let dt;try{dt=I.pack.call(this,d,Qe=>(_=re,re=null,w+=Qe,w>pt&&Xe(w),{target:_,targetView:Ce,position:w-Qe}),te)}finally{re&&(_=re,Ce=q,w=Ke,pt=_.length-10)}dt&&(dt.length+w>pt&&Xe(dt.length+w),w=av(dt,_,w,I.type));return}}if(Array.isArray(d))Qr(d);else{if(d.toJSON){const k=d.toJSON();if(k!==d)return te(k)}if(O==="function")return te(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,Ce.setBigInt64(w,d);else if(d<BigInt(1)<<BigInt(64)&&d>0)_[w++]=207,Ce.setBigUint64(w,d);else if(this.largeBigIntToFloat)_[w++]=203,Ce.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)},Fn=this.variableMapSize||this.coercibleKeyAsNumber?d=>{let O=Object.keys(d),m=O.length;m<16?_[w++]=128|m:m<65536?(_[w++]=222,_[w++]=m>>8,_[w++]=m&255):(_[w++]=223,Ce.setUint32(w,m),w+=4);let y;if(this.coercibleKeyAsNumber)for(let k=0;k<m;k++){y=O[k];let R=Number(y);te(isNaN(R)?y:R),te(d[y])}else for(let k=0;k<m;k++)te(y=O[k]),te(d[y])}:(d,O)=>{_[w++]=222;let m=w-t;w+=2;let y=0;for(let k in d)(O||d.hasOwnProperty(k))&&(te(k),te(d[k]),y++);_[m+++t]=y>>8,_[m+t]=y&255},Wn=this.useRecords===!1?Fn:e.progressiveRecords&&!Q?(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=w++-t,R;for(let U in d)if(O||d.hasOwnProperty(U)){if(m=y[U],m)y=m;else{let I=Object.keys(d),re=y;y=s.transitions;let q=0;for(let Ke=0,dt=I.length;Ke<dt;Ke++){let Qe=I[Ke];m=y[Qe],m||(m=y[Qe]=Object.create(null),q++),y=m}k+t+1==w?(w--,en(y,I,q)):Jn(y,I,k,q),R=!0,y=re[U]}te(d[U])}if(!R){let U=y[xn];U?_[k+t]=U:Jn(y,Object.keys(d),k,0)}}:(d,O)=>{let m,y=s.transitions||(s.transitions=Object.create(null)),k=0;for(let U in d)(O||d.hasOwnProperty(U))&&(m=y[U],m||(m=y[U]=Object.create(null),k++),y=m);let R=y[xn];R?R>=96&&Q?(_[w++]=((R-=96)&31)+96,_[w++]=R>>5):_[w++]=R:en(y,y.__keys__||Object.keys(d),k);for(let U in d)(O||d.hasOwnProperty(U))&&te(d[U])},Yn=typeof this.useRecords=="function"&&this.useRecords,sr=Yn?(d,O)=>{Yn(d)?Wn(d,O):Fn(d,O)}:Wn,Xe=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 m=new ha(O);return Ce=m.dataView||(m.dataView=new DataView(m.buffer,0,O)),d=Math.min(d,_.length),_.copy?_.copy(m,0,t,d):m.set(_.slice(t,d)),w-=t,t=0,pt=m.length-10,_=m},en=(d,O,m)=>{let y=s.nextId;y||(y=64),y<ce&&this.shouldShareStructure&&!this.shouldShareStructure(O)?(y=s.nextOwnId,y<Ne||(y=ce),s.nextOwnId=y+1):(y>=Ne&&(y=ce),s.nextId=y+1);let k=O.highByte=y>=96&&Q?y-96>>5:-1;d[xn]=y,d.__keys__=O,s[y-64]=O,y<ce?(O.isShared=!0,s.sharedLength=y-63,n=!0,k>=0?(_[w++]=(y&31)+96,_[w++]=k):_[w++]=y):(k>=0?(_[w++]=213,_[w++]=114,_[w++]=(y&31)+96,_[w++]=k):(_[w++]=212,_[w++]=114,_[w++]=y),m&&(rr+=nr*m),ee.length>=E&&(ee.shift()[xn]=0),ee.push(d),te(O))},Jn=(d,O,m,y)=>{let k=_,R=w,U=pt,I=t;_=Hn,w=0,t=0,_||(Hn=_=new ha(8192)),pt=_.length-10,en(d,O,y),Hn=_;let re=w;if(_=k,w=R,pt=U,t=I,re>1){let q=w+re-1;q>pt&&Xe(q);let Ke=m+t;_.copyWithin(Ke+re,Ke+1,w),_.set(Hn.slice(0,re),Ke),w=q}else _[m+t]=Hn[0]},Vi=(d,O)=>{let m=tv(d,_,t,w,s,Xe,(y,k,R)=>{if(R)return n=!0;w=k;let U=_;return te(y),qn(),U!==_?{position:w,targetView:Ce,target:_}:w},this);if(m===0)return sr(d,!0);w=m}}useBuffer(e){_=e,Ce=new DataView(_.buffer,_.byteOffset,_.byteLength),w=0}clearSharedData(){this.structures&&(this.structures=[]),this.typedStructs&&(this.typedStructs=[])}}Jd=[Date,Set,Error,RegExp,ArrayBuffer,Object.getPrototypeOf(Uint8Array.prototype).constructor,Ld];Ro=[{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!==Gd&&this.moreTypes?Zu(r,Wd.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){Ce.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 Hd=new sv({useRecords:!1});const cv=Hd.pack;Hd.pack;const uv=512,lv=1024,dv=2048;class hv{constructor(){j(this,"contentType","application/msgpack")}encode(e){return cv(Ln.toSnake(e))}decode(e,t){const n=Ln.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(Ln.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=Ln.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 zo;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(zo||(zo={}));const L=Oe.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 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 Ut 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()}}Ut.create=r=>new Ut(r);const $s=(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 Xd=$s;function mv(r){Xd=r}function oi(){return Xd}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}},yv=[];function K(r,e){const t=ci({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,oi(),$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"}),Qd=r=>({status:"dirty",value:r}),wt=r=>({status:"valid",value:r}),Po=r=>r.status==="aborted",Uo=r=>r.status==="dirty",Cs=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 Qt{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(Cs(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 Ut(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 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 ut,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(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:Rr(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:Rr(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:X.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return xr.create(this,this._def)}nullable(){return vn.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Dt.create(this,this._def)}promise(){return Vn.create(this,this._def)}or(e){return Ps.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:X.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new Vs({...de(this._def),innerType:this,defaultValue:t,typeName:X.ZodDefault})}brand(){return new th({typeName:X.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:X.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return Qs.create(this,e)}readonly(){return mi.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 eo;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 Ct extends fe{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==L.string){const s=this._getOrReturnCtx(e);return K(s,{code:C.invalid_type,expected:L.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),K(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),K(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?K(n,{code:C.too_big,maximum:s.value,type:"string",inclusive:!0,exact:!0,message:s.message}):i&&K(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),K(n,{validation:"email",code:C.invalid_string,message:s.message}),t.dirty());else if(s.kind==="emoji")eo||(eo=new RegExp(kv,"u")),eo.test(e.data)||(n=this._getOrReturnCtx(e,n),K(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),K(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),K(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),K(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),K(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),K(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),K(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),K(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),K(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),K(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),K(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),K(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 Ct({...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 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,...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 Fr 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 K(s,{code:C.invalid_type,expected:L.number,received:s.parsedType}),oe}let t;const n=new ut;for(const s of this._def.checks)s.kind==="int"?Oe.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),K(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),K(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),K(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),K(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),K(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 Fr({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:Y.toString(s)}]})}_addCheck(e){return new Fr({...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)}}Fr.create=r=>new Fr({checks:[],typeName:X.ZodNumber,coerce:(r==null?void 0:r.coerce)||!1,...de(r)});class Wr 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 K(s,{code:C.invalid_type,expected:L.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),K(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),K(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),K(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 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]})}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}}Wr.create=r=>{var e;return new Wr({checks:[],typeName:X.ZodBigInt,coerce:(e=r==null?void 0:r.coerce)!==null&&e!==void 0?e:!1,...de(r)})};class js extends fe{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==L.boolean){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.boolean,received:t.parsedType}),oe}return wt(e.data)}}js.create=r=>new js({typeName:X.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 K(s,{code:C.invalid_type,expected:L.date,received:s.parsedType}),oe}if(isNaN(e.data.getTime())){const s=this._getOrReturnCtx(e);return K(s,{code:C.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),K(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),K(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:X.ZodDate,...de(r)});class li extends fe{_parse(e){if(this._getType(e)!==L.symbol){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.symbol,received:t.parsedType}),oe}return wt(e.data)}}li.create=r=>new li({typeName:X.ZodSymbol,...de(r)});class Rs extends fe{_parse(e){if(this._getType(e)!==L.undefined){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.undefined,received:t.parsedType}),oe}return wt(e.data)}}Rs.create=r=>new Rs({typeName:X.ZodUndefined,...de(r)});class zs extends fe{_parse(e){if(this._getType(e)!==L.null){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.null,received:t.parsedType}),oe}return wt(e.data)}}zs.create=r=>new zs({typeName:X.ZodNull,...de(r)});class Bn extends fe{constructor(){super(...arguments),this._any=!0}_parse(e){return wt(e.data)}}Bn.create=r=>new Bn({typeName:X.ZodAny,...de(r)});class un extends fe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return wt(e.data)}}un.create=r=>new un({typeName:X.ZodUnknown,...de(r)});class Er extends fe{_parse(e){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.never,received:t.parsedType}),oe}}Er.create=r=>new Er({typeName:X.ZodNever,...de(r)});class di extends fe{_parse(e){if(this._getType(e)!==L.undefined){const t=this._getOrReturnCtx(e);return K(t,{code:C.invalid_type,expected:L.void,received:t.parsedType}),oe}return wt(e.data)}}di.create=r=>new di({typeName:X.ZodVoid,...de(r)});class Dt extends fe{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==L.array)return K(t,{code:C.invalid_type,expected:L.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)&&(K(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&&(K(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&&(K(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 Qt(t,i,t.path,o)))).then(i=>ut.mergeArray(n,i));const a=[...t.data].map((i,o)=>s.type._parseSync(new Qt(t,i,t.path,o)));return ut.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new Dt({...this._def,minLength:{value:e,message:Y.toString(t)}})}max(e,t){return new Dt({...this._def,maxLength:{value:e,message:Y.toString(t)}})}length(e,t){return new Dt({...this._def,exactLength:{value:e,message:Y.toString(t)}})}nonempty(e){return this.min(1,e)}}Dt.create=(r,e)=>new Dt({type:r,minLength:null,maxLength:null,exactLength:null,typeName:X.ZodArray,...de(e)});function En(r){if(r instanceof Le){const e={};for(const t in r.shape){const n=r.shape[t];e[t]=xr.create(En(n))}return new Le({...r._def,shape:()=>e})}else return r instanceof Dt?new Dt({...r._def,type:En(r.element)}):r instanceof xr?xr.create(En(r.unwrap())):r instanceof vn?vn.create(En(r.unwrap())):r instanceof er?er.create(r.items.map(e=>En(e))):r}class Le 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 K(c,{code:C.invalid_type,expected:L.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 Er&&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],g=n.data[c];o.push({key:{status:"valid",value:c},value:l._parse(new Qt(n,g,n.path,c)),alwaysSet:c in n.data})}if(this._def.catchall instanceof Er){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&&(K(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 g=n.data[l];o.push({key:{status:"valid",value:l},value:c._parse(new Qt(n,g,n.path,l)),alwaysSet:l in n.data})}}return n.common.async?Promise.resolve().then(async()=>{const c=[];for(const l of o){const g=await l.key;c.push({key:g,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 Y.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=Y.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 Oe.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 Oe.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new Le({...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 Le({...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 xr;)s=s._def.innerType;t[n]=s}}),new Le({...this._def,shape:()=>t})}keyof(){return eh(Oe.objectKeys(this.shape))}}Le.create=(r,e)=>new Le({shape:()=>r,unknownKeys:"strip",catchall:Er.create(),typeName:X.ZodObject,...de(e)});Le.strictCreate=(r,e)=>new Le({shape:()=>r,unknownKeys:"strict",catchall:Er.create(),typeName:X.ZodObject,...de(e)});Le.lazycreate=(r,e)=>new Le({shape:r,unknownKeys:"strip",catchall:Er.create(),typeName:X.ZodObject,...de(e)});class Ps 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 Ut(o.ctx.common.issues));return K(t,{code:C.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},g=c._parseSync({data:t.data,path:t.path,parent:l});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,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 Ut(c));return K(t,{code:C.invalid_union,unionErrors:o}),oe}}get options(){return this._def.options}}Ps.create=(r,e)=>new Ps({options:r,typeName:X.ZodUnion,...de(e)});const Ra=r=>r instanceof Ms?Ra(r.schema):r instanceof Vt?Ra(r.innerType()):r instanceof Ls?[r.value]:r instanceof Yr?r.options:r instanceof Bs?Object.keys(r.enum):r instanceof Vs?Ra(r._def.innerType):r instanceof Rs?[void 0]:r instanceof zs?[null]:null;class Ri extends fe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.object)return K(t,{code:C.invalid_type,expected:L.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}):(K(t,{code:C.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=Ra(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:X.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...de(n)})}}function Do(r,e){const t=Rr(r),n=Rr(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(Po(a)||Po(i))return oe;const o=Do(a.value,i.value);return o.valid?((Uo(a)||Uo(i))&&t.dirty(),{status:t.value,value:o.data}):(K(n,{code:C.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}))}}Us.create=(r,e,t)=>new Us({left:r,right:e,typeName:X.ZodIntersection,...de(t)});class er extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.array)return K(n,{code:C.invalid_type,expected:L.array,received:n.parsedType}),oe;if(n.data.length<this._def.items.length)return K(n,{code:C.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),oe;!this._def.rest&&n.data.length>this._def.items.length&&(K(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 Qt(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 er({...this._def,rest:e})}}er.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new er({items:r,typeName:X.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 K(n,{code:C.invalid_type,expected:L.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 Qt(n,o,n.path,o)),value:i._parse(new Qt(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 fe?new Ds({keyType:e,valueType:t,typeName:X.ZodRecord,...de(n)}):new Ds({keyType:Ct.create(),valueType:e,typeName:X.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 K(n,{code:C.invalid_type,expected:L.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 Qt(n,o,n.path,[l,"key"])),value:a._parse(new Qt(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,g=await c.value;if(l.status==="aborted"||g.status==="aborted")return oe;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const c of i){const l=c.key,g=c.value;if(l.status==="aborted"||g.status==="aborted")return oe;(l.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(l.value,g.value)}return{status:t.value,value:o}}}}hi.create=(r,e,t)=>new hi({valueType:e,keyType:r,typeName:X.ZodMap,...de(t)});class gn extends fe{_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==L.set)return K(n,{code:C.invalid_type,expected:L.set,received:n.parsedType}),oe;const s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(K(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&&(K(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 g of c){if(g.status==="aborted")return oe;g.status==="dirty"&&t.dirty(),l.add(g.value)}return{status:t.value,value:l}}const o=[...n.data.values()].map((c,l)=>a._parse(new Qt(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:X.ZodSet,...de(e)});class $n extends fe{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==L.function)return K(t,{code:C.invalid_type,expected:L.function,received:t.parsedType}),oe;function n(o,c){return ci({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,oi(),$s].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(),$s].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 Vn){const o=this;return wt(async function(...c){const l=new Ut([]),g=await o._def.args.parseAsync(c,a).catch(Q=>{throw l.addIssue(n(c,Q)),l}),E=await Reflect.apply(i,this,g);return await o._def.returns._def.type.parseAsync(E,a).catch(Q=>{throw l.addIssue(s(E,Q)),l})})}else{const o=this;return wt(function(...c){const l=o._def.args.safeParse(c,a);if(!l.success)throw new Ut([n(c,l.error)]);const g=Reflect.apply(i,this,l.data),E=o._def.returns.safeParse(g,a);if(!E.success)throw new Ut([s(g,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new $n({...this._def,args:er.create(e).rest(un.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||er.create([]).rest(un.create()),returns:t||un.create(),typeName:X.ZodFunction,...de(n)})}}class Ms 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})}}Ms.create=(r,e)=>new Ms({getter:r,typeName:X.ZodLazy,...de(e)});class Ls extends fe{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return K(t,{received:t.data,code:C.invalid_literal,expected:this._def.value}),oe}return{status:"valid",value:e.data}}get value(){return this._def.value}}Ls.create=(r,e)=>new Ls({value:r,typeName:X.ZodLiteral,...de(e)});function eh(r,e){return new Yr({values:r,typeName:X.ZodEnum,...de(e)})}class Yr extends fe{_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{expected:Oe.joinValues(n),received:t.parsedType,code:C.invalid_type}),oe}if(this._def.values.indexOf(e.data)===-1){const t=this._getOrReturnCtx(e),n=this._def.values;return K(t,{received:t.data,code:C.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 Yr.create(e)}exclude(e){return Yr.create(this.options.filter(t=>!e.includes(t)))}}Yr.create=eh;class Bs 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 K(n,{expected:Oe.joinValues(s),received:n.parsedType,code:C.invalid_type}),oe}if(t.indexOf(e.data)===-1){const s=Oe.objectValues(t);return K(n,{received:n.data,code:C.invalid_enum_value,options:s}),oe}return wt(e.data)}get enum(){return this._def.values}}Bs.create=(r,e)=>new Bs({values:r,typeName:X.ZodNativeEnum,...de(e)});class Vn 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 K(t,{code:C.invalid_type,expected:L.promise,received:t.parsedType}),oe;const n=t.parsedType===L.promise?t.data:Promise.resolve(t.data);return wt(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}}Vn.create=(r,e)=>new Vn({type:r,typeName:X.ZodPromise,...de(e)});class Vt extends fe{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=>{K(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(!Cs(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=>Cs(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:X.ZodEffects,effect:e,...de(t)});Vt.createWithPreprocess=(r,e,t)=>new Vt({schema:e,effect:{type:"preprocess",transform:r},typeName:X.ZodEffects,...de(t)});class xr extends fe{_parse(e){return this._getType(e)===L.undefined?wt(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}xr.create=(r,e)=>new xr({innerType:r,typeName:X.ZodOptional,...de(e)});class vn extends fe{_parse(e){return this._getType(e)===L.null?wt(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}vn.create=(r,e)=>new vn({innerType:r,typeName:X.ZodNullable,...de(e)});class Vs 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}}Vs.create=(r,e)=>new Vs({innerType:r,typeName:X.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 Ut(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new Ut(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}pi.create=(r,e)=>new pi({innerType:r,typeName:X.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 K(t,{code:C.invalid_type,expected:L.nan,received:t.parsedType}),oe}return{status:"valid",value:e.data}}}fi.create=r=>new fi({typeName:X.ZodNaN,...de(r)});const Ev=Symbol("zod_brand");class th 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 Qs 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"?oe:s.status==="dirty"?(t.dirty(),Qd(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 Qs({in:e,out:t,typeName:X.ZodPipeline})}}class mi extends fe{_parse(e){const t=this._def.innerType._parse(e);return Cs(t)&&(t.value=Object.freeze(t.value)),t}}mi.create=(r,e)=>new mi({innerType:r,typeName:X.ZodReadonly,...de(e)});const rh=(r,e={},t)=>r?Bn.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})}}):Bn.create(),Av={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 Iv=(r,e={message:`Input not instance of ${r.name}`})=>rh(t=>t instanceof r,e),nh=Ct.create,sh=Fr.create,Zv=fi.create,$v=Wr.create,ah=js.create,Cv=yn.create,jv=li.create,Rv=Rs.create,zv=zs.create,Pv=Bn.create,Uv=un.create,Dv=Er.create,Mv=di.create,Lv=Dt.create,Bv=Le.create,Vv=Le.strictCreate,Kv=Ps.create,qv=Ri.create,Fv=Us.create,Wv=er.create,Yv=Ds.create,Jv=hi.create,Gv=gn.create,Hv=$n.create,Xv=Ms.create,Qv=Ls.create,ew=Yr.create,tw=Bs.create,rw=Vn.create,Ru=Vt.create,nw=xr.create,sw=vn.create,aw=Vt.createWithPreprocess,iw=Qs.create,ow=()=>nh().optional(),cw=()=>sh().optional(),uw=()=>ah().optional(),lw={string:r=>Ct.create({...r,coerce:!0}),number:r=>Fr.create({...r,coerce:!0}),boolean:r=>js.create({...r,coerce:!0}),bigint:r=>Wr.create({...r,coerce:!0}),date:r=>yn.create({...r,coerce:!0})},dw=oe;var br=Object.freeze({__proto__:null,defaultErrorMap:$s,setErrorMap:mv,getErrorMap:oi,makeIssue:ci,EMPTY_PATH:yv,addIssueToContext:K,ParseStatus:ut,INVALID:oe,DIRTY:Qd,OK:wt,isAborted:Po,isDirty:Uo,isValid:Cs,isAsync:ui,get util(){return Oe},get objectUtil(){return zo},ZodParsedType:L,getParsedType:Rr,ZodType:fe,ZodString:Ct,ZodNumber:Fr,ZodBigInt:Wr,ZodBoolean:js,ZodDate:yn,ZodSymbol:li,ZodUndefined:Rs,ZodNull:zs,ZodAny:Bn,ZodUnknown:un,ZodNever:Er,ZodVoid:di,ZodArray:Dt,ZodObject:Le,ZodUnion:Ps,ZodDiscriminatedUnion:Ri,ZodIntersection:Us,ZodTuple:er,ZodRecord:Ds,ZodMap:hi,ZodSet:gn,ZodFunction:$n,ZodLazy:Ms,ZodLiteral:Ls,ZodEnum:Yr,ZodNativeEnum:Bs,ZodPromise:Vn,ZodEffects:Vt,ZodTransformer:Vt,ZodOptional:xr,ZodNullable:vn,ZodDefault:Vs,ZodCatch:pi,ZodNaN:fi,BRAND:Ev,ZodBranded:th,ZodPipeline:Qs,ZodReadonly:mi,custom:rh,Schema:fe,ZodSchema:fe,late:Av,get ZodFirstPartyTypeKind(){return X},coerce:lw,any:Pv,array:Lv,bigint:$v,boolean:ah,date:Cv,discriminatedUnion:qv,effect:Ru,enum:ew,function:Hv,instanceof:Iv,intersection:Fv,lazy:Xv,literal:Qv,map:Jv,nan:Zv,nativeEnum:tw,never:Dv,null:zv,nullable:sw,number:sh,object:Bv,oboolean:uw,onumber:cw,optional:nw,ostring:ow,pipeline:iw,preprocess:aw,promise:rw,record:Yv,set:Gv,strictObject:Vv,string:nh,symbol:jv,transformer:Ru,tuple:Wv,undefined:Rv,union:Kv,unknown:Uv,void:Mv,NEVER:dw,ZodIssueCode:C,quotelessJson:fv,ZodError:Ut});class ea extends Error{constructor(e,t){super(e),We(this,"discriminator","FreighterError"),We(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},Mo="unknown",zu="nil",zi="freighter",ta=br.object({type:br.string(),data:br.string()});class pw{constructor(){We(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:Mo,data:JSON.stringify(e)}}decode(e){if(e==null||e.type===zu)return null;if(e.type===Mo)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 ih=new pw,oh=({encode:r,decode:e})=>ih.register({encode:r,decode:e}),Ec=r=>ih.decode(r);class Pu extends ea{constructor(e){super(e,Mo)}}class Ks extends ea{constructor(){super("EOF",zi)}}class yi extends ea{constructor(){super("StreamClosed",zi)}}class qs extends ea{constructor(e={}){const{message:t="Unreachable",url:n=qg.UNKNOWN}=e;super(t,zi),We(this,"url"),this.url=n}}const za="freighter",fw=r=>{if(r.type!==zi)return null;if(r instanceof Ks)return{type:za,data:"EOF"};if(r instanceof yi)return{type:za,data:"StreamClosed"};if(r instanceof qs)return{type:za,data:"Unreachable"};throw new Error(`Unknown error type: ${r.type}: ${r.message}`)},mw=r=>{if(r.type!==za)return null;switch(r.data){case"EOF":return new Ks;case"StreamClosed":return new yi;case"Unreachable":return new qs;default:throw new Error(`Unknown error type: ${r.data}`)}};oh({encode:fw,decode:mw});class ch{constructor(){We(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 uh="Content-Type",Uu=r=>{if(Dd.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 ch{constructor(e,t,n=!1){return super(),We(this,"endpoint"),We(this,"encoder"),We(this,"fetch"),this.endpoint=e.replace({protocol:n?"https":"http"}),this.encoder=t,this.fetch=Uu(this.endpoint.protocol),new Proxy(this,{get:(s,a,i)=>a==="endpoint"?this.endpoint:Reflect.get(s,a,i)})}get headers(){return{[uh]: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 g={...l,params:{}};o.headers={...this.headers,...l.params};let E;try{E=await Uu(l.protocol)(l.target,o)}catch(ce){let Ne=ce;return Ne.message==="Load failed"&&(Ne=new qs({url:i})),[g,Ne]}const Q=await E.arrayBuffer();if(E!=null&&E.ok)return s!=null&&(a=this.encoder.decode(Q,s)),[g,null];try{if(E.status!==400)return[g,new Error(E.statusText)];const ce=this.encoder.decode(Q,ta),Ne=Ec(ce);return[g,Ne]}catch(ce){return[g,new Error(`[freighter] - failed to decode error: ${E.statusText}: ${ce.message}`)]}});return[a,c]}}const J=async(r,e,t,n,s)=>{const[a,i]=await r.send(e,t,n,s);if(i!=null)throw i;return a},gw=()=>Dd.RUNTIME!=="node"?r=>new WebSocket(r):r=>new(require("ws")).WebSocket(r,{rejectUnauthorized:!1}),vw=br.object({type:br.union([br.literal("data"),br.literal("close")]),payload:br.unknown().optional(),error:br.optional(ta)});class ww{constructor(e,t,n,s){We(this,"encoder"),We(this,"reqSchema"),We(this,"resSchema"),We(this,"ws"),We(this,"serverClosed"),We(this,"sendClosed"),We(this,"receiveDataQueue",[]),We(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=Ec(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 Ks:new yi}}}const bw="freighterctx",_w=1e3,kw=1001,Ow=[_w,kw],Tw=r=>Ow.includes(r.code),lh=class dh extends ch{constructor(e,t,n=!1){super(),We(this,"baseUrl"),We(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=dh.MESSAGE_TYPE;const g=await this.wrapSocket(c,t,n);return g instanceof Error?[l,g]:(a=g,[l,null])});if(i!=null)throw i;return a}buildURL(e,t){const n=Kg({[uh]: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))}})}};We(lh,"MESSAGE_TYPE","arraybuffer");let xw=lh;const wr="sy.api.";var Ir=(r=>(r.General=wr+"general",r.Parse=wr+"parse",r.Auth=wr+"auth",r.Unexpected=wr+"unexpected",r.Validation=wr+"validation",r.Query=wr+"query",r.Route=wr+"route",r))(Ir||{});class Hr extends ea{constructor(e){super(e,wr)}}class jt extends Hr{constructor(t){var e=(...tk)=>(super(...tk),h(this,"fields"),this);typeof t=="string"?(e(t),this.fields=[]):Array.isArray(t)?(e(t.map(n=>`${n.field}: ${n.message}`).join(`
8
8
  `)),this.fields=t):(e(`${t.field}: ${t.message}`),this.fields=[t])}}class hh extends Hr{}class ph extends Hr{}class Ac extends Hr{}class wn extends Hr{constructor(e){super(`
9
9
  Unexpected error encountered:
10
10
 
11
11
  ${e}
12
12
 
13
13
  Please report this to the Synnax team.
14
- `)}}class tr extends Hr{}class Sw extends tr{}class Nw extends tr{}class fh extends Hr{constructor(t,n){super(t);h(this,"path");this.path=n}}class Ew extends Hr{}const Aw=r=>{if(!r.type.startsWith(wr))return null;switch(r.type){case Ir.General:return new hh(r.data);case Ir.Parse:return new ph(r.data);case Ir.Auth:return new Ac(r.data);case Ir.Unexpected:return new wn(r.data);case Ir.Validation:return new jt(r.data);case Ir.Query:return new tr(r.data);case Ir.Route:return new fh(r.data,r.data);default:return new wn(r.data)}},Iw=()=>{throw new Error("Not implemented")};oh({encode:Iw,decode:Aw});const Zw=async(r,e)=>{const[t,n]=await e(r);return n==null?[t,n]:n instanceof qs?[t,new qs({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,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 rt(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 jt("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Gs.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 mh=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}=Gr(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 $w(this,e)}async page(e,t,n){return this.sugar(await this.retriever.page(e,t,n))}createDebouncedBatchRetriever(e=10){return new dc(new td(new vs(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(n=>new Ic({...n,frameClient:t}))}};class $w{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 Cw=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:dc,Channel:Ic,Client:mh,ClusterRetriever:vs,Creator:Ga,DebouncedBatchRetriever:td,analyzeParams:Gr,keyZ:Js,newPayload:Ql,parseChannels:ed,payload:Gs},Symbol.toStringTag,{value:"Module"})),jw=u.z.object({key:u.z.string(),username:u.z.string()}),Rw=r=>async(e,t)=>{try{const n=await r();e.params.Authorization=`Bearer ${n}`}catch(n){return[e,n]}return await t(e)},zw=u.z.object({username:u.z.string(),password:u.z.string()}),Pw=u.z.object({token:u.z.string(),user:jw}),Uw="/auth/login";let Dw=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(Uw,e,zw,Pw).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 Rw(async()=>{if(this.authenticated||await this.authenticating,this.token==null)throw new Ac("[auth] - attempting to authenticate without a token");return this.token})}};const Mw=["disconnected","connecting","connected","failed"],yh=u.z.enum(Mw),gh=u.z.object({status:yh,error:u.z.instanceof(Error).optional(),message:u.z.string().optional(),clusterKey:u.z.string()}),Lw=u.z.object({clusterKey:u.z.string()}),Du={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},An=class An{constructor(e,t=Pe.seconds(30),n){h(this,"_state");h(this,"pollFrequency",Pe.seconds(30));h(this,"client");h(this,"name");h(this,"interval");h(this,"onChangeHandlers",[]);this._state={...Du},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({}),Lw);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",Du),h(An,"connectionStateZ",gh);let Fs=An;const Bw=Object.freeze(Object.defineProperty({__proto__:null,Checker:Fs,state:gh,status:yh},Symbol.toStringTag,{value:"Module"})),Zr=class Zr extends Number{};h(Zr,"Absolute",255),h(Zr,"Default",1),h(Zr,"z",u.z.union([u.z.instanceof(Zr),u.z.number().int().min(0).max(255).transform(e=>new Zr(e)),u.z.instanceof(Number).transform(e=>new Zr(e))]));let Jr=Zr;const Mu=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=Mu(r);throw Mu===null?new jt("[Frame] - channel keys or names must be provided when constructing a frame."):new jt(`[Frame] - ${n}s and arrays must be the same length.
15
- Got ${t.length} ${n}s and ${e.length} arrays.`)};class yt{constructor(e=[],t=[]){h(this,"columns",[]);h(this,"series",[]);if(e instanceof yt){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=>wh(i));Lu(s.keys,a),s.keys.forEach((i,o)=>this.push(i,a[o]))}else Object.entries(e).forEach(([s,a])=>this.push(s,...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 jt(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
14
+ `)}}class tr extends Hr{}class Sw extends tr{}class Nw extends tr{}class fh extends Hr{constructor(t,n){super(t);h(this,"path");this.path=n}}class Ew extends Hr{}const Aw=r=>{if(!r.type.startsWith(wr))return null;switch(r.type){case Ir.General:return new hh(r.data);case Ir.Parse:return new ph(r.data);case Ir.Auth:return new Ac(r.data);case Ir.Unexpected:return new wn(r.data);case Ir.Validation:return new jt(r.data);case Ir.Query:return new tr(r.data);case Ir.Route:return new fh(r.data,r.data);default:return new wn(r.data)}},Iw=()=>{throw new Error("Not implemented")};oh({encode:Iw,decode:Aw});const Zw=async(r,e)=>{const[t,n]=await e(r);return n==null?[t,n]:n instanceof qs?[t,new qs({message:`Cannot reach cluster at ${n.url.host}:${n.url.port}`,url:n.url})]:[t,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 rt(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 jt("cannot read from a channel that has not been created");return this._frameClient}get payload(){return Gs.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 mh=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}=Gr(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 $w(this,e)}async page(e,t,n){return this.sugar(await this.retriever.page(e,t,n))}createDebouncedBatchRetriever(e=10){return new dc(new td(new vs(this.client),e))}sugar(e){const{frameClient:t}=this;return e.map(n=>new Ic({...n,frameClient:t}))}};class $w{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 Cw=Object.freeze(Object.defineProperty({__proto__:null,CacheRetriever:dc,Channel:Ic,Client:mh,ClusterRetriever:vs,Creator:Ga,DebouncedBatchRetriever:td,analyzeParams:Gr,keyZ:Js,newPayload:Ql,parseChannels:ed,payload:Gs},Symbol.toStringTag,{value:"Module"})),jw=u.z.object({key:u.z.string(),username:u.z.string()}),Rw=r=>async(e,t)=>{try{const n=await r();e.params.Authorization=`Bearer ${n}`}catch(n){return[e,n]}return await t(e)},zw=u.z.object({username:u.z.string(),password:u.z.string()}),Pw=u.z.object({token:u.z.string(),user:jw}),Uw="/auth/login";let Dw=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(Uw,e,zw,Pw).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 Rw(async()=>{if(this.authenticated||await this.authenticating,this.token==null)throw new Ac("[auth] - attempting to authenticate without a token");return this.token})}};const Mw=["disconnected","connecting","connected","failed"],yh=u.z.enum(Mw),gh=u.z.object({status:yh,error:u.z.instanceof(Error).optional(),message:u.z.string().optional(),clusterKey:u.z.string()}),Lw=u.z.object({clusterKey:u.z.string()}),Du={clusterKey:"",status:"disconnected",error:void 0,message:"Disconnected"},An=class An{constructor(e,t=Pe.seconds(30),n){h(this,"_state");h(this,"pollFrequency",Pe.seconds(30));h(this,"client");h(this,"name");h(this,"interval");h(this,"onChangeHandlers",[]);this._state={...Du},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({}),Lw);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",Du),h(An,"connectionStateZ",gh);let Fs=An;const Bw=Object.freeze(Object.defineProperty({__proto__:null,Checker:Fs,state:gh,status:yh},Symbol.toStringTag,{value:"Module"})),Zr=class Zr extends Number{};h(Zr,"Absolute",255),h(Zr,"Default",1),h(Zr,"z",u.z.union([u.z.instanceof(Zr),u.z.number().int().min(0).max(255).transform(e=>new Zr(e)),u.z.instanceof(Number).transform(e=>new Zr(e))]));let Jr=Zr;const Mu=r=>{const e=Se(r);return e.length===0?null:typeof e[0]=="number"?"key":"name"},Lu=(r,e)=>{const t=Se(r);if(t.length===e.length)return;const n=Mu(r);throw Mu===null?new jt("[Frame] - channel keys or names must be provided when constructing a frame."):new jt(`[Frame] - ${n}s and arrays must be the same length.
15
+ Got ${t.length} ${n}s and ${e.length} arrays.`)};class yt{constructor(e=[],t=[]){h(this,"columns",[]);h(this,"series",[]);if(e instanceof yt){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=>wh(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 jt(`[Frame] - invalid frame construction parameters. data parameter ust be a frame
16
16
  payload, a list of lazy arrays, a lazy array, a map, or a record keyed by channel
17
17
  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=>bh(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 Zt.ZERO;const n=je.min(...this.series.map(a=>a.timeRange.start)),s=je.max(...this.series.map(a=>a.timeRange.end));return new Zt(n,s)}const t=this.get(e);return t==null?Zt.ZERO:new Zt(t[0].timeRange.start,t[t.length-1].timeRange.end)}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 yt){if(this.colType!==null&&e.colType!==this.colType)throw new jt("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 jt("keyVariant must match");if(typeof e!="string"&&this.colType==="name")throw new jt("keyVariant must match");this.columns.push(...Array.from({length:t.length},()=>e))}}concat(e){return new yt([...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 yt;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 yt;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 vh=u.z.object({timeRange:Zt.z.optional(),alignment:u.z.number().optional(),dataType:rt.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(()=>[]),vh.array().optional().default([])])}),wh=r=>{const{dataType:e,data:t,timeRange:n,alignment:s}=r;return new ic({data:t,dataType:e,timeRange:n,glBufferUsage:"static",alignment:s})},bh=r=>({timeRange:r._timeRange,dataType:r.dataType,data:new Uint8Array(r.data.buffer),alignment:r.alignment});class Ui{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 Ui(e);return await n.update(t),n}async update(e){const{variant:t,normalized:n}=Gr(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{variant:t,normalized:n}=Gr(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 jt(`Channel ${i} was not provided in the list of channels when opening the writer`);a.set(o.name,o.key)}),this.keys=s.map(i=>i.key)}adapt(e){if(this.adapter==null)return e.columns.forEach(n=>{if(typeof n!="number")throw new jt(`Channel ${n} was not provided in the list of channels when opening the writer`)}),e;const t=this.adapter;return e.map((n,s)=>{if(typeof n=="string"){const a=t.get(n);if(a==null)throw new Error(`Channel ${n} not found`);return[a,s]}return[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.
18
18
  Please report this error to the Synnax team.`);if(t==null)throw new wn(`${this.name} received unexpected null error on closure.
19
19
  Please report this error to Synnax team.
20
- `);if(!(t instanceof Ks))throw t}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Lo=new Pe(-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||{}),_h=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(_h||{});const Vw=u.z.object({command:u.z.nativeEnum(Cc),span:Pe.z.optional(),bounds:Zt.z.optional(),stamp:je.z.optional(),keys:u.z.number().array().optional()}),Kw=u.z.object({variant:u.z.nativeEnum(_h),ack:u.z.boolean(),command:u.z.nativeEnum(Cc),error:ta.optional().nullable(),frame:Pi.optional()}),ss=class ss{constructor(e,t){h(this,"stream");h(this,"adapter");h(this,"value");this.stream=new $c("Iterator",e),this.value=new yt,this.adapter=t}static async _open(e,t,n,s){const a=await Ui.open(n,t),i=await s.stream(ss.ENDPOINT,Vw,Kw),o=new ss(i,a);return await o.execute({command:0,keys:a.keys,bounds:e}),o}async next(e=Lo){return await this.execute({command:1,span:new Pe(e)})}async prev(e=Lo){return await this.execute({command:2,span:new Pe(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 je(e)})}async seekGE(e){return await this.execute({command:6,stamp:new je(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new qw(this)}async execute(e){for(this.stream.send(e),this.value=new yt;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new yt(t.frame)))}}};h(ss,"ENDPOINT","/frame/iterate");let gi=ss;class qw{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 Fw=u.z.object({start:je.z.optional(),keys:u.z.number().array()}),Ww=u.z.object({frame:Pi,error:ta.optional().nullable()}),Yw="/frame/stream";class Di{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 Ui.open(n,t),i=await s.stream(Yw,Fw,Ww),o=new Di(i,a);return i.send({start:new je(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 yt((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()}),Jw=u.z.object({subject:jc,resource:u.z.number(),authority:Jr.z}),Gw=(...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}),Hw=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 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.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||{}),Ws=(r=>(r[r.PersistStream=1]="PersistStream",r[r.PersistOnly=2]="PersistOnly",r[r.StreamOnly=3]="StreamOnly",r))(Ws||{});const Xw=u.z.object({start:je.z.optional(),controlSubject:jc.optional(),keys:u.z.number().array().optional(),authorities:Jr.z.array().optional(),mode:u.z.nativeEnum(Ws).optional()}),Qw=u.z.object({command:u.z.nativeEnum(zc),config:Xw.optional(),frame:Pi.optional()}),eb=u.z.object({ack:u.z.boolean(),command:u.z.nativeEnum(zc),error:ta.optional().nullable()});var ln;let kh=(ln=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=Jr.Absolute,controlSubject:a,start:i,mode:o}){const c=await Zc.open(e,n),l=await t.stream(ln.ENDPOINT,Qw,eb),g=new ln(l,c);return await g.execute({command:0,config:{start:new je(i),keys:c.keys,controlSubject:a,authorities:Ne(s),mode:o}}),g}async write(e,t){return["string","number"].includes(typeof e)&&(e=new yt(e,new ic({data:t}))),e=this.adapter.adapt(new yt(e)),this.stream.send({command:1,frame:e.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?Ec(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(ln,"ENDPOINT","/frame/write"),ln),Oh=class{constructor(e,t){h(this,"stream");h(this,"retriever");this.stream=e,this.retriever=t}async newIterator(e,t){return await gi._open(e,t,this.retriever,this.stream)}async newWriter({start:e,channels:t,controlSubject:n,authorities:s=Jr.Absolute,mode:a=Ws.PersistStream}){return await kh._open(this.retriever,this.stream,{start:e??je.now(),controlSubject:n,channels:t,authorities:s,mode:a})}async newStreamer(e,t=je.now()){return await Di._open(t,e,this.retriever,this.stream)}async write(e,t,n){const s=await this.newWriter({start:t,channels:e,mode:Ws.PersistOnly});try{await s.write(e,n),await s.commit()}finally{await s.close()}}async read(e,t){const{single:n}=Gr(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 yt;try{for await(const a of n)s.push(a)}finally{await n.close()}return s}};const tb=Object.freeze(Object.defineProperty({__proto__:null,AUTO_SPAN:Lo,Client:Oh,Frame:yt,Iterator:gi,Streamer:Di,Writer:kh,WriterMode:Ws,frameZ:Pi,series:vh,seriesFromPayload:wh,seriesToPayload:bh},Symbol.toStringTag,{value:"Module"}));let Th=class{constructor(e,t,n){h(this,"tasks");h(this,"racks");h(this,"devices");this.tasks=e,this.racks=t,this.devices=n}};const rb=Object.freeze(Object.defineProperty({__proto__:null,Client:Th},Symbol.toStringTag,{value:"Module"})),ra=u.z.number(),Pc=u.z.object({key:ra,name:u.z.string()}),nb=Pc.partial({key:!0}),Uc=u.z.string(),Mi=u.z.object({key:Uc,rack:ra,name:u.z.string(),make:u.z.string(),model:u.z.string(),location:u.z.string(),properties:u.z.string()});class na{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.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 na(a,s,t,n)}}const sb="sy_device_set",ab="sy_device_delete";let xh=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 na.open(this.frameClient,sb,ab,ib)}};const ib=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(Mi).map(t=>({variant:r,key:t.key,value:t})),to="/hardware/device/retrieve",ro=u.z.object({search:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional(),keys:Uc.array().optional()}),no=u.z.object({devices:Mi.array()});let Sh=class{constructor(e){h(this,"client");this.client=e}async search(e){return(await J(this.client,to,{keys:[e]},ro,no)).devices}async page(e,t){return(await J(this.client,to,{offset:e,limit:t},ro,no)).devices}async retrieve(e){return(await J(this.client,to,{keys:e},ro,no)).devices}};const ob="/hardware/device/create",cb="/hardware/device/delete",ub=u.z.object({devices:Mi.array()}),lb=u.z.object({devices:Mi.array()}),db=u.z.object({keys:Uc.array()}),hb=u.z.object({});let Nh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await J(this.client,ob,{devices:e},ub,lb)).devices}async delete(e){await J(this.client,cb,{keys:e},db,hb)}};const pb=Object.freeze(Object.defineProperty({__proto__:null,Client:xh,Retriever:Sh,Writer:Nh},Symbol.toStringTag,{value:"Module"}));let Eh=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 Ah(t.key,t.name,this.taskWriter,this.taskRetriever))}};class Ah{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 fb="/hardware/rack/create",mb="/hardware/rack/delete",yb=u.z.object({racks:nb.array()}),gb=u.z.object({racks:Pc.array()}),vb=u.z.object({keys:ra.array()}),wb=u.z.object({});let Ih=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await J(this.client,fb,{racks:e},yb,gb)).racks}async delete(e){await J(this.client,mb,{keys:e},vb,wb)}};const so="/hardware/rack/retrieve",ao=u.z.object({keys:ra.array().optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),io=u.z.object({racks:Pc.array()});let Zh=class{constructor(e){h(this,"client");this.client=e}async page(e,t){return(await J(this.client,so,{offset:e,limit:t},ao,io)).racks}async search(e){return(await J(this.client,so,{search:e},ao,io)).racks}async retrieve(e){return(await J(this.client,so,{keys:e},ao,io)).racks}};const bb=Object.freeze(Object.defineProperty({__proto__:null,Client:Eh,Rack:Ah,Retriever:Zh,Writer:Ih},Symbol.toStringTag,{value:"Module"}));let $h=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 Dc=u.z.union([u.z.string(),u.z.bigint().transform(r=>r.toString()),u.z.number().transform(r=>r.toString())]),Mc=u.z.object({key:Dc,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=Mc.omit({key:!0}).extend({key:Dc.transform(r=>r.toString()).optional(),config:u.z.unknown().transform(r=>JSON.stringify(r))}),oo=u.z.object({rack:ra.optional(),keys:u.z.string().array().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),co=u.z.object({tasks:u.z.union([Mc.array(),u.z.null().transform(()=>[])])}),uo="/hardware/task/retrieve";let Ch=class{constructor(e){h(this,"client");this.client=e}async retrieve(e){return(await J(this.client,uo,e,oo,co)).tasks}async search(e){return(await J(this.client,uo,{keys:[e]},oo,co)).tasks}async page(e,t){return(await J(this.client,uo,{offset:e,limit:t},oo,co)).tasks}};const kb="/hardware/task/create",Ob="/hardware/task/delete",Tb=u.z.object({tasks:_b.array()}),xb=u.z.object({tasks:Mc.array()}),Sb=u.z.object({keys:Dc.array()}),Nb=u.z.object({});let jh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await J(this.client,kb,{tasks:e},Tb,xb)).tasks}async delete(e){await J(this.client,Ob,{keys:e},Sb,Nb)}};const Eb=Object.freeze(Object.defineProperty({__proto__:null,Client:$h,Retriever:Ch,Writer:jh},Symbol.toStringTag,{value:"Module"}));class Ab{constructor(e,t){h(this,"key");h(this,"name");this.key=t,this.name=e}get ontologyID(){return new nt({type:"group",key:this.key})}}const Ib=u.z.string().uuid(),Zb=u.z.object({key:Ib,name:u.z.string()}),Rh=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")]),Mt=u.z.object({type:Rh,key:u.z.string()}),zh=u.z.string().transform(r=>{const[e,t]=r.split(":");return{type:e,key:t}}),Ph=u.z.union([zh,Mt]),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([Ph,u.z.instanceof(In)]).transform(e=>new In(e)));let nt=In;const $b=new nt({type:"builtin",key:"root"}),Uh=u.z.object({type:u.z.number()}),Dh=u.z.object({type:Rh,fields:u.z.record(Uh)}),Mh=u.z.object({id:nt.z,name:u.z.string(),schema:Dh.optional(),data:u.z.record(u.z.unknown()).optional()}).transform(r=>({key:r.id.toString(),...r})),Cb=u.z.object({from:nt.z,type:u.z.string(),to:nt.z}),Bo=r=>{const[e,t,n]=r.split("->");return{from:new nt(e),type:t,to:new nt(n)}},jb=u.z.object({group:Zb}),Rb=u.z.object({parent:Mt,name:u.z.string()}),zb=u.z.object({key:u.z.string(),name:u.z.string()}),Pb=u.z.object({keys:u.z.array(u.z.string())});var Jt;let Ub=(Jt=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const[n,s]=await this.client.send(Jt.ENDPOINT,{parent:e,name:t},Rb,jb);if(s!=null)throw s;return n.group}async rename(e,t){const n={key:e,name:t},[,s]=await this.client.send(Jt.ENDPOINT_RENAME,n,zb,u.z.object({}));if(s!=null)throw s}async delete(e){const t={keys:e},[,n]=await this.client.send(Jt.ENDPOINT_DELETE,t,Pb,u.z.object({}));if(n!=null)throw n}},h(Jt,"ENDPOINT","/ontology/create-group"),h(Jt,"ENDPOINT_RENAME","/ontology/rename-group"),h(Jt,"ENDPOINT_DELETE","/ontology/delete-group"),Jt),Db=class{constructor(e){h(this,"creator");this.creator=new Ub(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 Ab(e.name,e.key)}};const Mb=u.z.object({ids:Mt.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()}),Lb=u.z.object({resources:Mh.array()});var Cn;let Bb=(Cn=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 nt(s).payload),includeFieldData:n,includeSchema:t})}async retrieveChildren(e,t=!0,n=!0){return await this.execute({ids:Ne(e).map(s=>new nt(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 nt(s).payload),parents:!0,includeSchema:t,includeFieldData:n})}async execute(e){return(await J(this.client,Cn.ENDPOINT,e,Mb,Lb)).resources}},h(Cn,"ENDPOINT","/ontology/retrieve"),Cn);const lo={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},Bu=u.z.object({id:Mt,children:Mt.array()}),Vb=u.z.object({from:Mt,to:Mt,children:Mt.array()});let Kb=class{constructor(e){h(this,"client");this.client=e}async addChildren(e,...t){await J(this.client,lo.ADD_CHILDREN,{id:e,children:t},Bu,u.z.object({}))}async removeChildren(e,...t){await J(this.client,lo.REMOVE_CHILDREN,{id:e,children:t},Bu,u.z.object({}))}async moveChildren(e,t,...n){const s={from:e,to:t,children:n};await J(this.client,lo.MOVE_CHILDREN,s,Vb,u.z.object({}))}};const Vu="sy_ontology_resource_set",Ku="sy_ontology_resource_delete",qu="sy_ontology_relationship_set",Fu="sy_ontology_relationship_delete";class Li{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(qu);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"set",key:Bo(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(Fu);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"delete",key:Bo(n)}))}async parseResourceSets(e){const t=e.get(Vu);if(t.length===0)return[];const n=t[0].toStrings().map(s=>new nt(s));try{return(await this.retriever.retrieve(n)).map(a=>({variant:"set",key:a.id,value:a}))}catch(s){if(s instanceof tr)return console.warn(s),[];throw s}}parseResourceDeletes(e){const t=e.get(Ku);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"delete",key:new nt(n)}))}static async open(e,t){const n=await e.newStreamer([Vu,Ku,qu,Fu]);return new Li(n,t)}}let Lh=class{constructor(e,t){h(this,"groups");h(this,"retriever");h(this,"writer");h(this,"framer");this.retriever=new Bb(e),this.writer=new Kb(e),this.groups=new Db(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 tr(`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 Li.open(this.framer,this.retriever)}};const qb=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:Li,Client:Lh,ID:nt,Root:$b,crudeIDZ:Ph,idZ:Mt,parseRelationship:Bo,relationshipSchemaZ:Cb,resourceSchemaZ:Mh,schemaFieldZ:Uh,schemaZ:Dh,stringIDZ:zh},Symbol.toStringTag,{value:"Module"})),Kn=u.z.string().uuid(),sa=u.z.object({key:Kn,name:u.z.string().min(1),color:u.z.string()}),Fb=r=>new nt({type:"label",key:r}),Wb=u.z.object({keys:Kn.array().optional(),for:Mt.optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),Yb=u.z.object({labels:sa.array().optional().default([])});var jn;let Bh=(jn=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(jn.ENDPOINT,e,Wb,Yb);if(n!=null)throw n;return t.labels}},h(jn,"ENDPOINT","/label/retrieve"),jn);const Vh=sa.extend({key:Kn.optional()}),Jb=u.z.object({labels:Vh.array()}),Gb=u.z.object({labels:sa.array()}),Hb=u.z.object({keys:Kn.array()}),Kh=u.z.object({id:Mt,labels:Kn.array()}),Xb=Kh,ho=u.z.object({}),Qb="/label/create",e_="/label/delete",t_="/label/set",r_="/label/remove";let qh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await J(this.client,Qb,{labels:Ne(e)},Jb,Gb)).labels}async delete(e){await J(this.client,e_,{keys:Ne(e)},Hb,ho)}async set(e,t){await J(this.client,t_,{id:e,labels:t},Kh,ho)}async remove(e,t){await J(this.client,r_,{id:e,labels:t},Xb,ho)}};const n_="sy_label_set",s_="sy_label_delete";let Fh=class{constructor(e,t){h(this,"retriever");h(this,"writer");h(this,"frameClient");this.writer=new qh(e),this.retriever=new Bh(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 na.open(this.frameClient,n_,s_,a_)}};const a_=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON(sa).map(t=>({variant:r,key:t.key,value:t})),i_=Object.freeze(Object.defineProperty({__proto__:null,Client:Fh,Retriever:Bh,Writer:qh,keyZ:Kn,labelZ:sa,newLabelPayloadZ:Vh,ontologyID:Fb},Symbol.toStringTag,{value:"Module"})),lt=u.z.string().uuid(),aa=u.z.object({key:lt,name:u.z.string().min(1),timeRange:Zt.z}),Wh=aa.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=lt.safeParse(e[0]).success;return{single:!Array.isArray(r),variant:t?"keys":"names",normalized:e,actual:r}},o_=u.z.object({}),c_=u.z.object({range:aa}),u_=u.z.object({range:lt}),l_=u.z.object({range:lt}),d_=u.z.object({}),h_="/range/set-active",p_="/range/retrieve-active",f_="/range/clear-active";class m_{constructor(e){h(this,"client");this.client=e}async setActive(e){await J(this.client,h_,{range:e},u_,o_)}async retrieveActive(){const[e,t]=await this.client.send(p_,{},u.z.object({}),c_);if(t instanceof tr)return null;if(t!=null)throw t;return e.range}async clearActive(e){await J(this.client,f_,{range:e},l_,d_)}}const y_="sy_range_alias_set",g_="sy_range_alias_delete",v_=u.z.object({range:lt,aliases:u.z.string().array()}),w_=u.z.object({aliases:u.z.record(u.z.string(),Js)}),b_=u.z.object({range:lt,aliases:u.z.record(Js.or(u.z.string()),u.z.string())}),__=u.z.unknown(),k_=u.z.object({range:lt,channels:Js.array()}),O_=u.z.unknown(),T_=u.z.object({range:lt}),x_=u.z.object({aliases:u.z.record(u.z.string(),u.z.string())}),Ft=class Ft{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 J(this.client,Ft.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},v_,w_);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 J(this.client,Ft.SET_ENDPOINT,{range:this.rangeKey,aliases:e},b_,__)}async list(){return(await J(this.client,Ft.LIST_ENDPOINT,{range:this.rangeKey},T_,x_)).aliases}async delete(e){await J(this.client,Ft.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},k_,O_)}async openChangeTracker(){return await na.open(this.frameClient,y_,g_,E_(this.rangeKey))}};h(Ft,"SET_ENDPOINT","/range/alias/set"),h(Ft,"RESOLVE_ENDPOINT","/range/alias/resolve"),h(Ft,"LIST_ENDPOINT","/range/alias/list"),h(Ft,"DELETE_ENDPOINT","/range/alias/delete");let Vo=Ft;const S_=u.z.object({range:lt,channel:Js,alias:u.z.string()}),N_="---",E_=r=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(N_)[0]===r).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(S_).map(n=>({variant:e,key:n.alias,value:n})),A_=u.z.object({range:lt,keys:u.z.string().array()}),I_=u.z.object({pairs:u.z.record(u.z.string(),u.z.string())}),Z_=u.z.object({range:lt,pairs:u.z.record(u.z.string(),u.z.string())}),$_=u.z.object({range:lt,keys:u.z.string().array()}),$r=class $r{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($r.GET_ENDPOINT,{range:this.rangeKey,keys:Ne(e)},A_,I_);if(n!=null)throw n;return Array.isArray(e)?t.pairs:t.pairs[e]}async set(e,t=""){await J(this.client,$r.SET_ENDPOINT,{range:this.rangeKey,pairs:zl(e)?e:{[e]:t}},Z_,u.z.unknown())}async delete(e){await J(this.client,$r.DELETE_ENDPOINT,{range:this.rangeKey,keys:Ne(e)},$_,u.z.unknown())}};h($r,"GET_ENDPOINT","/range/kv/get"),h($r,"SET_ENDPOINT","/range/kv/set"),h($r,"DELETE_ENDPOINT","/range/kv/delete");let Ko=$r;const po=r=>new nt({type:"range",key:r});class Yh{constructor(e,t=Zt.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 tr(`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(po(this.key))}async addLabel(...e){await this.labelClient.label(po(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(po(this.key),e)}}let Jh=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 m_(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 tr(`range matching ${n} not found`);if(s.length>1)throw new tr(`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 Yh(t.name,t.timeRange,t.key,this.frameClient,new Ko(t.key,this.unaryClient),new Vo(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}};const C_=u.z.object({ranges:aa.array()}),j_=u.z.object({ranges:Wh.array()}),R_=u.z.object({keys:lt.array()}),z_=u.z.object({}),P_=u.z.object({key:lt,name:u.z.string()}),U_=u.z.object({}),D_="/range/create",M_="/range/delete",L_="/range/rename";let Gh=class{constructor(e){h(this,"client");this.client=e}async rename(e,t){await J(this.client,L_,{key:e,name:t},P_,U_)}async create(e){return(await J(this.client,D_,{ranges:e},j_,C_)).ranges}async delete(e){await J(this.client,M_,{keys:e},R_,z_)}};const B_=u.z.object({keys:lt.array().optional(),names:u.z.array(u.z.string()).optional(),term:u.z.string().optional()}),V_=u.z.object({ranges:u.z.array(aa)});let Hh=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,B_,V_);if(n!=null)throw n;return t.ranges}};const K_=Object.freeze(Object.defineProperty({__proto__:null,Client:Jh,Range:Yh,Retriever:Hh,Writer:Gh,analyzeParams:Lc,keyZ:lt,newPayloadZ:Wh,payloadZ:aa},Symbol.toStringTag,{value:"Module"})),q_="/api/v1/";class F_{constructor(e,t=!1){h(this,"url");h(this,"unary");h(this,"stream");h(this,"secure");this.secure=t,this.url=e.child(q_);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 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))}),Kc=u.z.string().uuid(),qc=u.z.object({key:u.z.string(),name:u.z.string(),data:oc.or(u.z.string().transform(r=>JSON.parse(r)))}),W_=u.z.object({keys:u.z.string().array()}),Y_=u.z.object({linePlots:qc.array()});let J_=class{constructor(e){h(this,"ENDPOINT","/workspace/lineplot/retrieve");h(this,"client");this.client=e}async retrieve(e){const t=Ne(e);return(await J(this.client,this.ENDPOINT,{keys:t},W_,Y_)).linePlots}};const G_=qc.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),H_=u.z.object({workspace:Xr,linePlots:G_.array()}),X_=u.z.object({linePlots:qc.array()}),Q_=u.z.object({keys:Kc.array()}),e1=u.z.object({}),t1=u.z.object({key:Kc,name:u.z.string()}),r1=u.z.object({}),n1=u.z.object({key:Kc,data:u.z.string()}),s1=u.z.object({}),a1="/workspace/lineplot/create",i1="/workspace/lineplot/delete",o1="/workspace/lineplot/rename",c1="/workspace/lineplot/set-data";let u1=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await J(this.client,a1,{workspace:e,linePlots:[n]},H_,X_)).linePlots[0]}async delete(e){const t=Ne(e);await J(this.client,i1,{keys:t},Q_,e1)}async rename(e,t){await J(this.client,o1,{key:e,name:t},t1,r1)}async setData(e,t){await J(this.client,c1,{key:e,data:JSON.stringify(t)},n1,s1)}},l1=class{constructor(e){h(this,"writer");h(this,"retriever");this.writer=new u1(e),this.retriever=new J_(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 Bi=u.z.string().uuid(),d1=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))}),h1=u.z.object({keys:u.z.string().array()}),p1=u.z.object({pids:Fc.array()});let f1=class{constructor(e){h(this,"ENDPOINT","/workspace/pid/retrieve");h(this,"client");this.client=e}async retrieve(e){return(await J(this.client,this.ENDPOINT,{keys:Ne(e)},h1,p1)).pids}};const m1=d1.partial({key:!0,snapshot:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),y1=u.z.object({workspace:Xr,pids:m1.array()}),g1=u.z.object({pids:Fc.array()}),v1=u.z.object({keys:Bi.array()}),w1=u.z.object({}),b1=u.z.object({key:Bi,name:u.z.string()}),Wu=u.z.object({}),_1=u.z.object({key:Bi,data:u.z.string()});u.z.object({});const k1=u.z.object({key:Bi,name:u.z.string(),snapshot:u.z.boolean()}),O1=u.z.object({pid:Fc}),T1="/workspace/pid/create",x1="/workspace/pid/delete",S1="/workspace/pid/rename",N1="/workspace/pid/set-data",E1="/workspace/pid/copy";let A1=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await J(this.client,T1,{workspace:e,pids:[n]},y1,g1)).pids[0]}async copy(e,t,n){return(await J(this.client,E1,{key:e,name:t,snapshot:n},k1,O1)).pid}async delete(e){const t=Ne(e);await J(this.client,x1,{keys:t},v1,w1)}async rename(e,t){await J(this.client,S1,{key:e,name:t},b1,Wu)}async setData(e,t){await J(this.client,N1,{key:e,data:JSON.stringify(t)},_1,Wu)}},I1=class{constructor(e){h(this,"writer");h(this,"retriever");this.writer=new A1(e),this.retriever=new f1(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 Z1=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()}),$1=u.z.object({workspaces:Vc.array()}),bi=class bi{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 J(this.client,bi.ENDPOINT,e,Z1,$1)).workspaces}};h(bi,"ENDPOINT","/workspace/retrieve");let qo=bi;const C1=Bc.partial({key:!0}).transform(r=>({...r,layout:JSON.stringify(r.layout)})),j1=u.z.object({workspaces:C1.array()}),R1=u.z.object({workspaces:Vc.array()}),z1=u.z.object({keys:Xr.array()}),P1=u.z.object({}),U1=u.z.object({key:Xr,name:u.z.string()}),D1=u.z.object({}),M1=u.z.object({key:Xr,layout:u.z.string()}),L1=u.z.object({}),B1="/workspace/create",V1="/workspace/delete",K1="/workspace/rename",q1="/workspace/set-layout";class F1{constructor(e){h(this,"client");this.client=e}async create(e){return(await J(this.client,B1,{workspaces:Ne(e)},j1,R1)).workspaces}async delete(e){await J(this.client,V1,{keys:Ne(e)},z1,P1)}async rename(e,t){await J(this.client,K1,{key:e,name:t},U1,D1)}async setLayout(e,t){await J(this.client,q1,{key:e,layout:JSON.stringify(t)},M1,L1)}}class Xh{constructor(e){h(this,"pid");h(this,"linePlot");h(this,"retriever");h(this,"writer");this.pid=new I1(e),this.linePlot=new l1(e),this.retriever=new qo(e),this.writer=new F1(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 W1=Object.freeze(Object.defineProperty({__proto__:null,Client:Xh,keyZ:Xr,workspaceRemoteZ:Vc,workspaceZ:Bc},Symbol.toStringTag,{value:"Module"})),Qh=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:Pe.z.default(Pe.seconds(30)),secure:u.z.boolean().optional().default(!1),name:u.z.string().optional()});class ep{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=je.now(),this.props=Qh.parse(e);const{host:t,port:n,username:s,password:a,connectivityPollFrequency:i,secure:o}=this.props;this.transport=new F_(new cm({host:t,port:Number(n)}),o),this.transport.use(Zw),s!=null&&a!=null&&(this.auth=new Dw(this.transport.unary,{username:s,password:a}),this.transport.use(this.auth.middleware()));const c=new dc(new vs(this.transport.unary)),l=new Ga(this.transport.unary);this.telem=new Oh(this.transport.stream,c),this.channels=new mh(this.telem,c,this.transport.unary,l),this.connectivity=new Fs(this.transport.unary,i,e.name),this.ontology=new Lh(this.transport.unary,this.telem);const g=new Hh(this.transport.unary),E=new Gh(this.transport.unary);this.labels=new Fh(this.transport.unary,this.telem),this.ranges=new Jh(this.telem,g,E,this.transport.unary,c,this.labels),this.workspaces=new Xh(this.transport.unary);const Q=new xh(new Sh(this.transport.unary),new Nh(this.transport.unary),this.telem),ce=new Ch(this.transport.unary),Se=new jh(this.transport.unary),ee=new $h(ce,Se),rr=new Eh(new Zh(this.transport.unary),new Ih(this.transport.unary),this.telem,Se,ce);this.hardware=new Th(ee,rr,Q)}close(){this.connectivity.stopChecking()}}h(ep,"connectivity",Fs);const Y1=Object.freeze(Object.defineProperty({__proto__:null,Authority:Jr,StateTracker:Rc,filterTransfersByChannelKey:Gw,stateZ:Jw,subjectZ:jc,transferString:Hw},Symbol.toStringTag,{value:"Module"}));exports.AuthError=Ac;exports.Authority=Jr;exports.Channel=Ic;exports.ContiguityError=Ew;exports.DataType=rt;exports.Density=it;exports.Frame=yt;exports.GeneralError=hh;exports.ParseError=ph;exports.QueryError=tr;exports.Rate=xi;exports.RouteError=fh;exports.Series=ic;exports.Synnax=ep;exports.TimeRange=Zt;exports.TimeSpan=Pe;exports.TimeStamp=je;exports.UnexpectedError=wn;exports.ValidationError=jt;exports.channel=Cw;exports.connection=Bw;exports.control=Y1;exports.device=pb;exports.framer=tb;exports.hardware=rb;exports.label=i_;exports.ontology=qb;exports.rack=bb;exports.ranger=K_;exports.synnaxPropsZ=Qh;exports.task=Eb;exports.workspace=W1;
20
+ `);if(!(t instanceof Ks))throw t}closeSend(){this.stream.closeSend()}send(e){const t=this.stream.send(e);if(t!=null)throw t}}const Lo=new Pe(-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||{}),_h=(r=>(r[r.None=0]="None",r[r.Ack=1]="Ack",r[r.Data=2]="Data",r))(_h||{});const Vw=u.z.object({command:u.z.nativeEnum(Cc),span:Pe.z.optional(),bounds:Zt.z.optional(),stamp:je.z.optional(),keys:u.z.number().array().optional()}),Kw=u.z.object({variant:u.z.nativeEnum(_h),ack:u.z.boolean(),command:u.z.nativeEnum(Cc),error:ta.optional().nullable(),frame:Pi.optional()}),ss=class ss{constructor(e,t){h(this,"stream");h(this,"adapter");h(this,"value");this.stream=new $c("Iterator",e),this.value=new yt,this.adapter=t}static async _open(e,t,n,s){const a=await Ui.open(n,t),i=await s.stream(ss.ENDPOINT,Vw,Kw),o=new ss(i,a);return await o.execute({command:0,keys:a.keys,bounds:e}),o}async next(e=Lo){return await this.execute({command:1,span:new Pe(e)})}async prev(e=Lo){return await this.execute({command:2,span:new Pe(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 je(e)})}async seekGE(e){return await this.execute({command:6,stamp:new je(e)})}async valid(){return await this.execute({command:7})}async close(){await this.stream.closeAndAck()}[Symbol.asyncIterator](){return new qw(this)}async execute(e){for(this.stream.send(e),this.value=new yt;;){const t=await this.stream.receive();if(t.variant===1)return t.ack;this.value.push(this.adapter.adapt(new yt(t.frame)))}}};h(ss,"ENDPOINT","/frame/iterate");let gi=ss;class qw{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 Fw=u.z.object({start:je.z.optional(),keys:u.z.number().array()}),Ww=u.z.object({frame:Pi,error:ta.optional().nullable()}),Yw="/frame/stream";class Di{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 Ui.open(n,t),i=await s.stream(Yw,Fw,Ww),o=new Di(i,a);return i.send({start:new je(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 yt((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()}),Jw=u.z.object({subject:jc,resource:u.z.number(),authority:Jr.z}),Gw=(...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}),Hw=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 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.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||{}),Ws=(r=>(r[r.PersistStream=1]="PersistStream",r[r.PersistOnly=2]="PersistOnly",r[r.StreamOnly=3]="StreamOnly",r))(Ws||{});const Xw=u.z.object({start:je.z.optional(),controlSubject:jc.optional(),keys:u.z.number().array().optional(),authorities:Jr.z.array().optional(),mode:u.z.nativeEnum(Ws).optional()}),Qw=u.z.object({command:u.z.nativeEnum(zc),config:Xw.optional(),frame:Pi.optional()}),eb=u.z.object({ack:u.z.boolean(),command:u.z.nativeEnum(zc),error:ta.optional().nullable()});var ln;let kh=(ln=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=Jr.Absolute,controlSubject:a,start:i,mode:o}){const c=await Zc.open(e,n),l=await t.stream(ln.ENDPOINT,Qw,eb),g=new ln(l,c);return await g.execute({command:0,config:{start:new je(i),keys:c.keys,controlSubject:a,authorities:Se(s),mode:o}}),g}async write(e,t){return["string","number"].includes(typeof e)&&(e=new yt(e,new ic({data:t}))),e=this.adapter.adapt(new yt(e)),this.stream.send({command:1,frame:e.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?Ec(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(ln,"ENDPOINT","/frame/write"),ln),Oh=class{constructor(e,t){h(this,"stream");h(this,"retriever");this.stream=e,this.retriever=t}async newIterator(e,t){return await gi._open(e,t,this.retriever,this.stream)}async newWriter({start:e,channels:t,controlSubject:n,authorities:s=Jr.Absolute,mode:a=Ws.PersistStream}){return await kh._open(this.retriever,this.stream,{start:e??je.now(),controlSubject:n,channels:t,authorities:s,mode:a})}async newStreamer(e,t=je.now()){return await Di._open(t,e,this.retriever,this.stream)}async write(e,t,n){const s=await this.newWriter({start:t,channels:e,mode:Ws.PersistOnly});try{await s.write(e,n),await s.commit()}finally{await s.close()}}async read(e,t){const{single:n}=Gr(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 yt;try{for await(const a of n)s.push(a)}finally{await n.close()}return s}};const tb=Object.freeze(Object.defineProperty({__proto__:null,AUTO_SPAN:Lo,Client:Oh,Frame:yt,Iterator:gi,Streamer:Di,Writer:kh,WriterMode:Ws,frameZ:Pi,series:vh,seriesFromPayload:wh,seriesToPayload:bh},Symbol.toStringTag,{value:"Module"}));let Th=class{constructor(e,t,n){h(this,"tasks");h(this,"racks");h(this,"devices");this.tasks=e,this.racks=t,this.devices=n}};const rb=Object.freeze(Object.defineProperty({__proto__:null,Client:Th},Symbol.toStringTag,{value:"Module"})),ra=u.z.number(),Pc=u.z.object({key:ra,name:u.z.string()}),nb=Pc.partial({key:!0}),Uc=u.z.string(),Mi=u.z.object({key:Uc,rack:ra,name:u.z.string(),make:u.z.string(),model:u.z.string(),location:u.z.string(),properties:u.z.string()});class na{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.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 na(a,s,t,n)}}const sb="sy_device_set",ab="sy_device_delete";let xh=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 na.open(this.frameClient,sb,ab,ib)}};const ib=(r,e)=>r==="delete"?e.toStrings().map(t=>({variant:r,key:t,value:void 0})):e.parseJSON(Mi).map(t=>({variant:r,key:t.key,value:t})),to="/hardware/device/retrieve",ro=u.z.object({search:u.z.string().optional(),limit:u.z.number().optional(),offset:u.z.number().optional(),keys:Uc.array().optional()}),no=u.z.object({devices:Mi.array()});let Sh=class{constructor(e){h(this,"client");this.client=e}async search(e){return(await J(this.client,to,{keys:[e]},ro,no)).devices}async page(e,t){return(await J(this.client,to,{offset:e,limit:t},ro,no)).devices}async retrieve(e){return(await J(this.client,to,{keys:e},ro,no)).devices}};const ob="/hardware/device/create",cb="/hardware/device/delete",ub=u.z.object({devices:Mi.array()}),lb=u.z.object({devices:Mi.array()}),db=u.z.object({keys:Uc.array()}),hb=u.z.object({});let Nh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await J(this.client,ob,{devices:e},ub,lb)).devices}async delete(e){await J(this.client,cb,{keys:e},db,hb)}};const pb=Object.freeze(Object.defineProperty({__proto__:null,Client:xh,Retriever:Sh,Writer:Nh},Symbol.toStringTag,{value:"Module"}));let Eh=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 Ah(t.key,t.name,this.taskWriter,this.taskRetriever))}};class Ah{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 fb="/hardware/rack/create",mb="/hardware/rack/delete",yb=u.z.object({racks:nb.array()}),gb=u.z.object({racks:Pc.array()}),vb=u.z.object({keys:ra.array()}),wb=u.z.object({});let Ih=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await J(this.client,fb,{racks:e},yb,gb)).racks}async delete(e){await J(this.client,mb,{keys:e},vb,wb)}};const so="/hardware/rack/retrieve",ao=u.z.object({keys:ra.array().optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),io=u.z.object({racks:Pc.array()});let Zh=class{constructor(e){h(this,"client");this.client=e}async page(e,t){return(await J(this.client,so,{offset:e,limit:t},ao,io)).racks}async search(e){return(await J(this.client,so,{search:e},ao,io)).racks}async retrieve(e){return(await J(this.client,so,{keys:e},ao,io)).racks}};const bb=Object.freeze(Object.defineProperty({__proto__:null,Client:Eh,Rack:Ah,Retriever:Zh,Writer:Ih},Symbol.toStringTag,{value:"Module"}));let $h=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 Dc=u.z.union([u.z.string(),u.z.bigint().transform(r=>r.toString()),u.z.number().transform(r=>r.toString())]),Mc=u.z.object({key:Dc,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=Mc.omit({key:!0}).extend({key:Dc.transform(r=>r.toString()).optional(),config:u.z.unknown().transform(r=>JSON.stringify(r))}),oo=u.z.object({rack:ra.optional(),keys:u.z.string().array().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),co=u.z.object({tasks:u.z.union([Mc.array(),u.z.null().transform(()=>[])])}),uo="/hardware/task/retrieve";let Ch=class{constructor(e){h(this,"client");this.client=e}async retrieve(e){return(await J(this.client,uo,e,oo,co)).tasks}async search(e){return(await J(this.client,uo,{keys:[e]},oo,co)).tasks}async page(e,t){return(await J(this.client,uo,{offset:e,limit:t},oo,co)).tasks}};const kb="/hardware/task/create",Ob="/hardware/task/delete",Tb=u.z.object({tasks:_b.array()}),xb=u.z.object({tasks:Mc.array()}),Sb=u.z.object({keys:Dc.array()}),Nb=u.z.object({});let jh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await J(this.client,kb,{tasks:e},Tb,xb)).tasks}async delete(e){await J(this.client,Ob,{keys:e},Sb,Nb)}};const Eb=Object.freeze(Object.defineProperty({__proto__:null,Client:$h,Retriever:Ch,Writer:jh},Symbol.toStringTag,{value:"Module"}));class Ab{constructor(e,t){h(this,"key");h(this,"name");this.key=t,this.name=e}get ontologyID(){return new nt({type:"group",key:this.key})}}const Ib=u.z.string().uuid(),Zb=u.z.object({key:Ib,name:u.z.string()}),Rh=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")]),Mt=u.z.object({type:Rh,key:u.z.string()}),zh=u.z.string().transform(r=>{const[e,t]=r.split(":");return{type:e,key:t}}),Ph=u.z.union([zh,Mt]),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([Ph,u.z.instanceof(In)]).transform(e=>new In(e)));let nt=In;const $b=new nt({type:"builtin",key:"root"}),Uh=u.z.object({type:u.z.number()}),Dh=u.z.object({type:Rh,fields:u.z.record(Uh)}),Mh=u.z.object({id:nt.z,name:u.z.string(),schema:Dh.optional(),data:u.z.record(u.z.unknown()).optional()}).transform(r=>({key:r.id.toString(),...r})),Cb=u.z.object({from:nt.z,type:u.z.string(),to:nt.z}),Bo=r=>{const[e,t,n]=r.split("->");return{from:new nt(e),type:t,to:new nt(n)}},jb=u.z.object({group:Zb}),Rb=u.z.object({parent:Mt,name:u.z.string()}),zb=u.z.object({key:u.z.string(),name:u.z.string()}),Pb=u.z.object({keys:u.z.array(u.z.string())});var Jt;let Ub=(Jt=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const[n,s]=await this.client.send(Jt.ENDPOINT,{parent:e,name:t},Rb,jb);if(s!=null)throw s;return n.group}async rename(e,t){const n={key:e,name:t},[,s]=await this.client.send(Jt.ENDPOINT_RENAME,n,zb,u.z.object({}));if(s!=null)throw s}async delete(e){const t={keys:e},[,n]=await this.client.send(Jt.ENDPOINT_DELETE,t,Pb,u.z.object({}));if(n!=null)throw n}},h(Jt,"ENDPOINT","/ontology/create-group"),h(Jt,"ENDPOINT_RENAME","/ontology/rename-group"),h(Jt,"ENDPOINT_DELETE","/ontology/delete-group"),Jt),Db=class{constructor(e){h(this,"creator");this.creator=new Ub(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 Ab(e.name,e.key)}};const Mb=u.z.object({ids:Mt.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()}),Lb=u.z.object({resources:Mh.array()});var Cn;let Bb=(Cn=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 nt(s).payload),includeFieldData:n,includeSchema:t})}async retrieveChildren(e,t=!0,n=!0){return await this.execute({ids:Se(e).map(s=>new nt(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 nt(s).payload),parents:!0,includeSchema:t,includeFieldData:n})}async execute(e){return(await J(this.client,Cn.ENDPOINT,e,Mb,Lb)).resources}},h(Cn,"ENDPOINT","/ontology/retrieve"),Cn);const lo={ADD_CHILDREN:"/ontology/add-children",REMOVE_CHILDREN:"/ontology/remove-children",MOVE_CHILDREN:"/ontology/move-children"},Bu=u.z.object({id:Mt,children:Mt.array()}),Vb=u.z.object({from:Mt,to:Mt,children:Mt.array()});let Kb=class{constructor(e){h(this,"client");this.client=e}async addChildren(e,...t){await J(this.client,lo.ADD_CHILDREN,{id:e,children:t},Bu,u.z.object({}))}async removeChildren(e,...t){await J(this.client,lo.REMOVE_CHILDREN,{id:e,children:t},Bu,u.z.object({}))}async moveChildren(e,t,...n){const s={from:e,to:t,children:n};await J(this.client,lo.MOVE_CHILDREN,s,Vb,u.z.object({}))}};const Vu="sy_ontology_resource_set",Ku="sy_ontology_resource_delete",qu="sy_ontology_relationship_set",Fu="sy_ontology_relationship_delete";class Li{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(qu);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"set",key:Bo(n),value:void 0}))}parseRelationshipDeletes(e){const t=e.get(Fu);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"delete",key:Bo(n)}))}async parseResourceSets(e){const t=e.get(Vu);if(t.length===0)return[];const n=t[0].toStrings().map(s=>new nt(s));try{return(await this.retriever.retrieve(n)).map(a=>({variant:"set",key:a.id,value:a}))}catch(s){if(s instanceof tr)return console.warn(s),[];throw s}}parseResourceDeletes(e){const t=e.get(Ku);return t.length===0?[]:t[0].toStrings().map(n=>({variant:"delete",key:new nt(n)}))}static async open(e,t){const n=await e.newStreamer([Vu,Ku,qu,Fu]);return new Li(n,t)}}let Lh=class{constructor(e,t){h(this,"groups");h(this,"retriever");h(this,"writer");h(this,"framer");this.retriever=new Bb(e),this.writer=new Kb(e),this.groups=new Db(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 tr(`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 Li.open(this.framer,this.retriever)}};const qb=Object.freeze(Object.defineProperty({__proto__:null,ChangeTracker:Li,Client:Lh,ID:nt,Root:$b,crudeIDZ:Ph,idZ:Mt,parseRelationship:Bo,relationshipSchemaZ:Cb,resourceSchemaZ:Mh,schemaFieldZ:Uh,schemaZ:Dh,stringIDZ:zh},Symbol.toStringTag,{value:"Module"})),Kn=u.z.string().uuid(),sa=u.z.object({key:Kn,name:u.z.string().min(1),color:u.z.string()}),Fb=r=>new nt({type:"label",key:r}),Wb=u.z.object({keys:Kn.array().optional(),for:Mt.optional(),search:u.z.string().optional(),offset:u.z.number().optional(),limit:u.z.number().optional()}),Yb=u.z.object({labels:sa.array().optional().default([])});var jn;let Bh=(jn=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(jn.ENDPOINT,e,Wb,Yb);if(n!=null)throw n;return t.labels}},h(jn,"ENDPOINT","/label/retrieve"),jn);const Vh=sa.extend({key:Kn.optional()}),Jb=u.z.object({labels:Vh.array()}),Gb=u.z.object({labels:sa.array()}),Hb=u.z.object({keys:Kn.array()}),Kh=u.z.object({id:Mt,labels:Kn.array()}),Xb=Kh,ho=u.z.object({}),Qb="/label/create",e_="/label/delete",t_="/label/set",r_="/label/remove";let qh=class{constructor(e){h(this,"client");this.client=e}async create(e){return(await J(this.client,Qb,{labels:Se(e)},Jb,Gb)).labels}async delete(e){await J(this.client,e_,{keys:Se(e)},Hb,ho)}async set(e,t){await J(this.client,t_,{id:e,labels:t},Kh,ho)}async remove(e,t){await J(this.client,r_,{id:e,labels:t},Xb,ho)}};const n_="sy_label_set",s_="sy_label_delete";let Fh=class{constructor(e,t){h(this,"retriever");h(this,"writer");h(this,"frameClient");this.writer=new qh(e),this.retriever=new Bh(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 na.open(this.frameClient,n_,s_,a_)}};const a_=(r,e)=>r==="delete"?e.toUUIDs().map(t=>({variant:r,key:t})):e.parseJSON(sa).map(t=>({variant:r,key:t.key,value:t})),i_=Object.freeze(Object.defineProperty({__proto__:null,Client:Fh,Retriever:Bh,Writer:qh,keyZ:Kn,labelZ:sa,newLabelPayloadZ:Vh,ontologyID:Fb},Symbol.toStringTag,{value:"Module"})),lt=u.z.string().uuid(),aa=u.z.object({key:lt,name:u.z.string().min(1),timeRange:Zt.z}),Wh=aa.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=lt.safeParse(e[0]).success;return{single:!Array.isArray(r),variant:t?"keys":"names",normalized:e,actual:r}},o_=u.z.object({}),c_=u.z.object({range:aa}),u_=u.z.object({range:lt}),l_=u.z.object({range:lt}),d_=u.z.object({}),h_="/range/set-active",p_="/range/retrieve-active",f_="/range/clear-active";class m_{constructor(e){h(this,"client");this.client=e}async setActive(e){await J(this.client,h_,{range:e},u_,o_)}async retrieveActive(){const[e,t]=await this.client.send(p_,{},u.z.object({}),c_);if(t instanceof tr)return null;if(t!=null)throw t;return e.range}async clearActive(e){await J(this.client,f_,{range:e},l_,d_)}}const y_="sy_range_alias_set",g_="sy_range_alias_delete",v_=u.z.object({range:lt,aliases:u.z.string().array()}),w_=u.z.object({aliases:u.z.record(u.z.string(),Js)}),b_=u.z.object({range:lt,aliases:u.z.record(Js.or(u.z.string()),u.z.string())}),__=u.z.unknown(),k_=u.z.object({range:lt,channels:Js.array()}),O_=u.z.unknown(),T_=u.z.object({range:lt}),x_=u.z.object({aliases:u.z.record(u.z.string(),u.z.string())}),Ft=class Ft{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 J(this.client,Ft.RESOLVE_ENDPOINT,{range:this.rangeKey,aliases:t},v_,w_);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 J(this.client,Ft.SET_ENDPOINT,{range:this.rangeKey,aliases:e},b_,__)}async list(){return(await J(this.client,Ft.LIST_ENDPOINT,{range:this.rangeKey},T_,x_)).aliases}async delete(e){await J(this.client,Ft.DELETE_ENDPOINT,{range:this.rangeKey,channels:e},k_,O_)}async openChangeTracker(){return await na.open(this.frameClient,y_,g_,E_(this.rangeKey))}};h(Ft,"SET_ENDPOINT","/range/alias/set"),h(Ft,"RESOLVE_ENDPOINT","/range/alias/resolve"),h(Ft,"LIST_ENDPOINT","/range/alias/list"),h(Ft,"DELETE_ENDPOINT","/range/alias/delete");let Vo=Ft;const S_=u.z.object({range:lt,channel:Js,alias:u.z.string()}),N_="---",E_=r=>(e,t)=>e==="delete"?t.toStrings().filter(n=>n.split(N_)[0]===r).map(n=>({variant:e,key:n,value:void 0})):t.parseJSON(S_).map(n=>({variant:e,key:n.alias,value:n})),A_=u.z.object({range:lt,keys:u.z.string().array()}),I_=u.z.object({pairs:u.z.record(u.z.string(),u.z.string())}),Z_=u.z.object({range:lt,pairs:u.z.record(u.z.string(),u.z.string())}),$_=u.z.object({range:lt,keys:u.z.string().array()}),$r=class $r{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($r.GET_ENDPOINT,{range:this.rangeKey,keys:Se(e)},A_,I_);if(n!=null)throw n;return Array.isArray(e)?t.pairs:t.pairs[e]}async set(e,t=""){await J(this.client,$r.SET_ENDPOINT,{range:this.rangeKey,pairs:zl(e)?e:{[e]:t}},Z_,u.z.unknown())}async delete(e){await J(this.client,$r.DELETE_ENDPOINT,{range:this.rangeKey,keys:Se(e)},$_,u.z.unknown())}};h($r,"GET_ENDPOINT","/range/kv/get"),h($r,"SET_ENDPOINT","/range/kv/set"),h($r,"DELETE_ENDPOINT","/range/kv/delete");let Ko=$r;const po=r=>new nt({type:"range",key:r});class Yh{constructor(e,t=Zt.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 tr(`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(po(this.key))}async addLabel(...e){await this.labelClient.label(po(this.key),e)}async removeLabel(...e){await this.labelClient.removeLabels(po(this.key),e)}}let Jh=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 m_(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 tr(`range matching ${n} not found`);if(s.length>1)throw new tr(`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 Yh(t.name,t.timeRange,t.key,this.frameClient,new Ko(t.key,this.unaryClient),new Vo(t.key,this.frameClient,this.unaryClient),this.channels,this.labelClient))}};const C_=u.z.object({ranges:aa.array()}),j_=u.z.object({ranges:Wh.array()}),R_=u.z.object({keys:lt.array()}),z_=u.z.object({}),P_=u.z.object({key:lt,name:u.z.string()}),U_=u.z.object({}),D_="/range/create",M_="/range/delete",L_="/range/rename";let Gh=class{constructor(e){h(this,"client");this.client=e}async rename(e,t){await J(this.client,L_,{key:e,name:t},P_,U_)}async create(e){return(await J(this.client,D_,{ranges:e},j_,C_)).ranges}async delete(e){await J(this.client,M_,{keys:e},R_,z_)}};const B_=u.z.object({keys:lt.array().optional(),names:u.z.array(u.z.string()).optional(),term:u.z.string().optional()}),V_=u.z.object({ranges:u.z.array(aa)});let Hh=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,B_,V_);if(n!=null)throw n;return t.ranges}};const K_=Object.freeze(Object.defineProperty({__proto__:null,Client:Jh,Range:Yh,Retriever:Hh,Writer:Gh,analyzeParams:Lc,keyZ:lt,newPayloadZ:Wh,payloadZ:aa},Symbol.toStringTag,{value:"Module"})),q_="/api/v1/";class F_{constructor(e,t=!1){h(this,"url");h(this,"unary");h(this,"stream");h(this,"secure");this.secure=t,this.url=e.child(q_);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 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))}),Kc=u.z.string().uuid(),qc=u.z.object({key:u.z.string(),name:u.z.string(),data:oc.or(u.z.string().transform(r=>JSON.parse(r)))}),W_=u.z.object({keys:u.z.string().array()}),Y_=u.z.object({linePlots:qc.array()});let J_=class{constructor(e){h(this,"ENDPOINT","/workspace/lineplot/retrieve");h(this,"client");this.client=e}async retrieve(e){const t=Se(e);return(await J(this.client,this.ENDPOINT,{keys:t},W_,Y_)).linePlots}};const G_=qc.partial({key:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),H_=u.z.object({workspace:Xr,linePlots:G_.array()}),X_=u.z.object({linePlots:qc.array()}),Q_=u.z.object({keys:Kc.array()}),e1=u.z.object({}),t1=u.z.object({key:Kc,name:u.z.string()}),r1=u.z.object({}),n1=u.z.object({key:Kc,data:u.z.string()}),s1=u.z.object({}),a1="/workspace/lineplot/create",i1="/workspace/lineplot/delete",o1="/workspace/lineplot/rename",c1="/workspace/lineplot/set-data";let u1=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await J(this.client,a1,{workspace:e,linePlots:[n]},H_,X_)).linePlots[0]}async delete(e){const t=Se(e);await J(this.client,i1,{keys:t},Q_,e1)}async rename(e,t){await J(this.client,o1,{key:e,name:t},t1,r1)}async setData(e,t){await J(this.client,c1,{key:e,data:JSON.stringify(t)},n1,s1)}},l1=class{constructor(e){h(this,"writer");h(this,"retriever");this.writer=new u1(e),this.retriever=new J_(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 Bi=u.z.string().uuid(),d1=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))}),h1=u.z.object({keys:u.z.string().array()}),p1=u.z.object({pids:Fc.array()});let f1=class{constructor(e){h(this,"ENDPOINT","/workspace/pid/retrieve");h(this,"client");this.client=e}async retrieve(e){return(await J(this.client,this.ENDPOINT,{keys:Se(e)},h1,p1)).pids}};const m1=d1.partial({key:!0,snapshot:!0}).transform(r=>({...r,data:JSON.stringify(r.data)})),y1=u.z.object({workspace:Xr,pids:m1.array()}),g1=u.z.object({pids:Fc.array()}),v1=u.z.object({keys:Bi.array()}),w1=u.z.object({}),b1=u.z.object({key:Bi,name:u.z.string()}),Wu=u.z.object({}),_1=u.z.object({key:Bi,data:u.z.string()});u.z.object({});const k1=u.z.object({key:Bi,name:u.z.string(),snapshot:u.z.boolean()}),O1=u.z.object({pid:Fc}),T1="/workspace/pid/create",x1="/workspace/pid/delete",S1="/workspace/pid/rename",N1="/workspace/pid/set-data",E1="/workspace/pid/copy";let A1=class{constructor(e){h(this,"client");this.client=e}async create(e,t){const n={...t,data:JSON.stringify(t.data)};return(await J(this.client,T1,{workspace:e,pids:[n]},y1,g1)).pids[0]}async copy(e,t,n){return(await J(this.client,E1,{key:e,name:t,snapshot:n},k1,O1)).pid}async delete(e){const t=Se(e);await J(this.client,x1,{keys:t},v1,w1)}async rename(e,t){await J(this.client,S1,{key:e,name:t},b1,Wu)}async setData(e,t){await J(this.client,N1,{key:e,data:JSON.stringify(t)},_1,Wu)}},I1=class{constructor(e){h(this,"writer");h(this,"retriever");this.writer=new A1(e),this.retriever=new f1(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 Z1=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()}),$1=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 J(this.client,bi.ENDPOINT,e,Z1,$1)).workspaces}};h(bi,"ENDPOINT","/workspace/retrieve");let qo=bi;const C1=Bc.partial({key:!0}).transform(r=>({...r,layout:JSON.stringify(r.layout)})),j1=u.z.object({workspaces:C1.array()}),R1=u.z.object({workspaces:Vc.array()}),z1=u.z.object({keys:Xr.array()}),P1=u.z.object({}),U1=u.z.object({key:Xr,name:u.z.string()}),D1=u.z.object({}),M1=u.z.object({key:Xr,layout:u.z.string()}),L1=u.z.object({}),B1="/workspace/create",V1="/workspace/delete",K1="/workspace/rename",q1="/workspace/set-layout";class F1{constructor(e){h(this,"client");this.client=e}async create(e){return(await J(this.client,B1,{workspaces:Se(e)},j1,R1)).workspaces}async delete(e){await J(this.client,V1,{keys:Se(e)},z1,P1)}async rename(e,t){await J(this.client,K1,{key:e,name:t},U1,D1)}async setLayout(e,t){await J(this.client,q1,{key:e,layout:JSON.stringify(t)},M1,L1)}}class Xh{constructor(e){h(this,"pid");h(this,"linePlot");h(this,"retriever");h(this,"writer");this.pid=new I1(e),this.linePlot=new l1(e),this.retriever=new qo(e),this.writer=new F1(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 W1=Object.freeze(Object.defineProperty({__proto__:null,Client:Xh,keyZ:Xr,workspaceRemoteZ:Vc,workspaceZ:Bc},Symbol.toStringTag,{value:"Module"})),Qh=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:Pe.z.default(Pe.seconds(30)),secure:u.z.boolean().optional().default(!1),name:u.z.string().optional()});class ep{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=je.now(),this.props=Qh.parse(e);const{host:t,port:n,username:s,password:a,connectivityPollFrequency:i,secure:o}=this.props;this.transport=new F_(new cm({host:t,port:Number(n)}),o),this.transport.use(Zw),s!=null&&a!=null&&(this.auth=new Dw(this.transport.unary,{username:s,password:a}),this.transport.use(this.auth.middleware()));const c=new dc(new vs(this.transport.unary)),l=new Ga(this.transport.unary);this.telem=new Oh(this.transport.stream,c),this.channels=new mh(this.telem,c,this.transport.unary,l),this.connectivity=new Fs(this.transport.unary,i,e.name),this.ontology=new Lh(this.transport.unary,this.telem);const g=new Hh(this.transport.unary),E=new Gh(this.transport.unary);this.labels=new Fh(this.transport.unary,this.telem),this.ranges=new Jh(this.telem,g,E,this.transport.unary,c,this.labels),this.workspaces=new Xh(this.transport.unary);const Q=new xh(new Sh(this.transport.unary),new Nh(this.transport.unary),this.telem),ce=new Ch(this.transport.unary),Ne=new jh(this.transport.unary),ee=new $h(ce,Ne),rr=new Eh(new Zh(this.transport.unary),new Ih(this.transport.unary),this.telem,Ne,ce);this.hardware=new Th(ee,rr,Q)}close(){this.connectivity.stopChecking()}}h(ep,"connectivity",Fs);const Y1=Object.freeze(Object.defineProperty({__proto__:null,Authority:Jr,StateTracker:Rc,filterTransfersByChannelKey:Gw,stateZ:Jw,subjectZ:jc,transferString:Hw},Symbol.toStringTag,{value:"Module"}));exports.AuthError=Ac;exports.Authority=Jr;exports.Channel=Ic;exports.ContiguityError=Ew;exports.DataType=rt;exports.Density=it;exports.Frame=yt;exports.GeneralError=hh;exports.ParseError=ph;exports.QueryError=tr;exports.Rate=xi;exports.RouteError=fh;exports.Series=ic;exports.Synnax=ep;exports.TimeRange=Zt;exports.TimeSpan=Pe;exports.TimeStamp=je;exports.UnexpectedError=wn;exports.ValidationError=jt;exports.channel=Cw;exports.connection=Bw;exports.control=Y1;exports.device=pb;exports.framer=tb;exports.hardware=rb;exports.label=i_;exports.ontology=qb;exports.rack=bb;exports.ranger=K_;exports.synnaxPropsZ=Qh;exports.task=Eb;exports.workspace=W1;
21
21
  //# sourceMappingURL=client.cjs.map