@resconet/qp-bridge 0.0.1-alpha.13 → 0.0.1-alpha.14

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/README.md CHANGED
@@ -49,6 +49,7 @@ await setAnswer("numericQuestion", 42);
49
49
  - [onAnswerChange](#onanswerchange)
50
50
  - [withBusyIndicator](#withbusyindicator)
51
51
  - [saveQuestionnaire](#savequestionnaire)
52
+ - [completeAndCloseQuestionnaire](#completeandclosequestionnaire)
52
53
 
53
54
  ### setAnswer
54
55
 
@@ -255,6 +256,27 @@ console.log('Questionnaire saved successfully');
255
256
  ```
256
257
 
257
258
 
259
+ ### completeAndCloseQuestionnaire
260
+
261
+ Completes and closes the current questionnaire.
262
+ Triggers the complete and close operation for the questionnaire.
263
+
264
+ | Function | Type |
265
+ | ---------- | ---------- |
266
+ | `completeAndCloseQuestionnaire` | `() => Promise<void>` |
267
+
268
+ Returns:
269
+
270
+ A promise that resolves when the questionnaire has been successfully completed and closed.
271
+
272
+ Examples:
273
+
274
+ ```typescript
275
+ await completeAndCloseQuestionnaire();
276
+ console.log('Questionnaire completed and closed successfully');
277
+ ```
278
+
279
+
258
280
 
259
281
 
260
282
  <!-- TSDOC_END -->
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let pe;const gt=new Uint8Array(16);function yt(){if(!pe&&(pe=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!pe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return pe(gt)}const k=[];for(let s=0;s<256;++s)k.push((s+256).toString(16).slice(1));function vt(s,e=0){return k[s[e+0]]+k[s[e+1]]+k[s[e+2]]+k[s[e+3]]+"-"+k[s[e+4]]+k[s[e+5]]+"-"+k[s[e+6]]+k[s[e+7]]+"-"+k[s[e+8]]+k[s[e+9]]+"-"+k[s[e+10]]+k[s[e+11]]+k[s[e+12]]+k[s[e+13]]+k[s[e+14]]+k[s[e+15]]}const _t=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ae={randomUUID:_t};function xt(s,e,t){if(Ae.randomUUID&&!e&&!s)return Ae.randomUUID();s=s||{};const n=s.random||(s.rng||yt)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,vt(n)}var x;(function(s){s.assertEqual=r=>r;function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},s.getValidEnumValues=r=>{const a=s.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return s.objectValues(i)},s.objectValues=r=>s.objectKeys(r).map(function(a){return r[a]}),s.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},s.find=(r,a)=>{for(const i of r)if(a(i))return i},s.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)}s.joinValues=n,s.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Re;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Re||(Re={}));const f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),P=s=>{switch(typeof s){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(s)?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(s)?f.array:s===null?f.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?f.promise:typeof Map<"u"&&s instanceof Map?f.map:typeof Set<"u"&&s instanceof Set?f.set:typeof Date<"u"&&s 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"]),bt=s=>JSON.stringify(s,null,2).replace(/"([^"]+)":/g,"$1:");class T extends Error{constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},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(t(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(t(i))):o[d]=o[d]||{_errors:[]},o=o[d],u++}}};return r(this),n}static assert(e){if(!(e instanceof T))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=t=>t.message){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}T.create=s=>new T(s);const W=(s,e)=>{let t;switch(s.code){case c.invalid_type:s.received===f.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,x.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(s.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(s.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(s.options)}, received '${s.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:x.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case c.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case c.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(s)}return{message:t}};let $e=W;function kt(s){$e=s}function me(){return $e}const ge=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,a=[...t,...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}},wt=[];function l(s,e){const t=me(),n=ge({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===W?void 0:W].filter(r=>!!r)});s.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,t){const n=[];for(const r of t){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,t){const n=[];for(const r of t){const a=await r.key,i=await r.value;n.push({key:a,value:i})}return w.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){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=s=>({status:"dirty",value:s}),S=s=>({status:"valid",value:s}),Ze=s=>s.status==="aborted",Ee=s=>s.status==="dirty",F=s=>s.status==="valid",ee=s=>typeof Promise<"u"&&s instanceof Promise;function ye(s,e,t,n){if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(s)}function Ve(s,e,t,n,r){if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(s,t),t}var h;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));var X,K;class N{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,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 Pe=(s,e)=>{if(F(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new T(s.common.issues);return this._error=t,this._error}}};function y(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{var u,d;const{message:g}=s;return i.code==="invalid_enum_value"?{message:g??o.defaultError}:typeof o.data>"u"?{message:(u=g??n)!==null&&u!==void 0?u:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(d=g??t)!==null&&d!==void 0?d:o.defaultError}},description:r}}class v{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 P(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:P(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:P(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ee(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const r={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},a=this._parseSync({data:e,path:r.path,parent:r});return Pe(r,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(ee(r)?r:Promise.resolve(r));return Pe(n,a)}refine(e,t){const n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;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,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!1))}_refinement(e){return new M({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 C.create(this,this._def)}promise(){return H.create(this,this._def)}or(e){return re.create([this,e],this._def)}and(e){return ae.create(this,e,this._def)}transform(e){return new M({...y(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t=typeof e=="function"?e:()=>e;return new ue({...y(this._def),innerType:this,defaultValue:t,typeName:p.ZodDefault})}brand(){return new Me({typeName:p.ZodBranded,type:this,...y(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new le({...y(this._def),innerType:this,catchValue:t,typeName:p.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return he.create(this,e)}readonly(){return fe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const St=/^c[^\s-]{8,}$/i,Tt=/^[0-9a-z]+$/,Rt=/^[0-9A-HJKMNP-TV-Z]{26}$/,Zt=/^[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,Et=/^[a-z0-9_-]{21}$/i,Ct=/^[-+]?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)?)??$/,Mt=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Ot="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Te;const Nt=/^(?:(?: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])$/,It=/^(([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})))$/,jt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,De="((\\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])))",At=new RegExp(`^${De}$`);function Le(s){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Pt(s){return new RegExp(`^${Le(s)}$`)}function Ue(s){let e=`${De}T${Le(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function qt(s,e){return!!((e==="v4"||!e)&&Nt.test(s)||(e==="v6"||!e)&&It.test(s))}class E extends v{_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")Mt.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")Te||(Te=new RegExp(Ot,"u")),Te.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")Zt.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")Et.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")St.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")Tt.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")Rt.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"?Ue(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"?At.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Pt(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"?Ct.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"?jt.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,t,n){return this.refinement(r=>e.test(r),{validation:t,code:c.invalid_string,...h.errToObj(n)})}_addCheck(e){return new E({...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 t,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:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!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,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...h.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new E({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new E({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new E({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}E.create=s=>{var e;return new E({checks:[],typeName:p.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...y(s)})};function $t(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,a=parseInt(s.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}class q extends v{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"?$t(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,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,n,r){return new q({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:h.toString(r)}]})}_addCheck(e){return new q({...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,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}q.create=s=>new q({checks:[],typeName:p.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...y(s)});class $ extends v{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,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,n,r){return new $({...this._def,checks:[...this._def.checks,{kind:e,value:t,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,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}$.create=s=>{var e;return new $({checks:[],typeName:p.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...y(s)})};class te extends v{_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 S(e.data)}}te.create=s=>new te({typeName:p.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...y(s)});class U extends v{_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 U({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}U.create=s=>new U({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:p.ZodDate,...y(s)});class ve extends v{_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 S(e.data)}}ve.create=s=>new ve({typeName:p.ZodSymbol,...y(s)});class se extends v{_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 S(e.data)}}se.create=s=>new se({typeName:p.ZodUndefined,...y(s)});class ne extends v{_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 S(e.data)}}ne.create=s=>new ne({typeName:p.ZodNull,...y(s)});class Y extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return S(e.data)}}Y.create=s=>new Y({typeName:p.ZodAny,...y(s)});class L extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return S(e.data)}}L.create=s=>new L({typeName:p.ZodUnknown,...y(s)});class A extends v{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:c.invalid_type,expected:f.never,received:t.parsedType}),m}}A.create=s=>new A({typeName:p.ZodNever,...y(s)});class _e extends v{_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 S(e.data)}}_e.create=s=>new _e({typeName:p.ZodVoid,...y(s)});class C extends v{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==f.array)return l(t,{code:c.invalid_type,expected:f.array,received:t.parsedType}),m;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&(l(t,{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&&t.data.length<r.minLength.value&&(l(t,{code:c.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(l(t,{code:c.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>r.type._parseAsync(new N(t,i,t.path,o)))).then(i=>w.mergeArray(n,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new N(t,i,t.path,o)));return w.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new C({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new C({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new C({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}}C.create=(s,e)=>new C({type:s,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...y(e)});function B(s){if(s instanceof b){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=O.create(B(n))}return new b({...s._def,shape:()=>e})}else return s instanceof C?new C({...s._def,type:B(s.element)}):s instanceof O?O.create(B(s.unwrap())):s instanceof D?D.create(B(s.unwrap())):s instanceof I?I.create(s.items.map(e=>B(e))):s}class b extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t}}_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}),m}const{status:n,ctx:r}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof A&&this._def.unknownKeys==="strip"))for(const d in r.data)i.includes(d)||o.push(d);const u=[];for(const d of i){const g=a[d],Z=r.data[d];u.push({key:{status:"valid",value:d},value:g._parse(new N(r,Z,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof A){const d=this._def.unknownKeys;if(d==="passthrough")for(const g of o)u.push({key:{status:"valid",value:g},value:{status:"valid",value:r.data[g]}});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 g of o){const Z=r.data[g];u.push({key:{status:"valid",value:g},value:d._parse(new N(r,Z,r.path,g)),alwaysSet:g in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const g of u){const Z=await g.key,je=await g.value;d.push({key:Z,value:je,alwaysSet:g.alwaysSet})}return d}).then(d=>w.mergeObjectSync(n,d)):w.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new b({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var r,a,i,o;const u=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.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,t){return this.augment({[e]:t})}catchall(e){return new b({...this._def,catchall:e})}pick(e){const t={};return x.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new b({...this._def,shape:()=>t})}omit(e){const t={};return x.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new b({...this._def,shape:()=>t})}deepPartial(){return B(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}),new b({...this._def,shape:()=>t})}required(e){const t={};return x.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof O;)a=a._def.innerType;t[n]=a}}),new b({...this._def,shape:()=>t})}keyof(){return ze(x.objectKeys(this.shape))}}b.create=(s,e)=>new b({shape:()=>s,unknownKeys:"strip",catchall:A.create(),typeName:p.ZodObject,...y(e)});b.strictCreate=(s,e)=>new b({shape:()=>s,unknownKeys:"strict",catchall:A.create(),typeName:p.ZodObject,...y(e)});b.lazycreate=(s,e)=>new b({shape:s,unknownKeys:"strip",catchall:A.create(),typeName:p.ZodObject,...y(e)});class re extends v{_parse(e){const{ctx:t}=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 t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new T(o.ctx.common.issues));return l(t,{code:c.invalid_union,unionErrors:i}),m}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const u of n){const d={...t,common:{...t.common,issues:[]},parent:null},g=u._parseSync({data:t.data,path:t.path,parent:d});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new T(u));return l(t,{code:c.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}re.create=(s,e)=>new re({options:s,typeName:p.ZodUnion,...y(e)});const j=s=>s instanceof oe?j(s.schema):s instanceof M?j(s.innerType()):s instanceof ce?[s.value]:s instanceof V?s.options:s instanceof de?x.objectValues(s.enum):s instanceof ue?j(s._def.innerType):s instanceof se?[void 0]:s instanceof ne?[null]:s instanceof O?[void 0,...j(s.unwrap())]:s instanceof D?[null,...j(s.unwrap())]:s instanceof Me||s instanceof fe?j(s.unwrap()):s instanceof le?j(s._def.innerType):[];class ke extends v{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return l(t,{code:c.invalid_type,expected:f.object,received:t.parsedType}),m;const n=this.discriminator,r=t.data[n],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{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,t,n){const r=new Map;for(const a of t){const i=j(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 ke({typeName:p.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...y(n)})}}function Ce(s,e){const t=P(s),n=P(e);if(s===e)return{valid:!0,data:s};if(t===f.object&&n===f.object){const r=x.objectKeys(e),a=x.objectKeys(s).filter(o=>r.indexOf(o)!==-1),i={...s,...e};for(const o of a){const u=Ce(s[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===f.array&&n===f.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<s.length;a++){const i=s[a],o=e[a],u=Ce(i,o);if(!u.valid)return{valid:!1};r.push(u.data)}return{valid:!0,data:r}}else return t===f.date&&n===f.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class ae extends v{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(Ze(a)||Ze(i))return m;const o=Ce(a.value,i.value);return o.valid?((Ee(a)||Ee(i))&&t.dirty(),{status:t.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}))}}ae.create=(s,e,t)=>new ae({left:s,right:e,typeName:p.ZodIntersection,...y(t)});class I extends v{_parse(e){const{status:t,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"}),t.dirty());const a=[...n.data].map((i,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new N(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>w.mergeArray(t,i)):w.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new I({...this._def,rest:e})}}I.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new I({items:s,typeName:p.ZodTuple,rest:null,...y(e)})};class ie extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==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(t,r):w.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof v?new ie({keyType:e,valueType:t,typeName:p.ZodRecord,...y(n)}):new ie({keyType:E.create(),valueType:e,typeName:p.ZodRecord,...y(t)})}}class xe extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==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,u],d)=>({key:r._parse(new N(n,o,n.path,[d,"key"])),value:a._parse(new N(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,g=await u.value;if(d.status==="aborted"||g.status==="aborted")return m;(d.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(d.value,g.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const d=u.key,g=u.value;if(d.status==="aborted"||g.status==="aborted")return m;(d.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(d.value,g.value)}return{status:t.value,value:o}}}}xe.create=(s,e,t)=>new xe({valueType:e,keyType:s,typeName:p.ZodMap,...y(t)});class z extends v{_parse(e){const{status:t,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}),t.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}),t.dirty());const a=this._def.valueType;function i(u){const d=new Set;for(const g of u){if(g.status==="aborted")return m;g.status==="dirty"&&t.dirty(),d.add(g.value)}return{status:t.value,value:d}}const o=[...n.data.values()].map((u,d)=>a._parse(new N(n,u,n.path,d)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new z({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new z({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}z.create=(s,e)=>new z({valueType:s,minSize:null,maxSize:null,typeName:p.ZodSet,...y(e)});class Q extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return l(t,{code:c.invalid_type,expected:f.function,received:t.parsedType}),m;function n(o,u){return ge({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,me(),W].filter(d=>!!d),issueData:{code:c.invalid_arguments,argumentsError:u}})}function r(o,u){return ge({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,me(),W].filter(d=>!!d),issueData:{code:c.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof H){const o=this;return S(async function(...u){const d=new T([]),g=await o._def.args.parseAsync(u,a).catch(Se=>{throw d.addIssue(n(u,Se)),d}),Z=await Reflect.apply(i,this,g);return await o._def.returns._def.type.parseAsync(Z,a).catch(Se=>{throw d.addIssue(r(Z,Se)),d})})}else{const o=this;return S(function(...u){const d=o._def.args.safeParse(u,a);if(!d.success)throw new T([n(u,d.error)]);const g=Reflect.apply(i,this,d.data),Z=o._def.returns.safeParse(g,a);if(!Z.success)throw new T([r(g,Z.error)]);return Z.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Q({...this._def,args:I.create(e).rest(L.create())})}returns(e){return new Q({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new Q({args:e||I.create([]).rest(L.create()),returns:t||L.create(),typeName:p.ZodFunction,...y(n)})}}class oe extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}oe.create=(s,e)=>new oe({getter:s,typeName:p.ZodLazy,...y(e)});class ce extends v{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}ce.create=(s,e)=>new ce({value:s,typeName:p.ZodLiteral,...y(e)});function ze(s,e){return new V({values:s,typeName:p.ZodEnum,...y(e)})}class V extends v{constructor(){super(...arguments),X.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return l(t,{expected:x.joinValues(n),received:t.parsedType,code:c.invalid_type}),m}if(ye(this,X)||Ve(this,X,new Set(this._def.values)),!ye(this,X).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return l(t,{received:t.data,code:c.invalid_enum_value,options:n}),m}return S(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return V.create(e,{...this._def,...t})}exclude(e,t=this._def){return V.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}X=new WeakMap;V.create=ze;class de extends v{constructor(){super(...arguments),K.set(this,void 0)}_parse(e){const t=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){const r=x.objectValues(t);return l(n,{expected:x.joinValues(r),received:n.parsedType,code:c.invalid_type}),m}if(ye(this,K)||Ve(this,K,new Set(x.getValidEnumValues(this._def.values))),!ye(this,K).has(e.data)){const r=x.objectValues(t);return l(n,{received:n.data,code:c.invalid_enum_value,options:r}),m}return S(e.data)}get enum(){return this._def.values}}K=new WeakMap;de.create=(s,e)=>new de({values:s,typeName:p.ZodNativeEnum,...y(e)});class H extends v{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return l(t,{code:c.invalid_type,expected:f.promise,received:t.parsedType}),m;const n=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return S(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}H.create=(s,e)=>new H({type:s,typeName:p.ZodPromise,...y(e)});class M extends v{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:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{l(n,i),i.fatal?t.abort():t.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(t.value==="aborted")return m;const u=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return u.status==="aborted"?m:u.status==="dirty"||t.value==="dirty"?G(u.value):u});{if(t.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"||t.value==="dirty"?G(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"?m:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.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(!F(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:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>F(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);x.assertNever(r)}}M.create=(s,e,t)=>new M({schema:s,typeName:p.ZodEffects,effect:e,...y(t)});M.createWithPreprocess=(s,e,t)=>new M({schema:e,effect:{type:"preprocess",transform:s},typeName:p.ZodEffects,...y(t)});class O extends v{_parse(e){return this._getType(e)===f.undefined?S(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}O.create=(s,e)=>new O({innerType:s,typeName:p.ZodOptional,...y(e)});class D extends v{_parse(e){return this._getType(e)===f.null?S(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}D.create=(s,e)=>new D({innerType:s,typeName:p.ZodNullable,...y(e)});class ue extends v{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ue.create=(s,e)=>new ue({innerType:s,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class le extends v{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ee(r)?r.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new T(n.common.issues)},input:n.data})})):{status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new T(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}le.create=(s,e)=>new le({innerType:s,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class be extends v{_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}}}be.create=s=>new be({typeName:p.ZodNaN,...y(s)});const Vt=Symbol("zod_brand");class Me extends v{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class he extends v{_parse(e){const{status:t,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"?(t.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"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new he({in:e,out:t,typeName:p.ZodPipeline})}}class fe extends v{_parse(e){const t=this._def.innerType._parse(e),n=r=>(F(r)&&(r.value=Object.freeze(r.value)),r);return ee(t)?t.then(r=>n(r)):n(t)}unwrap(){return this._def.innerType}}fe.create=(s,e)=>new fe({innerType:s,typeName:p.ZodReadonly,...y(e)});function Be(s,e={},t){return s?Y.create().superRefine((n,r)=>{var a,i;if(!s(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,d=typeof o=="string"?{message:o}:o;r.addIssue({code:"custom",...d,fatal:u})}}):Y.create()}const Dt={object:b.lazycreate};var p;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(p||(p={}));const Lt=(s,e={message:`Input not instance of ${s.name}`})=>Be(t=>t instanceof s,e),Ge=E.create,Qe=q.create,Ut=be.create,zt=$.create,We=te.create,Bt=U.create,Gt=ve.create,Qt=se.create,Wt=ne.create,Yt=Y.create,Ht=L.create,Jt=A.create,Xt=_e.create,Kt=C.create,Ft=b.create,es=b.strictCreate,ts=re.create,ss=ke.create,ns=ae.create,rs=I.create,as=ie.create,is=xe.create,os=z.create,cs=Q.create,ds=oe.create,us=ce.create,ls=V.create,fs=de.create,hs=H.create,qe=M.create,ps=O.create,ms=D.create,gs=M.createWithPreprocess,ys=he.create,vs=()=>Ge().optional(),_s=()=>Qe().optional(),xs=()=>We().optional(),bs={string:s=>E.create({...s,coerce:!0}),number:s=>q.create({...s,coerce:!0}),boolean:s=>te.create({...s,coerce:!0}),bigint:s=>$.create({...s,coerce:!0}),date:s=>U.create({...s,coerce:!0})},ks=m;var _=Object.freeze({__proto__:null,defaultErrorMap:W,setErrorMap:kt,getErrorMap:me,makeIssue:ge,EMPTY_PATH:wt,addIssueToContext:l,ParseStatus:w,INVALID:m,DIRTY:G,OK:S,isAborted:Ze,isDirty:Ee,isValid:F,isAsync:ee,get util(){return x},get objectUtil(){return Re},ZodParsedType:f,getParsedType:P,ZodType:v,datetimeRegex:Ue,ZodString:E,ZodNumber:q,ZodBigInt:$,ZodBoolean:te,ZodDate:U,ZodSymbol:ve,ZodUndefined:se,ZodNull:ne,ZodAny:Y,ZodUnknown:L,ZodNever:A,ZodVoid:_e,ZodArray:C,ZodObject:b,ZodUnion:re,ZodDiscriminatedUnion:ke,ZodIntersection:ae,ZodTuple:I,ZodRecord:ie,ZodMap:xe,ZodSet:z,ZodFunction:Q,ZodLazy:oe,ZodLiteral:ce,ZodEnum:V,ZodNativeEnum:de,ZodPromise:H,ZodEffects:M,ZodTransformer:M,ZodOptional:O,ZodNullable:D,ZodDefault:ue,ZodCatch:le,ZodNaN:be,BRAND:Vt,ZodBranded:Me,ZodPipeline:he,ZodReadonly:fe,custom:Be,Schema:v,ZodSchema:v,late:Dt,get ZodFirstPartyTypeKind(){return p},coerce:bs,any:Yt,array:Kt,bigint:zt,boolean:We,date:Bt,discriminatedUnion:ss,effect:qe,enum:ls,function:cs,instanceof:Lt,intersection:ns,lazy:ds,literal:us,map:is,nan:Ut,nativeEnum:fs,never:Jt,null:Wt,nullable:ms,number:Qe,object:Ft,oboolean:xs,onumber:_s,optional:ps,ostring:vs,pipeline:ys,preprocess:gs,promise:hs,record:as,set:os,strictObject:es,string:Ge,symbol:Gt,transformer:qe,tuple:rs,undefined:Qt,union:ts,unknown:Ht,void:Xt,NEVER:ks,ZodIssueCode:c,quotelessJson:bt,ZodError:T});const R=_.object({type:_.literal("qp-bridge"),id:_.string().optional()}),Ye=R.extend({status:_.literal("answerChanged"),question:_.string(),answer:_.unknown()}),we=R.extend({status:_.literal("success")}),He=R.extend({status:_.literal("error"),message:_.string()}),Oe=_.object({semanticColor:_.string().optional(),label:_.string(),description:_.string(),disabled:_.boolean(),required:_.boolean(),hidden:_.boolean()}),Je=Oe.partial(),Ne=_.object({label:_.string(),hidden:_.boolean(),collapsed:_.boolean()}),Xe=Ne.partial(),Ke=R.extend({action:_.literal("getQuestion"),question:_.string()}),Fe=we.extend({question:Oe}),et=R.extend({action:_.literal("setQuestion"),question:_.string(),questionData:Je}),tt=R.extend({action:_.literal("getGroup"),group:_.string()}),st=we.extend({group:Ne}),nt=R.extend({action:_.literal("setGroup"),group:_.string(),groupData:Xe}),rt=R.extend({action:_.literal("setAnswer"),question:_.string(),answer:_.unknown()}),at=R.extend({action:_.literal("busyIndicatorStart")}),it=R.extend({action:_.literal("busyIndicatorEnd")}),ot=R.extend({action:_.literal("saveQuestionnaire")});function ct(s){return Ye.safeParse(s).success}function dt(s){return R.safeParse(s).success}function ut(s){return we.safeParse(s).success}function lt(s){return He.safeParse(s).success}function ws(s){return Ke.safeParse(s).success}function ft(s){return Fe.safeParse(s).success}function Ss(s){return rt.safeParse(s).success}function Ts(s){return et.safeParse(s).success}function Rs(s){return nt.safeParse(s).success}function Zs(s){return tt.safeParse(s).success}function ht(s){return st.safeParse(s).success}function pt(s){return at.safeParse(s).success}function mt(s){return it.safeParse(s).success}function Es(s){return ot.safeParse(s).success}function Cs(s){return pt(s)||mt(s)}async function Ms(s,e){await J({type:"qp-bridge",action:"setAnswer",question:s,answer:e})}async function Os(s){return await $s({type:"qp-bridge",action:"getQuestion",question:s})}async function Ns(s,e){await J({type:"qp-bridge",action:"setQuestion",question:s,questionData:e})}async function Is(s){return await Vs({type:"qp-bridge",action:"getGroup",group:s})}async function js(s,e){await J({type:"qp-bridge",action:"setGroup",group:s,groupData:e})}function As(s){const e=t=>{ct(t.data)&&s(t.data.question,t.data.answer)};return window.addEventListener("message",e),{cancelSubscription:()=>{window.removeEventListener("message",e)}}}async function Ps(s){await J({type:"qp-bridge",action:"busyIndicatorStart"});try{return await s()}finally{await J({type:"qp-bridge",action:"busyIndicatorEnd"})}}async function qs(){await J({type:"qp-bridge",action:"saveQuestionnaire"})}async function Ie(s,e){return new Promise((t,n)=>{const r=xt(),a=i=>{if(!dt(i.data)||i.data.id!==r)return;const u=e(i.data);u.success?t(u.data):lt(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({...s,id:r},"*")})}async function $s(s){return Ie(s,e=>ft(e)?{success:!0,data:e.question}:{success:!1})}async function Vs(s){return Ie(s,e=>ht(e)?{success:!0,data:e.group}:{success:!1})}function J(s){return Ie(s,e=>ut(e)?{success:!0,data:void 0}:{success:!1})}exports.busyIndicatorEndRequestMessageSchema=it;exports.busyIndicatorStartRequestMessageSchema=at;exports.getGroup=Is;exports.getGroupRequestMessageSchema=tt;exports.getGroupSuccessResponseMessageSchema=st;exports.getQuestion=Os;exports.getQuestionRequestMessageSchema=Ke;exports.getQuestionSuccessResponseMessageSchema=Fe;exports.groupOptionalScheme=Xe;exports.groupSchema=Ne;exports.isBusyIndicatorEndRequestMessage=mt;exports.isBusyIndicatorStartRequestMessage=pt;exports.isErrorMessage=lt;exports.isGetGroupRequestMessage=Zs;exports.isGetGroupSuccessResponseMessage=ht;exports.isGetQuestionRequestMessage=ws;exports.isGetQuestionSuccessResponseMessage=ft;exports.isOnAnswerChangeMessage=ct;exports.isQpBridgeMessage=dt;exports.isSaveQuestionnaireRequestMessage=Es;exports.isSetAnswerRequestMessage=Ss;exports.isSetGroupRequestMessage=Rs;exports.isSetQuestionRequestMessage=Ts;exports.isSuccessMessage=ut;exports.isWithBusyIndicatorRequestMessage=Cs;exports.onAnswerChange=As;exports.onAnswerChangeMessageSchema=Ye;exports.qpBridgeMessageSchema=R;exports.questionOptionalScheme=Je;exports.questionSchema=Oe;exports.responseErrorMessageSchema=He;exports.responseSuccessMessageSchema=we;exports.saveQuestionnaire=qs;exports.saveQuestionnaireRequestMessageSchema=ot;exports.setAnswer=Ms;exports.setAnswerRequestMessageSchema=rt;exports.setGroup=js;exports.setGroupRequestMessageSchema=nt;exports.setQuestion=Ns;exports.setQuestionRequestMessageSchema=et;exports.withBusyIndicator=Ps;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});let pe;const yt=new Uint8Array(16);function vt(){if(!pe&&(pe=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!pe))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return pe(yt)}const k=[];for(let s=0;s<256;++s)k.push((s+256).toString(16).slice(1));function _t(s,e=0){return k[s[e+0]]+k[s[e+1]]+k[s[e+2]]+k[s[e+3]]+"-"+k[s[e+4]]+k[s[e+5]]+"-"+k[s[e+6]]+k[s[e+7]]+"-"+k[s[e+8]]+k[s[e+9]]+"-"+k[s[e+10]]+k[s[e+11]]+k[s[e+12]]+k[s[e+13]]+k[s[e+14]]+k[s[e+15]]}const xt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),je={randomUUID:xt};function bt(s,e,t){if(je.randomUUID&&!e&&!s)return je.randomUUID();s=s||{};const n=s.random||(s.rng||vt)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,_t(n)}var x;(function(s){s.assertEqual=r=>r;function e(r){}s.assertIs=e;function t(r){throw new Error}s.assertNever=t,s.arrayToEnum=r=>{const a={};for(const i of r)a[i]=i;return a},s.getValidEnumValues=r=>{const a=s.objectKeys(r).filter(o=>typeof r[r[o]]!="number"),i={};for(const o of a)i[o]=r[o];return s.objectValues(i)},s.objectValues=r=>s.objectKeys(r).map(function(a){return r[a]}),s.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},s.find=(r,a)=>{for(const i of r)if(a(i))return i},s.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)}s.joinValues=n,s.jsonStringifyReplacer=(r,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Re;(function(s){s.mergeShapes=(e,t)=>({...e,...t})})(Re||(Re={}));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=s=>{switch(typeof s){case"undefined":return f.undefined;case"string":return f.string;case"number":return isNaN(s)?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(s)?f.array:s===null?f.null:s.then&&typeof s.then=="function"&&s.catch&&typeof s.catch=="function"?f.promise:typeof Map<"u"&&s instanceof Map?f.map:typeof Set<"u"&&s instanceof Set?f.set:typeof Date<"u"&&s 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"]),kt=s=>JSON.stringify(s,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 t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(a){return a.message},n={_errors:[]},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(t(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(t(i))):o[d]=o[d]||{_errors:[]},o=o[d],u++}}};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=t=>t.message){const t={},n=[];for(const r of this.issues)r.path.length>0?(t[r.path[0]]=t[r.path[0]]||[],t[r.path[0]].push(e(r))):n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}R.create=s=>new R(s);const Y=(s,e)=>{let t;switch(s.code){case c.invalid_type:s.received===f.undefined?t="Required":t=`Expected ${s.expected}, received ${s.received}`;break;case c.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(s.expected,x.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(s.keys,", ")}`;break;case c.invalid_union:t="Invalid input";break;case c.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(s.options)}`;break;case c.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(s.options)}, received '${s.received}'`;break;case c.invalid_arguments:t="Invalid function arguments";break;case c.invalid_return_type:t="Invalid function return type";break;case c.invalid_date:t="Invalid date";break;case c.invalid_string:typeof s.validation=="object"?"includes"in s.validation?(t=`Invalid input: must include "${s.validation.includes}"`,typeof s.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${s.validation.position}`)):"startsWith"in s.validation?t=`Invalid input: must start with "${s.validation.startsWith}"`:"endsWith"in s.validation?t=`Invalid input: must end with "${s.validation.endsWith}"`:x.assertNever(s.validation):s.validation!=="regex"?t=`Invalid ${s.validation}`:t="Invalid";break;case c.too_small:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at least":"more than"} ${s.minimum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at least":"over"} ${s.minimum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${s.minimum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly equal to ":s.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(s.minimum))}`:t="Invalid input";break;case c.too_big:s.type==="array"?t=`Array must contain ${s.exact?"exactly":s.inclusive?"at most":"less than"} ${s.maximum} element(s)`:s.type==="string"?t=`String must contain ${s.exact?"exactly":s.inclusive?"at most":"under"} ${s.maximum} character(s)`:s.type==="number"?t=`Number must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="bigint"?t=`BigInt must be ${s.exact?"exactly":s.inclusive?"less than or equal to":"less than"} ${s.maximum}`:s.type==="date"?t=`Date must be ${s.exact?"exactly":s.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(s.maximum))}`:t="Invalid input";break;case c.custom:t="Invalid input";break;case c.invalid_intersection_types:t="Intersection results could not be merged";break;case c.not_multiple_of:t=`Number must be a multiple of ${s.multipleOf}`;break;case c.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(s)}return{message:t}};let $e=Y;function wt(s){$e=s}function me(){return $e}const ge=s=>{const{data:e,path:t,errorMaps:n,issueData:r}=s,a=[...t,...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}},St=[];function l(s,e){const t=me(),n=ge({issueData:e,data:s.data,path:s.path,errorMaps:[s.common.contextualErrorMap,s.schemaErrorMap,t,t===Y?void 0:Y].filter(r=>!!r)});s.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,t){const n=[];for(const r of t){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,t){const n=[];for(const r of t){const a=await r.key,i=await r.value;n.push({key:a,value:i})}return w.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){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=s=>({status:"dirty",value:s}),S=s=>({status:"valid",value:s}),Ze=s=>s.status==="aborted",Ce=s=>s.status==="dirty",F=s=>s.status==="valid",ee=s=>typeof Promise<"u"&&s instanceof Promise;function ye(s,e,t,n){if(typeof e=="function"?s!==e||!n:!e.has(s))throw new TypeError("Cannot read private member from an object whose class did not declare it");return e.get(s)}function Ve(s,e,t,n,r){if(typeof e=="function"?s!==e||!r:!e.has(s))throw new TypeError("Cannot write private member to an object whose class did not declare it");return e.set(s,t),t}var h;(function(s){s.errToObj=e=>typeof e=="string"?{message:e}:e||{},s.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(h||(h={}));var X,K;class N{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,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 qe=(s,e)=>{if(F(e))return{success:!0,data:e.value};if(!s.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new R(s.common.issues);return this._error=t,this._error}}};function y(s){if(!s)return{};const{errorMap:e,invalid_type_error:t,required_error:n,description:r}=s;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:r}:{errorMap:(i,o)=>{var u,d;const{message:g}=s;return i.code==="invalid_enum_value"?{message:g??o.defaultError}:typeof o.data>"u"?{message:(u=g??n)!==null&&u!==void 0?u:o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:(d=g??t)!==null&&d!==void 0?d:o.defaultError}},description:r}}class v{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,t){return t||{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 t=this._parse(e);if(ee(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){var n;const r={common:{issues:[],async:(n=t==null?void 0:t.async)!==null&&n!==void 0?n:!1,contextualErrorMap:t==null?void 0:t.errorMap},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)},a=this._parseSync({data:e,path:r.path,parent:r});return qe(r,a)}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t==null?void 0:t.errorMap,async:!0},path:(t==null?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:q(e)},r=this._parse({data:e,path:n.path,parent:n}),a=await(ee(r)?r:Promise.resolve(r));return qe(n,a)}refine(e,t){const n=r=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(r):t;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,t){return this._refinement((n,r)=>e(n)?!0:(r.addIssue(typeof t=="function"?t(n,r):t),!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 M.create(this,this._def)}promise(){return J.create(this,this._def)}or(e){return re.create([this,e],this._def)}and(e){return ae.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 t=typeof e=="function"?e:()=>e;return new ue({...y(this._def),innerType:this,defaultValue:t,typeName:p.ZodDefault})}brand(){return new Ee({typeName:p.ZodBranded,type:this,...y(this._def)})}catch(e){const t=typeof e=="function"?e:()=>e;return new le({...y(this._def),innerType:this,catchValue:t,typeName:p.ZodCatch})}describe(e){const t=this.constructor;return new t({...this._def,description:e})}pipe(e){return he.create(this,e)}readonly(){return fe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Tt=/^c[^\s-]{8,}$/i,Rt=/^[0-9a-z]+$/,Zt=/^[0-9A-HJKMNP-TV-Z]{26}$/,Ct=/^[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,Mt=/^[a-z0-9_-]{21}$/i,Et=/^[-+]?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)?)??$/,Ot=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,Nt="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Te;const It=/^(?:(?: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])$/,At=/^(([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})))$/,jt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,De="((\\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])))",qt=new RegExp(`^${De}$`);function Le(s){let e="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return s.precision?e=`${e}\\.\\d{${s.precision}}`:s.precision==null&&(e=`${e}(\\.\\d+)?`),e}function Pt(s){return new RegExp(`^${Le(s)}$`)}function Ue(s){let e=`${De}T${Le(s)}`;const t=[];return t.push(s.local?"Z?":"Z"),s.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function $t(s,e){return!!((e==="v4"||!e)&&It.test(s)||(e==="v6"||!e)&&At.test(s))}class C extends v{_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")Ot.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")Te||(Te=new RegExp(Nt,"u")),Te.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")Ct.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")Mt.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")Tt.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")Rt.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")Zt.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"?Ue(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"?qt.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{code:c.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Pt(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"?Et.test(e.data)||(r=this._getOrReturnCtx(e,r),l(r,{validation:"duration",code:c.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?$t(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"?jt.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,t,n){return this.refinement(r=>e.test(r),{validation:t,code:c.invalid_string,...h.errToObj(n)})}_addCheck(e){return new C({...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 t,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:(t=e==null?void 0:e.offset)!==null&&t!==void 0?t:!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,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t==null?void 0:t.position,...h.errToObj(t==null?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new C({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new C({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new C({...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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}C.create=s=>{var e;return new C({checks:[],typeName:p.ZodString,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...y(s)})};function Vt(s,e){const t=(s.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,r=t>n?t:n,a=parseInt(s.toFixed(r).replace(".","")),i=parseInt(e.toFixed(r).replace(".",""));return a%i/Math.pow(10,r)}class P extends v{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"?Vt(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,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,n,r){return new P({...this._def,checks:[...this._def.checks,{kind:e,value:t,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,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}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 t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}P.create=s=>new P({checks:[],typeName:p.ZodNumber,coerce:(s==null?void 0:s.coerce)||!1,...y(s)});class $ extends v{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,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,n,r){return new $({...this._def,checks:[...this._def.checks,{kind:e,value:t,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,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}}$.create=s=>{var e;return new $({checks:[],typeName:p.ZodBigInt,coerce:(e=s==null?void 0:s.coerce)!==null&&e!==void 0?e:!1,...y(s)})};class te extends v{_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 S(e.data)}}te.create=s=>new te({typeName:p.ZodBoolean,coerce:(s==null?void 0:s.coerce)||!1,...y(s)});class U extends v{_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 U({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}}U.create=s=>new U({checks:[],coerce:(s==null?void 0:s.coerce)||!1,typeName:p.ZodDate,...y(s)});class ve extends v{_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 S(e.data)}}ve.create=s=>new ve({typeName:p.ZodSymbol,...y(s)});class se extends v{_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 S(e.data)}}se.create=s=>new se({typeName:p.ZodUndefined,...y(s)});class ne extends v{_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 S(e.data)}}ne.create=s=>new ne({typeName:p.ZodNull,...y(s)});class H extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return S(e.data)}}H.create=s=>new H({typeName:p.ZodAny,...y(s)});class L extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return S(e.data)}}L.create=s=>new L({typeName:p.ZodUnknown,...y(s)});class j extends v{_parse(e){const t=this._getOrReturnCtx(e);return l(t,{code:c.invalid_type,expected:f.never,received:t.parsedType}),m}}j.create=s=>new j({typeName:p.ZodNever,...y(s)});class _e extends v{_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 S(e.data)}}_e.create=s=>new _e({typeName:p.ZodVoid,...y(s)});class M extends v{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==f.array)return l(t,{code:c.invalid_type,expected:f.array,received:t.parsedType}),m;if(r.exactLength!==null){const i=t.data.length>r.exactLength.value,o=t.data.length<r.exactLength.value;(i||o)&&(l(t,{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&&t.data.length<r.minLength.value&&(l(t,{code:c.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),r.maxLength!==null&&t.data.length>r.maxLength.value&&(l(t,{code:c.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>r.type._parseAsync(new N(t,i,t.path,o)))).then(i=>w.mergeArray(n,i));const a=[...t.data].map((i,o)=>r.type._parseSync(new N(t,i,t.path,o)));return w.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new M({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new M({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new M({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}}M.create=(s,e)=>new M({type:s,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...y(e)});function Q(s){if(s instanceof b){const e={};for(const t in s.shape){const n=s.shape[t];e[t]=O.create(Q(n))}return new b({...s._def,shape:()=>e})}else return s instanceof M?new M({...s._def,type:Q(s.element)}):s instanceof O?O.create(Q(s.unwrap())):s instanceof D?D.create(Q(s.unwrap())):s instanceof I?I.create(s.items.map(e=>Q(e))):s}class b extends v{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t}}_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}),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 d in r.data)i.includes(d)||o.push(d);const u=[];for(const d of i){const g=a[d],Z=r.data[d];u.push({key:{status:"valid",value:d},value:g._parse(new N(r,Z,r.path,d)),alwaysSet:d in r.data})}if(this._def.catchall instanceof j){const d=this._def.unknownKeys;if(d==="passthrough")for(const g of o)u.push({key:{status:"valid",value:g},value:{status:"valid",value:r.data[g]}});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 g of o){const Z=r.data[g];u.push({key:{status:"valid",value:g},value:d._parse(new N(r,Z,r.path,g)),alwaysSet:g in r.data})}}return r.common.async?Promise.resolve().then(async()=>{const d=[];for(const g of u){const Z=await g.key,Ae=await g.value;d.push({key:Z,value:Ae,alwaysSet:g.alwaysSet})}return d}).then(d=>w.mergeObjectSync(n,d)):w.mergeObjectSync(n,u)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new b({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{var r,a,i,o;const u=(i=(a=(r=this._def).errorMap)===null||a===void 0?void 0:a.call(r,t,n).message)!==null&&i!==void 0?i:n.defaultError;return t.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,t){return this.augment({[e]:t})}catchall(e){return new b({...this._def,catchall:e})}pick(e){const t={};return x.objectKeys(e).forEach(n=>{e[n]&&this.shape[n]&&(t[n]=this.shape[n])}),new b({...this._def,shape:()=>t})}omit(e){const t={};return x.objectKeys(this.shape).forEach(n=>{e[n]||(t[n]=this.shape[n])}),new b({...this._def,shape:()=>t})}deepPartial(){return Q(this)}partial(e){const t={};return x.objectKeys(this.shape).forEach(n=>{const r=this.shape[n];e&&!e[n]?t[n]=r:t[n]=r.optional()}),new b({...this._def,shape:()=>t})}required(e){const t={};return x.objectKeys(this.shape).forEach(n=>{if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof O;)a=a._def.innerType;t[n]=a}}),new b({...this._def,shape:()=>t})}keyof(){return ze(x.objectKeys(this.shape))}}b.create=(s,e)=>new b({shape:()=>s,unknownKeys:"strip",catchall:j.create(),typeName:p.ZodObject,...y(e)});b.strictCreate=(s,e)=>new b({shape:()=>s,unknownKeys:"strict",catchall:j.create(),typeName:p.ZodObject,...y(e)});b.lazycreate=(s,e)=>new b({shape:s,unknownKeys:"strip",catchall:j.create(),typeName:p.ZodObject,...y(e)});class re extends v{_parse(e){const{ctx:t}=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 t.common.issues.push(...o.ctx.common.issues),o.result;const i=a.map(o=>new R(o.ctx.common.issues));return l(t,{code:c.invalid_union,unionErrors:i}),m}if(t.common.async)return Promise.all(n.map(async a=>{const i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(r);{let a;const i=[];for(const u of n){const d={...t,common:{...t.common,issues:[]},parent:null},g=u._parseSync({data:t.data,path:t.path,parent:d});if(g.status==="valid")return g;g.status==="dirty"&&!a&&(a={result:g,ctx:d}),d.common.issues.length&&i.push(d.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;const o=i.map(u=>new R(u));return l(t,{code:c.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}re.create=(s,e)=>new re({options:s,typeName:p.ZodUnion,...y(e)});const A=s=>s instanceof oe?A(s.schema):s instanceof E?A(s.innerType()):s instanceof ce?[s.value]:s instanceof V?s.options:s instanceof de?x.objectValues(s.enum):s instanceof ue?A(s._def.innerType):s instanceof se?[void 0]:s instanceof ne?[null]:s instanceof O?[void 0,...A(s.unwrap())]:s instanceof D?[null,...A(s.unwrap())]:s instanceof Ee||s instanceof fe?A(s.unwrap()):s instanceof le?A(s._def.innerType):[];class ke extends v{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return l(t,{code:c.invalid_type,expected:f.object,received:t.parsedType}),m;const n=this.discriminator,r=t.data[n],a=this.optionsMap.get(r);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(l(t,{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,t,n){const r=new Map;for(const a of t){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 ke({typeName:p.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:r,...y(n)})}}function Me(s,e){const t=q(s),n=q(e);if(s===e)return{valid:!0,data:s};if(t===f.object&&n===f.object){const r=x.objectKeys(e),a=x.objectKeys(s).filter(o=>r.indexOf(o)!==-1),i={...s,...e};for(const o of a){const u=Me(s[o],e[o]);if(!u.valid)return{valid:!1};i[o]=u.data}return{valid:!0,data:i}}else if(t===f.array&&n===f.array){if(s.length!==e.length)return{valid:!1};const r=[];for(let a=0;a<s.length;a++){const i=s[a],o=e[a],u=Me(i,o);if(!u.valid)return{valid:!1};r.push(u.data)}return{valid:!0,data:r}}else return t===f.date&&n===f.date&&+s==+e?{valid:!0,data:s}:{valid:!1}}class ae extends v{_parse(e){const{status:t,ctx:n}=this._processInputParams(e),r=(a,i)=>{if(Ze(a)||Ze(i))return m;const o=Me(a.value,i.value);return o.valid?((Ce(a)||Ce(i))&&t.dirty(),{status:t.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}))}}ae.create=(s,e,t)=>new ae({left:s,right:e,typeName:p.ZodIntersection,...y(t)});class I extends v{_parse(e){const{status:t,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"}),t.dirty());const a=[...n.data].map((i,o)=>{const u=this._def.items[o]||this._def.rest;return u?u._parse(new N(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>w.mergeArray(t,i)):w.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new I({...this._def,rest:e})}}I.create=(s,e)=>{if(!Array.isArray(s))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new I({items:s,typeName:p.ZodTuple,rest:null,...y(e)})};class ie extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==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(t,r):w.mergeObjectSync(t,r)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof v?new ie({keyType:e,valueType:t,typeName:p.ZodRecord,...y(n)}):new ie({keyType:C.create(),valueType:e,typeName:p.ZodRecord,...y(t)})}}class xe extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==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,u],d)=>({key:r._parse(new N(n,o,n.path,[d,"key"])),value:a._parse(new N(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,g=await u.value;if(d.status==="aborted"||g.status==="aborted")return m;(d.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(d.value,g.value)}return{status:t.value,value:o}})}else{const o=new Map;for(const u of i){const d=u.key,g=u.value;if(d.status==="aborted"||g.status==="aborted")return m;(d.status==="dirty"||g.status==="dirty")&&t.dirty(),o.set(d.value,g.value)}return{status:t.value,value:o}}}}xe.create=(s,e,t)=>new xe({valueType:e,keyType:s,typeName:p.ZodMap,...y(t)});class z extends v{_parse(e){const{status:t,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}),t.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}),t.dirty());const a=this._def.valueType;function i(u){const d=new Set;for(const g of u){if(g.status==="aborted")return m;g.status==="dirty"&&t.dirty(),d.add(g.value)}return{status:t.value,value:d}}const o=[...n.data.values()].map((u,d)=>a._parse(new N(n,u,n.path,d)));return n.common.async?Promise.all(o).then(u=>i(u)):i(o)}min(e,t){return new z({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new z({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}}z.create=(s,e)=>new z({valueType:s,minSize:null,maxSize:null,typeName:p.ZodSet,...y(e)});class W extends v{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return l(t,{code:c.invalid_type,expected:f.function,received:t.parsedType}),m;function n(o,u){return ge({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,me(),Y].filter(d=>!!d),issueData:{code:c.invalid_arguments,argumentsError:u}})}function r(o,u){return ge({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,me(),Y].filter(d=>!!d),issueData:{code:c.invalid_return_type,returnTypeError:u}})}const a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof J){const o=this;return S(async function(...u){const d=new R([]),g=await o._def.args.parseAsync(u,a).catch(Se=>{throw d.addIssue(n(u,Se)),d}),Z=await Reflect.apply(i,this,g);return await o._def.returns._def.type.parseAsync(Z,a).catch(Se=>{throw d.addIssue(r(Z,Se)),d})})}else{const o=this;return S(function(...u){const d=o._def.args.safeParse(u,a);if(!d.success)throw new R([n(u,d.error)]);const g=Reflect.apply(i,this,d.data),Z=o._def.returns.safeParse(g,a);if(!Z.success)throw new R([r(g,Z.error)]);return Z.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new W({...this._def,args:I.create(e).rest(L.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,t,n){return new W({args:e||I.create([]).rest(L.create()),returns:t||L.create(),typeName:p.ZodFunction,...y(n)})}}class oe extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}}oe.create=(s,e)=>new oe({getter:s,typeName:p.ZodLazy,...y(e)});class ce extends v{_parse(e){if(e.data!==this._def.value){const t=this._getOrReturnCtx(e);return l(t,{received:t.data,code:c.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}ce.create=(s,e)=>new ce({value:s,typeName:p.ZodLiteral,...y(e)});function ze(s,e){return new V({values:s,typeName:p.ZodEnum,...y(e)})}class V extends v{constructor(){super(...arguments),X.set(this,void 0)}_parse(e){if(typeof e.data!="string"){const t=this._getOrReturnCtx(e),n=this._def.values;return l(t,{expected:x.joinValues(n),received:t.parsedType,code:c.invalid_type}),m}if(ye(this,X)||Ve(this,X,new Set(this._def.values)),!ye(this,X).has(e.data)){const t=this._getOrReturnCtx(e),n=this._def.values;return l(t,{received:t.data,code:c.invalid_enum_value,options:n}),m}return S(e.data)}get options(){return this._def.values}get enum(){const e={};for(const t of this._def.values)e[t]=t;return e}get Values(){const e={};for(const t of this._def.values)e[t]=t;return e}get Enum(){const e={};for(const t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return V.create(e,{...this._def,...t})}exclude(e,t=this._def){return V.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}}X=new WeakMap;V.create=ze;class de extends v{constructor(){super(...arguments),K.set(this,void 0)}_parse(e){const t=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){const r=x.objectValues(t);return l(n,{expected:x.joinValues(r),received:n.parsedType,code:c.invalid_type}),m}if(ye(this,K)||Ve(this,K,new Set(x.getValidEnumValues(this._def.values))),!ye(this,K).has(e.data)){const r=x.objectValues(t);return l(n,{received:n.data,code:c.invalid_enum_value,options:r}),m}return S(e.data)}get enum(){return this._def.values}}K=new WeakMap;de.create=(s,e)=>new de({values:s,typeName:p.ZodNativeEnum,...y(e)});class J extends v{unwrap(){return this._def.type}_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return l(t,{code:c.invalid_type,expected:f.promise,received:t.parsedType}),m;const n=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return S(n.then(r=>this._def.type.parseAsync(r,{path:t.path,errorMap:t.common.contextualErrorMap})))}}J.create=(s,e)=>new J({type:s,typeName:p.ZodPromise,...y(e)});class E extends v{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:t,ctx:n}=this._processInputParams(e),r=this._def.effect||null,a={addIssue:i=>{l(n,i),i.fatal?t.abort():t.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(t.value==="aborted")return m;const u=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return u.status==="aborted"?m:u.status==="dirty"||t.value==="dirty"?G(u.value):u});{if(t.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"||t.value==="dirty"?G(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"?m:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.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(!F(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:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>F(i)?Promise.resolve(r.transform(i.value,a)).then(o=>({status:t.value,value:o})):i);x.assertNever(r)}}E.create=(s,e,t)=>new E({schema:s,typeName:p.ZodEffects,effect:e,...y(t)});E.createWithPreprocess=(s,e,t)=>new E({schema:e,effect:{type:"preprocess",transform:s},typeName:p.ZodEffects,...y(t)});class O extends v{_parse(e){return this._getType(e)===f.undefined?S(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}O.create=(s,e)=>new O({innerType:s,typeName:p.ZodOptional,...y(e)});class D extends v{_parse(e){return this._getType(e)===f.null?S(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}D.create=(s,e)=>new D({innerType:s,typeName:p.ZodNullable,...y(e)});class ue extends v{_parse(e){const{ctx:t}=this._processInputParams(e);let n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}}ue.create=(s,e)=>new ue({innerType:s,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class le extends v{_parse(e){const{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},r=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return ee(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}}le.create=(s,e)=>new le({innerType:s,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class be extends v{_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}}}be.create=s=>new be({typeName:p.ZodNaN,...y(s)});const Dt=Symbol("zod_brand");class Ee extends v{_parse(e){const{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}}class he extends v{_parse(e){const{status:t,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"?(t.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"?(t.dirty(),{status:"dirty",value:r.value}):this._def.out._parseSync({data:r.value,path:n.path,parent:n})}}static create(e,t){return new he({in:e,out:t,typeName:p.ZodPipeline})}}class fe extends v{_parse(e){const t=this._def.innerType._parse(e),n=r=>(F(r)&&(r.value=Object.freeze(r.value)),r);return ee(t)?t.then(r=>n(r)):n(t)}unwrap(){return this._def.innerType}}fe.create=(s,e)=>new fe({innerType:s,typeName:p.ZodReadonly,...y(e)});function Be(s,e={},t){return s?H.create().superRefine((n,r)=>{var a,i;if(!s(n)){const o=typeof e=="function"?e(n):typeof e=="string"?{message:e}:e,u=(i=(a=o.fatal)!==null&&a!==void 0?a:t)!==null&&i!==void 0?i:!0,d=typeof o=="string"?{message:o}:o;r.addIssue({code:"custom",...d,fatal:u})}}):H.create()}const Lt={object:b.lazycreate};var p;(function(s){s.ZodString="ZodString",s.ZodNumber="ZodNumber",s.ZodNaN="ZodNaN",s.ZodBigInt="ZodBigInt",s.ZodBoolean="ZodBoolean",s.ZodDate="ZodDate",s.ZodSymbol="ZodSymbol",s.ZodUndefined="ZodUndefined",s.ZodNull="ZodNull",s.ZodAny="ZodAny",s.ZodUnknown="ZodUnknown",s.ZodNever="ZodNever",s.ZodVoid="ZodVoid",s.ZodArray="ZodArray",s.ZodObject="ZodObject",s.ZodUnion="ZodUnion",s.ZodDiscriminatedUnion="ZodDiscriminatedUnion",s.ZodIntersection="ZodIntersection",s.ZodTuple="ZodTuple",s.ZodRecord="ZodRecord",s.ZodMap="ZodMap",s.ZodSet="ZodSet",s.ZodFunction="ZodFunction",s.ZodLazy="ZodLazy",s.ZodLiteral="ZodLiteral",s.ZodEnum="ZodEnum",s.ZodEffects="ZodEffects",s.ZodNativeEnum="ZodNativeEnum",s.ZodOptional="ZodOptional",s.ZodNullable="ZodNullable",s.ZodDefault="ZodDefault",s.ZodCatch="ZodCatch",s.ZodPromise="ZodPromise",s.ZodBranded="ZodBranded",s.ZodPipeline="ZodPipeline",s.ZodReadonly="ZodReadonly"})(p||(p={}));const Ut=(s,e={message:`Input not instance of ${s.name}`})=>Be(t=>t instanceof s,e),Qe=C.create,Ge=P.create,zt=be.create,Bt=$.create,We=te.create,Qt=U.create,Gt=ve.create,Wt=se.create,Yt=ne.create,Ht=H.create,Jt=L.create,Xt=j.create,Kt=_e.create,Ft=M.create,es=b.create,ts=b.strictCreate,ss=re.create,ns=ke.create,rs=ae.create,as=I.create,is=ie.create,os=xe.create,cs=z.create,ds=W.create,us=oe.create,ls=ce.create,fs=V.create,hs=de.create,ps=J.create,Pe=E.create,ms=O.create,gs=D.create,ys=E.createWithPreprocess,vs=he.create,_s=()=>Qe().optional(),xs=()=>Ge().optional(),bs=()=>We().optional(),ks={string:s=>C.create({...s,coerce:!0}),number:s=>P.create({...s,coerce:!0}),boolean:s=>te.create({...s,coerce:!0}),bigint:s=>$.create({...s,coerce:!0}),date:s=>U.create({...s,coerce:!0})},ws=m;var _=Object.freeze({__proto__:null,defaultErrorMap:Y,setErrorMap:wt,getErrorMap:me,makeIssue:ge,EMPTY_PATH:St,addIssueToContext:l,ParseStatus:w,INVALID:m,DIRTY:G,OK:S,isAborted:Ze,isDirty:Ce,isValid:F,isAsync:ee,get util(){return x},get objectUtil(){return Re},ZodParsedType:f,getParsedType:q,ZodType:v,datetimeRegex:Ue,ZodString:C,ZodNumber:P,ZodBigInt:$,ZodBoolean:te,ZodDate:U,ZodSymbol:ve,ZodUndefined:se,ZodNull:ne,ZodAny:H,ZodUnknown:L,ZodNever:j,ZodVoid:_e,ZodArray:M,ZodObject:b,ZodUnion:re,ZodDiscriminatedUnion:ke,ZodIntersection:ae,ZodTuple:I,ZodRecord:ie,ZodMap:xe,ZodSet:z,ZodFunction:W,ZodLazy:oe,ZodLiteral:ce,ZodEnum:V,ZodNativeEnum:de,ZodPromise:J,ZodEffects:E,ZodTransformer:E,ZodOptional:O,ZodNullable:D,ZodDefault:ue,ZodCatch:le,ZodNaN:be,BRAND:Dt,ZodBranded:Ee,ZodPipeline:he,ZodReadonly:fe,custom:Be,Schema:v,ZodSchema:v,late:Lt,get ZodFirstPartyTypeKind(){return p},coerce:ks,any:Ht,array:Ft,bigint:Bt,boolean:We,date:Qt,discriminatedUnion:ns,effect:Pe,enum:fs,function:ds,instanceof:Ut,intersection:rs,lazy:us,literal:ls,map:os,nan:zt,nativeEnum:hs,never:Xt,null:Yt,nullable:gs,number:Ge,object:es,oboolean:bs,onumber:xs,optional:ms,ostring:_s,pipeline:vs,preprocess:ys,promise:ps,record:is,set:cs,strictObject:ts,string:Qe,symbol:Gt,transformer:Pe,tuple:as,undefined:Wt,union:ss,unknown:Jt,void:Kt,NEVER:ws,ZodIssueCode:c,quotelessJson:kt,ZodError:R});const T=_.object({type:_.literal("qp-bridge"),id:_.string().optional()}),Ye=T.extend({status:_.literal("answerChanged"),question:_.string(),answer:_.unknown()}),we=T.extend({status:_.literal("success")}),He=T.extend({status:_.literal("error"),message:_.string()}),Oe=_.object({semanticColor:_.string().optional(),label:_.string(),description:_.string(),disabled:_.boolean(),required:_.boolean(),hidden:_.boolean()}),Je=Oe.partial(),Ne=_.object({label:_.string(),hidden:_.boolean(),collapsed:_.boolean()}),Xe=Ne.partial(),Ke=T.extend({action:_.literal("getQuestion"),question:_.string()}),Fe=we.extend({question:Oe}),et=T.extend({action:_.literal("setQuestion"),question:_.string(),questionData:Je}),tt=T.extend({action:_.literal("getGroup"),group:_.string()}),st=we.extend({group:Ne}),nt=T.extend({action:_.literal("setGroup"),group:_.string(),groupData:Xe}),rt=T.extend({action:_.literal("setAnswer"),question:_.string(),answer:_.unknown()}),at=T.extend({action:_.literal("busyIndicatorStart")}),it=T.extend({action:_.literal("busyIndicatorEnd")}),ot=T.extend({action:_.literal("saveQuestionnaire")}),ct=T.extend({action:_.literal("completeAndCloseQuestionnaire")});function dt(s){return Ye.safeParse(s).success}function ut(s){return T.safeParse(s).success}function lt(s){return we.safeParse(s).success}function ft(s){return He.safeParse(s).success}function Ss(s){return Ke.safeParse(s).success}function ht(s){return Fe.safeParse(s).success}function Ts(s){return rt.safeParse(s).success}function Rs(s){return et.safeParse(s).success}function Zs(s){return nt.safeParse(s).success}function Cs(s){return tt.safeParse(s).success}function pt(s){return st.safeParse(s).success}function mt(s){return at.safeParse(s).success}function gt(s){return it.safeParse(s).success}function Ms(s){return ot.safeParse(s).success}function Es(s){return ct.safeParse(s).success}function Os(s){return mt(s)||gt(s)}async function Ns(s,e){await B({type:"qp-bridge",action:"setAnswer",question:s,answer:e})}async function Is(s){return await Ls({type:"qp-bridge",action:"getQuestion",question:s})}async function As(s,e){await B({type:"qp-bridge",action:"setQuestion",question:s,questionData:e})}async function js(s){return await Us({type:"qp-bridge",action:"getGroup",group:s})}async function qs(s,e){await B({type:"qp-bridge",action:"setGroup",group:s,groupData:e})}function Ps(s){const e=t=>{dt(t.data)&&s(t.data.question,t.data.answer)};return window.addEventListener("message",e),{cancelSubscription:()=>{window.removeEventListener("message",e)}}}async function $s(s){await B({type:"qp-bridge",action:"busyIndicatorStart"});try{return await s()}finally{await B({type:"qp-bridge",action:"busyIndicatorEnd"})}}async function Vs(){await B({type:"qp-bridge",action:"saveQuestionnaire"})}async function Ds(){await B({type:"qp-bridge",action:"completeAndCloseQuestionnaire"})}async function Ie(s,e){return new Promise((t,n)=>{const r=bt(),a=i=>{if(!ut(i.data)||i.data.id!==r)return;const u=e(i.data);u.success?t(u.data):ft(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({...s,id:r},"*")})}async function Ls(s){return Ie(s,e=>ht(e)?{success:!0,data:e.question}:{success:!1})}async function Us(s){return Ie(s,e=>pt(e)?{success:!0,data:e.group}:{success:!1})}function B(s){return Ie(s,e=>lt(e)?{success:!0,data:void 0}:{success:!1})}exports.busyIndicatorEndRequestMessageSchema=it;exports.busyIndicatorStartRequestMessageSchema=at;exports.completeAndCloseQuestionnaire=Ds;exports.completeAndCloseQuestionnaireRequestMessageSchema=ct;exports.getGroup=js;exports.getGroupRequestMessageSchema=tt;exports.getGroupSuccessResponseMessageSchema=st;exports.getQuestion=Is;exports.getQuestionRequestMessageSchema=Ke;exports.getQuestionSuccessResponseMessageSchema=Fe;exports.groupOptionalScheme=Xe;exports.groupSchema=Ne;exports.isBusyIndicatorEndRequestMessage=gt;exports.isBusyIndicatorStartRequestMessage=mt;exports.isCompleteAndCloseQuestionnaireRequestMessage=Es;exports.isErrorMessage=ft;exports.isGetGroupRequestMessage=Cs;exports.isGetGroupSuccessResponseMessage=pt;exports.isGetQuestionRequestMessage=Ss;exports.isGetQuestionSuccessResponseMessage=ht;exports.isOnAnswerChangeMessage=dt;exports.isQpBridgeMessage=ut;exports.isSaveQuestionnaireRequestMessage=Ms;exports.isSetAnswerRequestMessage=Ts;exports.isSetGroupRequestMessage=Zs;exports.isSetQuestionRequestMessage=Rs;exports.isSuccessMessage=lt;exports.isWithBusyIndicatorRequestMessage=Os;exports.onAnswerChange=Ps;exports.onAnswerChangeMessageSchema=Ye;exports.qpBridgeMessageSchema=T;exports.questionOptionalScheme=Je;exports.questionSchema=Oe;exports.responseErrorMessageSchema=He;exports.responseSuccessMessageSchema=we;exports.saveQuestionnaire=Vs;exports.saveQuestionnaireRequestMessageSchema=ot;exports.setAnswer=Ns;exports.setAnswerRequestMessageSchema=rt;exports.setGroup=qs;exports.setGroupRequestMessageSchema=nt;exports.setQuestion=As;exports.setQuestionRequestMessageSchema=et;exports.withBusyIndicator=$s;
package/index.mjs CHANGED
@@ -185,7 +185,7 @@ class S extends Error {
185
185
  }
186
186
  }
187
187
  S.create = (s) => new S(s);
188
- const Q = (s, e) => {
188
+ const Y = (s, e) => {
189
189
  let t;
190
190
  switch (s.code) {
191
191
  case c.invalid_type:
@@ -241,7 +241,7 @@ const Q = (s, e) => {
241
241
  }
242
242
  return { message: t };
243
243
  };
244
- let Pe = Q;
244
+ let Pe = Y;
245
245
  function et(s) {
246
246
  Pe = s;
247
247
  }
@@ -278,7 +278,7 @@ function l(s, e) {
278
278
  s.common.contextualErrorMap,
279
279
  s.schemaErrorMap,
280
280
  t,
281
- t === Q ? void 0 : Q
281
+ t === Y ? void 0 : Y
282
282
  // then global default map
283
283
  ].filter((r) => !!r)
284
284
  });
@@ -327,7 +327,7 @@ class w {
327
327
  }
328
328
  const m = Object.freeze({
329
329
  status: "aborted"
330
- }), G = (s) => ({ status: "dirty", value: s }), T = (s) => ({ status: "valid", value: s }), Ze = (s) => s.status === "aborted", Re = (s) => s.status === "dirty", F = (s) => s.status === "valid", ee = (s) => typeof Promise < "u" && s instanceof Promise;
330
+ }), G = (s) => ({ status: "dirty", value: s }), T = (s) => ({ status: "valid", value: s }), Ze = (s) => s.status === "aborted", Ce = (s) => s.status === "dirty", F = (s) => s.status === "valid", ee = (s) => typeof Promise < "u" && s instanceof Promise;
331
331
  function ye(s, e, t, n) {
332
332
  if (typeof e == "function" ? s !== e || !n : !e.has(s))
333
333
  throw new TypeError("Cannot read private member from an object whose class did not declare it");
@@ -500,7 +500,7 @@ class v {
500
500
  return E.create(this, this._def);
501
501
  }
502
502
  promise() {
503
- return H.create(this, this._def);
503
+ return J.create(this, this._def);
504
504
  }
505
505
  or(e) {
506
506
  return re.create([this, e], this._def);
@@ -579,7 +579,7 @@ function De(s) {
579
579
  function mt(s, e) {
580
580
  return !!((e === "v4" || !e) && ut.test(s) || (e === "v6" || !e) && lt.test(s));
581
581
  }
582
- class C extends v {
582
+ class R extends v {
583
583
  _parse(e) {
584
584
  if (this._def.coerce && (e.data = String(e.data)), this._getType(e) !== f.string) {
585
585
  const a = this._getOrReturnCtx(e);
@@ -731,7 +731,7 @@ class C extends v {
731
731
  });
732
732
  }
733
733
  _addCheck(e) {
734
- return new C({
734
+ return new R({
735
735
  ...this._def,
736
736
  checks: [...this._def.checks, e]
737
737
  });
@@ -857,19 +857,19 @@ class C extends v {
857
857
  return this.min(1, h.errToObj(e));
858
858
  }
859
859
  trim() {
860
- return new C({
860
+ return new R({
861
861
  ...this._def,
862
862
  checks: [...this._def.checks, { kind: "trim" }]
863
863
  });
864
864
  }
865
865
  toLowerCase() {
866
- return new C({
866
+ return new R({
867
867
  ...this._def,
868
868
  checks: [...this._def.checks, { kind: "toLowerCase" }]
869
869
  });
870
870
  }
871
871
  toUpperCase() {
872
- return new C({
872
+ return new R({
873
873
  ...this._def,
874
874
  checks: [...this._def.checks, { kind: "toUpperCase" }]
875
875
  });
@@ -929,9 +929,9 @@ class C extends v {
929
929
  return e;
930
930
  }
931
931
  }
932
- C.create = (s) => {
932
+ R.create = (s) => {
933
933
  var e;
934
- return new C({
934
+ return new R({
935
935
  checks: [],
936
936
  typeName: p.ZodString,
937
937
  coerce: (e = s == null ? void 0 : s.coerce) !== null && e !== void 0 ? e : !1,
@@ -1389,7 +1389,7 @@ ne.create = (s) => new ne({
1389
1389
  typeName: p.ZodNull,
1390
1390
  ...y(s)
1391
1391
  });
1392
- class Y extends v {
1392
+ class H extends v {
1393
1393
  constructor() {
1394
1394
  super(...arguments), this._any = !0;
1395
1395
  }
@@ -1397,7 +1397,7 @@ class Y extends v {
1397
1397
  return T(e.data);
1398
1398
  }
1399
1399
  }
1400
- Y.create = (s) => new Y({
1400
+ H.create = (s) => new H({
1401
1401
  typeName: p.ZodAny,
1402
1402
  ...y(s)
1403
1403
  });
@@ -1517,12 +1517,12 @@ E.create = (s, e) => new E({
1517
1517
  typeName: p.ZodArray,
1518
1518
  ...y(e)
1519
1519
  });
1520
- function B(s) {
1520
+ function Q(s) {
1521
1521
  if (s instanceof b) {
1522
1522
  const e = {};
1523
1523
  for (const t in s.shape) {
1524
1524
  const n = s.shape[t];
1525
- e[t] = O.create(B(n));
1525
+ e[t] = O.create(Q(n));
1526
1526
  }
1527
1527
  return new b({
1528
1528
  ...s._def,
@@ -1531,8 +1531,8 @@ function B(s) {
1531
1531
  } else
1532
1532
  return s instanceof E ? new E({
1533
1533
  ...s._def,
1534
- type: B(s.element)
1535
- }) : s instanceof O ? O.create(B(s.unwrap())) : s instanceof D ? D.create(B(s.unwrap())) : s instanceof M ? M.create(s.items.map((e) => B(e))) : s;
1534
+ type: Q(s.element)
1535
+ }) : s instanceof O ? O.create(Q(s.unwrap())) : s instanceof D ? D.create(Q(s.unwrap())) : s instanceof M ? M.create(s.items.map((e) => Q(e))) : s;
1536
1536
  }
1537
1537
  class b extends v {
1538
1538
  constructor() {
@@ -1559,10 +1559,10 @@ class b extends v {
1559
1559
  i.includes(d) || o.push(d);
1560
1560
  const u = [];
1561
1561
  for (const d of i) {
1562
- const g = a[d], Z = r.data[d];
1562
+ const g = a[d], C = r.data[d];
1563
1563
  u.push({
1564
1564
  key: { status: "valid", value: d },
1565
- value: g._parse(new I(r, Z, r.path, d)),
1565
+ value: g._parse(new I(r, C, r.path, d)),
1566
1566
  alwaysSet: d in r.data
1567
1567
  });
1568
1568
  }
@@ -1584,11 +1584,11 @@ class b extends v {
1584
1584
  } else {
1585
1585
  const d = this._def.catchall;
1586
1586
  for (const g of o) {
1587
- const Z = r.data[g];
1587
+ const C = r.data[g];
1588
1588
  u.push({
1589
1589
  key: { status: "valid", value: g },
1590
1590
  value: d._parse(
1591
- new I(r, Z, r.path, g)
1591
+ new I(r, C, r.path, g)
1592
1592
  //, ctx.child(key), value, getParsedType(value)
1593
1593
  ),
1594
1594
  alwaysSet: g in r.data
@@ -1598,9 +1598,9 @@ class b extends v {
1598
1598
  return r.common.async ? Promise.resolve().then(async () => {
1599
1599
  const d = [];
1600
1600
  for (const g of u) {
1601
- const Z = await g.key, Ie = await g.value;
1601
+ const C = await g.key, Ie = await g.value;
1602
1602
  d.push({
1603
- key: Z,
1603
+ key: C,
1604
1604
  value: Ie,
1605
1605
  alwaysSet: g.alwaysSet
1606
1606
  });
@@ -1769,7 +1769,7 @@ class b extends v {
1769
1769
  * @deprecated
1770
1770
  */
1771
1771
  deepPartial() {
1772
- return B(this);
1772
+ return Q(this);
1773
1773
  }
1774
1774
  partial(e) {
1775
1775
  const t = {};
@@ -1958,14 +1958,14 @@ class ke extends v {
1958
1958
  });
1959
1959
  }
1960
1960
  }
1961
- function Ce(s, e) {
1961
+ function Re(s, e) {
1962
1962
  const t = P(s), n = P(e);
1963
1963
  if (s === e)
1964
1964
  return { valid: !0, data: s };
1965
1965
  if (t === f.object && n === f.object) {
1966
1966
  const r = x.objectKeys(e), a = x.objectKeys(s).filter((o) => r.indexOf(o) !== -1), i = { ...s, ...e };
1967
1967
  for (const o of a) {
1968
- const u = Ce(s[o], e[o]);
1968
+ const u = Re(s[o], e[o]);
1969
1969
  if (!u.valid)
1970
1970
  return { valid: !1 };
1971
1971
  i[o] = u.data;
@@ -1976,7 +1976,7 @@ function Ce(s, e) {
1976
1976
  return { valid: !1 };
1977
1977
  const r = [];
1978
1978
  for (let a = 0; a < s.length; a++) {
1979
- const i = s[a], o = e[a], u = Ce(i, o);
1979
+ const i = s[a], o = e[a], u = Re(i, o);
1980
1980
  if (!u.valid)
1981
1981
  return { valid: !1 };
1982
1982
  r.push(u.data);
@@ -1990,8 +1990,8 @@ class ae extends v {
1990
1990
  const { status: t, ctx: n } = this._processInputParams(e), r = (a, i) => {
1991
1991
  if (Ze(a) || Ze(i))
1992
1992
  return m;
1993
- const o = Ce(a.value, i.value);
1994
- return o.valid ? ((Re(a) || Re(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(n, {
1993
+ const o = Re(a.value, i.value);
1994
+ return o.valid ? ((Ce(a) || Ce(i)) && t.dirty(), { status: t.value, value: o.data }) : (l(n, {
1995
1995
  code: c.invalid_intersection_types
1996
1996
  }), m);
1997
1997
  };
@@ -2107,7 +2107,7 @@ class ie extends v {
2107
2107
  typeName: p.ZodRecord,
2108
2108
  ...y(n)
2109
2109
  }) : new ie({
2110
- keyType: C.create(),
2110
+ keyType: R.create(),
2111
2111
  valueType: e,
2112
2112
  typeName: p.ZodRecord,
2113
2113
  ...y(t)
@@ -2246,7 +2246,7 @@ class W extends v {
2246
2246
  t.common.contextualErrorMap,
2247
2247
  t.schemaErrorMap,
2248
2248
  me(),
2249
- Q
2249
+ Y
2250
2250
  ].filter((d) => !!d),
2251
2251
  issueData: {
2252
2252
  code: c.invalid_arguments,
@@ -2262,7 +2262,7 @@ class W extends v {
2262
2262
  t.common.contextualErrorMap,
2263
2263
  t.schemaErrorMap,
2264
2264
  me(),
2265
- Q
2265
+ Y
2266
2266
  ].filter((d) => !!d),
2267
2267
  issueData: {
2268
2268
  code: c.invalid_return_type,
@@ -2271,14 +2271,14 @@ class W extends v {
2271
2271
  });
2272
2272
  }
2273
2273
  const a = { errorMap: t.common.contextualErrorMap }, i = t.data;
2274
- if (this._def.returns instanceof H) {
2274
+ if (this._def.returns instanceof J) {
2275
2275
  const o = this;
2276
2276
  return T(async function(...u) {
2277
2277
  const d = new S([]), g = await o._def.args.parseAsync(u, a).catch((we) => {
2278
2278
  throw d.addIssue(n(u, we)), d;
2279
- }), Z = await Reflect.apply(i, this, g);
2280
- return await o._def.returns._def.type.parseAsync(Z, a).catch((we) => {
2281
- throw d.addIssue(r(Z, we)), d;
2279
+ }), C = await Reflect.apply(i, this, g);
2280
+ return await o._def.returns._def.type.parseAsync(C, a).catch((we) => {
2281
+ throw d.addIssue(r(C, we)), d;
2282
2282
  });
2283
2283
  });
2284
2284
  } else {
@@ -2287,10 +2287,10 @@ class W extends v {
2287
2287
  const d = o._def.args.safeParse(u, a);
2288
2288
  if (!d.success)
2289
2289
  throw new S([n(u, d.error)]);
2290
- const g = Reflect.apply(i, this, d.data), Z = o._def.returns.safeParse(g, a);
2291
- if (!Z.success)
2292
- throw new S([r(g, Z.error)]);
2293
- return Z.data;
2290
+ const g = Reflect.apply(i, this, d.data), C = o._def.returns.safeParse(g, a);
2291
+ if (!C.success)
2292
+ throw new S([r(g, C.error)]);
2293
+ return C.data;
2294
2294
  });
2295
2295
  }
2296
2296
  }
@@ -2462,7 +2462,7 @@ de.create = (s, e) => new de({
2462
2462
  typeName: p.ZodNativeEnum,
2463
2463
  ...y(e)
2464
2464
  });
2465
- class H extends v {
2465
+ class J extends v {
2466
2466
  unwrap() {
2467
2467
  return this._def.type;
2468
2468
  }
@@ -2481,7 +2481,7 @@ class H extends v {
2481
2481
  })));
2482
2482
  }
2483
2483
  }
2484
- H.create = (s, e) => new H({
2484
+ J.create = (s, e) => new J({
2485
2485
  type: s,
2486
2486
  typeName: p.ZodPromise,
2487
2487
  ...y(e)
@@ -2750,13 +2750,13 @@ fe.create = (s, e) => new fe({
2750
2750
  ...y(e)
2751
2751
  });
2752
2752
  function Ue(s, e = {}, t) {
2753
- return s ? Y.create().superRefine((n, r) => {
2753
+ return s ? H.create().superRefine((n, r) => {
2754
2754
  var a, i;
2755
2755
  if (!s(n)) {
2756
2756
  const o = typeof e == "function" ? e(n) : typeof e == "string" ? { message: e } : e, u = (i = (a = o.fatal) !== null && a !== void 0 ? a : t) !== null && i !== void 0 ? i : !0, d = typeof o == "string" ? { message: o } : o;
2757
2757
  r.addIssue({ code: "custom", ...d, fatal: u });
2758
2758
  }
2759
- }) : Y.create();
2759
+ }) : H.create();
2760
2760
  }
2761
2761
  const vt = {
2762
2762
  object: b.lazycreate
@@ -2767,8 +2767,8 @@ var p;
2767
2767
  })(p || (p = {}));
2768
2768
  const _t = (s, e = {
2769
2769
  message: `Input not instance of ${s.name}`
2770
- }) => Ue((t) => t instanceof s, e), ze = C.create, Be = $.create, xt = be.create, bt = V.create, Ge = te.create, kt = U.create, wt = ve.create, Tt = se.create, St = ne.create, Zt = Y.create, Rt = L.create, Ct = A.create, Et = _e.create, Nt = E.create, Ot = b.create, It = b.strictCreate, Mt = re.create, jt = ke.create, At = ae.create, Pt = M.create, $t = ie.create, Vt = xe.create, qt = z.create, Dt = W.create, Lt = oe.create, Ut = ce.create, zt = q.create, Bt = de.create, Gt = H.create, Ae = N.create, Wt = O.create, Qt = D.create, Yt = N.createWithPreprocess, Ht = he.create, Jt = () => ze().optional(), Xt = () => Be().optional(), Kt = () => Ge().optional(), Ft = {
2771
- string: (s) => C.create({ ...s, coerce: !0 }),
2770
+ }) => Ue((t) => t instanceof s, e), ze = R.create, Be = $.create, xt = be.create, bt = V.create, Qe = te.create, kt = U.create, wt = ve.create, Tt = se.create, St = ne.create, Zt = H.create, Ct = L.create, Rt = A.create, Et = _e.create, Nt = E.create, Ot = b.create, It = b.strictCreate, Mt = re.create, jt = ke.create, At = ae.create, Pt = M.create, $t = ie.create, Vt = xe.create, qt = z.create, Dt = W.create, Lt = oe.create, Ut = ce.create, zt = q.create, Bt = de.create, Qt = J.create, Ae = N.create, Gt = O.create, Wt = D.create, Yt = N.createWithPreprocess, Ht = he.create, Jt = () => ze().optional(), Xt = () => Be().optional(), Kt = () => Qe().optional(), Ft = {
2771
+ string: (s) => R.create({ ...s, coerce: !0 }),
2772
2772
  number: (s) => $.create({ ...s, coerce: !0 }),
2773
2773
  boolean: (s) => te.create({
2774
2774
  ...s,
@@ -2779,7 +2779,7 @@ const _t = (s, e = {
2779
2779
  }, es = m;
2780
2780
  var _ = /* @__PURE__ */ Object.freeze({
2781
2781
  __proto__: null,
2782
- defaultErrorMap: Q,
2782
+ defaultErrorMap: Y,
2783
2783
  setErrorMap: et,
2784
2784
  getErrorMap: me,
2785
2785
  makeIssue: ge,
@@ -2790,7 +2790,7 @@ var _ = /* @__PURE__ */ Object.freeze({
2790
2790
  DIRTY: G,
2791
2791
  OK: T,
2792
2792
  isAborted: Ze,
2793
- isDirty: Re,
2793
+ isDirty: Ce,
2794
2794
  isValid: F,
2795
2795
  isAsync: ee,
2796
2796
  get util() {
@@ -2803,7 +2803,7 @@ var _ = /* @__PURE__ */ Object.freeze({
2803
2803
  getParsedType: P,
2804
2804
  ZodType: v,
2805
2805
  datetimeRegex: De,
2806
- ZodString: C,
2806
+ ZodString: R,
2807
2807
  ZodNumber: $,
2808
2808
  ZodBigInt: V,
2809
2809
  ZodBoolean: te,
@@ -2811,7 +2811,7 @@ var _ = /* @__PURE__ */ Object.freeze({
2811
2811
  ZodSymbol: ve,
2812
2812
  ZodUndefined: se,
2813
2813
  ZodNull: ne,
2814
- ZodAny: Y,
2814
+ ZodAny: H,
2815
2815
  ZodUnknown: L,
2816
2816
  ZodNever: A,
2817
2817
  ZodVoid: _e,
@@ -2829,7 +2829,7 @@ var _ = /* @__PURE__ */ Object.freeze({
2829
2829
  ZodLiteral: ce,
2830
2830
  ZodEnum: q,
2831
2831
  ZodNativeEnum: de,
2832
- ZodPromise: H,
2832
+ ZodPromise: J,
2833
2833
  ZodEffects: N,
2834
2834
  ZodTransformer: N,
2835
2835
  ZodOptional: O,
@@ -2852,7 +2852,7 @@ var _ = /* @__PURE__ */ Object.freeze({
2852
2852
  any: Zt,
2853
2853
  array: Nt,
2854
2854
  bigint: bt,
2855
- boolean: Ge,
2855
+ boolean: Qe,
2856
2856
  date: kt,
2857
2857
  discriminatedUnion: jt,
2858
2858
  effect: Ae,
@@ -2865,18 +2865,18 @@ var _ = /* @__PURE__ */ Object.freeze({
2865
2865
  map: Vt,
2866
2866
  nan: xt,
2867
2867
  nativeEnum: Bt,
2868
- never: Ct,
2868
+ never: Rt,
2869
2869
  null: St,
2870
- nullable: Qt,
2870
+ nullable: Wt,
2871
2871
  number: Be,
2872
2872
  object: Ot,
2873
2873
  oboolean: Kt,
2874
2874
  onumber: Xt,
2875
- optional: Wt,
2875
+ optional: Gt,
2876
2876
  ostring: Jt,
2877
2877
  pipeline: Ht,
2878
2878
  preprocess: Yt,
2879
- promise: Gt,
2879
+ promise: Qt,
2880
2880
  record: $t,
2881
2881
  set: qt,
2882
2882
  strictObject: It,
@@ -2886,151 +2886,156 @@ var _ = /* @__PURE__ */ Object.freeze({
2886
2886
  tuple: Pt,
2887
2887
  undefined: Tt,
2888
2888
  union: Mt,
2889
- unknown: Rt,
2889
+ unknown: Ct,
2890
2890
  void: Et,
2891
2891
  NEVER: es,
2892
2892
  ZodIssueCode: c,
2893
2893
  quotelessJson: Fe,
2894
2894
  ZodError: S
2895
2895
  });
2896
- const R = _.object({
2896
+ const Z = _.object({
2897
2897
  type: _.literal("qp-bridge"),
2898
2898
  id: _.string().optional()
2899
- }), ts = R.extend({
2899
+ }), ts = Z.extend({
2900
2900
  status: _.literal("answerChanged"),
2901
2901
  question: _.string(),
2902
2902
  answer: _.unknown()
2903
- }), Ne = R.extend({
2903
+ }), Ne = Z.extend({
2904
2904
  status: _.literal("success")
2905
- }), ss = R.extend({
2905
+ }), ss = Z.extend({
2906
2906
  status: _.literal("error"),
2907
2907
  message: _.string()
2908
- }), We = _.object({
2908
+ }), Ge = _.object({
2909
2909
  semanticColor: _.string().optional(),
2910
2910
  label: _.string(),
2911
2911
  description: _.string(),
2912
2912
  disabled: _.boolean(),
2913
2913
  required: _.boolean(),
2914
2914
  hidden: _.boolean()
2915
- }), ns = We.partial(), Qe = _.object({
2915
+ }), ns = Ge.partial(), We = _.object({
2916
2916
  label: _.string(),
2917
2917
  hidden: _.boolean(),
2918
2918
  collapsed: _.boolean()
2919
- }), rs = Qe.partial(), as = R.extend({
2919
+ }), rs = We.partial(), as = Z.extend({
2920
2920
  action: _.literal("getQuestion"),
2921
2921
  question: _.string()
2922
2922
  }), is = Ne.extend({
2923
- question: We
2924
- }), os = R.extend({
2923
+ question: Ge
2924
+ }), os = Z.extend({
2925
2925
  action: _.literal("setQuestion"),
2926
2926
  question: _.string(),
2927
2927
  questionData: ns
2928
- }), cs = R.extend({
2928
+ }), cs = Z.extend({
2929
2929
  action: _.literal("getGroup"),
2930
2930
  group: _.string()
2931
2931
  }), ds = Ne.extend({
2932
- group: Qe
2933
- }), us = R.extend({
2932
+ group: We
2933
+ }), us = Z.extend({
2934
2934
  action: _.literal("setGroup"),
2935
2935
  group: _.string(),
2936
2936
  groupData: rs
2937
- }), ls = R.extend({
2937
+ }), ls = Z.extend({
2938
2938
  action: _.literal("setAnswer"),
2939
2939
  question: _.string(),
2940
2940
  answer: _.unknown()
2941
- }), fs = R.extend({
2941
+ }), fs = Z.extend({
2942
2942
  action: _.literal("busyIndicatorStart")
2943
- }), hs = R.extend({
2943
+ }), hs = Z.extend({
2944
2944
  action: _.literal("busyIndicatorEnd")
2945
- }), ps = R.extend({
2945
+ }), ps = Z.extend({
2946
2946
  action: _.literal("saveQuestionnaire")
2947
+ }), ms = Z.extend({
2948
+ action: _.literal("completeAndCloseQuestionnaire")
2947
2949
  });
2948
- function ms(s) {
2949
- return ts.safeParse(s).success;
2950
- }
2951
2950
  function gs(s) {
2952
- return R.safeParse(s).success;
2951
+ return ts.safeParse(s).success;
2953
2952
  }
2954
2953
  function ys(s) {
2955
- return Ne.safeParse(s).success;
2954
+ return Z.safeParse(s).success;
2956
2955
  }
2957
2956
  function vs(s) {
2957
+ return Ne.safeParse(s).success;
2958
+ }
2959
+ function _s(s) {
2958
2960
  return ss.safeParse(s).success;
2959
2961
  }
2960
- function Ss(s) {
2962
+ function Zs(s) {
2961
2963
  return as.safeParse(s).success;
2962
2964
  }
2963
- function _s(s) {
2965
+ function xs(s) {
2964
2966
  return is.safeParse(s).success;
2965
2967
  }
2966
- function Zs(s) {
2968
+ function Cs(s) {
2967
2969
  return ls.safeParse(s).success;
2968
2970
  }
2969
2971
  function Rs(s) {
2970
2972
  return os.safeParse(s).success;
2971
2973
  }
2972
- function Cs(s) {
2974
+ function Es(s) {
2973
2975
  return us.safeParse(s).success;
2974
2976
  }
2975
- function Es(s) {
2977
+ function Ns(s) {
2976
2978
  return cs.safeParse(s).success;
2977
2979
  }
2978
- function xs(s) {
2980
+ function bs(s) {
2979
2981
  return ds.safeParse(s).success;
2980
2982
  }
2981
- function bs(s) {
2983
+ function ks(s) {
2982
2984
  return fs.safeParse(s).success;
2983
2985
  }
2984
- function ks(s) {
2986
+ function ws(s) {
2985
2987
  return hs.safeParse(s).success;
2986
2988
  }
2987
- function Ns(s) {
2989
+ function Os(s) {
2988
2990
  return ps.safeParse(s).success;
2989
2991
  }
2990
- function Os(s) {
2991
- return bs(s) || ks(s);
2992
+ function Is(s) {
2993
+ return ms.safeParse(s).success;
2992
2994
  }
2993
- async function Is(s, e) {
2994
- await J({
2995
+ function Ms(s) {
2996
+ return ks(s) || ws(s);
2997
+ }
2998
+ async function js(s, e) {
2999
+ await B({
2995
3000
  type: "qp-bridge",
2996
3001
  action: "setAnswer",
2997
3002
  question: s,
2998
3003
  answer: e
2999
3004
  });
3000
3005
  }
3001
- async function Ms(s) {
3002
- return await ws({
3006
+ async function As(s) {
3007
+ return await Ts({
3003
3008
  type: "qp-bridge",
3004
3009
  action: "getQuestion",
3005
3010
  question: s
3006
3011
  });
3007
3012
  }
3008
- async function js(s, e) {
3009
- await J({
3013
+ async function Ps(s, e) {
3014
+ await B({
3010
3015
  type: "qp-bridge",
3011
3016
  action: "setQuestion",
3012
3017
  question: s,
3013
3018
  questionData: e
3014
3019
  });
3015
3020
  }
3016
- async function As(s) {
3017
- return await Ts({
3021
+ async function $s(s) {
3022
+ return await Ss({
3018
3023
  type: "qp-bridge",
3019
3024
  action: "getGroup",
3020
3025
  group: s
3021
3026
  });
3022
3027
  }
3023
- async function Ps(s, e) {
3024
- await J({
3028
+ async function Vs(s, e) {
3029
+ await B({
3025
3030
  type: "qp-bridge",
3026
3031
  action: "setGroup",
3027
3032
  group: s,
3028
3033
  groupData: e
3029
3034
  });
3030
3035
  }
3031
- function $s(s) {
3036
+ function qs(s) {
3032
3037
  const e = (t) => {
3033
- ms(t.data) && s(t.data.question, t.data.answer);
3038
+ gs(t.data) && s(t.data.question, t.data.answer);
3034
3039
  };
3035
3040
  return window.addEventListener("message", e), {
3036
3041
  cancelSubscription: () => {
@@ -3038,86 +3043,95 @@ function $s(s) {
3038
3043
  }
3039
3044
  };
3040
3045
  }
3041
- async function Vs(s) {
3042
- await J({
3046
+ async function Ds(s) {
3047
+ await B({
3043
3048
  type: "qp-bridge",
3044
3049
  action: "busyIndicatorStart"
3045
3050
  });
3046
3051
  try {
3047
3052
  return await s();
3048
3053
  } finally {
3049
- await J({
3054
+ await B({
3050
3055
  type: "qp-bridge",
3051
3056
  action: "busyIndicatorEnd"
3052
3057
  });
3053
3058
  }
3054
3059
  }
3055
- async function qs() {
3056
- await J({
3060
+ async function Ls() {
3061
+ await B({
3057
3062
  type: "qp-bridge",
3058
3063
  action: "saveQuestionnaire"
3059
3064
  });
3060
3065
  }
3066
+ async function Us() {
3067
+ await B({
3068
+ type: "qp-bridge",
3069
+ action: "completeAndCloseQuestionnaire"
3070
+ });
3071
+ }
3061
3072
  async function Oe(s, e) {
3062
3073
  return new Promise((t, n) => {
3063
3074
  const r = Ke(), a = (i) => {
3064
- if (!gs(i.data) || i.data.id !== r)
3075
+ if (!ys(i.data) || i.data.id !== r)
3065
3076
  return;
3066
3077
  const u = e(i.data);
3067
- u.success ? t(u.data) : vs(i.data) ? n(new Error(i.data.message)) : n(new Error("Unknown message received")), window.removeEventListener("message", a);
3078
+ u.success ? t(u.data) : _s(i.data) ? n(new Error(i.data.message)) : n(new Error("Unknown message received")), window.removeEventListener("message", a);
3068
3079
  };
3069
3080
  window.addEventListener("message", a), window.parent.postMessage({ ...s, id: r }, "*");
3070
3081
  });
3071
3082
  }
3072
- async function ws(s) {
3073
- return Oe(s, (e) => _s(e) ? { success: !0, data: e.question } : { success: !1 });
3074
- }
3075
3083
  async function Ts(s) {
3076
- return Oe(s, (e) => xs(e) ? { success: !0, data: e.group } : { success: !1 });
3084
+ return Oe(s, (e) => xs(e) ? { success: !0, data: e.question } : { success: !1 });
3077
3085
  }
3078
- function J(s) {
3079
- return Oe(s, (e) => ys(e) ? { success: !0, data: void 0 } : { success: !1 });
3086
+ async function Ss(s) {
3087
+ return Oe(s, (e) => bs(e) ? { success: !0, data: e.group } : { success: !1 });
3088
+ }
3089
+ function B(s) {
3090
+ return Oe(s, (e) => vs(e) ? { success: !0, data: void 0 } : { success: !1 });
3080
3091
  }
3081
3092
  export {
3082
3093
  hs as busyIndicatorEndRequestMessageSchema,
3083
3094
  fs as busyIndicatorStartRequestMessageSchema,
3084
- As as getGroup,
3095
+ Us as completeAndCloseQuestionnaire,
3096
+ ms as completeAndCloseQuestionnaireRequestMessageSchema,
3097
+ $s as getGroup,
3085
3098
  cs as getGroupRequestMessageSchema,
3086
3099
  ds as getGroupSuccessResponseMessageSchema,
3087
- Ms as getQuestion,
3100
+ As as getQuestion,
3088
3101
  as as getQuestionRequestMessageSchema,
3089
3102
  is as getQuestionSuccessResponseMessageSchema,
3090
3103
  rs as groupOptionalScheme,
3091
- Qe as groupSchema,
3092
- ks as isBusyIndicatorEndRequestMessage,
3093
- bs as isBusyIndicatorStartRequestMessage,
3094
- vs as isErrorMessage,
3095
- Es as isGetGroupRequestMessage,
3096
- xs as isGetGroupSuccessResponseMessage,
3097
- Ss as isGetQuestionRequestMessage,
3098
- _s as isGetQuestionSuccessResponseMessage,
3099
- ms as isOnAnswerChangeMessage,
3100
- gs as isQpBridgeMessage,
3101
- Ns as isSaveQuestionnaireRequestMessage,
3102
- Zs as isSetAnswerRequestMessage,
3103
- Cs as isSetGroupRequestMessage,
3104
+ We as groupSchema,
3105
+ ws as isBusyIndicatorEndRequestMessage,
3106
+ ks as isBusyIndicatorStartRequestMessage,
3107
+ Is as isCompleteAndCloseQuestionnaireRequestMessage,
3108
+ _s as isErrorMessage,
3109
+ Ns as isGetGroupRequestMessage,
3110
+ bs as isGetGroupSuccessResponseMessage,
3111
+ Zs as isGetQuestionRequestMessage,
3112
+ xs as isGetQuestionSuccessResponseMessage,
3113
+ gs as isOnAnswerChangeMessage,
3114
+ ys as isQpBridgeMessage,
3115
+ Os as isSaveQuestionnaireRequestMessage,
3116
+ Cs as isSetAnswerRequestMessage,
3117
+ Es as isSetGroupRequestMessage,
3104
3118
  Rs as isSetQuestionRequestMessage,
3105
- ys as isSuccessMessage,
3106
- Os as isWithBusyIndicatorRequestMessage,
3107
- $s as onAnswerChange,
3119
+ vs as isSuccessMessage,
3120
+ Ms as isWithBusyIndicatorRequestMessage,
3121
+ qs as onAnswerChange,
3108
3122
  ts as onAnswerChangeMessageSchema,
3109
- R as qpBridgeMessageSchema,
3123
+ Z as qpBridgeMessageSchema,
3110
3124
  ns as questionOptionalScheme,
3111
- We as questionSchema,
3125
+ Ge as questionSchema,
3112
3126
  ss as responseErrorMessageSchema,
3113
3127
  Ne as responseSuccessMessageSchema,
3114
- qs as saveQuestionnaire,
3128
+ Ls as saveQuestionnaire,
3115
3129
  ps as saveQuestionnaireRequestMessageSchema,
3116
- Is as setAnswer,
3130
+ js as setAnswer,
3117
3131
  ls as setAnswerRequestMessageSchema,
3118
- Ps as setGroup,
3132
+ Vs as setGroup,
3119
3133
  us as setGroupRequestMessageSchema,
3120
- js as setQuestion,
3134
+ Ps as setQuestion,
3121
3135
  os as setQuestionRequestMessageSchema,
3122
- Vs as withBusyIndicator
3136
+ Ds as withBusyIndicator
3123
3137
  };
@@ -412,6 +412,20 @@ export declare const saveQuestionnaireRequestMessageSchema: z.ZodObject<z.object
412
412
  action: "saveQuestionnaire";
413
413
  id?: string | undefined;
414
414
  }>;
415
+ export declare const completeAndCloseQuestionnaireRequestMessageSchema: z.ZodObject<z.objectUtil.extendShape<{
416
+ type: z.ZodLiteral<"qp-bridge">;
417
+ id: z.ZodOptional<z.ZodString>;
418
+ }, {
419
+ action: z.ZodLiteral<"completeAndCloseQuestionnaire">;
420
+ }>, "strip", z.ZodTypeAny, {
421
+ type: "qp-bridge";
422
+ action: "completeAndCloseQuestionnaire";
423
+ id?: string | undefined;
424
+ }, {
425
+ type: "qp-bridge";
426
+ action: "completeAndCloseQuestionnaire";
427
+ id?: string | undefined;
428
+ }>;
415
429
  export type QpBridgeMessage = z.infer<typeof qpBridgeMessageSchema>;
416
430
  export type ResponseSuccessMessage = z.infer<typeof responseSuccessMessageSchema>;
417
431
  export type ResponseErrorMessage = z.infer<typeof responseErrorMessageSchema>;
@@ -430,6 +444,7 @@ export type SetGroupRequestMessage = z.infer<typeof setGroupRequestMessageSchema
430
444
  export type BusyIndicatorStartRequestMessage = z.infer<typeof busyIndicatorStartRequestMessageSchema>;
431
445
  export type BusyIndicatorEndRequestMessage = z.infer<typeof busyIndicatorEndRequestMessageSchema>;
432
446
  export type SaveQuestionnaireRequestMessage = z.infer<typeof saveQuestionnaireRequestMessageSchema>;
447
+ export type CompleteAndCloseQuestionnaireRequestMessage = z.infer<typeof completeAndCloseQuestionnaireRequestMessageSchema>;
433
448
  export type WithBusyIndicatorRequestMessage = BusyIndicatorStartRequestMessage | BusyIndicatorEndRequestMessage;
434
449
  export declare function isOnAnswerChangeMessage(data: unknown): data is OnAnswerChangeMessage;
435
450
  export declare function isQpBridgeMessage(data: unknown): data is QpBridgeMessage;
@@ -445,4 +460,5 @@ export declare function isGetGroupSuccessResponseMessage(data: unknown): data is
445
460
  export declare function isBusyIndicatorStartRequestMessage(data: unknown): data is BusyIndicatorStartRequestMessage;
446
461
  export declare function isBusyIndicatorEndRequestMessage(data: unknown): data is BusyIndicatorEndRequestMessage;
447
462
  export declare function isSaveQuestionnaireRequestMessage(data: unknown): data is SaveQuestionnaireRequestMessage;
463
+ export declare function isCompleteAndCloseQuestionnaireRequestMessage(data: unknown): data is CompleteAndCloseQuestionnaireRequestMessage;
448
464
  export declare function isWithBusyIndicatorRequestMessage(data: unknown): data is WithBusyIndicatorRequestMessage;
@@ -118,3 +118,16 @@ export declare function withBusyIndicator<T>(action: () => Promise<T>): Promise<
118
118
  * ```
119
119
  */
120
120
  export declare function saveQuestionnaire(): Promise<void>;
121
+ /**
122
+ * Completes and closes the current questionnaire.
123
+ * Triggers the complete and close operation for the questionnaire.
124
+ *
125
+ * @returns {Promise<void>} A promise that resolves when the questionnaire has been successfully completed and closed.
126
+ * @throws {Error} Throws if the complete and close operation fails.
127
+ * @example
128
+ * ```typescript
129
+ * await completeAndCloseQuestionnaire();
130
+ * console.log('Questionnaire completed and closed successfully');
131
+ * ```
132
+ */
133
+ export declare function completeAndCloseQuestionnaire(): Promise<void>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@resconet/qp-bridge",
3
- "version": "0.0.1-alpha.13",
3
+ "version": "0.0.1-alpha.14",
4
4
  "dependencies": {
5
5
  "zod": "^3.23.8",
6
6
  "uuid": "^9.0.1"