@resconet/qp-bridge 1.4.0 → 1.4.1-alpha.11

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
@@ -56,6 +56,9 @@ await setAnswer("numericQuestion", 42);
56
56
  - [initOnSaveMessageHandler](#initonsavemessagehandler)
57
57
  - [removeOnSaveMessageHandler](#removeonsavemessagehandler)
58
58
  - [getQuestionnaire](#getquestionnaire)
59
+ - [traverseQuestionnaireItems](#traversequestionnaireitems)
60
+ - [flattenQuestionnaireItems](#flattenquestionnaireitems)
61
+ - [flattenQuestions](#flattenquestions)
59
62
  - [setAnswer](#setanswer)
60
63
  - [getQuestion](#getquestion)
61
64
  - [setQuestion](#setquestion)
@@ -413,7 +416,7 @@ Retrieves a questionnaire on which the user is currently working.
413
416
 
414
417
  | Function | Type |
415
418
  | ---------- | ---------- |
416
- | `getQuestionnaire` | `(options?: QpBridgeOptions or undefined) => Promise<{ id: string; isNew: boolean; label: string; description?: string or undefined; regarding?: { id: string; name: string; entityName: string; } or undefined; }>` |
419
+ | `getQuestionnaire` | `(options?: QpBridgeOptions or undefined) => Promise<{ id: string; name: string; isNew: boolean; label: string; items: QuestionnaireItem[]; description?: string or undefined; regarding?: { ...; } or undefined; }>` |
417
420
 
418
421
  Returns:
419
422
 
@@ -422,19 +425,48 @@ A promise that resolves to the questionnaire object.
422
425
  The resolved `Questionnaire` object has the following properties:
423
426
  - `isNew` — Whether the questionnaire is a new (unsaved) record.
424
427
  - `id` — Unique identifier (UUID) of the questionnaire record.
425
- - `label` — Display name of the questionnaire.
428
+ - `name` — Logical questionnaire name.
429
+ - `label` — Display name of the questionnaire. Kept as an alias for existing bridge consumers.
426
430
  - `description` _(optional)_ — Description or notes for the questionnaire.
427
431
  - `regarding` _(optional)_ — Reference to the related entity this questionnaire is associated with (`entityName`, `id`, `name`).
432
+ - `items` — Questionnaire item tree in domain-model order. Items can be questions, groups, repeatable groups, or static components.
428
433
 
429
434
  Examples:
430
435
 
431
436
  ```typescript
432
437
  const questionnaire = await getQuestionnaire();
433
- console.log(questionnaire.id); // Outputs the ID of the questionnaire
434
- console.log(questionnaire.isNew); // Outputs whether the questionnaire is new
438
+ console.log(questionnaire.id);
439
+ console.log(questionnaire.items.map(item => item.name));
440
+ console.log(flattenQuestions(questionnaire).map(question => question.name));
435
441
  ```
436
442
 
437
443
 
444
+ ### traverseQuestionnaireItems
445
+
446
+ Traverses the questionnaire item tree in pre-order and passes parent context to the visitor.
447
+
448
+ Repeatable groups are visited before their group instances.
449
+
450
+ | Function | Type |
451
+ | ---------- | ---------- |
452
+ | `traverseQuestionnaireItems` | `(questionnaire: { id: string; name: string; isNew: boolean; label: string; items: QuestionnaireItem[]; description?: string or undefined; regarding?: { id: string; name: string; entityName: string; } or undefined; }, visitor: QuestionnaireItemVisitor) => void` |
453
+
454
+ ### flattenQuestionnaireItems
455
+
456
+ Returns every questionnaire item in tree order.
457
+
458
+ | Function | Type |
459
+ | ---------- | ---------- |
460
+ | `flattenQuestionnaireItems` | `(questionnaire: { id: string; name: string; isNew: boolean; label: string; items: QuestionnaireItem[]; description?: string or undefined; regarding?: { id: string; name: string; entityName: string; } or undefined; }) => QuestionnaireItem[]` |
461
+
462
+ ### flattenQuestions
463
+
464
+ Returns every question from the questionnaire item tree in tree order.
465
+
466
+ | Function | Type |
467
+ | ---------- | ---------- |
468
+ | `flattenQuestions` | `(questionnaire: { id: string; name: string; isNew: boolean; label: string; items: QuestionnaireItem[]; description?: string or undefined; regarding?: { id: string; name: string; entityName: string; } or undefined; }) => { ...; }[]` |
469
+
438
470
  ### setAnswer
439
471
 
440
472
  Sets the answer for a specific question in the questionnaire.
package/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var ge={exports:{}},Ae;function zt(){if(Ae)return ge.exports;Ae=1;var t=ge.exports={},e,s;function n(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?e=setTimeout:e=n}catch{e=n}try{typeof clearTimeout=="function"?s=clearTimeout:s=a}catch{s=a}})();function r(k){if(e===setTimeout)return setTimeout(k,0);if((e===n||!e)&&setTimeout)return e=setTimeout,setTimeout(k,0);try{return e(k,0)}catch{try{return e.call(null,k,0)}catch{return e.call(this,k,0)}}}function i(k){if(s===clearTimeout)return clearTimeout(k);if((s===a||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(k);try{return s(k)}catch{try{return s.call(null,k)}catch{return s.call(this,k)}}}var o=[],d=!1,l,y=-1;function N(){!d||!l||(d=!1,l.length?o=l.concat(o):y=-1,o.length&&q())}function q(){if(!d){var k=r(N);d=!0;for(var T=o.length;T;){for(l=o,o=[];++y<T;)l&&l[y].run();y=-1,T=o.length}l=null,d=!1,i(k)}}t.nextTick=function(k){var T=new Array(arguments.length-1);if(arguments.length>1)for(var U=1;U<arguments.length;U++)T[U-1]=arguments[U];o.push(new Ee(k,T)),o.length===1&&!d&&r(q)};function Ee(k,T){this.fun=k,this.array=T}Ee.prototype.run=function(){this.fun.apply(null,this.array)},t.title="browser",t.browser=!0,t.env={},t.argv=[],t.version="",t.versions={};function O(){}return t.on=O,t.addListener=O,t.once=O,t.off=O,t.removeListener=O,t.removeAllListeners=O,t.emit=O,t.prependListener=O,t.prependOnceListener=O,t.listeners=function(k){return[]},t.binding=function(k){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(k){throw new Error("process.chdir is not supported")},t.umask=function(){return 0},ge.exports}var Ft=zt();let ie;const Wt=new Uint8Array(16);function Ht(){if(!ie&&(ie=typeof crypto<"u"&&crypto.getRandomValues&&crypto.getRandomValues.bind(crypto),!ie))throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");return ie(Wt)}const R=[];for(let t=0;t<256;++t)R.push((t+256).toString(16).slice(1));function Jt(t,e=0){return R[t[e+0]]+R[t[e+1]]+R[t[e+2]]+R[t[e+3]]+"-"+R[t[e+4]]+R[t[e+5]]+"-"+R[t[e+6]]+R[t[e+7]]+"-"+R[t[e+8]]+R[t[e+9]]+"-"+R[t[e+10]]+R[t[e+11]]+R[t[e+12]]+R[t[e+13]]+R[t[e+14]]+R[t[e+15]]}const Yt=typeof crypto<"u"&&crypto.randomUUID&&crypto.randomUUID.bind(crypto),Ne={randomUUID:Yt};function ze(t,e,s){if(Ne.randomUUID&&!t)return Ne.randomUUID();t=t||{};const n=t.random||(t.rng||Ht)();return n[6]=n[6]&15|64,n[8]=n[8]&63|128,Jt(n)}var _;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function s(a){throw new Error}t.assertNever=s,t.arrayToEnum=a=>{const r={};for(const i of a)r[i]=i;return r},t.getValidEnumValues=a=>{const r=t.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(const o of r)i[o]=a[o];return t.objectValues(i)},t.objectValues=a=>t.objectKeys(a).map(function(r){return a[r]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const r=[];for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&r.push(i);return r},t.find=(a,r)=>{for(const i of a)if(r(i))return i},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,r=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(r)}t.joinValues=n,t.jsonStringifyReplacer=(a,r)=>typeof r=="bigint"?r.toString():r})(_||(_={}));var qe;(function(t){t.mergeShapes=(e,s)=>({...e,...s})})(qe||(qe={}));const f=_.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),P=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(t)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}},c=_.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"]);class j extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=e}format(e){const s=e||function(r){return r.message},n={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)n._errors.push(s(i));else{let o=n,d=0;for(;d<i.path.length;){const l=i.path[d];d===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(s(i))):o[l]=o[l]||{_errors:[]},o=o[l],d++}}};return a(this),n}static assert(e){if(!(e instanceof j))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,_.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=s=>s.message){const s={},n=[];for(const a of this.issues)if(a.path.length>0){const r=a.path[0];s[r]=s[r]||[],s[r].push(e(a))}else n.push(e(a));return{formErrors:n,fieldErrors:s}}get formErrors(){return this.flatten()}}j.create=t=>new j(t);const ve=(t,e)=>{let s;switch(t.code){case c.invalid_type:t.received===f.undefined?s="Required":s=`Expected ${t.expected}, received ${t.received}`;break;case c.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(t.expected,_.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:s=`Unrecognized key(s) in object: ${_.joinValues(t.keys,", ")}`;break;case c.invalid_union:s="Invalid input";break;case c.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${_.joinValues(t.options)}`;break;case c.invalid_enum_value:s=`Invalid enum value. Expected ${_.joinValues(t.options)}, received '${t.received}'`;break;case c.invalid_arguments:s="Invalid function arguments";break;case c.invalid_return_type:s="Invalid function return type";break;case c.invalid_date:s="Invalid date";break;case c.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(s=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(s=`${s} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?s=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?s=`Invalid input: must end with "${t.validation.endsWith}"`:_.assertNever(t.validation):t.validation!=="regex"?s=`Invalid ${t.validation}`:s="Invalid";break;case c.too_small:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:s="Invalid input";break;case c.too_big:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?s=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:s="Invalid input";break;case c.custom:s="Invalid input";break;case c.invalid_intersection_types:s="Intersection results could not be merged";break;case c.not_multiple_of:s=`Number must be a multiple of ${t.multipleOf}`;break;case c.not_finite:s="Number must be finite";break;default:s=e.defaultError,_.assertNever(t)}return{message:s}};let Xt=ve;function Kt(){return Xt}const es=t=>{const{data:e,path:s,errorMaps:n,issueData:a}=t,r=[...s,...a.path||[]],i={...a,path:r};if(a.message!==void 0)return{...a,path:r,message:a.message};let o="";const d=n.filter(l=>!!l).slice().reverse();for(const l of d)o=l(i,{data:e,defaultError:o}).message;return{...a,path:r,message:o}};function u(t,e){const s=Kt(),n=es({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,s,s===ve?void 0:ve].filter(a=>!!a)});t.common.issues.push(n)}class M{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,s){const n=[];for(const a of s){if(a.status==="aborted")return p;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,s){const n=[];for(const a of s){const r=await a.key,i=await a.value;n.push({key:r,value:i})}return M.mergeObjectSync(e,n)}static mergeObjectSync(e,s){const n={};for(const a of s){const{key:r,value:i}=a;if(r.status==="aborted"||i.status==="aborted")return p;r.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(n[r.value]=i.value)}return{status:e.value,value:n}}}const p=Object.freeze({status:"aborted"}),K=t=>({status:"dirty",value:t}),I=t=>({status:"valid",value:t}),Oe=t=>t.status==="aborted",Ze=t=>t.status==="dirty",z=t=>t.status==="valid",oe=t=>typeof Promise<"u"&&t instanceof Promise;var h;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));class A{constructor(e,s,n,a){this._cachedPath=[],this.parent=e,this.data=s,this._path=n,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const je=(t,e)=>{if(z(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const s=new j(t.common.issues);return this._error=s,this._error}}};function g(t){if(!t)return{};const{errorMap:e,invalid_type_error:s,required_error:n,description:a}=t;if(e&&(s||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,o)=>{const{message:d}=t;return i.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:d??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:d??s??o.defaultError}},description:a}}class v{get description(){return this._def.description}_getType(e){return P(e.data)}_getOrReturnCtx(e,s){return s||{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 M,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 s=this._parse(e);if(oe(s))throw new Error("Synchronous parse encountered promise.");return s}_parseAsync(e){const s=this._parse(e);return Promise.resolve(s)}parse(e,s){const n=this.safeParse(e,s);if(n.success)return n.data;throw n.error}safeParse(e,s){const n={common:{issues:[],async:s?.async??!1,contextualErrorMap:s?.errorMap},path:s?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},a=this._parseSync({data:e,path:n.path,parent:n});return je(n,a)}"~validate"(e){const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:s});return z(n)?{value:n.value}:{issues:s.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(n=>z(n)?{value:n.value}:{issues:s.common.issues})}async parseAsync(e,s){const n=await this.safeParseAsync(e,s);if(n.success)return n.data;throw n.error}async safeParseAsync(e,s){const n={common:{issues:[],contextualErrorMap:s?.errorMap,async:!0},path:s?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:P(e)},a=this._parse({data:e,path:n.path,parent:n}),r=await(oe(a)?a:Promise.resolve(a));return je(n,r)}refine(e,s){const n=a=>typeof s=="string"||typeof s>"u"?{message:s}:typeof s=="function"?s(a):s;return this._refinement((a,r)=>{const i=e(a),o=()=>r.addIssue({code:c.custom,...n(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,s){return this._refinement((n,a)=>e(n)?!0:(a.addIssue(typeof s=="function"?s(n,a):s),!1))}_refinement(e){return new H({schema:this,typeName:m.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}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),this["~standard"]={version:1,vendor:"zod",validate:s=>this["~validate"](s)}}optional(){return L.create(this,this._def)}nullable(){return J.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return E.create(this)}promise(){return fe.create(this,this._def)}or(e){return ue.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new H({...g(this._def),schema:this,typeName:m.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const s=typeof e=="function"?e:()=>e;return new we({...g(this._def),innerType:this,defaultValue:s,typeName:m.ZodDefault})}brand(){return new ws({typeName:m.ZodBranded,type:this,...g(this._def)})}catch(e){const s=typeof e=="function"?e:()=>e;return new Se({...g(this._def),innerType:this,catchValue:s,typeName:m.ZodCatch})}describe(e){const s=this.constructor;return new s({...this._def,description:e})}pipe(e){return Me.create(this,e)}readonly(){return Re.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ts=/^c[^\s-]{8,}$/i,ss=/^[0-9a-z]+$/,ns=/^[0-9A-HJKMNP-TV-Z]{26}$/i,as=/^[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,rs=/^[a-z0-9_-]{21}$/i,is=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,os=/^[-+]?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)?)??$/,cs=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,us="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let ye;const ds=/^(?:(?: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])$/,ls=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,fs=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,hs=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,ms=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ps=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Fe="((\\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])))",gs=new RegExp(`^${Fe}$`);function We(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const s=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${s}`}function ys(t){return new RegExp(`^${We(t)}$`)}function vs(t){let e=`${Fe}T${We(t)}`;const s=[];return s.push(t.local?"Z?":"Z"),t.offset&&s.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${s.join("|")})`,new RegExp(`^${e}$`)}function _s(t,e){return!!((e==="v4"||!e)&&ds.test(t)||(e==="v6"||!e)&&fs.test(t))}function xs(t,e){if(!is.test(t))return!1;try{const[s]=t.split(".");if(!s)return!1;const n=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function bs(t,e){return!!((e==="v4"||!e)&&ls.test(t)||(e==="v6"||!e)&&hs.test(t))}class Z extends v{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.string,received:r.parsedType}),p}const n=new M;let a;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind==="max")e.data.length>r.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind==="length"){const i=e.data.length>r.value,o=e.data.length<r.value;(i||o)&&(a=this._getOrReturnCtx(e,a),i?u(a,{code:c.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&u(a,{code:c.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),n.dirty())}else if(r.kind==="email")cs.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"email",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="emoji")ye||(ye=new RegExp(us,"u")),ye.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"emoji",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="uuid")as.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"uuid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="nanoid")rs.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"nanoid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid")ts.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid2")ss.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid2",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="ulid")ns.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"ulid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),u(a,{validation:"url",code:c.invalid_string,message:r.message}),n.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"regex",code:c.invalid_string,message:r.message}),n.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()):r.kind==="datetime"?vs(r).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:"datetime",message:r.message}),n.dirty()):r.kind==="date"?gs.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:"date",message:r.message}),n.dirty()):r.kind==="time"?ys(r).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:"time",message:r.message}),n.dirty()):r.kind==="duration"?os.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"duration",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="ip"?_s(e.data,r.version)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"ip",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="jwt"?xs(e.data,r.alg)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"jwt",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="cidr"?bs(e.data,r.version)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cidr",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="base64"?ms.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="base64url"?ps.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64url",code:c.invalid_string,message:r.message}),n.dirty()):_.assertNever(r);return{status:n.value,value:e.data}}_regex(e,s,n){return this.refinement(a=>e.test(a),{validation:s,code:c.invalid_string,...h.errToObj(n)})}_addCheck(e){return new Z({...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)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.errToObj(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?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,s){return this._addCheck({kind:"regex",regex:e,...h.errToObj(s)})}includes(e,s){return this._addCheck({kind:"includes",value:e,position:s?.position,...h.errToObj(s?.message)})}startsWith(e,s){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(s)})}endsWith(e,s){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(s)})}min(e,s){return this._addCheck({kind:"min",value:e,...h.errToObj(s)})}max(e,s){return this._addCheck({kind:"max",value:e,...h.errToObj(s)})}length(e,s){return this._addCheck({kind:"length",value:e,...h.errToObj(s)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new Z({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Z({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Z({...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 isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxLength(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}Z.create=t=>new Z({checks:[],typeName:m.ZodString,coerce:t?.coerce??!1,...g(t)});function ks(t,e){const s=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=s>n?s:n,r=Number.parseInt(t.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return r%i/10**a}class F 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 r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.number,received:r.parsedType}),p}let n;const a=new M;for(const r of this._def.checks)r.kind==="int"?_.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?ks(e.data,r.value)!==0&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.not_finite,message:r.message}),a.dirty()):_.assertNever(r);return{status:a.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,h.toString(s))}gt(e,s){return this.setLimit("min",e,!1,h.toString(s))}lte(e,s){return this.setLimit("max",e,!0,h.toString(s))}lt(e,s){return this.setLimit("max",e,!1,h.toString(s))}setLimit(e,s,n,a){return new F({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:h.toString(a)}]})}_addCheck(e){return new F({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(s)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&_.isInteger(e.value))}get isFinite(){let e=null,s=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(s===null||n.value>s)&&(s=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(s)&&Number.isFinite(e)}}F.create=t=>new F({checks:[],typeName:m.ZodNumber,coerce:t?.coerce||!1,...g(t)});class ne extends v{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let n;const a=new M;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):_.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:f.bigint,received:s.parsedType}),p}gte(e,s){return this.setLimit("min",e,!0,h.toString(s))}gt(e,s){return this.setLimit("min",e,!1,h.toString(s))}lte(e,s){return this.setLimit("max",e,!0,h.toString(s))}lt(e,s){return this.setLimit("max",e,!1,h.toString(s))}setLimit(e,s,n,a){return new ne({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:h.toString(a)}]})}_addCheck(e){return new ne({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(s)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}ne.create=t=>new ne({checks:[],typeName:m.ZodBigInt,coerce:t?.coerce??!1,...g(t)});class _e extends v{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.boolean,received:n.parsedType}),p}return I(e.data)}}_e.create=t=>new _e({typeName:m.ZodBoolean,coerce:t?.coerce||!1,...g(t)});class ce extends v{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.date,received:r.parsedType}),p}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_date}),p}const n=new M;let a;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),n.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),n.dirty()):_.assertNever(r);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}min(e,s){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(s)})}max(e,s){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(s)})}get minDate(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e!=null?new Date(e):null}}ce.create=t=>new ce({checks:[],coerce:t?.coerce||!1,typeName:m.ZodDate,...g(t)});class Pe extends v{_parse(e){if(this._getType(e)!==f.symbol){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.symbol,received:n.parsedType}),p}return I(e.data)}}Pe.create=t=>new Pe({typeName:m.ZodSymbol,...g(t)});class Le extends v{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.undefined,received:n.parsedType}),p}return I(e.data)}}Le.create=t=>new Le({typeName:m.ZodUndefined,...g(t)});class Ge extends v{_parse(e){if(this._getType(e)!==f.null){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.null,received:n.parsedType}),p}return I(e.data)}}Ge.create=t=>new Ge({typeName:m.ZodNull,...g(t)});class $e extends v{constructor(){super(...arguments),this._any=!0}_parse(e){return I(e.data)}}$e.create=t=>new $e({typeName:m.ZodAny,...g(t)});class xe extends v{constructor(){super(...arguments),this._unknown=!0}_parse(e){return I(e.data)}}xe.create=t=>new xe({typeName:m.ZodUnknown,...g(t)});class G extends v{_parse(e){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:f.never,received:s.parsedType}),p}}G.create=t=>new G({typeName:m.ZodNever,...g(t)});class Be extends v{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.void,received:n.parsedType}),p}return I(e.data)}}Be.create=t=>new Be({typeName:m.ZodVoid,...g(t)});class E extends v{_parse(e){const{ctx:s,status:n}=this._processInputParams(e),a=this._def;if(s.parsedType!==f.array)return u(s,{code:c.invalid_type,expected:f.array,received:s.parsedType}),p;if(a.exactLength!==null){const i=s.data.length>a.exactLength.value,o=s.data.length<a.exactLength.value;(i||o)&&(u(s,{code:i?c.too_big:c.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&s.data.length<a.minLength.value&&(u(s,{code:c.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&s.data.length>a.maxLength.value&&(u(s,{code:c.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),s.common.async)return Promise.all([...s.data].map((i,o)=>a.type._parseAsync(new A(s,i,s.path,o)))).then(i=>M.mergeArray(n,i));const r=[...s.data].map((i,o)=>a.type._parseSync(new A(s,i,s.path,o)));return M.mergeArray(n,r)}get element(){return this._def.type}min(e,s){return new E({...this._def,minLength:{value:e,message:h.toString(s)}})}max(e,s){return new E({...this._def,maxLength:{value:e,message:h.toString(s)}})}length(e,s){return new E({...this._def,exactLength:{value:e,message:h.toString(s)}})}nonempty(e){return this.min(1,e)}}E.create=(t,e)=>new E({type:t,minLength:null,maxLength:null,exactLength:null,typeName:m.ZodArray,...g(e)});function D(t){if(t instanceof w){const e={};for(const s in t.shape){const n=t.shape[s];e[s]=L.create(D(n))}return new w({...t._def,shape:()=>e})}else return t instanceof E?new E({...t._def,type:D(t.element)}):t instanceof L?L.create(D(t.unwrap())):t instanceof J?J.create(D(t.unwrap())):t instanceof V?V.create(t.items.map(e=>D(e))):t}class w 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(),s=_.objectKeys(e);return this._cached={shape:e,keys:s},this._cached}_parse(e){if(this._getType(e)!==f.object){const l=this._getOrReturnCtx(e);return u(l,{code:c.invalid_type,expected:f.object,received:l.parsedType}),p}const{status:n,ctx:a}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof G&&this._def.unknownKeys==="strip"))for(const l in a.data)i.includes(l)||o.push(l);const d=[];for(const l of i){const y=r[l],N=a.data[l];d.push({key:{status:"valid",value:l},value:y._parse(new A(a,N,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof G){const l=this._def.unknownKeys;if(l==="passthrough")for(const y of o)d.push({key:{status:"valid",value:y},value:{status:"valid",value:a.data[y]}});else if(l==="strict")o.length>0&&(u(a,{code:c.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const y of o){const N=a.data[y];d.push({key:{status:"valid",value:y},value:l._parse(new A(a,N,a.path,y)),alwaysSet:y in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const y of d){const N=await y.key,q=await y.value;l.push({key:N,value:q,alwaysSet:y.alwaysSet})}return l}).then(l=>M.mergeObjectSync(n,l)):M.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(s,n)=>{const a=this._def.errorMap?.(s,n).message??n.defaultError;return s.code==="unrecognized_keys"?{message:h.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:m.ZodObject})}setKey(e,s){return this.augment({[e]:s})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const s={};for(const n of _.objectKeys(e))e[n]&&this.shape[n]&&(s[n]=this.shape[n]);return new w({...this._def,shape:()=>s})}omit(e){const s={};for(const n of _.objectKeys(this.shape))e[n]||(s[n]=this.shape[n]);return new w({...this._def,shape:()=>s})}deepPartial(){return D(this)}partial(e){const s={};for(const n of _.objectKeys(this.shape)){const a=this.shape[n];e&&!e[n]?s[n]=a:s[n]=a.optional()}return new w({...this._def,shape:()=>s})}required(e){const s={};for(const n of _.objectKeys(this.shape))if(e&&!e[n])s[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof L;)r=r._def.innerType;s[n]=r}return new w({...this._def,shape:()=>s})}keyof(){return He(_.objectKeys(this.shape))}}w.create=(t,e)=>new w({shape:()=>t,unknownKeys:"strip",catchall:G.create(),typeName:m.ZodObject,...g(e)});w.strictCreate=(t,e)=>new w({shape:()=>t,unknownKeys:"strict",catchall:G.create(),typeName:m.ZodObject,...g(e)});w.lazycreate=(t,e)=>new w({shape:t,unknownKeys:"strip",catchall:G.create(),typeName:m.ZodObject,...g(e)});class ue extends v{_parse(e){const{ctx:s}=this._processInputParams(e),n=this._def.options;function a(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return s.common.issues.push(...o.ctx.common.issues),o.result;const i=r.map(o=>new j(o.ctx.common.issues));return u(s,{code:c.invalid_union,unionErrors:i}),p}if(s.common.async)return Promise.all(n.map(async r=>{const i={...s,common:{...s.common,issues:[]},parent:null};return{result:await r._parseAsync({data:s.data,path:s.path,parent:i}),ctx:i}})).then(a);{let r;const i=[];for(const d of n){const l={...s,common:{...s.common,issues:[]},parent:null},y=d._parseSync({data:s.data,path:s.path,parent:l});if(y.status==="valid")return y;y.status==="dirty"&&!r&&(r={result:y,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(r)return s.common.issues.push(...r.ctx.common.issues),r.result;const o=i.map(d=>new j(d));return u(s,{code:c.invalid_union,unionErrors:o}),p}}get options(){return this._def.options}}ue.create=(t,e)=>new ue({options:t,typeName:m.ZodUnion,...g(e)});function be(t,e){const s=P(t),n=P(e);if(t===e)return{valid:!0,data:t};if(s===f.object&&n===f.object){const a=_.objectKeys(e),r=_.objectKeys(t).filter(o=>a.indexOf(o)!==-1),i={...t,...e};for(const o of r){const d=be(t[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(s===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let r=0;r<t.length;r++){const i=t[r],o=e[r],d=be(i,o);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return s===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class de extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e),a=(r,i)=>{if(Oe(r)||Oe(i))return p;const o=be(r.value,i.value);return o.valid?((Ze(r)||Ze(i))&&s.dirty(),{status:s.value,value:o.data}):(u(n,{code:c.invalid_intersection_types}),p)};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(([r,i])=>a(r,i)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}de.create=(t,e,s)=>new de({left:t,right:e,typeName:m.ZodIntersection,...g(s)});class V extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return u(n,{code:c.invalid_type,expected:f.array,received:n.parsedType}),p;if(n.data.length<this._def.items.length)return u(n,{code:c.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),p;!this._def.rest&&n.data.length>this._def.items.length&&(u(n,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s.dirty());const r=[...n.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new A(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(r).then(i=>M.mergeArray(s,i)):M.mergeArray(s,r)}get items(){return this._def.items}rest(e){return new V({...this._def,rest:e})}}V.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new V({items:t,typeName:m.ZodTuple,rest:null,...g(e)})};class le extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return u(n,{code:c.invalid_type,expected:f.object,received:n.parsedType}),p;const a=[],r=this._def.keyType,i=this._def.valueType;for(const o in n.data)a.push({key:r._parse(new A(n,o,n.path,o)),value:i._parse(new A(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?M.mergeObjectAsync(s,a):M.mergeObjectSync(s,a)}get element(){return this._def.valueType}static create(e,s,n){return s instanceof v?new le({keyType:e,valueType:s,typeName:m.ZodRecord,...g(n)}):new le({keyType:Z.create(),valueType:e,typeName:m.ZodRecord,...g(s)})}}class Qe extends v{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return u(n,{code:c.invalid_type,expected:f.map,received:n.parsedType}),p;const a=this._def.keyType,r=this._def.valueType,i=[...n.data.entries()].map(([o,d],l)=>({key:a._parse(new A(n,o,n.path,[l,"key"])),value:r._parse(new A(n,d,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const l=await d.key,y=await d.value;if(l.status==="aborted"||y.status==="aborted")return p;(l.status==="dirty"||y.status==="dirty")&&s.dirty(),o.set(l.value,y.value)}return{status:s.value,value:o}})}else{const o=new Map;for(const d of i){const l=d.key,y=d.value;if(l.status==="aborted"||y.status==="aborted")return p;(l.status==="dirty"||y.status==="dirty")&&s.dirty(),o.set(l.value,y.value)}return{status:s.value,value:o}}}}Qe.create=(t,e,s)=>new Qe({valueType:e,keyType:t,typeName:m.ZodMap,...g(s)});class ae extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return u(n,{code:c.invalid_type,expected:f.set,received:n.parsedType}),p;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(u(n,{code:c.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),s.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(u(n,{code:c.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),s.dirty());const r=this._def.valueType;function i(d){const l=new Set;for(const y of d){if(y.status==="aborted")return p;y.status==="dirty"&&s.dirty(),l.add(y.value)}return{status:s.value,value:l}}const o=[...n.data.values()].map((d,l)=>r._parse(new A(n,d,n.path,l)));return n.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,s){return new ae({...this._def,minSize:{value:e,message:h.toString(s)}})}max(e,s){return new ae({...this._def,maxSize:{value:e,message:h.toString(s)}})}size(e,s){return this.min(e,s).max(e,s)}nonempty(e){return this.min(1,e)}}ae.create=(t,e)=>new ae({valueType:t,minSize:null,maxSize:null,typeName:m.ZodSet,...g(e)});class Ve extends v{get schema(){return this._def.getter()}_parse(e){const{ctx:s}=this._processInputParams(e);return this._def.getter()._parse({data:s.data,path:s.path,parent:s})}}Ve.create=(t,e)=>new Ve({getter:t,typeName:m.ZodLazy,...g(e)});class ke extends v{_parse(e){if(e.data!==this._def.value){const s=this._getOrReturnCtx(e);return u(s,{received:s.data,code:c.invalid_literal,expected:this._def.value}),p}return{status:"valid",value:e.data}}get value(){return this._def.value}}ke.create=(t,e)=>new ke({value:t,typeName:m.ZodLiteral,...g(e)});function He(t,e){return new W({values:t,typeName:m.ZodEnum,...g(e)})}class W extends v{_parse(e){if(typeof e.data!="string"){const s=this._getOrReturnCtx(e),n=this._def.values;return u(s,{expected:_.joinValues(n),received:s.parsedType,code:c.invalid_type}),p}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const s=this._getOrReturnCtx(e),n=this._def.values;return u(s,{received:s.data,code:c.invalid_enum_value,options:n}),p}return I(e.data)}get options(){return this._def.values}get enum(){const e={};for(const s of this._def.values)e[s]=s;return e}get Values(){const e={};for(const s of this._def.values)e[s]=s;return e}get Enum(){const e={};for(const s of this._def.values)e[s]=s;return e}extract(e,s=this._def){return W.create(e,{...this._def,...s})}exclude(e,s=this._def){return W.create(this.options.filter(n=>!e.includes(n)),{...this._def,...s})}}W.create=He;class Ue extends v{_parse(e){const s=_.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){const a=_.objectValues(s);return u(n,{expected:_.joinValues(a),received:n.parsedType,code:c.invalid_type}),p}if(this._cache||(this._cache=new Set(_.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=_.objectValues(s);return u(n,{received:n.data,code:c.invalid_enum_value,options:a}),p}return I(e.data)}get enum(){return this._def.values}}Ue.create=(t,e)=>new Ue({values:t,typeName:m.ZodNativeEnum,...g(e)});class fe extends v{unwrap(){return this._def.type}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==f.promise&&s.common.async===!1)return u(s,{code:c.invalid_type,expected:f.promise,received:s.parsedType}),p;const n=s.parsedType===f.promise?s.data:Promise.resolve(s.data);return I(n.then(a=>this._def.type.parseAsync(a,{path:s.path,errorMap:s.common.contextualErrorMap})))}}fe.create=(t,e)=>new fe({type:t,typeName:m.ZodPromise,...g(e)});class H extends v{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===m.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:s,ctx:n}=this._processInputParams(e),a=this._def.effect||null,r={addIssue:i=>{u(n,i),i.fatal?s.abort():s.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),a.type==="preprocess"){const i=a.transform(n.data,r);if(n.common.async)return Promise.resolve(i).then(async o=>{if(s.value==="aborted")return p;const d=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return d.status==="aborted"?p:d.status==="dirty"||s.value==="dirty"?K(d.value):d});{if(s.value==="aborted")return p;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?p:o.status==="dirty"||s.value==="dirty"?K(o.value):o}}if(a.type==="refinement"){const i=o=>{const d=a.refinement(o,r);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?p:(o.status==="dirty"&&s.dirty(),i(o.value),{status:s.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?p:(o.status==="dirty"&&s.dirty(),i(o.value).then(()=>({status:s.value,value:o.value}))))}if(a.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!z(i))return p;const o=a.transform(i.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:s.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>z(i)?Promise.resolve(a.transform(i.value,r)).then(o=>({status:s.value,value:o})):p);_.assertNever(a)}}H.create=(t,e,s)=>new H({schema:t,typeName:m.ZodEffects,effect:e,...g(s)});H.createWithPreprocess=(t,e,s)=>new H({schema:e,effect:{type:"preprocess",transform:t},typeName:m.ZodEffects,...g(s)});class L extends v{_parse(e){return this._getType(e)===f.undefined?I(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}L.create=(t,e)=>new L({innerType:t,typeName:m.ZodOptional,...g(e)});class J extends v{_parse(e){return this._getType(e)===f.null?I(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}J.create=(t,e)=>new J({innerType:t,typeName:m.ZodNullable,...g(e)});class we extends v{_parse(e){const{ctx:s}=this._processInputParams(e);let n=s.data;return s.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:s.path,parent:s})}removeDefault(){return this._def.innerType}}we.create=(t,e)=>new we({innerType:t,typeName:m.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...g(e)});class Se extends v{_parse(e){const{ctx:s}=this._processInputParams(e),n={...s,common:{...s.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return oe(a)?a.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new j(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Se.create=(t,e)=>new Se({innerType:t,typeName:m.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...g(e)});class De extends v{_parse(e){if(this._getType(e)!==f.nan){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.nan,received:n.parsedType}),p}return{status:"valid",value:e.data}}}De.create=t=>new De({typeName:m.ZodNaN,...g(t)});class ws extends v{_parse(e){const{ctx:s}=this._processInputParams(e),n=s.data;return this._def.type._parse({data:n,path:s.path,parent:s})}unwrap(){return this._def.type}}class Me extends v{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?p:r.status==="dirty"?(s.dirty(),K(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?p:a.status==="dirty"?(s.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,s){return new Me({in:e,out:s,typeName:m.ZodPipeline})}}class Re extends v{_parse(e){const s=this._def.innerType._parse(e),n=a=>(z(a)&&(a.value=Object.freeze(a.value)),a);return oe(s)?s.then(a=>n(a)):n(s)}unwrap(){return this._def.innerType}}Re.create=(t,e)=>new Re({innerType:t,typeName:m.ZodReadonly,...g(e)});var m;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(m||(m={}));const x=Z.create,Ce=F.create,Q=_e.create,me=xe.create;G.create;const Ss=E.create,Y=w.create;ue.create;de.create;V.create;const Rs=le.create,b=ke.create;W.create;fe.create;L.create;J.create;const Je=1,$=Y({type:b("qp-bridge"),id:x().optional(),instanceId:x().optional()}),S=$.extend({featureVersion:Ce().optional()}),Ye=$.extend({status:b("answerChanged"),question:x(),answer:me()}),Xe=$.extend({action:b("commandExecuted"),commandName:x()}),Ke=$.extend({action:b("questionnaireLoaded")}),B=$.extend({status:b("success")}),et=$.extend({status:b("error"),message:x()}),Ie=Y({semanticColor:x().optional(),label:x(),description:x(),disabled:Q(),required:Q(),hidden:Q(),errorMessage:x().optional(),answer:me().optional()}),tt=Ie.partial(),st=Y({id:x().uuid(),name:x(),mimeType:x(),blobUrl:x()}),pe=Rs(me()),Te=Y({label:x(),hidden:Q(),collapsed:Q()}),nt=Te.partial(),Ms=Y({entityName:x(),id:x(),name:x()}),at=Y({isNew:Q(),id:x().uuid(),label:x(),description:x().optional(),regarding:Ms.optional()}),rt=S.extend({action:b("getQuestion"),question:x()}),it=B.extend({question:Ie}),ot=S.extend({action:b("setQuestion"),question:x(),questionData:tt}),ct=S.extend({action:b("getGroup"),group:x()}),ut=B.extend({group:Te}),dt=S.extend({action:b("getQuestionnaire")}),lt=B.extend({questionnaire:at}),ft=B.extend({canSave:Q()}),ht=S.extend({action:b("canSave")}),mt=S.extend({action:b("setGroup"),group:x(),groupData:nt}),pt=S.extend({action:b("setAnswer"),question:x(),answer:me()}),gt=S.extend({action:b("busyIndicatorStart")}),yt=S.extend({action:b("busyIndicatorEnd")}),vt=S.extend({action:b("saveQuestionnaire")}),_t=S.extend({action:b("completeAndCloseQuestionnaire")}),xt=S.extend({action:b("executeCustomCommand"),commandName:x()}),bt=S.extend({action:b("fetchEntities"),fetchXml:x()}),kt=B.extend({entities:Ss(pe)}),wt=S.extend({action:b("getEntityById"),entityName:x(),entityId:x()}),St=B.extend({entity:pe}),Rt=S.extend({action:b("saveEntity"),entity:pe}),Mt=S.extend({action:b("repeatGroup"),parentGroupName:x(),groupIndex:Ce()}),Ct=S.extend({action:b("addNewGroup"),groupName:x()}),It=S.extend({action:b("deleteGroup"),parentGroupName:x(),groupIndex:Ce()});function Cs(t){return st.safeParse(t).success}function Tt(t){return Ye.safeParse(t).success}function Et(t){return Xe.safeParse(t).success}function At(t){return Ke.safeParse(t).success}function he(t){return $.safeParse(t).success}function Is(t){return S.safeParse(t).success}function Nt(t){return B.safeParse(t).success}function qt(t){return et.safeParse(t).success}function Ts(t){return rt.safeParse(t).success}function Ot(t){return it.safeParse(t).success}function Es(t){return pt.safeParse(t).success}function As(t){return ot.safeParse(t).success}function Ns(t){return mt.safeParse(t).success}function qs(t){return ct.safeParse(t).success}function Os(t){return dt.safeParse(t).success}function Zt(t){return ut.safeParse(t).success}function jt(t){return lt.safeParse(t).success}function Zs(t){return ft.safeParse(t).success}function Pt(t){return ht.safeParse(t).success}function Lt(t){return gt.safeParse(t).success}function Gt(t){return yt.safeParse(t).success}function js(t){return vt.safeParse(t).success}function Ps(t){return _t.safeParse(t).success}function Ls(t){return xt.safeParse(t).success}function Gs(t){return Lt(t)||Gt(t)}function $t(t,e,s){return!he(t)||t.id!==e||s!==void 0&&t.instanceId!==s||!("status"in t)}function $s(t){return bt.safeParse(t).success}function Bt(t){return kt.safeParse(t).success}function Bs(t){return wt.safeParse(t).success}function Qt(t){return St.safeParse(t).success}function Qs(t){return Rt.safeParse(t).success}function Vs(t){return Mt.safeParse(t).success}function Us(t){return Ct.safeParse(t).success}function Ds(t){return It.safeParse(t).success}function re(t){if(t?.instanceId!=null)return t.instanceId;const e=globalThis.__RESCO_QP_BRIDGE_INSTANCE_ID;return typeof e=="string"?e:void 0}function Vt(t){if(t instanceof File||t instanceof Blob)return URL.createObjectURL(t);if(typeof t=="string"){if(/^data:/.test(t)){const r=t.match(/^data:([^;]+);base64,(.*)$/);if(r){const i=r[1],o=r[2],d=atob(o),l=new ArrayBuffer(d.length),y=new Uint8Array(l);for(let q=0;q<d.length;q++)y[q]=d.charCodeAt(q);const N=new Blob([l],{type:i});return URL.createObjectURL(N)}throw new Error("Invalid data URL format. Only base64 data URLs are supported.")}const e=atob(t),s=new ArrayBuffer(e.length),n=new Uint8Array(s);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);const a=new Blob([s]);return URL.createObjectURL(a)}if(t instanceof ArrayBuffer){const e=new Blob([t]);return URL.createObjectURL(e)}throw new Error("Unsupported content type for blobUrl")}function zs(t,e,s,n){return{id:n??ze(),name:t,mimeType:e,blobUrl:Vt(s)}}function Fs(t,e){let s=t.blobUrl;return e.content!==void 0&&(s=Vt(e.content)),{...t,...e,blobUrl:s}}Ft.env?.NODE_ENV!=="test"&&Ut();function Ut(){window.addEventListener("message",Dt)}function Ws(){window.removeEventListener("message",Dt)}async function Hs(t){return await _n({type:"qp-bridge",action:"getQuestionnaire"},t)}async function Js(t,e,s){await C({type:"qp-bridge",action:"setAnswer",question:t,answer:e},s)}async function Ys(t,e){return await yn({type:"qp-bridge",action:"getQuestion",question:t},e)}async function Xs(t,e,s){await C({type:"qp-bridge",action:"setQuestion",question:t,questionData:e},s)}async function Ks(t,e){return await vn({type:"qp-bridge",action:"getGroup",group:t},e)}async function en(t,e,s){await C({type:"qp-bridge",action:"setGroup",group:t,groupData:e},s)}function tn(t,e){const s=re(e),n=a=>{Tt(a.data)&&a.data.instanceId===s&&t(a.data.question,a.data.answer)};return window.addEventListener("message",n),{cancelSubscription:()=>{window.removeEventListener("message",n)}}}async function sn(t,e){await C({type:"qp-bridge",action:"busyIndicatorStart"},e);try{return await t()}finally{await C({type:"qp-bridge",action:"busyIndicatorEnd"},e)}}async function nn(t){await C({type:"qp-bridge",action:"saveQuestionnaire"},t)}async function an(t){await C({type:"qp-bridge",action:"completeAndCloseQuestionnaire"},t)}async function rn(t,e){await C({type:"qp-bridge",action:"executeCustomCommand",commandName:t},e)}const ee=[],te=[],se=[];function on(t,e){const s=re(e);return se.some(n=>n.handler===t&&n.instanceId===s)||se.push({handler:t,instanceId:s}),{cancelSubscription:()=>{const n=se.findIndex(a=>a.handler===t&&a.instanceId===s);n!==-1&&se.splice(n,1)}}}function cn(t,e){const s=re(e);return te.some(n=>n.handler===t&&n.instanceId===s)||te.push({handler:t,instanceId:s}),{cancelSubscription:()=>{const n=te.findIndex(a=>a.handler===t&&a.instanceId===s);n!==-1&&te.splice(n,1)}}}function un(t,e){const s=re(e);return ee.some(n=>n.validator===t&&n.instanceId===s)||ee.push({validator:t,instanceId:s}),{cancelSubscription:()=>{const n=ee.findIndex(a=>a.validator===t&&a.instanceId===s);n!==-1&&ee.splice(n,1)}}}async function Dt(t){try{if(Et(t.data)&&te.filter(e=>e.instanceId===t.data.instanceId).forEach(e=>e.handler(t.data.commandName)),At(t.data)&&se.filter(e=>e.instanceId===t.data.instanceId).forEach(e=>e.handler()),Pt(t.data)){const e=ee.filter(a=>a.instanceId===t.data.instanceId),s=await Promise.all(e.map(a=>a.validator())),n={type:"qp-bridge",status:"success",id:t.data.id,instanceId:t.data.instanceId,canSave:s.every(a=>a)};window.parent.postMessage(n,"*")}}catch(e){const s={type:"qp-bridge",status:"error",id:he(t.data)?t.data.id:void 0,instanceId:he(t.data)?t.data.instanceId:void 0,message:e instanceof Error?e.message:"Unknown error"};window.parent.postMessage(s,"*")}}async function dn(t,e){return await xn({type:"qp-bridge",action:"fetchEntities",fetchXml:t},e)}async function ln(t,e,s){return await bn({type:"qp-bridge",action:"getEntityById",entityName:t,entityId:e},s)}function fn(){return{isNew:!0}}async function hn(t,e){await C({type:"qp-bridge",action:"saveEntity",entity:t},e)}async function mn(t,e,s){await C({type:"qp-bridge",action:"repeatGroup",parentGroupName:t,groupIndex:e},s)}async function pn(t,e){await C({type:"qp-bridge",action:"addNewGroup",groupName:t},e)}async function gn(t,e,s){await C({type:"qp-bridge",action:"deleteGroup",parentGroupName:t,groupIndex:e},s)}async function X(t,e,s){return new Promise((n,a)=>{const r=ze(),i=re(s),o=d=>{if($t(d.data,r,i))return;const l=e(d.data);l.success?n(l.data):qt(d.data)?a(new Error(d.data.message)):a(new Error("Unknown message received")),window.removeEventListener("message",o)};window.addEventListener("message",o),window.parent.postMessage({...t,id:r,instanceId:i,featureVersion:Je},"*")})}async function yn(t,e){return X(t,s=>Ot(s)?{success:!0,data:s.question}:{success:!1},e)}async function vn(t,e){return X(t,s=>Zt(s)?{success:!0,data:s.group}:{success:!1},e)}async function _n(t,e){return X(t,s=>jt(s)?{success:!0,data:s.questionnaire}:{success:!1},e)}function C(t,e){return X(t,s=>Nt(s)?{success:!0,data:void 0}:{success:!1},e)}async function xn(t,e){return X(t,s=>Bt(s)?{success:!0,data:s.entities}:{success:!1},e)}async function bn(t,e){return X(t,s=>Qt(s)?{success:!0,data:s.entity}:{success:!1},e)}exports.QP_BRIDGE_FEATURE_VERSION=Je;exports.addNewGroup=pn;exports.addNewGroupRequestMessageSchema=Ct;exports.busyIndicatorEndRequestMessageSchema=yt;exports.busyIndicatorStartRequestMessageSchema=gt;exports.canSaveRequestMessageSchema=ht;exports.canSaveSuccessResponseMessageSchema=ft;exports.commandExecutedMessageSchema=Xe;exports.completeAndCloseQuestionnaire=an;exports.completeAndCloseQuestionnaireRequestMessageSchema=_t;exports.createMediaItem=zs;exports.createNewEntity=fn;exports.deleteGroup=gn;exports.deleteGroupRequestMessageSchema=It;exports.entitySchema=pe;exports.executeCustomCommand=rn;exports.executeCustomCommandRequestMessageSchema=xt;exports.fetchEntities=dn;exports.fetchEntitiesRequestMessageSchema=bt;exports.fetchEntitiesSuccessResponseMessageSchema=kt;exports.getEntityById=ln;exports.getEntityByIdRequestMessageSchema=wt;exports.getEntityByIdSuccessResponseMessageSchema=St;exports.getGroup=Ks;exports.getGroupRequestMessageSchema=ct;exports.getGroupSuccessResponseMessageSchema=ut;exports.getQuestion=Ys;exports.getQuestionRequestMessageSchema=rt;exports.getQuestionSuccessResponseMessageSchema=it;exports.getQuestionnaire=Hs;exports.getQuestionnaireRequestMessageSchema=dt;exports.getQuestionnaireSuccessResponseMessageSchema=lt;exports.groupOptionalScheme=nt;exports.groupSchema=Te;exports.initOnSaveMessageHandler=Ut;exports.isAddNewGroupRequestMessage=Us;exports.isBusyIndicatorEndRequestMessage=Gt;exports.isBusyIndicatorStartRequestMessage=Lt;exports.isCanSaveRequestMessage=Pt;exports.isCanSaveSuccessResponseMessage=Zs;exports.isCommandExecutedMessage=Et;exports.isCompleteAndCloseQuestionnaireRequestMessage=Ps;exports.isDeleteGroupRequestMessage=Ds;exports.isErrorMessage=qt;exports.isExecuteCustomCommandRequestMessage=Ls;exports.isFetchEntitiesRequestMessage=$s;exports.isFetchEntitiesSuccessResponseMessage=Bt;exports.isGetEntityByIdRequestMessage=Bs;exports.isGetEntityByIdSuccessResponseMessage=Qt;exports.isGetGroupRequestMessage=qs;exports.isGetGroupSuccessResponseMessage=Zt;exports.isGetQuestionRequestMessage=Ts;exports.isGetQuestionSuccessResponseMessage=Ot;exports.isGetQuestionnaireRequestMessage=Os;exports.isGetQuestionnaireSuccessResponseMessage=jt;exports.isMediaItem=Cs;exports.isNotRelevantMessage=$t;exports.isOnAnswerChangeMessage=Tt;exports.isQpBridgeMessage=he;exports.isQpBridgeRequestMessage=Is;exports.isQuestionnaireLoadedMessage=At;exports.isRepeatGroupRequestMessage=Vs;exports.isSaveEntityRequestMessage=Qs;exports.isSaveQuestionnaireRequestMessage=js;exports.isSetAnswerRequestMessage=Es;exports.isSetGroupRequestMessage=Ns;exports.isSetQuestionRequestMessage=As;exports.isSuccessMessage=Nt;exports.isWithBusyIndicatorRequestMessage=Gs;exports.mediaItemSchema=st;exports.onAnswerChange=tn;exports.onAnswerChangeMessageSchema=Ye;exports.onCommandExecuted=cn;exports.onQuestionnaireLoaded=on;exports.onSave=un;exports.qpBridgeBaseMessageSchema=$;exports.qpBridgeRequestMessageSchema=S;exports.questionOptionalScheme=tt;exports.questionSchema=Ie;exports.questionnaireLoadedMessageSchema=Ke;exports.questionnaireSchema=at;exports.removeOnSaveMessageHandler=Ws;exports.repeatGroup=mn;exports.repeatGroupRequestMessageSchema=Mt;exports.responseErrorMessageSchema=et;exports.responseSuccessMessageSchema=B;exports.saveEntity=hn;exports.saveEntityRequestMessageSchema=Rt;exports.saveQuestionnaire=nn;exports.saveQuestionnaireRequestMessageSchema=vt;exports.setAnswer=Js;exports.setAnswerRequestMessageSchema=pt;exports.setGroup=en;exports.setGroupRequestMessageSchema=mt;exports.setQuestion=Xs;exports.setQuestionRequestMessageSchema=ot;exports.updateMediaItem=Fs;exports.withBusyIndicator=sn;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});var we={exports:{}},Be;function as(){if(Be)return we.exports;Be=1;var t=we.exports={},e,s;function n(){throw new Error("setTimeout has not been defined")}function a(){throw new Error("clearTimeout has not been defined")}(function(){try{typeof setTimeout=="function"?e=setTimeout:e=n}catch{e=n}try{typeof clearTimeout=="function"?s=clearTimeout:s=a}catch{s=a}})();function r(k){if(e===setTimeout)return setTimeout(k,0);if((e===n||!e)&&setTimeout)return e=setTimeout,setTimeout(k,0);try{return e(k,0)}catch{try{return e.call(null,k,0)}catch{return e.call(this,k,0)}}}function i(k){if(s===clearTimeout)return clearTimeout(k);if((s===a||!s)&&clearTimeout)return s=clearTimeout,clearTimeout(k);try{return s(k)}catch{try{return s.call(null,k)}catch{return s.call(this,k)}}}var o=[],d=!1,l,v=-1;function N(){!d||!l||(d=!1,l.length?o=l.concat(o):v=-1,o.length&&O())}function O(){if(!d){var k=r(N);d=!0;for(var E=o.length;E;){for(l=o,o=[];++v<E;)l&&l[v].run();v=-1,E=o.length}l=null,d=!1,i(k)}}t.nextTick=function(k){var E=new Array(arguments.length-1);if(arguments.length>1)for(var H=1;H<arguments.length;H++)E[H-1]=arguments[H];o.push(new Qe(k,E)),o.length===1&&!d&&r(O)};function Qe(k,E){this.fun=k,this.array=E}Qe.prototype.run=function(){this.fun.apply(null,this.array)},t.title="browser",t.browser=!0,t.env={},t.argv=[],t.version="",t.versions={};function Z(){}return t.on=Z,t.addListener=Z,t.once=Z,t.off=Z,t.removeListener=Z,t.removeAllListeners=Z,t.emit=Z,t.prependListener=Z,t.prependOnceListener=Z,t.listeners=function(k){return[]},t.binding=function(k){throw new Error("process.binding is not supported")},t.cwd=function(){return"/"},t.chdir=function(k){throw new Error("process.chdir is not supported")},t.umask=function(){return 0},we.exports}var rs=as();const R=[];for(let t=0;t<256;++t)R.push((t+256).toString(16).slice(1));function is(t,e=0){return(R[t[e+0]]+R[t[e+1]]+R[t[e+2]]+R[t[e+3]]+"-"+R[t[e+4]]+R[t[e+5]]+"-"+R[t[e+6]]+R[t[e+7]]+"-"+R[t[e+8]]+R[t[e+9]]+"-"+R[t[e+10]]+R[t[e+11]]+R[t[e+12]]+R[t[e+13]]+R[t[e+14]]+R[t[e+15]]).toLowerCase()}const os=new Uint8Array(16);function cs(){return crypto.getRandomValues(os)}function Xe(t,e,s){return crypto.randomUUID?crypto.randomUUID():us(t)}function us(t,e,s){t=t||{};const n=t.random??t.rng?.()??cs();if(n.length<16)throw new Error("Random bytes length must be >= 16");return n[6]=n[6]&15|64,n[8]=n[8]&63|128,is(n)}var x;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function s(a){throw new Error}t.assertNever=s,t.arrayToEnum=a=>{const r={};for(const i of a)r[i]=i;return r},t.getValidEnumValues=a=>{const r=t.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),i={};for(const o of r)i[o]=a[o];return t.objectValues(i)},t.objectValues=a=>t.objectKeys(a).map(function(r){return a[r]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const r=[];for(const i in a)Object.prototype.hasOwnProperty.call(a,i)&&r.push(i);return r},t.find=(a,r)=>{for(const i of a)if(r(i))return i},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,r=" | "){return a.map(i=>typeof i=="string"?`'${i}'`:i).join(r)}t.joinValues=n,t.jsonStringifyReplacer=(a,r)=>typeof r=="bigint"?r.toString():r})(x||(x={}));var Ve;(function(t){t.mergeShapes=(e,s)=>({...e,...s})})(Ve||(Ve={}));const f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Q=t=>{switch(typeof t){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(t)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(t)?f.array:t===null?f.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?f.promise:typeof Map<"u"&&t instanceof Map?f.map:typeof Set<"u"&&t instanceof Set?f.set:typeof Date<"u"&&t instanceof Date?f.date:f.object;default:return f.unknown}},c=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class L extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const s=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,s):this.__proto__=s,this.name="ZodError",this.issues=e}format(e){const s=e||function(r){return r.message},n={_errors:[]},a=r=>{for(const i of r.issues)if(i.code==="invalid_union")i.unionErrors.map(a);else if(i.code==="invalid_return_type")a(i.returnTypeError);else if(i.code==="invalid_arguments")a(i.argumentsError);else if(i.path.length===0)n._errors.push(s(i));else{let o=n,d=0;for(;d<i.path.length;){const l=i.path[d];d===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(s(i))):o[l]=o[l]||{_errors:[]},o=o[l],d++}}};return a(this),n}static assert(e){if(!(e instanceof L))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=s=>s.message){const s={},n=[];for(const a of this.issues)if(a.path.length>0){const r=a.path[0];s[r]=s[r]||[],s[r].push(e(a))}else n.push(e(a));return{formErrors:n,fieldErrors:s}}get formErrors(){return this.flatten()}}L.create=t=>new L(t);const Re=(t,e)=>{let s;switch(t.code){case c.invalid_type:t.received===f.undefined?s="Required":s=`Expected ${t.expected}, received ${t.received}`;break;case c.invalid_literal:s=`Invalid literal value, expected ${JSON.stringify(t.expected,x.jsonStringifyReplacer)}`;break;case c.unrecognized_keys:s=`Unrecognized key(s) in object: ${x.joinValues(t.keys,", ")}`;break;case c.invalid_union:s="Invalid input";break;case c.invalid_union_discriminator:s=`Invalid discriminator value. Expected ${x.joinValues(t.options)}`;break;case c.invalid_enum_value:s=`Invalid enum value. Expected ${x.joinValues(t.options)}, received '${t.received}'`;break;case c.invalid_arguments:s="Invalid function arguments";break;case c.invalid_return_type:s="Invalid function return type";break;case c.invalid_date:s="Invalid date";break;case c.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(s=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(s=`${s} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?s=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?s=`Invalid input: must end with "${t.validation.endsWith}"`:x.assertNever(t.validation):t.validation!=="regex"?s=`Invalid ${t.validation}`:s="Invalid";break;case c.too_small:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?s=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:s="Invalid input";break;case c.too_big:t.type==="array"?s=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?s=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?s=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?s=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?s=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:s="Invalid input";break;case c.custom:s="Invalid input";break;case c.invalid_intersection_types:s="Intersection results could not be merged";break;case c.not_multiple_of:s=`Number must be a multiple of ${t.multipleOf}`;break;case c.not_finite:s="Number must be finite";break;default:s=e.defaultError,x.assertNever(t)}return{message:s}};let ds=Re;function ls(){return ds}const fs=t=>{const{data:e,path:s,errorMaps:n,issueData:a}=t,r=[...s,...a.path||[]],i={...a,path:r};if(a.message!==void 0)return{...a,path:r,message:a.message};let o="";const d=n.filter(l=>!!l).slice().reverse();for(const l of d)o=l(i,{data:e,defaultError:o}).message;return{...a,path:r,message:o}};function u(t,e){const s=ls(),n=fs({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,s,s===Re?void 0:Re].filter(a=>!!a)});t.common.issues.push(n)}class M{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,s){const n=[];for(const a of s){if(a.status==="aborted")return m;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,s){const n=[];for(const a of s){const r=await a.key,i=await a.value;n.push({key:r,value:i})}return M.mergeObjectSync(e,n)}static mergeObjectSync(e,s){const n={};for(const a of s){const{key:r,value:i}=a;if(r.status==="aborted"||i.status==="aborted")return m;r.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),r.value!=="__proto__"&&(typeof i.value<"u"||a.alwaysSet)&&(n[r.value]=i.value)}return{status:e.value,value:n}}}const m=Object.freeze({status:"aborted"}),ee=t=>({status:"dirty",value:t}),C=t=>({status:"valid",value:t}),Ue=t=>t.status==="aborted",De=t=>t.status==="dirty",Y=t=>t.status==="valid",oe=t=>typeof Promise<"u"&&t instanceof Promise;var h;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));class A{constructor(e,s,n,a){this._cachedPath=[],this.parent=e,this.data=s,this._path=n,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ze=(t,e)=>{if(Y(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const s=new L(t.common.issues);return this._error=s,this._error}}};function y(t){if(!t)return{};const{errorMap:e,invalid_type_error:s,required_error:n,description:a}=t;if(e&&(s||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(i,o)=>{const{message:d}=t;return i.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:d??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:d??s??o.defaultError}},description:a}}class _{get description(){return this._def.description}_getType(e){return Q(e.data)}_getOrReturnCtx(e,s){return s||{common:e.parent.common,data:e.data,parsedType:Q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new M,ctx:{common:e.parent.common,data:e.data,parsedType:Q(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const s=this._parse(e);if(oe(s))throw new Error("Synchronous parse encountered promise.");return s}_parseAsync(e){const s=this._parse(e);return Promise.resolve(s)}parse(e,s){const n=this.safeParse(e,s);if(n.success)return n.data;throw n.error}safeParse(e,s){const n={common:{issues:[],async:s?.async??!1,contextualErrorMap:s?.errorMap},path:s?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Q(e)},a=this._parseSync({data:e,path:n.path,parent:n});return ze(n,a)}"~validate"(e){const s={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Q(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:s});return Y(n)?{value:n.value}:{issues:s.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),s.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:s}).then(n=>Y(n)?{value:n.value}:{issues:s.common.issues})}async parseAsync(e,s){const n=await this.safeParseAsync(e,s);if(n.success)return n.data;throw n.error}async safeParseAsync(e,s){const n={common:{issues:[],contextualErrorMap:s?.errorMap,async:!0},path:s?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Q(e)},a=this._parse({data:e,path:n.path,parent:n}),r=await(oe(a)?a:Promise.resolve(a));return ze(n,r)}refine(e,s){const n=a=>typeof s=="string"||typeof s>"u"?{message:s}:typeof s=="function"?s(a):s;return this._refinement((a,r)=>{const i=e(a),o=()=>r.addIssue({code:c.custom,...n(a)});return typeof Promise<"u"&&i instanceof Promise?i.then(d=>d?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,s){return this._refinement((n,a)=>e(n)?!0:(a.addIssue(typeof s=="function"?s(n,a):s),!1))}_refinement(e){return new F({schema:this,typeName:p.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}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),this["~standard"]={version:1,vendor:"zod",validate:s=>this["~validate"](s)}}optional(){return G.create(this,this._def)}nullable(){return W.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return q.create(this)}promise(){return me.create(this,this._def)}or(e){return ue.create([this,e],this._def)}and(e){return de.create(this,e,this._def)}transform(e){return new F({...y(this._def),schema:this,typeName:p.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const s=typeof e=="function"?e:()=>e;return new pe({...y(this._def),innerType:this,defaultValue:s,typeName:p.ZodDefault})}brand(){return new st({typeName:p.ZodBranded,type:this,...y(this._def)})}catch(e){const s=typeof e=="function"?e:()=>e;return new ge({...y(this._def),innerType:this,catchValue:s,typeName:p.ZodCatch})}describe(e){const s=this.constructor;return new s({...this._def,description:e})}pipe(e){return Oe.create(this,e)}readonly(){return ye.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const hs=/^c[^\s-]{8,}$/i,ms=/^[0-9a-z]+$/,ps=/^[0-9A-HJKMNP-TV-Z]{26}$/i,gs=/^[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,ys=/^[a-z0-9_-]{21}$/i,vs=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_s=/^[-+]?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)?)??$/,xs=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,bs="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let Se;const ks=/^(?:(?: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])$/,ws=/^(?:(?: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])\/(3[0-2]|[12]?[0-9])$/,Ss=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Rs=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Ms=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Ts=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ke="((\\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])))",Cs=new RegExp(`^${Ke}$`);function et(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const s=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${s}`}function Is(t){return new RegExp(`^${et(t)}$`)}function Es(t){let e=`${Ke}T${et(t)}`;const s=[];return s.push(t.local?"Z?":"Z"),t.offset&&s.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${s.join("|")})`,new RegExp(`^${e}$`)}function qs(t,e){return!!((e==="v4"||!e)&&ks.test(t)||(e==="v6"||!e)&&Ss.test(t))}function As(t,e){if(!vs.test(t))return!1;try{const[s]=t.split(".");if(!s)return!1;const n=s.replace(/-/g,"+").replace(/_/g,"/").padEnd(s.length+(4-s.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&a?.typ!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function Ns(t,e){return!!((e==="v4"||!e)&&ws.test(t)||(e==="v6"||!e)&&Rs.test(t))}class P extends _{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.string,received:r.parsedType}),m}const n=new M;let a;for(const r of this._def.checks)if(r.kind==="min")e.data.length<r.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind==="max")e.data.length>r.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),n.dirty());else if(r.kind==="length"){const i=e.data.length>r.value,o=e.data.length<r.value;(i||o)&&(a=this._getOrReturnCtx(e,a),i?u(a,{code:c.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):o&&u(a,{code:c.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),n.dirty())}else if(r.kind==="email")xs.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"email",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="emoji")Se||(Se=new RegExp(bs,"u")),Se.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"emoji",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="uuid")gs.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"uuid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="nanoid")ys.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"nanoid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid")hs.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="cuid2")ms.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cuid2",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="ulid")ps.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"ulid",code:c.invalid_string,message:r.message}),n.dirty());else if(r.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),u(a,{validation:"url",code:c.invalid_string,message:r.message}),n.dirty()}else r.kind==="regex"?(r.regex.lastIndex=0,r.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"regex",code:c.invalid_string,message:r.message}),n.dirty())):r.kind==="trim"?e.data=e.data.trim():r.kind==="includes"?e.data.includes(r.value,r.position)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),n.dirty()):r.kind==="toLowerCase"?e.data=e.data.toLowerCase():r.kind==="toUpperCase"?e.data=e.data.toUpperCase():r.kind==="startsWith"?e.data.startsWith(r.value)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:{startsWith:r.value},message:r.message}),n.dirty()):r.kind==="endsWith"?e.data.endsWith(r.value)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:{endsWith:r.value},message:r.message}),n.dirty()):r.kind==="datetime"?Es(r).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:"datetime",message:r.message}),n.dirty()):r.kind==="date"?Cs.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:"date",message:r.message}),n.dirty()):r.kind==="time"?Is(r).test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{code:c.invalid_string,validation:"time",message:r.message}),n.dirty()):r.kind==="duration"?_s.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"duration",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="ip"?qs(e.data,r.version)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"ip",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="jwt"?As(e.data,r.alg)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"jwt",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="cidr"?Ns(e.data,r.version)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"cidr",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="base64"?Ms.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64",code:c.invalid_string,message:r.message}),n.dirty()):r.kind==="base64url"?Ts.test(e.data)||(a=this._getOrReturnCtx(e,a),u(a,{validation:"base64url",code:c.invalid_string,message:r.message}),n.dirty()):x.assertNever(r);return{status:n.value,value:e.data}}_regex(e,s,n){return this.refinement(a=>e.test(a),{validation:s,code:c.invalid_string,...h.errToObj(n)})}_addCheck(e){return new P({...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)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.errToObj(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?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,s){return this._addCheck({kind:"regex",regex:e,...h.errToObj(s)})}includes(e,s){return this._addCheck({kind:"includes",value:e,position:s?.position,...h.errToObj(s?.message)})}startsWith(e,s){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(s)})}endsWith(e,s){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(s)})}min(e,s){return this._addCheck({kind:"min",value:e,...h.errToObj(s)})}max(e,s){return this._addCheck({kind:"max",value:e,...h.errToObj(s)})}length(e,s){return this._addCheck({kind:"length",value:e,...h.errToObj(s)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new P({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new P({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new P({...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 isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxLength(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}P.create=t=>new P({checks:[],typeName:p.ZodString,coerce:t?.coerce??!1,...y(t)});function Os(t,e){const s=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=s>n?s:n,r=Number.parseInt(t.toFixed(a).replace(".","")),i=Number.parseInt(e.toFixed(a).replace(".",""));return r%i/10**a}class X extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.number,received:r.parsedType}),m}let n;const a=new M;for(const r of this._def.checks)r.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.invalid_type,expected:"integer",received:"float",message:r.message}),a.dirty()):r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),a.dirty()):r.kind==="multipleOf"?Os(e.data,r.value)!==0&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):r.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),u(n,{code:c.not_finite,message:r.message}),a.dirty()):x.assertNever(r);return{status:a.value,value:e.data}}gte(e,s){return this.setLimit("min",e,!0,h.toString(s))}gt(e,s){return this.setLimit("min",e,!1,h.toString(s))}lte(e,s){return this.setLimit("max",e,!0,h.toString(s))}lt(e,s){return this.setLimit("max",e,!1,h.toString(s))}setLimit(e,s,n,a){return new X({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:h.toString(a)}]})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(s)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,s=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(s===null||n.value>s)&&(s=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(s)&&Number.isFinite(e)}}X.create=t=>new X({checks:[],typeName:p.ZodNumber,coerce:t?.coerce||!1,...y(t)});class ae extends _{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let n;const a=new M;for(const r of this._def.checks)r.kind==="min"?(r.inclusive?e.data<r.value:e.data<=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="max"?(r.inclusive?e.data>r.value:e.data>=r.value)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),a.dirty()):r.kind==="multipleOf"?e.data%r.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),u(n,{code:c.not_multiple_of,multipleOf:r.value,message:r.message}),a.dirty()):x.assertNever(r);return{status:a.value,value:e.data}}_getInvalidInput(e){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:f.bigint,received:s.parsedType}),m}gte(e,s){return this.setLimit("min",e,!0,h.toString(s))}gt(e,s){return this.setLimit("min",e,!1,h.toString(s))}lte(e,s){return this.setLimit("max",e,!0,h.toString(s))}lt(e,s){return this.setLimit("max",e,!1,h.toString(s))}setLimit(e,s,n,a){return new ae({...this._def,checks:[...this._def.checks,{kind:e,value:s,inclusive:n,message:h.toString(a)}]})}_addCheck(e){return new ae({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,s){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(s)})}get minValue(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e}get maxValue(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e}}ae.create=t=>new ae({checks:[],typeName:p.ZodBigInt,coerce:t?.coerce??!1,...y(t)});class Me extends _{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.boolean,received:n.parsedType}),m}return C(e.data)}}Me.create=t=>new Me({typeName:p.ZodBoolean,coerce:t?.coerce||!1,...y(t)});class ce extends _{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_type,expected:f.date,received:r.parsedType}),m}if(Number.isNaN(e.data.getTime())){const r=this._getOrReturnCtx(e);return u(r,{code:c.invalid_date}),m}const n=new M;let a;for(const r of this._def.checks)r.kind==="min"?e.data.getTime()<r.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),n.dirty()):r.kind==="max"?e.data.getTime()>r.value&&(a=this._getOrReturnCtx(e,a),u(a,{code:c.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),n.dirty()):x.assertNever(r);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new ce({...this._def,checks:[...this._def.checks,e]})}min(e,s){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(s)})}max(e,s){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(s)})}get minDate(){let e=null;for(const s of this._def.checks)s.kind==="min"&&(e===null||s.value>e)&&(e=s.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const s of this._def.checks)s.kind==="max"&&(e===null||s.value<e)&&(e=s.value);return e!=null?new Date(e):null}}ce.create=t=>new ce({checks:[],coerce:t?.coerce||!1,typeName:p.ZodDate,...y(t)});class Fe extends _{_parse(e){if(this._getType(e)!==f.symbol){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.symbol,received:n.parsedType}),m}return C(e.data)}}Fe.create=t=>new Fe({typeName:p.ZodSymbol,...y(t)});class Te extends _{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.undefined,received:n.parsedType}),m}return C(e.data)}}Te.create=t=>new Te({typeName:p.ZodUndefined,...y(t)});class Ce extends _{_parse(e){if(this._getType(e)!==f.null){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.null,received:n.parsedType}),m}return C(e.data)}}Ce.create=t=>new Ce({typeName:p.ZodNull,...y(t)});class We extends _{constructor(){super(...arguments),this._any=!0}_parse(e){return C(e.data)}}We.create=t=>new We({typeName:p.ZodAny,...y(t)});class Ie extends _{constructor(){super(...arguments),this._unknown=!0}_parse(e){return C(e.data)}}Ie.create=t=>new Ie({typeName:p.ZodUnknown,...y(t)});class B extends _{_parse(e){const s=this._getOrReturnCtx(e);return u(s,{code:c.invalid_type,expected:f.never,received:s.parsedType}),m}}B.create=t=>new B({typeName:p.ZodNever,...y(t)});class He extends _{_parse(e){if(this._getType(e)!==f.undefined){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.void,received:n.parsedType}),m}return C(e.data)}}He.create=t=>new He({typeName:p.ZodVoid,...y(t)});class q extends _{_parse(e){const{ctx:s,status:n}=this._processInputParams(e),a=this._def;if(s.parsedType!==f.array)return u(s,{code:c.invalid_type,expected:f.array,received:s.parsedType}),m;if(a.exactLength!==null){const i=s.data.length>a.exactLength.value,o=s.data.length<a.exactLength.value;(i||o)&&(u(s,{code:i?c.too_big:c.too_small,minimum:o?a.exactLength.value:void 0,maximum:i?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&s.data.length<a.minLength.value&&(u(s,{code:c.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&s.data.length>a.maxLength.value&&(u(s,{code:c.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),s.common.async)return Promise.all([...s.data].map((i,o)=>a.type._parseAsync(new A(s,i,s.path,o)))).then(i=>M.mergeArray(n,i));const r=[...s.data].map((i,o)=>a.type._parseSync(new A(s,i,s.path,o)));return M.mergeArray(n,r)}get element(){return this._def.type}min(e,s){return new q({...this._def,minLength:{value:e,message:h.toString(s)}})}max(e,s){return new q({...this._def,maxLength:{value:e,message:h.toString(s)}})}length(e,s){return new q({...this._def,exactLength:{value:e,message:h.toString(s)}})}nonempty(e){return this.min(1,e)}}q.create=(t,e)=>new q({type:t,minLength:null,maxLength:null,exactLength:null,typeName:p.ZodArray,...y(e)});function J(t){if(t instanceof w){const e={};for(const s in t.shape){const n=t.shape[s];e[s]=G.create(J(n))}return new w({...t._def,shape:()=>e})}else return t instanceof q?new q({...t._def,type:J(t.element)}):t instanceof G?G.create(J(t.unwrap())):t instanceof W?W.create(J(t.unwrap())):t instanceof D?D.create(t.items.map(e=>J(e))):t}class w extends _{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),s=x.objectKeys(e);return this._cached={shape:e,keys:s},this._cached}_parse(e){if(this._getType(e)!==f.object){const l=this._getOrReturnCtx(e);return u(l,{code:c.invalid_type,expected:f.object,received:l.parsedType}),m}const{status:n,ctx:a}=this._processInputParams(e),{shape:r,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof B&&this._def.unknownKeys==="strip"))for(const l in a.data)i.includes(l)||o.push(l);const d=[];for(const l of i){const v=r[l],N=a.data[l];d.push({key:{status:"valid",value:l},value:v._parse(new A(a,N,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof B){const l=this._def.unknownKeys;if(l==="passthrough")for(const v of o)d.push({key:{status:"valid",value:v},value:{status:"valid",value:a.data[v]}});else if(l==="strict")o.length>0&&(u(a,{code:c.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const v of o){const N=a.data[v];d.push({key:{status:"valid",value:v},value:l._parse(new A(a,N,a.path,v)),alwaysSet:v in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const v of d){const N=await v.key,O=await v.value;l.push({key:N,value:O,alwaysSet:v.alwaysSet})}return l}).then(l=>M.mergeObjectSync(n,l)):M.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new w({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(s,n)=>{const a=this._def.errorMap?.(s,n).message??n.defaultError;return s.code==="unrecognized_keys"?{message:h.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new w({...this._def,unknownKeys:"strip"})}passthrough(){return new w({...this._def,unknownKeys:"passthrough"})}extend(e){return new w({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new w({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:p.ZodObject})}setKey(e,s){return this.augment({[e]:s})}catchall(e){return new w({...this._def,catchall:e})}pick(e){const s={};for(const n of x.objectKeys(e))e[n]&&this.shape[n]&&(s[n]=this.shape[n]);return new w({...this._def,shape:()=>s})}omit(e){const s={};for(const n of x.objectKeys(this.shape))e[n]||(s[n]=this.shape[n]);return new w({...this._def,shape:()=>s})}deepPartial(){return J(this)}partial(e){const s={};for(const n of x.objectKeys(this.shape)){const a=this.shape[n];e&&!e[n]?s[n]=a:s[n]=a.optional()}return new w({...this._def,shape:()=>s})}required(e){const s={};for(const n of x.objectKeys(this.shape))if(e&&!e[n])s[n]=this.shape[n];else{let r=this.shape[n];for(;r instanceof G;)r=r._def.innerType;s[n]=r}return new w({...this._def,shape:()=>s})}keyof(){return tt(x.objectKeys(this.shape))}}w.create=(t,e)=>new w({shape:()=>t,unknownKeys:"strip",catchall:B.create(),typeName:p.ZodObject,...y(e)});w.strictCreate=(t,e)=>new w({shape:()=>t,unknownKeys:"strict",catchall:B.create(),typeName:p.ZodObject,...y(e)});w.lazycreate=(t,e)=>new w({shape:t,unknownKeys:"strip",catchall:B.create(),typeName:p.ZodObject,...y(e)});class ue extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n=this._def.options;function a(r){for(const o of r)if(o.result.status==="valid")return o.result;for(const o of r)if(o.result.status==="dirty")return s.common.issues.push(...o.ctx.common.issues),o.result;const i=r.map(o=>new L(o.ctx.common.issues));return u(s,{code:c.invalid_union,unionErrors:i}),m}if(s.common.async)return Promise.all(n.map(async r=>{const i={...s,common:{...s.common,issues:[]},parent:null};return{result:await r._parseAsync({data:s.data,path:s.path,parent:i}),ctx:i}})).then(a);{let r;const i=[];for(const d of n){const l={...s,common:{...s.common,issues:[]},parent:null},v=d._parseSync({data:s.data,path:s.path,parent:l});if(v.status==="valid")return v;v.status==="dirty"&&!r&&(r={result:v,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(r)return s.common.issues.push(...r.ctx.common.issues),r.result;const o=i.map(d=>new L(d));return u(s,{code:c.invalid_union,unionErrors:o}),m}}get options(){return this._def.options}}ue.create=(t,e)=>new ue({options:t,typeName:p.ZodUnion,...y(e)});const j=t=>t instanceof fe?j(t.schema):t instanceof F?j(t.innerType()):t instanceof he?[t.value]:t instanceof z?t.options:t instanceof qe?x.objectValues(t.enum):t instanceof pe?j(t._def.innerType):t instanceof Te?[void 0]:t instanceof Ce?[null]:t instanceof G?[void 0,...j(t.unwrap())]:t instanceof W?[null,...j(t.unwrap())]:t instanceof st||t instanceof ye?j(t.unwrap()):t instanceof ge?j(t._def.innerType):[];class Ne extends _{_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==f.object)return u(s,{code:c.invalid_type,expected:f.object,received:s.parsedType}),m;const n=this.discriminator,a=s.data[n],r=this.optionsMap.get(a);return r?s.common.async?r._parseAsync({data:s.data,path:s.path,parent:s}):r._parseSync({data:s.data,path:s.path,parent:s}):(u(s,{code:c.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),m)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,s,n){const a=new Map;for(const r of s){const i=j(r.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(a.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);a.set(o,r)}}return new Ne({typeName:p.ZodDiscriminatedUnion,discriminator:e,options:s,optionsMap:a,...y(n)})}}function Ee(t,e){const s=Q(t),n=Q(e);if(t===e)return{valid:!0,data:t};if(s===f.object&&n===f.object){const a=x.objectKeys(e),r=x.objectKeys(t).filter(o=>a.indexOf(o)!==-1),i={...t,...e};for(const o of r){const d=Ee(t[o],e[o]);if(!d.valid)return{valid:!1};i[o]=d.data}return{valid:!0,data:i}}else if(s===f.array&&n===f.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let r=0;r<t.length;r++){const i=t[r],o=e[r],d=Ee(i,o);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return s===f.date&&n===f.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class de extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e),a=(r,i)=>{if(Ue(r)||Ue(i))return m;const o=Ee(r.value,i.value);return o.valid?((De(r)||De(i))&&s.dirty(),{status:s.value,value:o.data}):(u(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(([r,i])=>a(r,i)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}de.create=(t,e,s)=>new de({left:t,right:e,typeName:p.ZodIntersection,...y(s)});class D extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return u(n,{code:c.invalid_type,expected:f.array,received:n.parsedType}),m;if(n.data.length<this._def.items.length)return u(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&&(u(n,{code:c.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),s.dirty());const r=[...n.data].map((i,o)=>{const d=this._def.items[o]||this._def.rest;return d?d._parse(new A(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(r).then(i=>M.mergeArray(s,i)):M.mergeArray(s,r)}get items(){return this._def.items}rest(e){return new D({...this._def,rest:e})}}D.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new D({items:t,typeName:p.ZodTuple,rest:null,...y(e)})};class le extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return u(n,{code:c.invalid_type,expected:f.object,received:n.parsedType}),m;const a=[],r=this._def.keyType,i=this._def.valueType;for(const o in n.data)a.push({key:r._parse(new A(n,o,n.path,o)),value:i._parse(new A(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?M.mergeObjectAsync(s,a):M.mergeObjectSync(s,a)}get element(){return this._def.valueType}static create(e,s,n){return s instanceof _?new le({keyType:e,valueType:s,typeName:p.ZodRecord,...y(n)}):new le({keyType:P.create(),valueType:e,typeName:p.ZodRecord,...y(s)})}}class Je extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return u(n,{code:c.invalid_type,expected:f.map,received:n.parsedType}),m;const a=this._def.keyType,r=this._def.valueType,i=[...n.data.entries()].map(([o,d],l)=>({key:a._parse(new A(n,o,n.path,[l,"key"])),value:r._parse(new A(n,d,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of i){const l=await d.key,v=await d.value;if(l.status==="aborted"||v.status==="aborted")return m;(l.status==="dirty"||v.status==="dirty")&&s.dirty(),o.set(l.value,v.value)}return{status:s.value,value:o}})}else{const o=new Map;for(const d of i){const l=d.key,v=d.value;if(l.status==="aborted"||v.status==="aborted")return m;(l.status==="dirty"||v.status==="dirty")&&s.dirty(),o.set(l.value,v.value)}return{status:s.value,value:o}}}}Je.create=(t,e,s)=>new Je({valueType:e,keyType:t,typeName:p.ZodMap,...y(s)});class re extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return u(n,{code:c.invalid_type,expected:f.set,received:n.parsedType}),m;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(u(n,{code:c.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),s.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(u(n,{code:c.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),s.dirty());const r=this._def.valueType;function i(d){const l=new Set;for(const v of d){if(v.status==="aborted")return m;v.status==="dirty"&&s.dirty(),l.add(v.value)}return{status:s.value,value:l}}const o=[...n.data.values()].map((d,l)=>r._parse(new A(n,d,n.path,l)));return n.common.async?Promise.all(o).then(d=>i(d)):i(o)}min(e,s){return new re({...this._def,minSize:{value:e,message:h.toString(s)}})}max(e,s){return new re({...this._def,maxSize:{value:e,message:h.toString(s)}})}size(e,s){return this.min(e,s).max(e,s)}nonempty(e){return this.min(1,e)}}re.create=(t,e)=>new re({valueType:t,minSize:null,maxSize:null,typeName:p.ZodSet,...y(e)});class fe extends _{get schema(){return this._def.getter()}_parse(e){const{ctx:s}=this._processInputParams(e);return this._def.getter()._parse({data:s.data,path:s.path,parent:s})}}fe.create=(t,e)=>new fe({getter:t,typeName:p.ZodLazy,...y(e)});class he extends _{_parse(e){if(e.data!==this._def.value){const s=this._getOrReturnCtx(e);return u(s,{received:s.data,code:c.invalid_literal,expected:this._def.value}),m}return{status:"valid",value:e.data}}get value(){return this._def.value}}he.create=(t,e)=>new he({value:t,typeName:p.ZodLiteral,...y(e)});function tt(t,e){return new z({values:t,typeName:p.ZodEnum,...y(e)})}class z extends _{_parse(e){if(typeof e.data!="string"){const s=this._getOrReturnCtx(e),n=this._def.values;return u(s,{expected:x.joinValues(n),received:s.parsedType,code:c.invalid_type}),m}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const s=this._getOrReturnCtx(e),n=this._def.values;return u(s,{received:s.data,code:c.invalid_enum_value,options:n}),m}return C(e.data)}get options(){return this._def.values}get enum(){const e={};for(const s of this._def.values)e[s]=s;return e}get Values(){const e={};for(const s of this._def.values)e[s]=s;return e}get Enum(){const e={};for(const s of this._def.values)e[s]=s;return e}extract(e,s=this._def){return z.create(e,{...this._def,...s})}exclude(e,s=this._def){return z.create(this.options.filter(n=>!e.includes(n)),{...this._def,...s})}}z.create=tt;class qe extends _{_parse(e){const s=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){const a=x.objectValues(s);return u(n,{expected:x.joinValues(a),received:n.parsedType,code:c.invalid_type}),m}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=x.objectValues(s);return u(n,{received:n.data,code:c.invalid_enum_value,options:a}),m}return C(e.data)}get enum(){return this._def.values}}qe.create=(t,e)=>new qe({values:t,typeName:p.ZodNativeEnum,...y(e)});class me extends _{unwrap(){return this._def.type}_parse(e){const{ctx:s}=this._processInputParams(e);if(s.parsedType!==f.promise&&s.common.async===!1)return u(s,{code:c.invalid_type,expected:f.promise,received:s.parsedType}),m;const n=s.parsedType===f.promise?s.data:Promise.resolve(s.data);return C(n.then(a=>this._def.type.parseAsync(a,{path:s.path,errorMap:s.common.contextualErrorMap})))}}me.create=(t,e)=>new me({type:t,typeName:p.ZodPromise,...y(e)});class F extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===p.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:s,ctx:n}=this._processInputParams(e),a=this._def.effect||null,r={addIssue:i=>{u(n,i),i.fatal?s.abort():s.dirty()},get path(){return n.path}};if(r.addIssue=r.addIssue.bind(r),a.type==="preprocess"){const i=a.transform(n.data,r);if(n.common.async)return Promise.resolve(i).then(async o=>{if(s.value==="aborted")return m;const d=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return d.status==="aborted"?m:d.status==="dirty"||s.value==="dirty"?ee(d.value):d});{if(s.value==="aborted")return m;const o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?m:o.status==="dirty"||s.value==="dirty"?ee(o.value):o}}if(a.type==="refinement"){const i=o=>{const d=a.refinement(o,r);if(n.common.async)return Promise.resolve(d);if(d instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?m:(o.status==="dirty"&&s.dirty(),i(o.value),{status:s.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?m:(o.status==="dirty"&&s.dirty(),i(o.value).then(()=>({status:s.value,value:o.value}))))}if(a.type==="transform")if(n.common.async===!1){const i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!Y(i))return m;const o=a.transform(i.value,r);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:s.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>Y(i)?Promise.resolve(a.transform(i.value,r)).then(o=>({status:s.value,value:o})):m);x.assertNever(a)}}F.create=(t,e,s)=>new F({schema:t,typeName:p.ZodEffects,effect:e,...y(s)});F.createWithPreprocess=(t,e,s)=>new F({schema:e,effect:{type:"preprocess",transform:t},typeName:p.ZodEffects,...y(s)});class G extends _{_parse(e){return this._getType(e)===f.undefined?C(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}G.create=(t,e)=>new G({innerType:t,typeName:p.ZodOptional,...y(e)});class W extends _{_parse(e){return this._getType(e)===f.null?C(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}W.create=(t,e)=>new W({innerType:t,typeName:p.ZodNullable,...y(e)});class pe extends _{_parse(e){const{ctx:s}=this._processInputParams(e);let n=s.data;return s.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:s.path,parent:s})}removeDefault(){return this._def.innerType}}pe.create=(t,e)=>new pe({innerType:t,typeName:p.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...y(e)});class ge extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n={...s,common:{...s.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return oe(a)?a.then(r=>({status:"valid",value:r.status==="valid"?r.value:this._def.catchValue({get error(){return new L(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new L(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}ge.create=(t,e)=>new ge({innerType:t,typeName:p.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...y(e)});class Ye extends _{_parse(e){if(this._getType(e)!==f.nan){const n=this._getOrReturnCtx(e);return u(n,{code:c.invalid_type,expected:f.nan,received:n.parsedType}),m}return{status:"valid",value:e.data}}}Ye.create=t=>new Ye({typeName:p.ZodNaN,...y(t)});class st extends _{_parse(e){const{ctx:s}=this._processInputParams(e),n=s.data;return this._def.type._parse({data:n,path:s.path,parent:s})}unwrap(){return this._def.type}}class Oe extends _{_parse(e){const{status:s,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const r=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return r.status==="aborted"?m:r.status==="dirty"?(s.dirty(),ee(r.value)):this._def.out._parseAsync({data:r.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?m:a.status==="dirty"?(s.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,s){return new Oe({in:e,out:s,typeName:p.ZodPipeline})}}class ye extends _{_parse(e){const s=this._def.innerType._parse(e),n=a=>(Y(a)&&(a.value=Object.freeze(a.value)),a);return oe(s)?s.then(a=>n(a)):n(s)}unwrap(){return this._def.innerType}}ye.create=(t,e)=>new ye({innerType:t,typeName:p.ZodReadonly,...y(e)});var p;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(p||(p={}));const g=P.create,Ze=X.create,I=Me.create,_e=Ie.create;B.create;const xe=q.create,$=w.create,Zs=ue.create,js=Ne.create;de.create;D.create;const Ps=le.create,je=fe.create,b=he.create,Gs=z.create;me.create;G.create;W.create;const nt=2,V=$({type:b("qp-bridge"),id:g().optional(),instanceId:g().optional()}),S=V.extend({featureVersion:Ze().optional()}),at=V.extend({status:b("answerChanged"),question:g(),answer:_e()}),rt=V.extend({action:b("commandExecuted"),commandName:g()}),it=V.extend({action:b("questionnaireLoaded")}),U=V.extend({status:b("success")}),ot=V.extend({status:b("error"),message:g()}),ct=Gs(["imageMedia","shortText","longText","url","email","wholeNumber","decimalNumber","date","dateTime","singleSelect","multiSelect","optionSet","rating","yesNo","signature","lookup"]),be=$({type:ct,semanticColor:g().optional(),label:g().optional(),description:g().optional(),disabled:I(),required:I(),hidden:I(),errorMessage:g().optional(),answer:_e().optional()}),ut=be.partial(),dt=be.extend({itemType:b("question"),name:g()}),lt=$({id:g().uuid(),name:g(),mimeType:g(),blobUrl:g()}),ke=Ps(_e()),Pe=$({label:g(),hidden:I(),collapsed:I()}),Ge=Pe.partial(),ft=js("type",[$({itemType:b("staticComponent"),type:b("staticDescription"),name:g(),hidden:I().optional(),content:g()}),$({itemType:b("staticComponent"),type:b("button"),name:g(),hidden:I().optional(),clickText:g(),disabled:I().optional(),semanticColor:g().optional(),commandName:g().optional(),commandLabel:g().optional()})]),Ls=Ge.extend({itemType:b("group"),name:g()}),$s=$({itemType:b("repeatableGroup"),name:g(),label:g().optional(),hidden:I().optional()}),Le=je(()=>Zs([dt,$e,ht,ft])),$e=je(()=>Ls.extend({items:xe(Le)})),ht=je(()=>$s.extend({groups:xe($e)})),Qs=$({entityName:g(),id:g(),name:g()}),mt=$({isNew:I(),id:g().uuid(),name:g(),label:g(),description:g().optional(),regarding:Qs.optional(),items:xe(Le)}),pt=S.extend({action:b("getQuestion"),question:g()}),gt=U.extend({question:be}),yt=S.extend({action:b("setQuestion"),question:g(),questionData:ut}),vt=S.extend({action:b("getGroup"),group:g()}),_t=U.extend({group:Pe}),xt=S.extend({action:b("getQuestionnaire")}),bt=U.extend({questionnaire:mt}),kt=U.extend({canSave:I()}),wt=S.extend({action:b("canSave")}),St=S.extend({action:b("setGroup"),group:g(),groupData:Ge}),Rt=S.extend({action:b("setAnswer"),question:g(),answer:_e()}),Mt=S.extend({action:b("busyIndicatorStart")}),Tt=S.extend({action:b("busyIndicatorEnd")}),Ct=S.extend({action:b("saveQuestionnaire")}),It=S.extend({action:b("completeAndCloseQuestionnaire")}),Et=S.extend({action:b("executeCustomCommand"),commandName:g()}),qt=S.extend({action:b("fetchEntities"),fetchXml:g()}),At=U.extend({entities:xe(ke)}),Nt=S.extend({action:b("getEntityById"),entityName:g(),entityId:g()}),Ot=U.extend({entity:ke}),Zt=S.extend({action:b("saveEntity"),entity:ke}),jt=S.extend({action:b("repeatGroup"),parentGroupName:g(),groupIndex:Ze()}),Pt=S.extend({action:b("addNewGroup"),groupName:g()}),Gt=S.extend({action:b("deleteGroup"),parentGroupName:g(),groupIndex:Ze()});function Bs(t){return lt.safeParse(t).success}function Lt(t){return at.safeParse(t).success}function $t(t){return rt.safeParse(t).success}function Qt(t){return it.safeParse(t).success}function ve(t){return V.safeParse(t).success}function Vs(t){return S.safeParse(t).success}function Bt(t){return U.safeParse(t).success}function Vt(t){return ot.safeParse(t).success}function Us(t){return pt.safeParse(t).success}function Ut(t){return gt.safeParse(t).success}function Ds(t){return Rt.safeParse(t).success}function zs(t){return yt.safeParse(t).success}function Fs(t){return St.safeParse(t).success}function Ws(t){return vt.safeParse(t).success}function Hs(t){return xt.safeParse(t).success}function Dt(t){return _t.safeParse(t).success}function zt(t){return bt.safeParse(t).success}function Js(t){return kt.safeParse(t).success}function Ft(t){return wt.safeParse(t).success}function Wt(t){return Mt.safeParse(t).success}function Ht(t){return Tt.safeParse(t).success}function Ys(t){return Ct.safeParse(t).success}function Xs(t){return It.safeParse(t).success}function Ks(t){return Et.safeParse(t).success}function en(t){return Wt(t)||Ht(t)}function Jt(t,e,s){return!ve(t)||t.id!==e||s!==void 0&&t.instanceId!==s||!("status"in t)}function tn(t){return qt.safeParse(t).success}function Yt(t){return At.safeParse(t).success}function sn(t){return Nt.safeParse(t).success}function Xt(t){return Ot.safeParse(t).success}function nn(t){return Zt.safeParse(t).success}function an(t){return jt.safeParse(t).success}function rn(t){return Pt.safeParse(t).success}function on(t){return Gt.safeParse(t).success}function ie(t){if(t?.instanceId!=null)return t.instanceId;const e=globalThis.__RESCO_QP_BRIDGE_INSTANCE_ID;return typeof e=="string"?e:void 0}function Kt(t){if(t instanceof File||t instanceof Blob)return URL.createObjectURL(t);if(typeof t=="string"){if(/^data:/.test(t)){const r=t.match(/^data:([^;]+);base64,(.*)$/);if(r){const i=r[1],o=r[2],d=atob(o),l=new ArrayBuffer(d.length),v=new Uint8Array(l);for(let O=0;O<d.length;O++)v[O]=d.charCodeAt(O);const N=new Blob([l],{type:i});return URL.createObjectURL(N)}throw new Error("Invalid data URL format. Only base64 data URLs are supported.")}const e=atob(t),s=new ArrayBuffer(e.length),n=new Uint8Array(s);for(let r=0;r<e.length;r++)n[r]=e.charCodeAt(r);const a=new Blob([s]);return URL.createObjectURL(a)}if(t instanceof ArrayBuffer){const e=new Blob([t]);return URL.createObjectURL(e)}throw new Error("Unsupported content type for blobUrl")}function cn(t,e,s,n){return{id:n??Xe(),name:t,mimeType:e,blobUrl:Kt(s)}}function un(t,e){let s=t.blobUrl;return e.content!==void 0&&(s=Kt(e.content)),{...t,...e,blobUrl:s}}rs.env?.NODE_ENV!=="test"&&es();function es(){window.addEventListener("message",ns)}function dn(){window.removeEventListener("message",ns)}async function ln(t){return await jn({type:"qp-bridge",action:"getQuestionnaire"},t)}function ts(t,e){Ae(t.items,[],e)}function ss(t){const e=[];return ts(t,s=>e.push(s)),e}function fn(t){return ss(t).filter(hn)}function hn(t){return t.itemType==="question"}function Ae(t,e,s){for(const n of t)switch(s(n,e),n.itemType){case"question":case"staticComponent":break;case"group":Ae(n.items,[...e,n],s);break;case"repeatableGroup":Ae(n.groups,[...e,n],s);break;default:return n}}async function mn(t,e,s){await T({type:"qp-bridge",action:"setAnswer",question:t,answer:e},s)}async function pn(t,e){return await On({type:"qp-bridge",action:"getQuestion",question:t},e)}async function gn(t,e,s){await T({type:"qp-bridge",action:"setQuestion",question:t,questionData:e},s)}async function yn(t,e){return await Zn({type:"qp-bridge",action:"getGroup",group:t},e)}async function vn(t,e,s){await T({type:"qp-bridge",action:"setGroup",group:t,groupData:e},s)}function _n(t,e){const s=ie(e),n=a=>{Lt(a.data)&&a.data.instanceId===s&&t(a.data.question,a.data.answer)};return window.addEventListener("message",n),{cancelSubscription:()=>{window.removeEventListener("message",n)}}}async function xn(t,e){await T({type:"qp-bridge",action:"busyIndicatorStart"},e);try{return await t()}finally{await T({type:"qp-bridge",action:"busyIndicatorEnd"},e)}}async function bn(t){await T({type:"qp-bridge",action:"saveQuestionnaire"},t)}async function kn(t){await T({type:"qp-bridge",action:"completeAndCloseQuestionnaire"},t)}async function wn(t,e){await T({type:"qp-bridge",action:"executeCustomCommand",commandName:t},e)}const te=[],se=[],ne=[];function Sn(t,e){const s=ie(e);return ne.some(n=>n.handler===t&&n.instanceId===s)||ne.push({handler:t,instanceId:s}),{cancelSubscription:()=>{const n=ne.findIndex(a=>a.handler===t&&a.instanceId===s);n!==-1&&ne.splice(n,1)}}}function Rn(t,e){const s=ie(e);return se.some(n=>n.handler===t&&n.instanceId===s)||se.push({handler:t,instanceId:s}),{cancelSubscription:()=>{const n=se.findIndex(a=>a.handler===t&&a.instanceId===s);n!==-1&&se.splice(n,1)}}}function Mn(t,e){const s=ie(e);return te.some(n=>n.validator===t&&n.instanceId===s)||te.push({validator:t,instanceId:s}),{cancelSubscription:()=>{const n=te.findIndex(a=>a.validator===t&&a.instanceId===s);n!==-1&&te.splice(n,1)}}}async function ns(t){try{if($t(t.data)&&se.filter(e=>e.instanceId===t.data.instanceId).forEach(e=>e.handler(t.data.commandName)),Qt(t.data)&&ne.filter(e=>e.instanceId===t.data.instanceId).forEach(e=>e.handler()),Ft(t.data)){const e=te.filter(a=>a.instanceId===t.data.instanceId),s=await Promise.all(e.map(a=>a.validator())),n={type:"qp-bridge",status:"success",id:t.data.id,instanceId:t.data.instanceId,canSave:s.every(a=>a)};window.parent.postMessage(n,"*")}}catch(e){const s={type:"qp-bridge",status:"error",id:ve(t.data)?t.data.id:void 0,instanceId:ve(t.data)?t.data.instanceId:void 0,message:e instanceof Error?e.message:"Unknown error"};window.parent.postMessage(s,"*")}}async function Tn(t,e){return await Pn({type:"qp-bridge",action:"fetchEntities",fetchXml:t},e)}async function Cn(t,e,s){return await Gn({type:"qp-bridge",action:"getEntityById",entityName:t,entityId:e},s)}function In(){return{isNew:!0}}async function En(t,e){await T({type:"qp-bridge",action:"saveEntity",entity:t},e)}async function qn(t,e,s){await T({type:"qp-bridge",action:"repeatGroup",parentGroupName:t,groupIndex:e},s)}async function An(t,e){await T({type:"qp-bridge",action:"addNewGroup",groupName:t},e)}async function Nn(t,e,s){await T({type:"qp-bridge",action:"deleteGroup",parentGroupName:t,groupIndex:e},s)}async function K(t,e,s){return new Promise((n,a)=>{const r=Xe(),i=ie(s),o=d=>{if(Jt(d.data,r,i))return;const l=e(d.data);l.success?n(l.data):Vt(d.data)?a(new Error(d.data.message)):a(new Error("Unknown message received")),window.removeEventListener("message",o)};window.addEventListener("message",o),window.parent.postMessage({...t,id:r,instanceId:i,featureVersion:nt},"*")})}async function On(t,e){return K(t,s=>Ut(s)?{success:!0,data:s.question}:{success:!1},e)}async function Zn(t,e){return K(t,s=>Dt(s)?{success:!0,data:s.group}:{success:!1},e)}async function jn(t,e){return K(t,s=>zt(s)?{success:!0,data:s.questionnaire}:{success:!1},e)}function T(t,e){return K(t,s=>Bt(s)?{success:!0,data:void 0}:{success:!1},e)}async function Pn(t,e){return K(t,s=>Yt(s)?{success:!0,data:s.entities}:{success:!1},e)}async function Gn(t,e){return K(t,s=>Xt(s)?{success:!0,data:s.entity}:{success:!1},e)}exports.QP_BRIDGE_FEATURE_VERSION=nt;exports.addNewGroup=An;exports.addNewGroupRequestMessageSchema=Pt;exports.busyIndicatorEndRequestMessageSchema=Tt;exports.busyIndicatorStartRequestMessageSchema=Mt;exports.canSaveRequestMessageSchema=wt;exports.canSaveSuccessResponseMessageSchema=kt;exports.commandExecutedMessageSchema=rt;exports.completeAndCloseQuestionnaire=kn;exports.completeAndCloseQuestionnaireRequestMessageSchema=It;exports.createMediaItem=cn;exports.createNewEntity=In;exports.deleteGroup=Nn;exports.deleteGroupRequestMessageSchema=Gt;exports.entitySchema=ke;exports.executeCustomCommand=wn;exports.executeCustomCommandRequestMessageSchema=Et;exports.fetchEntities=Tn;exports.fetchEntitiesRequestMessageSchema=qt;exports.fetchEntitiesSuccessResponseMessageSchema=At;exports.flattenQuestionnaireItems=ss;exports.flattenQuestions=fn;exports.getEntityById=Cn;exports.getEntityByIdRequestMessageSchema=Nt;exports.getEntityByIdSuccessResponseMessageSchema=Ot;exports.getGroup=yn;exports.getGroupRequestMessageSchema=vt;exports.getGroupSuccessResponseMessageSchema=_t;exports.getQuestion=pn;exports.getQuestionRequestMessageSchema=pt;exports.getQuestionSuccessResponseMessageSchema=gt;exports.getQuestionnaire=ln;exports.getQuestionnaireRequestMessageSchema=xt;exports.getQuestionnaireSuccessResponseMessageSchema=bt;exports.groupOptionalScheme=Ge;exports.groupSchema=Pe;exports.initOnSaveMessageHandler=es;exports.isAddNewGroupRequestMessage=rn;exports.isBusyIndicatorEndRequestMessage=Ht;exports.isBusyIndicatorStartRequestMessage=Wt;exports.isCanSaveRequestMessage=Ft;exports.isCanSaveSuccessResponseMessage=Js;exports.isCommandExecutedMessage=$t;exports.isCompleteAndCloseQuestionnaireRequestMessage=Xs;exports.isDeleteGroupRequestMessage=on;exports.isErrorMessage=Vt;exports.isExecuteCustomCommandRequestMessage=Ks;exports.isFetchEntitiesRequestMessage=tn;exports.isFetchEntitiesSuccessResponseMessage=Yt;exports.isGetEntityByIdRequestMessage=sn;exports.isGetEntityByIdSuccessResponseMessage=Xt;exports.isGetGroupRequestMessage=Ws;exports.isGetGroupSuccessResponseMessage=Dt;exports.isGetQuestionRequestMessage=Us;exports.isGetQuestionSuccessResponseMessage=Ut;exports.isGetQuestionnaireRequestMessage=Hs;exports.isGetQuestionnaireSuccessResponseMessage=zt;exports.isMediaItem=Bs;exports.isNotRelevantMessage=Jt;exports.isOnAnswerChangeMessage=Lt;exports.isQpBridgeMessage=ve;exports.isQpBridgeRequestMessage=Vs;exports.isQuestionnaireLoadedMessage=Qt;exports.isRepeatGroupRequestMessage=an;exports.isSaveEntityRequestMessage=nn;exports.isSaveQuestionnaireRequestMessage=Ys;exports.isSetAnswerRequestMessage=Ds;exports.isSetGroupRequestMessage=Fs;exports.isSetQuestionRequestMessage=zs;exports.isSuccessMessage=Bt;exports.isWithBusyIndicatorRequestMessage=en;exports.mediaItemSchema=lt;exports.onAnswerChange=_n;exports.onAnswerChangeMessageSchema=at;exports.onCommandExecuted=Rn;exports.onQuestionnaireLoaded=Sn;exports.onSave=Mn;exports.qpBridgeBaseMessageSchema=V;exports.qpBridgeRequestMessageSchema=S;exports.questionOptionalScheme=ut;exports.questionSchema=be;exports.questionTypeSchema=ct;exports.questionnaireGroupSchema=$e;exports.questionnaireItemSchema=Le;exports.questionnaireLoadedMessageSchema=it;exports.questionnaireQuestionSchema=dt;exports.questionnaireRepeatableGroupSchema=ht;exports.questionnaireSchema=mt;exports.questionnaireStaticComponentSchema=ft;exports.removeOnSaveMessageHandler=dn;exports.repeatGroup=qn;exports.repeatGroupRequestMessageSchema=jt;exports.responseErrorMessageSchema=ot;exports.responseSuccessMessageSchema=U;exports.saveEntity=En;exports.saveEntityRequestMessageSchema=Zt;exports.saveQuestionnaire=bn;exports.saveQuestionnaireRequestMessageSchema=Ct;exports.setAnswer=mn;exports.setAnswerRequestMessageSchema=Rt;exports.setGroup=vn;exports.setGroupRequestMessageSchema=St;exports.setQuestion=gn;exports.setQuestionRequestMessageSchema=yt;exports.traverseQuestionnaireItems=ts;exports.updateMediaItem=un;exports.withBusyIndicator=xn;