@resconet/qp-bridge 0.0.1-alpha.18 → 0.0.1-alpha.19

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/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let ge;const kt=new Uint8Array(16);function wt(){if(!ge&&(ge=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ge))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ge(kt)}const k=[];for(let t=0;t<256;++t)k.push((t+256).toString(16).slice(1));function St(t,e=0){return k[t[e+0]]+k[t[e+1]]+k[t[e+2]]+k[t[e+3]]+"-"+k[t[e+4]]+k[t[e+5]]+"-"+k[t[e+6]]+k[t[e+7]]+"-"+k[t[e+8]]+k[t[e+9]]+"-"+k[t[e+10]]+k[t[e+11]]+k[t[e+12]]+k[t[e+13]]+k[t[e+14]]+k[t[e+15]]}const Tt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Pe={randomUUID:Tt};function Rt(t,e,s){if(Pe.randomUUID&&!e&&!t)return Pe.randomUUID();t=t||{};const n=t.random||(t.rng||wt)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,St(n)}var x;(function(t){t.assertEqual=r=>r;function e(r){}t.assertIs=e;function s(r){throw new Error}t.assertNever=s,t.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},t.getValidEnumValues=r=>{const a=t.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(a){return r[a]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},t.find=(r,a)=>{for(const i of r)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Ce;(function(t){t.mergeShapes=(e,s)=>({...e,...s})})(Ce||(Ce={}));const f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),q=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(t)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}},c=x.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"]),Ct=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class R extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const s=e||function(a){return a.message},n={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)n._errors.push(s(i));else{let o=n,d=0;for(;d<i.path.length;){const u=i.path[d];d===i.path.length-1?(o[u]=o[u]||{_errors:[]},o[u]._errors.push(s(i))):o[u]=o[u]||{_errors:[]},o=o[u],d++}}};return r(this),n}static assert(e){if(!(e instanceof R))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=s=>s.message){const s={},n=[];for(const r of this.issues)r.path.length>0?(s[r.path[0]]=s[r.path[0]]||[],s[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:s}}get formErrors(){return this.flatten()}}R.create=t=>new R(t);const H=(t,e)=>{let s;switch(t.code){case c.invalid_type:t.received===f.undefined?s="Required":s=`Expected ${t.expected}, received ${t.received}`;break;case c.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(t.expected,x.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:s=`Unrecognized key(s) in object: ${x.joinValues(t.keys,", ")}`;break;case c.invalid_union:s="Invalid input";break;case c.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${x.joinValues(t.options)}`;break;case c.invalid_enum_value:s=`Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;break;case c.invalid_arguments:s="Invalid function arguments";break;case c.invalid_return_type:s="Invalid function return type";break;case c.invalid_date:s="Invalid date";break;case c.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(s=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(s=`${s} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?s=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?s=`Invalid input: must end with "${t.validation.endsWith}"`:x.assertNever(t.validation):t.validation!=="regex"?s=`Invalid ${t.validation}`:s="Invalid";break;case c.too_small:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:s="Invalid input";break;case c.too_big:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?s=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:s="Invalid input";break;case c.custom:s="Invalid input";break;case c.invalid_intersection_types:s="Intersection results could not be merged";break;case c.not_multiple_of:s=`Number must be a multiple of ${t.multipleOf}`;break;case c.not_finite:s="Number must be finite";break;default:s=e.defaultError,x.assertNever(t)}return{message:s}};let De=H;function Mt(t){De=t}function ye(){return De}const ve=t=>{const{data:e,path:s,errorMaps:n,issueData:r}=t,a=[...s,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let o="";const d=n.filter(u=>!!u).slice().reverse();for(const u of d)o=u(i,{data:e,defaultError:o}).message;return{...r,path:a,message:o}},Zt=[];function l(t,e){const s=ye(),n=ve({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,s,s===H?void 0:H].filter(r=>!!r)});t.common.issues.push(n)}class w{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,s){const n=[];for(const r of s){if(r.status==="aborted")return m;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,s){const n=[];for(const r of s){const a=await r.key,i=await r.value;n.push({key:a,value:i})}return w.mergeObjectSync(e,n)}static mergeObjectSync(e,s){const n={};for(const r of s){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return m;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const m=Object.freeze({status:"aborted"}),G=t=>({status:"dirty",value:t}),T=t=>({status:"valid",value:t}),Me=t=>t.status==="aborted",Ze=t=>t.status==="dirty",ee=t=>t.status==="valid",te=t=>typeof Promise<"u"&&t instanceof Promise;function _e(t,e,s,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function Le(t,e,s,n,r){if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,s),s}var h;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));var X,K;class N{constructor(e,s,n,r){this._cachedPath=[],this.parent=e,this.data=s,this._path=n,this._key=r}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 $e=(t,e)=>{if(ee(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const s=new R(t.common.issues);return this._error=s,this._error}}};function y(t){if(!t)return{};const{errorMap:e,invalid_type_error:s,required_error:n,description:r}=t;if(e&&(s||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{var d,u;const{message:g}=t;return i.code==="invalid_enum_value"?{message:g??o.defaultError}:typeof o.data>"u"?{message:(d=g??n)!==null&&d!==void 0?d:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(u=g??s)!==null&&u!==void 0?u:o.defaultError}},description:r}}class _{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return q(e.data)}_getOrReturnCtx(e,s){return s||{common:e.parent.common,data:e.data,parsedType:q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new w,ctx:{common:e.parent.common,data:e.data,parsedType:q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const s=this._parse(e);if(te(s))throw new Error("Synchronous parse encountered promise.");return s}_parseAsync(e){const s=this._parse(e);return Promise.resolve(s)}parse(e,s){const n=this.safeParse(e,s);if(n.success)return n.data;throw n.error}safeParse(e,s){var n;const r={common:{issues:[],async:(n=s==null?void 0:s.async)!==null&&n!==void 0?n:!1,contextualErrorMap:s==null?void 0:s.errorMap},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)},a=this._parseSync({data:e,path:r.path,parent:r});return $e(r,a)}async parseAsync(e,s){const n=await this.safeParseAsync(e,s);if(n.success)return n.data;throw n.error}async safeParseAsync(e,s){const n={common:{issues:[],contextualErrorMap:s==null?void 0:s.errorMap,async:!0},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(te(r)?r:Promise.resolve(r));return $e(n,a)}refine(e,s){const n=r=>typeof s=="string"||typeof s>"u"?{message:s}:typeof s=="function"?s(r):s;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:c.custom,...n(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,s){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof s=="function"?s(n,r):s),!1))}_refinement(e){return new E({schema:this,typeName:p.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return O.create(this,this._def)}nullable(){return D.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Z.create(this,this._def)}promise(){return J.create(this,this._def)}or(e){return ae.create([this,e],this._def)}and(e){return ie.create(this,e,this._def)}transform(e){return new E({...y(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const s=typeof e=="function"?e:()=>e;return new le({...y(this._def),innerType:this,defaultValue:s,typeName:p.ZodDefault})}brand(){return new Oe({typeName:p.ZodBranded,type:this,...y(this._def)})}catch(e){const s=typeof e=="function"?e:()=>e;return new fe({...y(this._def),innerType:this,catchValue:s,typeName:p.ZodCatch})}describe(e){const s=this.constructor;return new s({...this._def,description:e})}pipe(e){return pe.create(this,e)}readonly(){return he.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Et=/^c[^\s-]{8,}$/i,Ot=/^[0-9a-z]+$/,Nt=/^[0-9A-HJKMNP-TV-Z]{26}$/,It=/^[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,At=/^[a-z0-9_-]{21}$/i,jt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,qt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Pt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Re;const $t=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Vt=/^(([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})))$/,Dt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ue="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Lt=new RegExp(`^${Ue}$`);function ze(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Ut(t){return new RegExp(`^${ze(t)}$`)}function Be(t){let e=`${Ue}T${ze(t)}`;const s=[];return s.push(t.local?"Z?":"Z"),t.offset&&s.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${s.join("|")})`,new RegExp(`^${e}$`)}function zt(t,e){return!!((e==="v4"||!e)&&$t.test(t)||(e==="v6"||!e)&&Vt.test(t))}class M extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.string,received:a.parsedType}),m}const n=new w;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(r=this._getOrReturnCtx(e,r),i?l(r,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(r,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")qt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"email",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Re||(Re=new RegExp(Pt,"u")),Re.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"emoji",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")It.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"uuid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")At.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"nanoid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")Et.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Ot.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid2",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")Nt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ulid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),l(r,{validation:"url",code:c.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"regex",code:c.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Be(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Lt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Ut(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?jt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"duration",code:c.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?zt(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ip",code:c.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Dt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64",code:c.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_regex(e,s,n){return this.refinement(r=>e.test(r),{validation:s,code:c.invalid_string,...h.errToObj(n)})}_addCheck(e){return new M({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}datetime(e){var s,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(s=e==null?void 0:e.offset)!==null&&s!==void 0?s:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...h.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...h.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,s){return this._addCheck({kind:"regex",regex:e,...h.errToObj(s)})}includes(e,s){return this._addCheck({kind:"includes",value:e,position:s==null?void 0:s.position,...h.errToObj(s==null?void 0:s.message)})}startsWith(e,s){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(s)})}endsWith(e,s){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(s)})}min(e,s){return this._addCheck({kind:"min",value:e,...h.errToObj(s)})}max(e,s){return this._addCheck({kind:"max",value:e,...h.errToObj(s)})}length(e,s){return this._addCheck({kind:"length",value:e,...h.errToObj(s)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new M({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new M({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new M({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}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 isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}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 isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxLength(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}M.create=t=>{var e;return new M({checks:[],typeName:p.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...y(t)})};function Bt(t,e){const s=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=s>n?s:n,a=parseInt(t.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}class P extends _{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)!==f.number){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.number,received:a.parsedType}),m}let n;const r=new w;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?Bt(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.not_finite,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,h.toString(s))}gt(e,s){return this.setLimit("min",e,!1,h.toString(s))}lte(e,s){return this.setLimit("max",e,!0,h.toString(s))}lt(e,s){return this.setLimit("max",e,!1,h.toString(s))}setLimit(e,s,n,r){return new P({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:h.toString(r)}]})}_addCheck(e){return new P({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(s)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,s=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(s===null||n.value>s)&&(s=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(s)&&Number.isFinite(e)}}P.create=t=>new P({checks:[],typeName:p.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...y(t)});class $ extends _{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)!==f.bigint){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.bigint,received:a.parsedType}),m}let n;const r=new w;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,h.toString(s))}gt(e,s){return this.setLimit("min",e,!1,h.toString(s))}lte(e,s){return this.setLimit("max",e,!0,h.toString(s))}lt(e,s){return this.setLimit("max",e,!1,h.toString(s))}setLimit(e,s,n,r){return new $({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:h.toString(r)}]})}_addCheck(e){return new $({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(s)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}$.create=t=>{var e;return new $({checks:[],typeName:p.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...y(t)})};class se extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.boolean,received:n.parsedType}),m}return T(e.data)}}se.create=t=>new se({typeName:p.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...y(t)});class z extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.date,received:a.parsedType}),m}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_date}),m}const n=new w;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new z({...this._def,checks:[...this._def.checks,e]})}min(e,s){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(s)})}max(e,s){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(s)})}get minDate(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e!=null?new Date(e):null}}z.create=t=>new z({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:p.ZodDate,...y(t)});class xe extends _{_parse(e){if(this._getType(e)!==f.symbol){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.symbol,received:n.parsedType}),m}return T(e.data)}}xe.create=t=>new xe({typeName:p.ZodSymbol,...y(t)});class ne extends _{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.undefined,received:n.parsedType}),m}return T(e.data)}}ne.create=t=>new ne({typeName:p.ZodUndefined,...y(t)});class re extends _{_parse(e){if(this._getType(e)!==f.null){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.null,received:n.parsedType}),m}return T(e.data)}}re.create=t=>new re({typeName:p.ZodNull,...y(t)});class Y extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return T(e.data)}}Y.create=t=>new Y({typeName:p.ZodAny,...y(t)});class U extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return T(e.data)}}U.create=t=>new U({typeName:p.ZodUnknown,...y(t)});class j extends _{_parse(e){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:f.never,received:s.parsedType}),m}}j.create=t=>new j({typeName:p.ZodNever,...y(t)});class be extends _{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.void,received:n.parsedType}),m}return T(e.data)}}be.create=t=>new be({typeName:p.ZodVoid,...y(t)});class Z extends _{_parse(e){const{ctx:s,status:n}=this._processInputParams(e),r=this._def;if(s.parsedType!==f.array)return l(s,{code:c.invalid_type,expected:f.array,received:s.parsedType}),m;if(r.exactLength!==null){const i=s.data.length>r.exactLength.value,o=s.data.length<r.exactLength.value;(i||o)&&(l(s,{code:i?c.too_big:c.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&s.data.length<r.minLength.value&&(l(s,{code:c.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&s.data.length>r.maxLength.value&&(l(s,{code:c.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),s.common.async)return Promise.all([...s.data].map((i,o)=>r.type._parseAsync(new N(s,i,s.path,o)))).then(i=>w.mergeArray(n,i));const a=[...s.data].map((i,o)=>r.type._parseSync(new N(s,i,s.path,o)));return w.mergeArray(n,a)}get element(){return this._def.type}min(e,s){return new Z({...this._def,minLength:{value:e,message:h.toString(s)}})}max(e,s){return new Z({...this._def,maxLength:{value:e,message:h.toString(s)}})}length(e,s){return new Z({...this._def,exactLength:{value:e,message:h.toString(s)}})}nonempty(e){return this.min(1,e)}}Z.create=(t,e)=>new Z({type:t,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...y(e)});function Q(t){if(t instanceof b){const e={};for(const s in t.shape){const n=t.shape[s];e[s]=O.create(Q(n))}return new b({...t._def,shape:()=>e})}else return t instanceof Z?new Z({...t._def,type:Q(t.element)}):t instanceof O?O.create(Q(t.unwrap())):t instanceof D?D.create(Q(t.unwrap())):t instanceof I?I.create(t.items.map(e=>Q(e))):t}class b extends _{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(),s=x.objectKeys(e);return this._cached={shape:e,keys:s}}_parse(e){if(this._getType(e)!==f.object){const u=this._getOrReturnCtx(e);return l(u,{code:c.invalid_type,expected:f.object,received:u.parsedType}),m}const{status:n,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof j&&this._def.unknownKeys==="strip"))for(const u in r.data)i.includes(u)||o.push(u);const d=[];for(const u of i){const g=a[u],C=r.data[u];d.push({key:{status:"valid",value:u},value:g._parse(new N(r,C,r.path,u)),alwaysSet:u in r.data})}if(this._def.catchall instanceof j){const u=this._def.unknownKeys;if(u==="passthrough")for(const g of o)d.push({key:{status:"valid",value:g},value:{status:"valid",value:r.data[g]}});else if(u==="strict")o.length>0&&(l(r,{code:c.unrecognized_keys,keys:o}),n.dirty());else if(u!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const u=this._def.catchall;for(const g of o){const C=r.data[g];d.push({key:{status:"valid",value:g},value:u._parse(new N(r,C,r.path,g)),alwaysSet:g in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const u=[];for(const g of d){const C=await g.key,qe=await g.value;u.push({key:C,value:qe,alwaysSet:g.alwaysSet})}return u}).then(u=>w.mergeObjectSync(n,u)):w.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new b({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(s,n)=>{var r,a,i,o;const d=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,s,n).message)!==null&&i!==void 0?i:n.defaultError;return s.code==="unrecognized_keys"?{message:(o=h.errToObj(e).message)!==null&&o!==void 0?o:d}:{message:d}}}:{}})}strip(){return new b({...this._def,unknownKeys:"strip"})}passthrough(){return new b({...this._def,unknownKeys:"passthrough"})}extend(e){return new b({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new b({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:p.ZodObject})}setKey(e,s){return this.augment({[e]:s})}catchall(e){return new b({...this._def,catchall:e})}pick(e){const s={};return x.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(s[n]=this.shape[n])}),new b({...this._def,shape:()=>s})}omit(e){const s={};return x.objectKeys(this.shape).forEach(n=>{e[n]||(s[n]=this.shape[n])}),new b({...this._def,shape:()=>s})}deepPartial(){return Q(this)}partial(e){const s={};return x.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?s[n]=r:s[n]=r.optional()}),new b({...this._def,shape:()=>s})}required(e){const s={};return x.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])s[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof O;)a=a._def.innerType;s[n]=a}}),new b({...this._def,shape:()=>s})}keyof(){return Qe(x.objectKeys(this.shape))}}b.create=(t,e)=>new b({shape:()=>t,unknownKeys:"strip",catchall:j.create(),typeName:p.ZodObject,...y(e)});b.strictCreate=(t,e)=>new b({shape:()=>t,unknownKeys:"strict",catchall:j.create(),typeName:p.ZodObject,...y(e)});b.lazycreate=(t,e)=>new b({shape:t,unknownKeys:"strip",catchall:j.create(),typeName:p.ZodObject,...y(e)});class ae extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n=this._def.options;function r(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 s.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new R(o.ctx.common.issues));return l(s,{code:c.invalid_union,unionErrors:i}),m}if(s.common.async)return Promise.all(n.map(async a=>{const i={...s,common:{...s.common,issues:[]},parent:null};return{result:await a._parseAsync({data:s.data,path:s.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const d of n){const u={...s,common:{...s.common,issues:[]},parent:null},g=d._parseSync({data:s.data,path:s.path,parent:u});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,ctx:u}),u.common.issues.length&&i.push(u.common.issues)}if(a)return s.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(d=>new R(d));return l(s,{code:c.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}ae.create=(t,e)=>new ae({options:t,typeName:p.ZodUnion,...y(e)});const A=t=>t instanceof ce?A(t.schema):t instanceof E?A(t.innerType()):t instanceof ue?[t.value]:t instanceof V?t.options:t instanceof de?x.objectValues(t.enum):t instanceof le?A(t._def.innerType):t instanceof ne?[void 0]:t instanceof re?[null]:t instanceof O?[void 0,...A(t.unwrap())]:t instanceof D?[null,...A(t.unwrap())]:t instanceof Oe||t instanceof he?A(t.unwrap()):t instanceof fe?A(t._def.innerType):[];class Se extends _{_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return l(s,{code:c.invalid_type,expected:f.object,received:s.parsedType}),m;const n=this.discriminator,r=s.data[n],a=this.optionsMap.get(r);return a?s.common.async?a._parseAsync({data:s.data,path:s.path,parent:s}):a._parseSync({data:s.data,path:s.path,parent:s}):(l(s,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,s,n){const r=new Map;for(const a of s){const i=A(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new Se({typeName:p.ZodDiscriminatedUnion,discriminator:e,options:s,optionsMap:r,...y(n)})}}function Ee(t,e){const s=q(t),n=q(e);if(t===e)return{valid:!0,data:t};if(s===f.object&&n===f.object){const r=x.objectKeys(e),a=x.objectKeys(t).filter(o=>r.indexOf(o)!==-1),i={...t,...e};for(const o of a){const d=Ee(t[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(s===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<t.length;a++){const i=t[a],o=e[a],d=Ee(i,o);if(!d.valid)return{valid:!1};r.push(d.data)}return{valid:!0,data:r}}else return s===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class ie extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(Me(a)||Me(i))return m;const o=Ee(a.value,i.value);return o.valid?((Ze(a)||Ze(i))&&s.dirty(),{status:s.value,value:o.data}):(l(n,{code:c.invalid_intersection_types}),m)};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])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}ie.create=(t,e,s)=>new ie({left:t,right:e,typeName:p.ZodIntersection,...y(s)});class I extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return l(n,{code:c.invalid_type,expected:f.array,received:n.parsedType}),m;if(n.data.length<this._def.items.length)return l(n,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),m;!this._def.rest&&n.data.length>this._def.items.length&&(l(n,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s.dirty());const a=[...n.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new N(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>w.mergeArray(s,i)):w.mergeArray(s,a)}get items(){return this._def.items}rest(e){return new I({...this._def,rest:e})}}I.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new I({items:t,typeName:p.ZodTuple,rest:null,...y(e)})};class oe extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return l(n,{code:c.invalid_type,expected:f.object,received:n.parsedType}),m;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)r.push({key:a._parse(new N(n,o,n.path,o)),value:i._parse(new N(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?w.mergeObjectAsync(s,r):w.mergeObjectSync(s,r)}get element(){return this._def.valueType}static create(e,s,n){return s instanceof _?new oe({keyType:e,valueType:s,typeName:p.ZodRecord,...y(n)}):new oe({keyType:M.create(),valueType:e,typeName:p.ZodRecord,...y(s)})}}class ke extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return l(n,{code:c.invalid_type,expected:f.map,received:n.parsedType}),m;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,d],u)=>({key:r._parse(new N(n,o,n.path,[u,"key"])),value:a._parse(new N(n,d,n.path,[u,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const u=await d.key,g=await d.value;if(u.status==="aborted"||g.status==="aborted")return m;(u.status==="dirty"||g.status==="dirty")&&s.dirty(),o.set(u.value,g.value)}return{status:s.value,value:o}})}else{const o=new Map;for(const d of i){const u=d.key,g=d.value;if(u.status==="aborted"||g.status==="aborted")return m;(u.status==="dirty"||g.status==="dirty")&&s.dirty(),o.set(u.value,g.value)}return{status:s.value,value:o}}}}ke.create=(t,e,s)=>new ke({valueType:e,keyType:t,typeName:p.ZodMap,...y(s)});class B extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return l(n,{code:c.invalid_type,expected:f.set,received:n.parsedType}),m;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(l(n,{code:c.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),s.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(l(n,{code:c.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),s.dirty());const a=this._def.valueType;function i(d){const u=new Set;for(const g of d){if(g.status==="aborted")return m;g.status==="dirty"&&s.dirty(),u.add(g.value)}return{status:s.value,value:u}}const o=[...n.data.values()].map((d,u)=>a._parse(new N(n,d,n.path,u)));return n.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,s){return new B({...this._def,minSize:{value:e,message:h.toString(s)}})}max(e,s){return new B({...this._def,maxSize:{value:e,message:h.toString(s)}})}size(e,s){return this.min(e,s).max(e,s)}nonempty(e){return this.min(1,e)}}B.create=(t,e)=>new B({valueType:t,minSize:null,maxSize:null,typeName:p.ZodSet,...y(e)});class W extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==f.function)return l(s,{code:c.invalid_type,expected:f.function,received:s.parsedType}),m;function n(o,d){return ve({data:o,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,ye(),H].filter(u=>!!u),issueData:{code:c.invalid_arguments,argumentsError:d}})}function r(o,d){return ve({data:o,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,ye(),H].filter(u=>!!u),issueData:{code:c.invalid_return_type,returnTypeError:d}})}const a={errorMap:s.common.contextualErrorMap},i=s.data;if(this._def.returns instanceof J){const o=this;return T(async function(...d){const u=new R([]),g=await o._def.args.parseAsync(d,a).catch(Te=>{throw u.addIssue(n(d,Te)),u}),C=await Reflect.apply(i,this,g);return await o._def.returns._def.type.parseAsync(C,a).catch(Te=>{throw u.addIssue(r(C,Te)),u})})}else{const o=this;return T(function(...d){const u=o._def.args.safeParse(d,a);if(!u.success)throw new R([n(d,u.error)]);const g=Reflect.apply(i,this,u.data),C=o._def.returns.safeParse(g,a);if(!C.success)throw new R([r(g,C.error)]);return C.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new W({...this._def,args:I.create(e).rest(U.create())})}returns(e){return new W({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,s,n){return new W({args:e||I.create([]).rest(U.create()),returns:s||U.create(),typeName:p.ZodFunction,...y(n)})}}class ce extends _{get schema(){return this._def.getter()}_parse(e){const{ctx:s}=this._processInputParams(e);return this._def.getter()._parse({data:s.data,path:s.path,parent:s})}}ce.create=(t,e)=>new ce({getter:t,typeName:p.ZodLazy,...y(e)});class ue extends _{_parse(e){if(e.data!==this._def.value){const s=this._getOrReturnCtx(e);return l(s,{received:s.data,code:c.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}ue.create=(t,e)=>new ue({value:t,typeName:p.ZodLiteral,...y(e)});function Qe(t,e){return new V({values:t,typeName:p.ZodEnum,...y(e)})}class V extends _{constructor(){super(...arguments),X.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const s=this._getOrReturnCtx(e),n=this._def.values;return l(s,{expected:x.joinValues(n),received:s.parsedType,code:c.invalid_type}),m}if(_e(this,X)||Le(this,X,new Set(this._def.values)),!_e(this,X).has(e.data)){const s=this._getOrReturnCtx(e),n=this._def.values;return l(s,{received:s.data,code:c.invalid_enum_value,options:n}),m}return T(e.data)}get options(){return this._def.values}get enum(){const e={};for(const s of this._def.values)e[s]=s;return e}get Values(){const e={};for(const s of this._def.values)e[s]=s;return e}get Enum(){const e={};for(const s of this._def.values)e[s]=s;return e}extract(e,s=this._def){return V.create(e,{...this._def,...s})}exclude(e,s=this._def){return V.create(this.options.filter(n=>!e.includes(n)),{...this._def,...s})}}X=new WeakMap;V.create=Qe;class de extends _{constructor(){super(...arguments),K.set(this,void 0)}_parse(e){const s=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){const r=x.objectValues(s);return l(n,{expected:x.joinValues(r),received:n.parsedType,code:c.invalid_type}),m}if(_e(this,K)||Le(this,K,new Set(x.getValidEnumValues(this._def.values))),!_e(this,K).has(e.data)){const r=x.objectValues(s);return l(n,{received:n.data,code:c.invalid_enum_value,options:r}),m}return T(e.data)}get enum(){return this._def.values}}K=new WeakMap;de.create=(t,e)=>new de({values:t,typeName:p.ZodNativeEnum,...y(e)});class J extends _{unwrap(){return this._def.type}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==f.promise&&s.common.async===!1)return l(s,{code:c.invalid_type,expected:f.promise,received:s.parsedType}),m;const n=s.parsedType===f.promise?s.data:Promise.resolve(s.data);return T(n.then(r=>this._def.type.parseAsync(r,{path:s.path,errorMap:s.common.contextualErrorMap})))}}J.create=(t,e)=>new J({type:t,typeName:p.ZodPromise,...y(e)});class E extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{l(n,i),i.fatal?s.abort():s.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(s.value==="aborted")return m;const d=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return d.status==="aborted"?m:d.status==="dirty"||s.value==="dirty"?G(d.value):d});{if(s.value==="aborted")return m;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?m:o.status==="dirty"||s.value==="dirty"?G(o.value):o}}if(r.type==="refinement"){const i=o=>{const d=r.refinement(o,a);if(n.common.async)return Promise.resolve(d);if(d 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"?m:(o.status==="dirty"&&s.dirty(),i(o.value),{status:s.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&s.dirty(),i(o.value).then(()=>({status:s.value,value:o.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!ee(i))return i;const o=r.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:s.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>ee(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:s.value,value:o})):i);x.assertNever(r)}}E.create=(t,e,s)=>new E({schema:t,typeName:p.ZodEffects,effect:e,...y(s)});E.createWithPreprocess=(t,e,s)=>new E({schema:e,effect:{type:"preprocess",transform:t},typeName:p.ZodEffects,...y(s)});class O extends _{_parse(e){return this._getType(e)===f.undefined?T(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}O.create=(t,e)=>new O({innerType:t,typeName:p.ZodOptional,...y(e)});class D extends _{_parse(e){return this._getType(e)===f.null?T(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}D.create=(t,e)=>new D({innerType:t,typeName:p.ZodNullable,...y(e)});class le extends _{_parse(e){const{ctx:s}=this._processInputParams(e);let n=s.data;return s.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:s.path,parent:s})}removeDefault(){return this._def.innerType}}le.create=(t,e)=>new le({innerType:t,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class fe extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n={...s,common:{...s.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return te(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new R(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new R(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}fe.create=(t,e)=>new fe({innerType:t,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class we extends _{_parse(e){if(this._getType(e)!==f.nan){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.nan,received:n.parsedType}),m}return{status:"valid",value:e.data}}}we.create=t=>new we({typeName:p.ZodNaN,...y(t)});const Qt=Symbol("zod_brand");class Oe extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n=s.data;return this._def.type._parse({data:n,path:s.path,parent:s})}unwrap(){return this._def.type}}class pe extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?m:a.status==="dirty"?(s.dirty(),G(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?m:r.status==="dirty"?(s.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,s){return new pe({in:e,out:s,typeName:p.ZodPipeline})}}class he extends _{_parse(e){const s=this._def.innerType._parse(e),n=r=>(ee(r)&&(r.value=Object.freeze(r.value)),r);return te(s)?s.then(r=>n(r)):n(s)}unwrap(){return this._def.innerType}}he.create=(t,e)=>new he({innerType:t,typeName:p.ZodReadonly,...y(e)});function Ge(t,e={},s){return t?Y.create().superRefine((n,r)=>{var a,i;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,d=(i=(a=o.fatal)!==null&&a!==void 0?a:s)!==null&&i!==void 0?i:!0,u=typeof o=="string"?{message:o}:o;r.addIssue({code:"custom",...u,fatal:d})}}):Y.create()}const Gt={object:b.lazycreate};var p;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(p||(p={}));const Wt=(t,e={message:`Input not instance of ${t.name}`})=>Ge(s=>s instanceof t,e),We=M.create,He=P.create,Ht=we.create,Yt=$.create,Ye=se.create,Jt=z.create,Xt=xe.create,Kt=ne.create,Ft=re.create,es=Y.create,ts=U.create,ss=j.create,ns=be.create,rs=Z.create,as=b.create,is=b.strictCreate,os=ae.create,cs=Se.create,us=ie.create,ds=I.create,ls=oe.create,fs=ke.create,hs=B.create,ps=W.create,ms=ce.create,gs=ue.create,ys=V.create,vs=de.create,_s=J.create,Ve=E.create,xs=O.create,bs=D.create,ks=E.createWithPreprocess,ws=pe.create,Ss=()=>We().optional(),Ts=()=>He().optional(),Rs=()=>Ye().optional(),Cs={string:t=>M.create({...t,coerce:!0}),number:t=>P.create({...t,coerce:!0}),boolean:t=>se.create({...t,coerce:!0}),bigint:t=>$.create({...t,coerce:!0}),date:t=>z.create({...t,coerce:!0})},Ms=m;var v=Object.freeze({__proto__:null,defaultErrorMap:H,setErrorMap:Mt,getErrorMap:ye,makeIssue:ve,EMPTY_PATH:Zt,addIssueToContext:l,ParseStatus:w,INVALID:m,DIRTY:G,OK:T,isAborted:Me,isDirty:Ze,isValid:ee,isAsync:te,get util(){return x},get objectUtil(){return Ce},ZodParsedType:f,getParsedType:q,ZodType:_,datetimeRegex:Be,ZodString:M,ZodNumber:P,ZodBigInt:$,ZodBoolean:se,ZodDate:z,ZodSymbol:xe,ZodUndefined:ne,ZodNull:re,ZodAny:Y,ZodUnknown:U,ZodNever:j,ZodVoid:be,ZodArray:Z,ZodObject:b,ZodUnion:ae,ZodDiscriminatedUnion:Se,ZodIntersection:ie,ZodTuple:I,ZodRecord:oe,ZodMap:ke,ZodSet:B,ZodFunction:W,ZodLazy:ce,ZodLiteral:ue,ZodEnum:V,ZodNativeEnum:de,ZodPromise:J,ZodEffects:E,ZodTransformer:E,ZodOptional:O,ZodNullable:D,ZodDefault:le,ZodCatch:fe,ZodNaN:we,BRAND:Qt,ZodBranded:Oe,ZodPipeline:pe,ZodReadonly:he,custom:Ge,Schema:_,ZodSchema:_,late:Gt,get ZodFirstPartyTypeKind(){return p},coerce:Cs,any:es,array:rs,bigint:Yt,boolean:Ye,date:Jt,discriminatedUnion:cs,effect:Ve,enum:ys,function:ps,instanceof:Wt,intersection:us,lazy:ms,literal:gs,map:fs,nan:Ht,nativeEnum:vs,never:ss,null:Ft,nullable:bs,number:He,object:as,oboolean:Rs,onumber:Ts,optional:xs,ostring:Ss,pipeline:ws,preprocess:ks,promise:_s,record:ls,set:hs,strictObject:is,string:We,symbol:Xt,transformer:Ve,tuple:ds,undefined:Kt,union:os,unknown:ts,void:ns,NEVER:Ms,ZodIssueCode:c,quotelessJson:Ct,ZodError:R});const S=v.object({type:v.literal("qp-bridge"),id:v.string().optional()}),Je=S.extend({status:v.literal("answerChanged"),question:v.string(),answer:v.unknown()}),me=S.extend({status:v.literal("success")}),Xe=S.extend({status:v.literal("error"),message:v.string()}),Ne=v.object({semanticColor:v.string().optional(),label:v.string(),description:v.string(),disabled:v.boolean(),required:v.boolean(),hidden:v.boolean(),errorMessage:v.string().optional()}),Ke=Ne.partial(),Ie=v.object({label:v.string(),hidden:v.boolean(),collapsed:v.boolean()}),Fe=Ie.partial(),et=S.extend({action:v.literal("getQuestion"),question:v.string()}),tt=me.extend({question:Ne}),st=S.extend({action:v.literal("setQuestion"),question:v.string(),questionData:Ke}),nt=S.extend({action:v.literal("getGroup"),group:v.string()}),rt=me.extend({group:Ie}),at=me.extend({canSave:v.boolean()}),it=S.extend({action:v.literal("canSave")}),ot=S.extend({action:v.literal("setGroup"),group:v.string(),groupData:Fe}),ct=S.extend({action:v.literal("setAnswer"),question:v.string(),answer:v.unknown()}),ut=S.extend({action:v.literal("busyIndicatorStart")}),dt=S.extend({action:v.literal("busyIndicatorEnd")}),lt=S.extend({action:v.literal("saveQuestionnaire")}),ft=S.extend({action:v.literal("completeAndCloseQuestionnaire")}),ht=S.extend({action:v.literal("executeCustomCommand"),commandName:v.string()});function pt(t){return Je.safeParse(t).success}function Ae(t){return S.safeParse(t).success}function mt(t){return me.safeParse(t).success}function gt(t){return Xe.safeParse(t).success}function Zs(t){return et.safeParse(t).success}function yt(t){return tt.safeParse(t).success}function Es(t){return ct.safeParse(t).success}function Os(t){return st.safeParse(t).success}function Ns(t){return ot.safeParse(t).success}function Is(t){return nt.safeParse(t).success}function vt(t){return rt.safeParse(t).success}function As(t){return at.safeParse(t).success}function _t(t){return it.safeParse(t).success}function xt(t){return ut.safeParse(t).success}function bt(t){return dt.safeParse(t).success}function js(t){return lt.safeParse(t).success}function qs(t){return ft.safeParse(t).success}function Ps(t){return ht.safeParse(t).success}function $s(t){return xt(t)||bt(t)}window.addEventListener("message",Js);async function Vs(t,e){await L({type:"qp-bridge",action:"setAnswer",question:t,answer:e})}async function Ds(t){return await Xs({type:"qp-bridge",action:"getQuestion",question:t})}async function Ls(t,e){await L({type:"qp-bridge",action:"setQuestion",question:t,questionData:e})}async function Us(t){return await Ks({type:"qp-bridge",action:"getGroup",group:t})}async function zs(t,e){await L({type:"qp-bridge",action:"setGroup",group:t,groupData:e})}function Bs(t){const e=s=>{pt(s.data)&&t(s.data.question,s.data.answer)};return window.addEventListener("message",e),{cancelSubscription:()=>{window.removeEventListener("message",e)}}}async function Qs(t){await L({type:"qp-bridge",action:"busyIndicatorStart"});try{return await t()}finally{await L({type:"qp-bridge",action:"busyIndicatorEnd"})}}async function Gs(){await L({type:"qp-bridge",action:"saveQuestionnaire"})}async function Ws(){await L({type:"qp-bridge",action:"completeAndCloseQuestionnaire"})}async function Hs(t){await L({type:"qp-bridge",action:"executeCustomCommand",commandName:t})}const F=[];function Ys(t){return F.includes(t)||F.push(t),{cancelSubscription:()=>{const e=F.indexOf(t);e!==-1&&F.splice(e,1)}}}async function Js(t){try{if(_t(t.data)){const e=await Promise.all(F.map(n=>n())),s={type:"qp-bridge",status:"success",id:t.data.id,canSave:e.every(n=>n)};window.parent.postMessage(s,"*")}}catch(e){const s={type:"qp-bridge",status:"error",id:Ae(t.data)?t.data.id:void 0,message:e instanceof Error?e.message:"Unknown error"};window.parent.postMessage(s,"*")}}async function je(t,e){return new Promise((s,n)=>{const r=Rt(),a=i=>{if(!Ae(i.data)||i.data.id!==r)return;const d=e(i.data);d.success?s(d.data):gt(i.data)?n(new Error(i.data.message)):n(new Error("Unknown message received")),window.removeEventListener("message",a)};window.addEventListener("message",a),window.parent.postMessage({...t,id:r},"*")})}async function Xs(t){return je(t,e=>yt(e)?{success:!0,data:e.question}:{success:!1})}async function Ks(t){return je(t,e=>vt(e)?{success:!0,data:e.group}:{success:!1})}function L(t){return je(t,e=>mt(e)?{success:!0,data:void 0}:{success:!1})}exports.busyIndicatorEndRequestMessageSchema=dt;exports.busyIndicatorStartRequestMessageSchema=ut;exports.canSaveRequestMessageSchema=it;exports.canSaveSuccessResponseMessageSchema=at;exports.completeAndCloseQuestionnaire=Ws;exports.completeAndCloseQuestionnaireRequestMessageSchema=ft;exports.executeCustomCommand=Hs;exports.executeCustomCommandRequestMessageSchema=ht;exports.getGroup=Us;exports.getGroupRequestMessageSchema=nt;exports.getGroupSuccessResponseMessageSchema=rt;exports.getQuestion=Ds;exports.getQuestionRequestMessageSchema=et;exports.getQuestionSuccessResponseMessageSchema=tt;exports.groupOptionalScheme=Fe;exports.groupSchema=Ie;exports.isBusyIndicatorEndRequestMessage=bt;exports.isBusyIndicatorStartRequestMessage=xt;exports.isCanSaveRequestMessage=_t;exports.isCanSaveSuccessResponseMessage=As;exports.isCompleteAndCloseQuestionnaireRequestMessage=qs;exports.isErrorMessage=gt;exports.isExecuteCustomCommandRequestMessage=Ps;exports.isGetGroupRequestMessage=Is;exports.isGetGroupSuccessResponseMessage=vt;exports.isGetQuestionRequestMessage=Zs;exports.isGetQuestionSuccessResponseMessage=yt;exports.isOnAnswerChangeMessage=pt;exports.isQpBridgeMessage=Ae;exports.isSaveQuestionnaireRequestMessage=js;exports.isSetAnswerRequestMessage=Es;exports.isSetGroupRequestMessage=Ns;exports.isSetQuestionRequestMessage=Os;exports.isSuccessMessage=mt;exports.isWithBusyIndicatorRequestMessage=$s;exports.onAnswerChange=Bs;exports.onAnswerChangeMessageSchema=Je;exports.onSave=Ys;exports.qpBridgeMessageSchema=S;exports.questionOptionalScheme=Ke;exports.questionSchema=Ne;exports.responseErrorMessageSchema=Xe;exports.responseSuccessMessageSchema=me;exports.saveQuestionnaire=Gs;exports.saveQuestionnaireRequestMessageSchema=lt;exports.setAnswer=Vs;exports.setAnswerRequestMessageSchema=ct;exports.setGroup=zs;exports.setGroupRequestMessageSchema=ot;exports.setQuestion=Ls;exports.setQuestionRequestMessageSchema=st;exports.withBusyIndicator=Qs;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let ye;const Tt=new Uint8Array(16);function Rt(){if(!ye&&(ye=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ye))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ye(Tt)}const w=[];for(let t=0;t<256;++t)w.push((t+256).toString(16).slice(1));function Ct(t,e=0){return w[t[e+0]]+w[t[e+1]]+w[t[e+2]]+w[t[e+3]]+"-"+w[t[e+4]]+w[t[e+5]]+"-"+w[t[e+6]]+w[t[e+7]]+"-"+w[t[e+8]]+w[t[e+9]]+"-"+w[t[e+10]]+w[t[e+11]]+w[t[e+12]]+w[t[e+13]]+w[t[e+14]]+w[t[e+15]]}const Mt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Pe={randomUUID:Mt};function Le(t,e,s){if(Pe.randomUUID&&!e&&!t)return Pe.randomUUID();t=t||{};const n=t.random||(t.rng||Rt)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Ct(n)}var x;(function(t){t.assertEqual=r=>r;function e(r){}t.assertIs=e;function s(r){throw new Error}t.assertNever=s,t.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},t.getValidEnumValues=r=>{const a=t.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return t.objectValues(i)},t.objectValues=r=>t.objectKeys(r).map(function(a){return r[a]}),t.objectKeys=typeof Object.keys=="function"?r=>Object.keys(r):r=>{const a=[];for(const i in r)Object.prototype.hasOwnProperty.call(r,i)&&a.push(i);return a},t.find=(r,a)=>{for(const i of r)if(a(i))return i},t.isInteger=typeof Number.isInteger=="function"?r=>Number.isInteger(r):r=>typeof r=="number"&&isFinite(r)&&Math.floor(r)===r;function n(r,a=" | "){return r.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}t.joinValues=n,t.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Me;(function(t){t.mergeShapes=(e,s)=>({...e,...s})})(Me||(Me={}));const f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),q=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(t)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}},c=x.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"]),Zt=t=>JSON.stringify(t,null,2).replace(/"([^"]+)":/g,"$1:");class C extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const s=e||function(a){return a.message},n={_errors:[]},r=a=>{for(const i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(r);else if(i.code==="invalid_return_type")r(i.returnTypeError);else if(i.code==="invalid_arguments")r(i.argumentsError);else if(i.path.length===0)n._errors.push(s(i));else{let o=n,u=0;for(;u<i.path.length;){const d=i.path[u];u===i.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(s(i))):o[d]=o[d]||{_errors:[]},o=o[d],u++}}};return r(this),n}static assert(e){if(!(e instanceof C))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=s=>s.message){const s={},n=[];for(const r of this.issues)r.path.length>0?(s[r.path[0]]=s[r.path[0]]||[],s[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:s}}get formErrors(){return this.flatten()}}C.create=t=>new C(t);const Y=(t,e)=>{let s;switch(t.code){case c.invalid_type:t.received===f.undefined?s="Required":s=`Expected ${t.expected}, received ${t.received}`;break;case c.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(t.expected,x.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:s=`Unrecognized key(s) in object: ${x.joinValues(t.keys,", ")}`;break;case c.invalid_union:s="Invalid input";break;case c.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${x.joinValues(t.options)}`;break;case c.invalid_enum_value:s=`Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;break;case c.invalid_arguments:s="Invalid function arguments";break;case c.invalid_return_type:s="Invalid function return type";break;case c.invalid_date:s="Invalid date";break;case c.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(s=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(s=`${s} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?s=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?s=`Invalid input: must end with "${t.validation.endsWith}"`:x.assertNever(t.validation):t.validation!=="regex"?s=`Invalid ${t.validation}`:s="Invalid";break;case c.too_small:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:s="Invalid input";break;case c.too_big:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?s=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:s="Invalid input";break;case c.custom:s="Invalid input";break;case c.invalid_intersection_types:s="Intersection results could not be merged";break;case c.not_multiple_of:s=`Number must be a multiple of ${t.multipleOf}`;break;case c.not_finite:s="Number must be finite";break;default:s=e.defaultError,x.assertNever(t)}return{message:s}};let Ve=Y;function Et(t){Ve=t}function ve(){return Ve}const _e=t=>{const{data:e,path:s,errorMaps:n,issueData:r}=t,a=[...s,...r.path||[]],i={...r,path:a};if(r.message!==void 0)return{...r,path:a,message:r.message};let o="";const u=n.filter(d=>!!d).slice().reverse();for(const d of u)o=d(i,{data:e,defaultError:o}).message;return{...r,path:a,message:o}},Ot=[];function l(t,e){const s=ve(),n=_e({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,s,s===Y?void 0:Y].filter(r=>!!r)});t.common.issues.push(n)}class k{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,s){const n=[];for(const r of s){if(r.status==="aborted")return g;r.status==="dirty"&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,s){const n=[];for(const r of s){const a=await r.key,i=await r.value;n.push({key:a,value:i})}return k.mergeObjectSync(e,n)}static mergeObjectSync(e,s){const n={};for(const r of s){const{key:a,value:i}=r;if(a.status==="aborted"||i.status==="aborted")return g;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||r.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}}const g=Object.freeze({status:"aborted"}),W=t=>({status:"dirty",value:t}),T=t=>({status:"valid",value:t}),Ze=t=>t.status==="aborted",Ee=t=>t.status==="dirty",te=t=>t.status==="valid",se=t=>typeof Promise<"u"&&t instanceof Promise;function xe(t,e,s,n){if(typeof e=="function"?t!==e||!n:!e.has(t))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(t)}function De(t,e,s,n,r){if(typeof e=="function"?t!==e||!r:!e.has(t))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(t,s),s}var h;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));var K,F;class I{constructor(e,s,n,r){this._cachedPath=[],this.parent=e,this.data=s,this._path=n,this._key=r}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 $e=(t,e)=>{if(te(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const s=new C(t.common.issues);return this._error=s,this._error}}};function v(t){if(!t)return{};const{errorMap:e,invalid_type_error:s,required_error:n,description:r}=t;if(e&&(s||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{var u,d;const{message:m}=t;return i.code==="invalid_enum_value"?{message:m??o.defaultError}:typeof o.data>"u"?{message:(u=m??n)!==null&&u!==void 0?u:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(d=m??s)!==null&&d!==void 0?d:o.defaultError}},description:r}}class _{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return q(e.data)}_getOrReturnCtx(e,s){return s||{common:e.parent.common,data:e.data,parsedType:q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new k,ctx:{common:e.parent.common,data:e.data,parsedType:q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const s=this._parse(e);if(se(s))throw new Error("Synchronous parse encountered promise.");return s}_parseAsync(e){const s=this._parse(e);return Promise.resolve(s)}parse(e,s){const n=this.safeParse(e,s);if(n.success)return n.data;throw n.error}safeParse(e,s){var n;const r={common:{issues:[],async:(n=s==null?void 0:s.async)!==null&&n!==void 0?n:!1,contextualErrorMap:s==null?void 0:s.errorMap},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)},a=this._parseSync({data:e,path:r.path,parent:r});return $e(r,a)}async parseAsync(e,s){const n=await this.safeParseAsync(e,s);if(n.success)return n.data;throw n.error}async safeParseAsync(e,s){const n={common:{issues:[],contextualErrorMap:s==null?void 0:s.errorMap,async:!0},path:(s==null?void 0:s.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(se(r)?r:Promise.resolve(r));return $e(n,a)}refine(e,s){const n=r=>typeof s=="string"||typeof s>"u"?{message:s}:typeof s=="function"?s(r):s;return this._refinement((r,a)=>{const i=e(r),o=()=>a.addIssue({code:c.custom,...n(r)});return typeof Promise<"u"&&i instanceof Promise?i.then(u=>u?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,s){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof s=="function"?s(n,r):s),!1))}_refinement(e){return new E({schema:this,typeName:p.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return O.create(this,this._def)}nullable(){return L.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Z.create(this,this._def)}promise(){return X.create(this,this._def)}or(e){return ie.create([this,e],this._def)}and(e){return oe.create(this,e,this._def)}transform(e){return new E({...v(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const s=typeof e=="function"?e:()=>e;return new fe({...v(this._def),innerType:this,defaultValue:s,typeName:p.ZodDefault})}brand(){return new Ie({typeName:p.ZodBranded,type:this,...v(this._def)})}catch(e){const s=typeof e=="function"?e:()=>e;return new he({...v(this._def),innerType:this,catchValue:s,typeName:p.ZodCatch})}describe(e){const s=this.constructor;return new s({...this._def,description:e})}pipe(e){return me.create(this,e)}readonly(){return pe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const It=/^c[^\s-]{8,}$/i,Nt=/^[0-9a-z]+$/,At=/^[0-9A-HJKMNP-TV-Z]{26}$/,jt=/^[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,qt=/^[a-z0-9_-]{21}$/i,Pt=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,$t=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ut="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Ce;const Lt=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,Vt=/^(([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})))$/,Dt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Be="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Bt=new RegExp(`^${Be}$`);function ze(t){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`),e}function zt(t){return new RegExp(`^${ze(t)}$`)}function Qe(t){let e=`${Be}T${ze(t)}`;const s=[];return s.push(t.local?"Z?":"Z"),t.offset&&s.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${s.join("|")})`,new RegExp(`^${e}$`)}function Qt(t,e){return!!((e==="v4"||!e)&&Lt.test(t)||(e==="v6"||!e)&&Vt.test(t))}class M extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.string,received:a.parsedType}),g}const n=new k;let r;for(const a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){const i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(r=this._getOrReturnCtx(e,r),i?l(r,{code:c.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&l(r,{code:c.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")$t.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"email",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ce||(Ce=new RegExp(Ut,"u")),Ce.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"emoji",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")jt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"uuid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")qt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"nanoid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")It.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")Nt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"cuid2",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")At.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ulid",code:c.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{r=this._getOrReturnCtx(e,r),l(r,{validation:"url",code:c.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"regex",code:c.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Qe(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Bt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?zt(a).test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?Pt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"duration",code:c.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Qt(e.data,a.version)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"ip",code:c.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Dt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"base64",code:c.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_regex(e,s,n){return this.refinement(r=>e.test(r),{validation:s,code:c.invalid_string,...h.errToObj(n)})}_addCheck(e){return new M({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}datetime(e){var s,n;return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(s=e==null?void 0:e.offset)!==null&&s!==void 0?s:!1,local:(n=e==null?void 0:e.local)!==null&&n!==void 0?n:!1,...h.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...h.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,s){return this._addCheck({kind:"regex",regex:e,...h.errToObj(s)})}includes(e,s){return this._addCheck({kind:"includes",value:e,position:s==null?void 0:s.position,...h.errToObj(s==null?void 0:s.message)})}startsWith(e,s){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(s)})}endsWith(e,s){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(s)})}min(e,s){return this._addCheck({kind:"min",value:e,...h.errToObj(s)})}max(e,s){return this._addCheck({kind:"max",value:e,...h.errToObj(s)})}length(e,s){return this._addCheck({kind:"length",value:e,...h.errToObj(s)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new M({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new M({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new M({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}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 isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}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 isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get minLength(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxLength(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}M.create=t=>{var e;return new M({checks:[],typeName:p.ZodString,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...v(t)})};function Gt(t,e){const s=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=s>n?s:n,a=parseInt(t.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}class P extends _{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)!==f.number){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.number,received:a.parsedType}),g}let n;const r=new k;for(const a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.invalid_type,expected:"integer",received:"float",message:a.message}),r.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),r.dirty()):a.kind==="multipleOf"?Gt(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),l(n,{code:c.not_finite,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,h.toString(s))}gt(e,s){return this.setLimit("min",e,!1,h.toString(s))}lte(e,s){return this.setLimit("max",e,!0,h.toString(s))}lt(e,s){return this.setLimit("max",e,!1,h.toString(s))}setLimit(e,s,n,r){return new P({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:h.toString(r)}]})}_addCheck(e){return new P({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(s)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,s=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(s===null||n.value>s)&&(s=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(s)&&Number.isFinite(e)}}P.create=t=>new P({checks:[],typeName:p.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...v(t)});class $ extends _{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)!==f.bigint){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.bigint,received:a.parsedType}),g}let n;const r=new k;for(const a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),r.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),l(n,{code:c.not_multiple_of,multipleOf:a.value,message:a.message}),r.dirty()):x.assertNever(a);return{status:r.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,h.toString(s))}gt(e,s){return this.setLimit("min",e,!1,h.toString(s))}lte(e,s){return this.setLimit("max",e,!0,h.toString(s))}lt(e,s){return this.setLimit("max",e,!1,h.toString(s))}setLimit(e,s,n,r){return new $({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:h.toString(r)}]})}_addCheck(e){return new $({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(s)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}$.create=t=>{var e;return new $({checks:[],typeName:p.ZodBigInt,coerce:(e=t==null?void 0:t.coerce)!==null&&e!==void 0?e:!1,...v(t)})};class ne extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.boolean,received:n.parsedType}),g}return T(e.data)}}ne.create=t=>new ne({typeName:p.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...v(t)});class z extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_type,expected:f.date,received:a.parsedType}),g}if(isNaN(e.data.getTime())){const a=this._getOrReturnCtx(e);return l(a,{code:c.invalid_date}),g}const n=new k;let r;for(const a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(r=this._getOrReturnCtx(e,r),l(r,{code:c.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new z({...this._def,checks:[...this._def.checks,e]})}min(e,s){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(s)})}max(e,s){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(s)})}get minDate(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e!=null?new Date(e):null}}z.create=t=>new z({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:p.ZodDate,...v(t)});class be extends _{_parse(e){if(this._getType(e)!==f.symbol){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.symbol,received:n.parsedType}),g}return T(e.data)}}be.create=t=>new be({typeName:p.ZodSymbol,...v(t)});class re extends _{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.undefined,received:n.parsedType}),g}return T(e.data)}}re.create=t=>new re({typeName:p.ZodUndefined,...v(t)});class ae extends _{_parse(e){if(this._getType(e)!==f.null){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.null,received:n.parsedType}),g}return T(e.data)}}ae.create=t=>new ae({typeName:p.ZodNull,...v(t)});class J extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return T(e.data)}}J.create=t=>new J({typeName:p.ZodAny,...v(t)});class B extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return T(e.data)}}B.create=t=>new B({typeName:p.ZodUnknown,...v(t)});class j extends _{_parse(e){const s=this._getOrReturnCtx(e);return l(s,{code:c.invalid_type,expected:f.never,received:s.parsedType}),g}}j.create=t=>new j({typeName:p.ZodNever,...v(t)});class we extends _{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.void,received:n.parsedType}),g}return T(e.data)}}we.create=t=>new we({typeName:p.ZodVoid,...v(t)});class Z extends _{_parse(e){const{ctx:s,status:n}=this._processInputParams(e),r=this._def;if(s.parsedType!==f.array)return l(s,{code:c.invalid_type,expected:f.array,received:s.parsedType}),g;if(r.exactLength!==null){const i=s.data.length>r.exactLength.value,o=s.data.length<r.exactLength.value;(i||o)&&(l(s,{code:i?c.too_big:c.too_small,minimum:o?r.exactLength.value:void 0,maximum:i?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(r.minLength!==null&&s.data.length<r.minLength.value&&(l(s,{code:c.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&s.data.length>r.maxLength.value&&(l(s,{code:c.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),s.common.async)return Promise.all([...s.data].map((i,o)=>r.type._parseAsync(new I(s,i,s.path,o)))).then(i=>k.mergeArray(n,i));const a=[...s.data].map((i,o)=>r.type._parseSync(new I(s,i,s.path,o)));return k.mergeArray(n,a)}get element(){return this._def.type}min(e,s){return new Z({...this._def,minLength:{value:e,message:h.toString(s)}})}max(e,s){return new Z({...this._def,maxLength:{value:e,message:h.toString(s)}})}length(e,s){return new Z({...this._def,exactLength:{value:e,message:h.toString(s)}})}nonempty(e){return this.min(1,e)}}Z.create=(t,e)=>new Z({type:t,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...v(e)});function G(t){if(t instanceof b){const e={};for(const s in t.shape){const n=t.shape[s];e[s]=O.create(G(n))}return new b({...t._def,shape:()=>e})}else return t instanceof Z?new Z({...t._def,type:G(t.element)}):t instanceof O?O.create(G(t.unwrap())):t instanceof L?L.create(G(t.unwrap())):t instanceof N?N.create(t.items.map(e=>G(e))):t}class b extends _{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(),s=x.objectKeys(e);return this._cached={shape:e,keys:s}}_parse(e){if(this._getType(e)!==f.object){const d=this._getOrReturnCtx(e);return l(d,{code:c.invalid_type,expected:f.object,received:d.parsedType}),g}const{status:n,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof j&&this._def.unknownKeys==="strip"))for(const d in r.data)i.includes(d)||o.push(d);const u=[];for(const d of i){const m=a[d],R=r.data[d];u.push({key:{status:"valid",value:d},value:m._parse(new I(r,R,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof j){const d=this._def.unknownKeys;if(d==="passthrough")for(const m of o)u.push({key:{status:"valid",value:m},value:{status:"valid",value:r.data[m]}});else if(d==="strict")o.length>0&&(l(r,{code:c.unrecognized_keys,keys:o}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const m of o){const R=r.data[m];u.push({key:{status:"valid",value:m},value:d._parse(new I(r,R,r.path,m)),alwaysSet:m in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const m of u){const R=await m.key,D=await m.value;d.push({key:R,value:D,alwaysSet:m.alwaysSet})}return d}).then(d=>k.mergeObjectSync(n,d)):k.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new b({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(s,n)=>{var r,a,i,o;const u=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,s,n).message)!==null&&i!==void 0?i:n.defaultError;return s.code==="unrecognized_keys"?{message:(o=h.errToObj(e).message)!==null&&o!==void 0?o:u}:{message:u}}}:{}})}strip(){return new b({...this._def,unknownKeys:"strip"})}passthrough(){return new b({...this._def,unknownKeys:"passthrough"})}extend(e){return new b({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new b({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:p.ZodObject})}setKey(e,s){return this.augment({[e]:s})}catchall(e){return new b({...this._def,catchall:e})}pick(e){const s={};return x.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(s[n]=this.shape[n])}),new b({...this._def,shape:()=>s})}omit(e){const s={};return x.objectKeys(this.shape).forEach(n=>{e[n]||(s[n]=this.shape[n])}),new b({...this._def,shape:()=>s})}deepPartial(){return G(this)}partial(e){const s={};return x.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?s[n]=r:s[n]=r.optional()}),new b({...this._def,shape:()=>s})}required(e){const s={};return x.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])s[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof O;)a=a._def.innerType;s[n]=a}}),new b({...this._def,shape:()=>s})}keyof(){return Ge(x.objectKeys(this.shape))}}b.create=(t,e)=>new b({shape:()=>t,unknownKeys:"strip",catchall:j.create(),typeName:p.ZodObject,...v(e)});b.strictCreate=(t,e)=>new b({shape:()=>t,unknownKeys:"strict",catchall:j.create(),typeName:p.ZodObject,...v(e)});b.lazycreate=(t,e)=>new b({shape:t,unknownKeys:"strip",catchall:j.create(),typeName:p.ZodObject,...v(e)});class ie extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n=this._def.options;function r(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 s.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new C(o.ctx.common.issues));return l(s,{code:c.invalid_union,unionErrors:i}),g}if(s.common.async)return Promise.all(n.map(async a=>{const i={...s,common:{...s.common,issues:[]},parent:null};return{result:await a._parseAsync({data:s.data,path:s.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const u of n){const d={...s,common:{...s.common,issues:[]},parent:null},m=u._parseSync({data:s.data,path:s.path,parent:d});if(m.status==="valid")return m;m.status==="dirty"&&!a&&(a={result:m,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return s.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new C(u));return l(s,{code:c.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}}ie.create=(t,e)=>new ie({options:t,typeName:p.ZodUnion,...v(e)});const A=t=>t instanceof ue?A(t.schema):t instanceof E?A(t.innerType()):t instanceof de?[t.value]:t instanceof U?t.options:t instanceof le?x.objectValues(t.enum):t instanceof fe?A(t._def.innerType):t instanceof re?[void 0]:t instanceof ae?[null]:t instanceof O?[void 0,...A(t.unwrap())]:t instanceof L?[null,...A(t.unwrap())]:t instanceof Ie||t instanceof pe?A(t.unwrap()):t instanceof he?A(t._def.innerType):[];class Te extends _{_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return l(s,{code:c.invalid_type,expected:f.object,received:s.parsedType}),g;const n=this.discriminator,r=s.data[n],a=this.optionsMap.get(r);return a?s.common.async?a._parseAsync({data:s.data,path:s.path,parent:s}):a._parseSync({data:s.data,path:s.path,parent:s}):(l(s,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,s,n){const r=new Map;for(const a of s){const i=A(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of i){if(r.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);r.set(o,a)}}return new Te({typeName:p.ZodDiscriminatedUnion,discriminator:e,options:s,optionsMap:r,...v(n)})}}function Oe(t,e){const s=q(t),n=q(e);if(t===e)return{valid:!0,data:t};if(s===f.object&&n===f.object){const r=x.objectKeys(e),a=x.objectKeys(t).filter(o=>r.indexOf(o)!==-1),i={...t,...e};for(const o of a){const u=Oe(t[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(s===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<t.length;a++){const i=t[a],o=e[a],u=Oe(i,o);if(!u.valid)return{valid:!1};r.push(u.data)}return{valid:!0,data:r}}else return s===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class oe extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(Ze(a)||Ze(i))return g;const o=Oe(a.value,i.value);return o.valid?((Ee(a)||Ee(i))&&s.dirty(),{status:s.value,value:o.data}):(l(n,{code:c.invalid_intersection_types}),g)};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])=>r(a,i)):r(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}oe.create=(t,e,s)=>new oe({left:t,right:e,typeName:p.ZodIntersection,...v(s)});class N extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return l(n,{code:c.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return l(n,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(l(n,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s.dirty());const a=[...n.data].map((i,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new I(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>k.mergeArray(s,i)):k.mergeArray(s,a)}get items(){return this._def.items}rest(e){return new N({...this._def,rest:e})}}N.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new N({items:t,typeName:p.ZodTuple,rest:null,...v(e)})};class ce extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return l(n,{code:c.invalid_type,expected:f.object,received:n.parsedType}),g;const r=[],a=this._def.keyType,i=this._def.valueType;for(const o in n.data)r.push({key:a._parse(new I(n,o,n.path,o)),value:i._parse(new I(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?k.mergeObjectAsync(s,r):k.mergeObjectSync(s,r)}get element(){return this._def.valueType}static create(e,s,n){return s instanceof _?new ce({keyType:e,valueType:s,typeName:p.ZodRecord,...v(n)}):new ce({keyType:M.create(),valueType:e,typeName:p.ZodRecord,...v(s)})}}class ke extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return l(n,{code:c.invalid_type,expected:f.map,received:n.parsedType}),g;const r=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,u],d)=>({key:r._parse(new I(n,o,n.path,[d,"key"])),value:a._parse(new I(n,u,n.path,[d,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const u of i){const d=await u.key,m=await u.value;if(d.status==="aborted"||m.status==="aborted")return g;(d.status==="dirty"||m.status==="dirty")&&s.dirty(),o.set(d.value,m.value)}return{status:s.value,value:o}})}else{const o=new Map;for(const u of i){const d=u.key,m=u.value;if(d.status==="aborted"||m.status==="aborted")return g;(d.status==="dirty"||m.status==="dirty")&&s.dirty(),o.set(d.value,m.value)}return{status:s.value,value:o}}}}ke.create=(t,e,s)=>new ke({valueType:e,keyType:t,typeName:p.ZodMap,...v(s)});class Q extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return l(n,{code:c.invalid_type,expected:f.set,received:n.parsedType}),g;const r=this._def;r.minSize!==null&&n.data.size<r.minSize.value&&(l(n,{code:c.too_small,minimum:r.minSize.value,type:"set",inclusive:!0,exact:!1,message:r.minSize.message}),s.dirty()),r.maxSize!==null&&n.data.size>r.maxSize.value&&(l(n,{code:c.too_big,maximum:r.maxSize.value,type:"set",inclusive:!0,exact:!1,message:r.maxSize.message}),s.dirty());const a=this._def.valueType;function i(u){const d=new Set;for(const m of u){if(m.status==="aborted")return g;m.status==="dirty"&&s.dirty(),d.add(m.value)}return{status:s.value,value:d}}const o=[...n.data.values()].map((u,d)=>a._parse(new I(n,u,n.path,d)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,s){return new Q({...this._def,minSize:{value:e,message:h.toString(s)}})}max(e,s){return new Q({...this._def,maxSize:{value:e,message:h.toString(s)}})}size(e,s){return this.min(e,s).max(e,s)}nonempty(e){return this.min(1,e)}}Q.create=(t,e)=>new Q({valueType:t,minSize:null,maxSize:null,typeName:p.ZodSet,...v(e)});class H extends _{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==f.function)return l(s,{code:c.invalid_type,expected:f.function,received:s.parsedType}),g;function n(o,u){return _e({data:o,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,ve(),Y].filter(d=>!!d),issueData:{code:c.invalid_arguments,argumentsError:u}})}function r(o,u){return _e({data:o,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,ve(),Y].filter(d=>!!d),issueData:{code:c.invalid_return_type,returnTypeError:u}})}const a={errorMap:s.common.contextualErrorMap},i=s.data;if(this._def.returns instanceof X){const o=this;return T(async function(...u){const d=new C([]),m=await o._def.args.parseAsync(u,a).catch(Re=>{throw d.addIssue(n(u,Re)),d}),R=await Reflect.apply(i,this,m);return await o._def.returns._def.type.parseAsync(R,a).catch(Re=>{throw d.addIssue(r(R,Re)),d})})}else{const o=this;return T(function(...u){const d=o._def.args.safeParse(u,a);if(!d.success)throw new C([n(u,d.error)]);const m=Reflect.apply(i,this,d.data),R=o._def.returns.safeParse(m,a);if(!R.success)throw new C([r(m,R.error)]);return R.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new H({...this._def,args:N.create(e).rest(B.create())})}returns(e){return new H({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,s,n){return new H({args:e||N.create([]).rest(B.create()),returns:s||B.create(),typeName:p.ZodFunction,...v(n)})}}class ue extends _{get schema(){return this._def.getter()}_parse(e){const{ctx:s}=this._processInputParams(e);return this._def.getter()._parse({data:s.data,path:s.path,parent:s})}}ue.create=(t,e)=>new ue({getter:t,typeName:p.ZodLazy,...v(e)});class de extends _{_parse(e){if(e.data!==this._def.value){const s=this._getOrReturnCtx(e);return l(s,{received:s.data,code:c.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}}de.create=(t,e)=>new de({value:t,typeName:p.ZodLiteral,...v(e)});function Ge(t,e){return new U({values:t,typeName:p.ZodEnum,...v(e)})}class U extends _{constructor(){super(...arguments),K.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const s=this._getOrReturnCtx(e),n=this._def.values;return l(s,{expected:x.joinValues(n),received:s.parsedType,code:c.invalid_type}),g}if(xe(this,K)||De(this,K,new Set(this._def.values)),!xe(this,K).has(e.data)){const s=this._getOrReturnCtx(e),n=this._def.values;return l(s,{received:s.data,code:c.invalid_enum_value,options:n}),g}return T(e.data)}get options(){return this._def.values}get enum(){const e={};for(const s of this._def.values)e[s]=s;return e}get Values(){const e={};for(const s of this._def.values)e[s]=s;return e}get Enum(){const e={};for(const s of this._def.values)e[s]=s;return e}extract(e,s=this._def){return U.create(e,{...this._def,...s})}exclude(e,s=this._def){return U.create(this.options.filter(n=>!e.includes(n)),{...this._def,...s})}}K=new WeakMap;U.create=Ge;class le extends _{constructor(){super(...arguments),F.set(this,void 0)}_parse(e){const s=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){const r=x.objectValues(s);return l(n,{expected:x.joinValues(r),received:n.parsedType,code:c.invalid_type}),g}if(xe(this,F)||De(this,F,new Set(x.getValidEnumValues(this._def.values))),!xe(this,F).has(e.data)){const r=x.objectValues(s);return l(n,{received:n.data,code:c.invalid_enum_value,options:r}),g}return T(e.data)}get enum(){return this._def.values}}F=new WeakMap;le.create=(t,e)=>new le({values:t,typeName:p.ZodNativeEnum,...v(e)});class X extends _{unwrap(){return this._def.type}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==f.promise&&s.common.async===!1)return l(s,{code:c.invalid_type,expected:f.promise,received:s.parsedType}),g;const n=s.parsedType===f.promise?s.data:Promise.resolve(s.data);return T(n.then(r=>this._def.type.parseAsync(r,{path:s.path,errorMap:s.common.contextualErrorMap})))}}X.create=(t,e)=>new X({type:t,typeName:p.ZodPromise,...v(e)});class E extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:s,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{l(n,i),i.fatal?s.abort():s.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),r.type==="preprocess"){const i=r.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(s.value==="aborted")return g;const u=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return u.status==="aborted"?g:u.status==="dirty"||s.value==="dirty"?W(u.value):u});{if(s.value==="aborted")return g;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"||s.value==="dirty"?W(o.value):o}}if(r.type==="refinement"){const i=o=>{const u=r.refinement(o,a);if(n.common.async)return Promise.resolve(u);if(u 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"?g:(o.status==="dirty"&&s.dirty(),i(o.value),{status:s.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&s.dirty(),i(o.value).then(()=>({status:s.value,value:o.value}))))}if(r.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!te(i))return i;const o=r.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:s.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>te(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:s.value,value:o})):i);x.assertNever(r)}}E.create=(t,e,s)=>new E({schema:t,typeName:p.ZodEffects,effect:e,...v(s)});E.createWithPreprocess=(t,e,s)=>new E({schema:e,effect:{type:"preprocess",transform:t},typeName:p.ZodEffects,...v(s)});class O extends _{_parse(e){return this._getType(e)===f.undefined?T(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}O.create=(t,e)=>new O({innerType:t,typeName:p.ZodOptional,...v(e)});class L extends _{_parse(e){return this._getType(e)===f.null?T(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}L.create=(t,e)=>new L({innerType:t,typeName:p.ZodNullable,...v(e)});class fe extends _{_parse(e){const{ctx:s}=this._processInputParams(e);let n=s.data;return s.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:s.path,parent:s})}removeDefault(){return this._def.innerType}}fe.create=(t,e)=>new fe({innerType:t,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});class he extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n={...s,common:{...s.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return se(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new C(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new C(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}he.create=(t,e)=>new he({innerType:t,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});class Se extends _{_parse(e){if(this._getType(e)!==f.nan){const n=this._getOrReturnCtx(e);return l(n,{code:c.invalid_type,expected:f.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}}Se.create=t=>new Se({typeName:p.ZodNaN,...v(t)});const Wt=Symbol("zod_brand");class Ie extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n=s.data;return this._def.type._parse({data:n,path:s.path,parent:s})}unwrap(){return this._def.type}}class me extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?g:a.status==="dirty"?(s.dirty(),W(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{const r=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?g:r.status==="dirty"?(s.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,s){return new me({in:e,out:s,typeName:p.ZodPipeline})}}class pe extends _{_parse(e){const s=this._def.innerType._parse(e),n=r=>(te(r)&&(r.value=Object.freeze(r.value)),r);return se(s)?s.then(r=>n(r)):n(s)}unwrap(){return this._def.innerType}}pe.create=(t,e)=>new pe({innerType:t,typeName:p.ZodReadonly,...v(e)});function We(t,e={},s){return t?J.create().superRefine((n,r)=>{var a,i;if(!t(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:s)!==null&&i!==void 0?i:!0,d=typeof o=="string"?{message:o}:o;r.addIssue({code:"custom",...d,fatal:u})}}):J.create()}const Ht={object:b.lazycreate};var p;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(p||(p={}));const Yt=(t,e={message:`Input not instance of ${t.name}`})=>We(s=>s instanceof t,e),He=M.create,Ye=P.create,Jt=Se.create,Xt=$.create,Je=ne.create,Kt=z.create,Ft=be.create,es=re.create,ts=ae.create,ss=J.create,ns=B.create,rs=j.create,as=we.create,is=Z.create,os=b.create,cs=b.strictCreate,us=ie.create,ds=Te.create,ls=oe.create,fs=N.create,hs=ce.create,ps=ke.create,ms=Q.create,gs=H.create,ys=ue.create,vs=de.create,_s=U.create,xs=le.create,bs=X.create,Ue=E.create,ws=O.create,ks=L.create,Ss=E.createWithPreprocess,Ts=me.create,Rs=()=>He().optional(),Cs=()=>Ye().optional(),Ms=()=>Je().optional(),Zs={string:t=>M.create({...t,coerce:!0}),number:t=>P.create({...t,coerce:!0}),boolean:t=>ne.create({...t,coerce:!0}),bigint:t=>$.create({...t,coerce:!0}),date:t=>z.create({...t,coerce:!0})},Es=g;var y=Object.freeze({__proto__:null,defaultErrorMap:Y,setErrorMap:Et,getErrorMap:ve,makeIssue:_e,EMPTY_PATH:Ot,addIssueToContext:l,ParseStatus:k,INVALID:g,DIRTY:W,OK:T,isAborted:Ze,isDirty:Ee,isValid:te,isAsync:se,get util(){return x},get objectUtil(){return Me},ZodParsedType:f,getParsedType:q,ZodType:_,datetimeRegex:Qe,ZodString:M,ZodNumber:P,ZodBigInt:$,ZodBoolean:ne,ZodDate:z,ZodSymbol:be,ZodUndefined:re,ZodNull:ae,ZodAny:J,ZodUnknown:B,ZodNever:j,ZodVoid:we,ZodArray:Z,ZodObject:b,ZodUnion:ie,ZodDiscriminatedUnion:Te,ZodIntersection:oe,ZodTuple:N,ZodRecord:ce,ZodMap:ke,ZodSet:Q,ZodFunction:H,ZodLazy:ue,ZodLiteral:de,ZodEnum:U,ZodNativeEnum:le,ZodPromise:X,ZodEffects:E,ZodTransformer:E,ZodOptional:O,ZodNullable:L,ZodDefault:fe,ZodCatch:he,ZodNaN:Se,BRAND:Wt,ZodBranded:Ie,ZodPipeline:me,ZodReadonly:pe,custom:We,Schema:_,ZodSchema:_,late:Ht,get ZodFirstPartyTypeKind(){return p},coerce:Zs,any:ss,array:is,bigint:Xt,boolean:Je,date:Kt,discriminatedUnion:ds,effect:Ue,enum:_s,function:gs,instanceof:Yt,intersection:ls,lazy:ys,literal:vs,map:ps,nan:Jt,nativeEnum:xs,never:rs,null:ts,nullable:ks,number:Ye,object:os,oboolean:Ms,onumber:Cs,optional:ws,ostring:Rs,pipeline:Ts,preprocess:Ss,promise:bs,record:hs,set:ms,strictObject:cs,string:He,symbol:Ft,transformer:Ue,tuple:fs,undefined:es,union:us,unknown:ns,void:as,NEVER:Es,ZodIssueCode:c,quotelessJson:Zt,ZodError:C});const S=y.object({type:y.literal("qp-bridge"),id:y.string().optional()}),Xe=S.extend({status:y.literal("answerChanged"),question:y.string(),answer:y.unknown()}),ge=S.extend({status:y.literal("success")}),Ke=S.extend({status:y.literal("error"),message:y.string()}),Ne=y.object({semanticColor:y.string().optional(),label:y.string(),description:y.string(),disabled:y.boolean(),required:y.boolean(),hidden:y.boolean(),errorMessage:y.string().optional()}),Fe=Ne.partial(),et=y.object({id:y.string().uuid(),name:y.string(),mimeType:y.string(),blobUrl:y.string()}),Ae=y.object({label:y.string(),hidden:y.boolean(),collapsed:y.boolean()}),tt=Ae.partial(),st=S.extend({action:y.literal("getQuestion"),question:y.string()}),nt=ge.extend({question:Ne}),rt=S.extend({action:y.literal("setQuestion"),question:y.string(),questionData:Fe}),at=S.extend({action:y.literal("getGroup"),group:y.string()}),it=ge.extend({group:Ae}),ot=ge.extend({canSave:y.boolean()}),ct=S.extend({action:y.literal("canSave")}),ut=S.extend({action:y.literal("setGroup"),group:y.string(),groupData:tt}),dt=S.extend({action:y.literal("setAnswer"),question:y.string(),answer:y.unknown()}),lt=S.extend({action:y.literal("busyIndicatorStart")}),ft=S.extend({action:y.literal("busyIndicatorEnd")}),ht=S.extend({action:y.literal("saveQuestionnaire")}),pt=S.extend({action:y.literal("completeAndCloseQuestionnaire")}),mt=S.extend({action:y.literal("executeCustomCommand"),commandName:y.string()});function Os(t){return et.safeParse(t).success}function gt(t){return Xe.safeParse(t).success}function je(t){return S.safeParse(t).success}function yt(t){return ge.safeParse(t).success}function vt(t){return Ke.safeParse(t).success}function Is(t){return st.safeParse(t).success}function _t(t){return nt.safeParse(t).success}function Ns(t){return dt.safeParse(t).success}function As(t){return rt.safeParse(t).success}function js(t){return ut.safeParse(t).success}function qs(t){return at.safeParse(t).success}function xt(t){return it.safeParse(t).success}function Ps(t){return ot.safeParse(t).success}function bt(t){return ct.safeParse(t).success}function wt(t){return lt.safeParse(t).success}function kt(t){return ft.safeParse(t).success}function $s(t){return ht.safeParse(t).success}function Us(t){return pt.safeParse(t).success}function Ls(t){return mt.safeParse(t).success}function Vs(t){return wt(t)||kt(t)}function St(t){if(t instanceof File||t instanceof Blob)return URL.createObjectURL(t);if(typeof t=="string"){if(/^data:/.test(t)){const a=t.match(/^data:([^;]+);base64,(.*)$/);if(a){const i=a[1],o=a[2],u=atob(o),d=new ArrayBuffer(u.length),m=new Uint8Array(d);for(let D=0;D<u.length;D++)m[D]=u.charCodeAt(D);const R=new Blob([d],{type:i});return URL.createObjectURL(R)}throw new Error("Invalid data URL format. Only base64 data URLs are supported.")}const e=atob(t),s=new ArrayBuffer(e.length),n=new Uint8Array(s);for(let a=0;a<e.length;a++)n[a]=e.charCodeAt(a);const r=new Blob([s]);return URL.createObjectURL(r)}if(t instanceof ArrayBuffer){const e=new Blob([t]);return URL.createObjectURL(e)}throw new Error("Unsupported content type for blobUrl")}function Ds(t,e,s,n){return{id:n??Le(),name:t,mimeType:e,blobUrl:St(s)}}function Bs(t,e){let s=t.blobUrl;return e.content!==void 0&&(s=St(e.content)),{...t,...e,blobUrl:s}}window.addEventListener("message",tn);async function zs(t,e){await V({type:"qp-bridge",action:"setAnswer",question:t,answer:e})}async function Qs(t){return await sn({type:"qp-bridge",action:"getQuestion",question:t})}async function Gs(t,e){await V({type:"qp-bridge",action:"setQuestion",question:t,questionData:e})}async function Ws(t){return await nn({type:"qp-bridge",action:"getGroup",group:t})}async function Hs(t,e){await V({type:"qp-bridge",action:"setGroup",group:t,groupData:e})}function Ys(t){const e=s=>{gt(s.data)&&t(s.data.question,s.data.answer)};return window.addEventListener("message",e),{cancelSubscription:()=>{window.removeEventListener("message",e)}}}async function Js(t){await V({type:"qp-bridge",action:"busyIndicatorStart"});try{return await t()}finally{await V({type:"qp-bridge",action:"busyIndicatorEnd"})}}async function Xs(){await V({type:"qp-bridge",action:"saveQuestionnaire"})}async function Ks(){await V({type:"qp-bridge",action:"completeAndCloseQuestionnaire"})}async function Fs(t){await V({type:"qp-bridge",action:"executeCustomCommand",commandName:t})}const ee=[];function en(t){return ee.includes(t)||ee.push(t),{cancelSubscription:()=>{const e=ee.indexOf(t);e!==-1&&ee.splice(e,1)}}}async function tn(t){try{if(bt(t.data)){const e=await Promise.all(ee.map(n=>n())),s={type:"qp-bridge",status:"success",id:t.data.id,canSave:e.every(n=>n)};window.parent.postMessage(s,"*")}}catch(e){const s={type:"qp-bridge",status:"error",id:je(t.data)?t.data.id:void 0,message:e instanceof Error?e.message:"Unknown error"};window.parent.postMessage(s,"*")}}async function qe(t,e){return new Promise((s,n)=>{const r=Le(),a=i=>{if(!je(i.data)||i.data.id!==r)return;const u=e(i.data);u.success?s(u.data):vt(i.data)?n(new Error(i.data.message)):n(new Error("Unknown message received")),window.removeEventListener("message",a)};window.addEventListener("message",a),window.parent.postMessage({...t,id:r},"*")})}async function sn(t){return qe(t,e=>_t(e)?{success:!0,data:e.question}:{success:!1})}async function nn(t){return qe(t,e=>xt(e)?{success:!0,data:e.group}:{success:!1})}function V(t){return qe(t,e=>yt(e)?{success:!0,data:void 0}:{success:!1})}exports.busyIndicatorEndRequestMessageSchema=ft;exports.busyIndicatorStartRequestMessageSchema=lt;exports.canSaveRequestMessageSchema=ct;exports.canSaveSuccessResponseMessageSchema=ot;exports.completeAndCloseQuestionnaire=Ks;exports.completeAndCloseQuestionnaireRequestMessageSchema=pt;exports.createMediaItem=Ds;exports.executeCustomCommand=Fs;exports.executeCustomCommandRequestMessageSchema=mt;exports.getGroup=Ws;exports.getGroupRequestMessageSchema=at;exports.getGroupSuccessResponseMessageSchema=it;exports.getQuestion=Qs;exports.getQuestionRequestMessageSchema=st;exports.getQuestionSuccessResponseMessageSchema=nt;exports.groupOptionalScheme=tt;exports.groupSchema=Ae;exports.isBusyIndicatorEndRequestMessage=kt;exports.isBusyIndicatorStartRequestMessage=wt;exports.isCanSaveRequestMessage=bt;exports.isCanSaveSuccessResponseMessage=Ps;exports.isCompleteAndCloseQuestionnaireRequestMessage=Us;exports.isErrorMessage=vt;exports.isExecuteCustomCommandRequestMessage=Ls;exports.isGetGroupRequestMessage=qs;exports.isGetGroupSuccessResponseMessage=xt;exports.isGetQuestionRequestMessage=Is;exports.isGetQuestionSuccessResponseMessage=_t;exports.isMediaItem=Os;exports.isOnAnswerChangeMessage=gt;exports.isQpBridgeMessage=je;exports.isSaveQuestionnaireRequestMessage=$s;exports.isSetAnswerRequestMessage=Ns;exports.isSetGroupRequestMessage=js;exports.isSetQuestionRequestMessage=As;exports.isSuccessMessage=yt;exports.isWithBusyIndicatorRequestMessage=Vs;exports.mediaItemSchema=et;exports.onAnswerChange=Ys;exports.onAnswerChangeMessageSchema=Xe;exports.onSave=en;exports.qpBridgeMessageSchema=S;exports.questionOptionalScheme=Fe;exports.questionSchema=Ne;exports.responseErrorMessageSchema=Ke;exports.responseSuccessMessageSchema=ge;exports.saveQuestionnaire=Xs;exports.saveQuestionnaireRequestMessageSchema=ht;exports.setAnswer=zs;exports.setAnswerRequestMessageSchema=dt;exports.setGroup=Hs;exports.setGroupRequestMessageSchema=ut;exports.setQuestion=Gs;exports.setQuestionRequestMessageSchema=rt;exports.updateMediaItem=Bs;exports.withBusyIndicator=Js;