directus-extension-fieldsplus
Version:
Collection of useful interfaces for Directus
1 lines • 150 kB
JavaScript
import{useStores as e,defineInterface as t,useApi as a}from"@directus/extensions-sdk";import{computed as i,ref as n,defineComponent as o,resolveComponent as r,openBlock as u,createBlock as s,withCtx as l,createVNode as d,normalizeStyle as c,normalizeClass as p,renderSlot as D,watch as m,createSlots as v,createElementVNode as f,toDisplayString as h,unref as g,isRef as F,inject as y,createElementBlock as x,createCommentVNode as b,toRefs as C,createTextVNode as _,Fragment as E,renderList as k,withDirectives as w,vModelText as S,resolveDirective as A,withModifiers as B}from"vue";import{useI18n as M}from"vue-i18n";var P=o({__name:"v-group-component",props:{start:{default:"open"},label:{default:""}},setup(e){const t=e,a=n(!1);return"open"===t.start&&(a.value=!0),(e,t)=>{const i=r("v-icon"),n=r("v-divider"),o=r("v-detail");return u(),s(o,{label:e.label,modelValue:a.value,"onUpdate:modelValue":t[0]||(t[0]=e=>a.value=e),"start-open":"open"===e.start,class:"group-detail"},{activator:l((({toggle:t,active:a})=>[d(n,{style:c({"--v-divider-label-color":e.headerColor}),class:p({active:a,edited:e.edited}),"inline-title":!1,large:"",onClick:t},{default:l((()=>[D(e.$slots,"headerIcon",{},void 0,!0),D(e.$slots,"header",{},void 0,!0),d(i,{class:"expand-icon",name:"expand_more"})])),_:2},1032,["style","class","onClick"])])),default:l((()=>[D(e.$slots,"default",{},void 0,!0)])),_:3},8,["label","modelValue","start-open"])}}}),T=[],O=[];function I(e,t){if(e&&"undefined"!=typeof document){var a,i=!0===t.prepend?"prepend":"append",n=!0===t.singleTag,o="string"==typeof t.container?document.querySelector(t.container):document.getElementsByTagName("head")[0];if(n){var r=T.indexOf(o);-1===r&&(r=T.push(o)-1,O[r]={}),a=O[r]&&O[r][i]?O[r][i]:O[r][i]=u()}else a=u();65279===e.charCodeAt(0)&&(e=e.substring(1)),a.styleSheet?a.styleSheet.cssText+=e:a.appendChild(document.createTextNode(e))}function u(){var e=document.createElement("style");if(e.setAttribute("type","text/css"),t.attributes)for(var a=Object.keys(t.attributes),n=0;n<a.length;n++)e.setAttribute(a[n],t.attributes[a[n]]);var r="prepend"===i?"afterbegin":"beforeend";return o.insertAdjacentElement(r,e),e}}I("\n.v-divider[data-v-21e6251d] {\n\tcursor: pointer;\n}\n.v-divider .expand-icon[data-v-21e6251d] {\n\tfloat: right;\n\ttransform: rotate(90deg) !important;\n\ttransition: transform var(--fast) var(--transition);\n}\n.v-divider.active .expand-icon[data-v-21e6251d] {\n\ttransform: rotate(0) !important;\n}\n.v-divider[data-v-21e6251d] .type-text {\n\tposition: relative;\n}\n.v-divider.edited:not(.active) .edit-dot[data-v-21e6251d] {\n\tposition: absolute;\n\ttop: 7px;\n\tleft: -7px;\n\tdisplay: block;\n\twidth: 4px;\n\theight: 4px;\n\tbackground-color: var(--theme--form--field--input--foreground-subdued);\n\tborder-radius: 4px;\n\tcontent: '';\n}\n.header-icon[data-v-21e6251d] {\n\tmargin-right: 12px !important;\n}\n",{});var j=(e,t)=>{const a=e.__vccOpts||e;for(const[e,i]of t)a[e]=i;return a},L=j(P,[["__scopeId","data-v-21e6251d"],["__file","v-group-component.vue"]]);function Z(e){let t=e;const{t:a}=M();return"string"==typeof e&&e.startsWith("$t:")&&(t=a(e.replace("$t:",""))),t}const R={class:"title"},N={class:""};var V,z,$=o({__name:"interface",props:{value:{default:{}},primaryKey:{},collection:{},field:{},disabled:{type:Boolean,default:!1},enableCreate:{type:Boolean,default:!0},enableSelect:{type:Boolean,default:!0},limit:{default:1},prefix:{default:""},allowDuplicates:{type:Boolean,default:!1},is_collection_fixed:{type:Boolean,default:!1},fixed_collection:{default:""},layout:{type:Boolean,default:!1},layouts:{default:[]},headerIcon:{}},emits:["input"],setup(t,{emit:a}){M();const o=t,c=a,p=n(!1),D=i((()=>{var e;return{collection:o.is_collection_fixed?o.fixed_collection:null==(e=o.value)?void 0:e.collection,...o.value}})),{edits:y,hasEdits:x,initialValues:b,values:C,search:_}=function(e){const t=n({}),a=i((()=>Object.keys(t.value).length>0)),o=i((()=>null===e.value?{name:null,collection:null,layout:"",search:null,scope:"all",filter:null}:{name:e.value.name,collection:e.value.collection,layout:e.value.layout,search:e.value.search,filter:e.value.filter})),r=i((()=>({...o.value,...t.value}))),u=i({get:()=>r.value.search,set(e){t.value={...t.value,search:e}}});return{edits:t,initialValues:o,values:r,hasEdits:a,updateFilters:function(e){t.value={...t.value,filter:e}},search:u}}(D),{fields:E}=function(t,{layout:a,layouts:n,is_collection_fixed:o,fixed_collection:r}){const{useCollectionsStore:u}=e(),s=u(),l=i((()=>s.collections.map((e=>({text:e.collection,value:e.collection}))).filter((e=>!e.text.startsWith("directus_"))))),d=i((()=>[{field:"name",name:"$t:name",type:"string",meta:{interface:"system-input-translated-string",options:{placeholder:"$t:preset_name_placeholder"},width:"half"}},{field:"layout",name:"$t:layout",type:"string",meta:{interface:"select-dropdown",width:"half",options:{choices:n},disabled:!a,readonly:!a}},{field:"collection",name:"$t:collection",type:"string",meta:{interface:"select-dropdown",options:{choices:l.value},width:"half",disabled:!!o,readonly:!!o}},{field:"limit",name:"$t:limit",type:"number",meta:{interface:"input",width:"half",options:{placeholder:"$t:limit"}}},{field:"search",name:"$t:search",type:"string",meta:{interface:"input",width:"half",options:{placeholder:"$t:search_items"}}},{field:"sort",name:"$t:sort",type:"string",meta:{interface:"input",width:"half",options:{placeholder:"$t:sort"}}},{field:"filter",name:"$t:filter",type:"json",meta:{interface:"system-filter",options:{collectionField:"collection",rawFieldNames:!0}}}]));return{allowCollection:l,fields:d}}(0,{...o});m((()=>y.value),(e=>{k.value=e}));const k=i({set:e=>{c("input",{...o.value,...e})},get:()=>({...o.value,...D.value,...y})});return(e,t)=>{const a=r("v-icon"),i=r("v-form");return u(),s(L,{start:e.start,key:e.field,label:"Query Builder"},v({header:l((()=>[f("span",R,h(g(Z)(k.value.name)),1)])),default:l((()=>[f("div",N,[d(i,{modelValue:g(y),"onUpdate:modelValue":t[0]||(t[0]=e=>F(y)?y.value=e:null),fields:g(E),loading:p.value,"initial-values":g(b)},null,8,["modelValue","fields","loading","initial-values"])])])),_:2},[e.headerIcon?{name:"headerIcon",fn:l((()=>[d(a,{name:e.headerIcon,class:"header-icon"},null,8,["name"])])),key:"0"}:void 0]),1032,["start"])}}}),G=t({id:"advanced-filters",name:"Advanced Filters",icon:"filter_alt",description:"",component:j($,[["__file","interface.vue"]]),types:["json","text"],options:e=>[{field:"is_collection_fixed",type:"boolean",name:"Fixed Collection",meta:{width:"half",interface:"boolean",required:!1,default_value:!1}},{field:"fixed_collection",type:"string",name:"Collection",meta:{width:"half",interface:"system-collection",readonly:!0,conditions:[{name:"Show on Fixed",rule:{_and:[{is_collection_fixed:{_eq:!0}}]},readonly:!1}]}},{field:"layout",type:"boolean",name:"Layout options",meta:{width:"half",interface:"boolean",required:!1,default_value:!1}},{field:"layouts",type:"boolean",name:"Layouts",meta:{width:"half",interface:"list",readonly:!0,conditions:[{name:"Readonly on layouts",rule:{_and:[{layout:{_eq:!0}}]},readonly:!1}],options:{template:"{{ text }}",fields:[{field:"text",type:"string",name:"$t:text",meta:{width:"half",required:!0,interface:"system-input-translated-string"}},{field:"value",type:"string",name:"$t:value",meta:{width:"half",interface:"input",required:!1,options:{font:"monospace"}}}]}}}]});!function(e){e.assertEqual=e=>e,e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const a of e)t[a]=a;return t},e.getValidEnumValues=t=>{const a=e.objectKeys(t).filter((e=>"number"!=typeof t[t[e]])),i={};for(const e of a)i[e]=t[e];return e.objectValues(i)},e.objectValues=t=>e.objectKeys(t).map((function(e){return t[e]})),e.objectKeys="function"==typeof Object.keys?e=>Object.keys(e):e=>{const t=[];for(const a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.push(a);return t},e.find=(e,t)=>{for(const a of e)if(t(a))return a},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&isFinite(e)&&Math.floor(e)===e,e.joinValues=function(e,t=" | "){return e.map((e=>"string"==typeof e?`'${e}'`:e)).join(t)},e.jsonStringifyReplacer=(e,t)=>"bigint"==typeof t?t.toString():t}(V||(V={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(z||(z={}));const W=V.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),U=e=>{switch(typeof e){case"undefined":return W.undefined;case"string":return W.string;case"number":return isNaN(e)?W.nan:W.number;case"boolean":return W.boolean;case"function":return W.function;case"bigint":return W.bigint;case"symbol":return W.symbol;case"object":return Array.isArray(e)?W.array:null===e?W.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?W.promise:"undefined"!=typeof Map&&e instanceof Map?W.map:"undefined"!=typeof Set&&e instanceof Set?W.set:"undefined"!=typeof Date&&e instanceof Date?W.date:W.object;default:return W.unknown}},K=V.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 X extends Error{constructor(e){super(),this.issues=[],this.addIssue=e=>{this.issues=[...this.issues,e]},this.addIssues=(e=[])=>{this.issues=[...this.issues,...e]};const t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}get errors(){return this.issues}format(e){const t=e||function(e){return e.message},a={_errors:[]},i=e=>{for(const n of e.issues)if("invalid_union"===n.code)n.unionErrors.map(i);else if("invalid_return_type"===n.code)i(n.returnTypeError);else if("invalid_arguments"===n.code)i(n.argumentsError);else if(0===n.path.length)a._errors.push(t(n));else{let e=a,i=0;for(;i<n.path.length;){const a=n.path[i];i===n.path.length-1?(e[a]=e[a]||{_errors:[]},e[a]._errors.push(t(n))):e[a]=e[a]||{_errors:[]},e=e[a],i++}}};return i(this),a}static assert(e){if(!(e instanceof X))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,V.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},a=[];for(const i of this.issues)i.path.length>0?(t[i.path[0]]=t[i.path[0]]||[],t[i.path[0]].push(e(i))):a.push(e(i));return{formErrors:a,fieldErrors:t}}get formErrors(){return this.flatten()}}X.create=e=>new X(e);const q=(e,t)=>{let a;switch(e.code){case K.invalid_type:a=e.received===W.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case K.invalid_literal:a=`Invalid literal value, expected ${JSON.stringify(e.expected,V.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:a=`Unrecognized key(s) in object: ${V.joinValues(e.keys,", ")}`;break;case K.invalid_union:a="Invalid input";break;case K.invalid_union_discriminator:a=`Invalid discriminator value. Expected ${V.joinValues(e.options)}`;break;case K.invalid_enum_value:a=`Invalid enum value. Expected ${V.joinValues(e.options)}, received '${e.received}'`;break;case K.invalid_arguments:a="Invalid function arguments";break;case K.invalid_return_type:a="Invalid function return type";break;case K.invalid_date:a="Invalid date";break;case K.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(a=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(a=`${a} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?a=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?a=`Invalid input: must end with "${e.validation.endsWith}"`:V.assertNever(e.validation):a="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case K.too_small:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at least":"more than"} ${e.minimum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at least":"over"} ${e.minimum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${e.minimum}`:"date"===e.type?`Date must be ${e.exact?"exactly equal to ":e.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(e.minimum))}`:"Invalid input";break;case K.too_big:a="array"===e.type?`Array must contain ${e.exact?"exactly":e.inclusive?"at most":"less than"} ${e.maximum} element(s)`:"string"===e.type?`String must contain ${e.exact?"exactly":e.inclusive?"at most":"under"} ${e.maximum} character(s)`:"number"===e.type?`Number must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"bigint"===e.type?`BigInt must be ${e.exact?"exactly":e.inclusive?"less than or equal to":"less than"} ${e.maximum}`:"date"===e.type?`Date must be ${e.exact?"exactly":e.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(e.maximum))}`:"Invalid input";break;case K.custom:a="Invalid input";break;case K.invalid_intersection_types:a="Intersection results could not be merged";break;case K.not_multiple_of:a=`Number must be a multiple of ${e.multipleOf}`;break;case K.not_finite:a="Number must be finite";break;default:a=t.defaultError,V.assertNever(e)}return{message:a}};let H=q;function J(){return H}const Q=e=>{const{data:t,path:a,errorMaps:i,issueData:n}=e,o=[...a,...n.path||[]],r={...n,path:o};if(void 0!==n.message)return{...n,path:o,message:n.message};let u="";const s=i.filter((e=>!!e)).slice().reverse();for(const e of s)u=e(r,{data:t,defaultError:u}).message;return{...n,path:o,message:u}};function Y(e,t){const a=J(),i=Q({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,a,a===q?void 0:q].filter((e=>!!e))});e.common.issues.push(i)}class ee{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const a=[];for(const i of t){if("aborted"===i.status)return te;"dirty"===i.status&&e.dirty(),a.push(i.value)}return{status:e.value,value:a}}static async mergeObjectAsync(e,t){const a=[];for(const e of t){const t=await e.key,i=await e.value;a.push({key:t,value:i})}return ee.mergeObjectSync(e,a)}static mergeObjectSync(e,t){const a={};for(const i of t){const{key:t,value:n}=i;if("aborted"===t.status)return te;if("aborted"===n.status)return te;"dirty"===t.status&&e.dirty(),"dirty"===n.status&&e.dirty(),"__proto__"===t.value||void 0===n.value&&!i.alwaysSet||(a[t.value]=n.value)}return{status:e.value,value:a}}}const te=Object.freeze({status:"aborted"}),ae=e=>({status:"dirty",value:e}),ie=e=>({status:"valid",value:e}),ne=e=>"aborted"===e.status,oe=e=>"dirty"===e.status,re=e=>"valid"===e.status,ue=e=>"undefined"!=typeof Promise&&e instanceof Promise;function se(e,t,a,i){if("a"===a&&!i)throw new TypeError("Private accessor was defined without a getter");if("function"==typeof t?e!==t||!i:!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return"m"===a?i:"a"===a?i.call(e):i?i.value:t.get(e)}function le(e,t,a,i,n){if("m"===i)throw new TypeError("Private method is not writable");if("a"===i&&!n)throw new TypeError("Private accessor was defined without a setter");if("function"==typeof t?e!==t||!n:!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");return"a"===i?n.call(e,a):n?n.value=a:t.set(e,a),a}var de,ce,pe;"function"==typeof SuppressedError&&SuppressedError,function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:null==e?void 0:e.message}(de||(de={}));class De{constructor(e,t,a,i){this._cachedPath=[],this.parent=e,this.data=t,this._path=a,this._key=i}get path(){return this._cachedPath.length||(this._key instanceof Array?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const me=(e,t)=>{if(re(t))return{success:!0,data:t.value};if(!e.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const t=new X(e.common.issues);return this._error=t,this._error}}};function ve(e){if(!e)return{};const{errorMap:t,invalid_type_error:a,required_error:i,description:n}=e;if(t&&(a||i))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:n};return{errorMap:(t,n)=>{var o,r;const{message:u}=e;return"invalid_enum_value"===t.code?{message:null!=u?u:n.defaultError}:void 0===n.data?{message:null!==(o=null!=u?u:i)&&void 0!==o?o:n.defaultError}:"invalid_type"!==t.code?{message:n.defaultError}:{message:null!==(r=null!=u?u:a)&&void 0!==r?r:n.defaultError}},description:n}}class fe{constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this)}get description(){return this._def.description}_getType(e){return U(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:U(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new ee,ctx:{common:e.parent.common,data:e.data,parsedType:U(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ue(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const a=this.safeParse(e,t);if(a.success)return a.data;throw a.error}safeParse(e,t){var a;const i={common:{issues:[],async:null!==(a=null==t?void 0:t.async)&&void 0!==a&&a,contextualErrorMap:null==t?void 0:t.errorMap},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:U(e)},n=this._parseSync({data:e,path:i.path,parent:i});return me(i,n)}async parseAsync(e,t){const a=await this.safeParseAsync(e,t);if(a.success)return a.data;throw a.error}async safeParseAsync(e,t){const a={common:{issues:[],contextualErrorMap:null==t?void 0:t.errorMap,async:!0},path:(null==t?void 0:t.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:U(e)},i=this._parse({data:e,path:a.path,parent:a}),n=await(ue(i)?i:Promise.resolve(i));return me(a,n)}refine(e,t){const a=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement(((t,i)=>{const n=e(t),o=()=>i.addIssue({code:K.custom,...a(t)});return"undefined"!=typeof Promise&&n instanceof Promise?n.then((e=>!!e||(o(),!1))):!!n||(o(),!1)}))}refinement(e,t){return this._refinement(((a,i)=>!!e(a)||(i.addIssue("function"==typeof t?t(a,i):t),!1)))}_refinement(e){return new dt({schema:this,typeName:bt.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}optional(){return ct.create(this,this._def)}nullable(){return pt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return We.create(this,this._def)}promise(){return lt.create(this,this._def)}or(e){return Xe.create([this,e],this._def)}and(e){return Qe.create(this,e,this._def)}transform(e){return new dt({...ve(this._def),schema:this,typeName:bt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Dt({...ve(this._def),innerType:this,defaultValue:t,typeName:bt.ZodDefault})}brand(){return new ht({typeName:bt.ZodBranded,type:this,...ve(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new mt({...ve(this._def),innerType:this,catchValue:t,typeName:bt.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return gt.create(this,e)}readonly(){return Ft.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const he=/^c[^\s-]{8,}$/i,ge=/^[0-9a-z]+$/,Fe=/^[0-9A-HJKMNP-TV-Z]{26}$/,ye=/^[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,xe=/^[a-z0-9_-]{21}$/i,be=/^[-+]?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)?)??$/,Ce=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let _e;const Ee=/^(?:(?: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])$/,ke=/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,we=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Se="((\\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])))",Ae=new RegExp(`^${Se}$`);function Be(e){let t="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";return e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`),t}function Me(e){let t=`${Se}T${Be(e)}`;const a=[];return a.push(e.local?"Z?":"Z"),e.offset&&a.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${a.join("|")})`,new RegExp(`^${t}$`)}class Pe extends fe{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==W.string){const t=this._getOrReturnCtx(e);return Y(t,{code:K.invalid_type,expected:W.string,received:t.parsedType}),te}const t=new ee;let a;for(const o of this._def.checks)if("min"===o.kind)e.data.length<o.value&&(a=this._getOrReturnCtx(e,a),Y(a,{code:K.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),t.dirty());else if("max"===o.kind)e.data.length>o.value&&(a=this._getOrReturnCtx(e,a),Y(a,{code:K.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!1,message:o.message}),t.dirty());else if("length"===o.kind){const i=e.data.length>o.value,n=e.data.length<o.value;(i||n)&&(a=this._getOrReturnCtx(e,a),i?Y(a,{code:K.too_big,maximum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}):n&&Y(a,{code:K.too_small,minimum:o.value,type:"string",inclusive:!0,exact:!0,message:o.message}),t.dirty())}else if("email"===o.kind)Ce.test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{validation:"email",code:K.invalid_string,message:o.message}),t.dirty());else if("emoji"===o.kind)_e||(_e=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),_e.test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{validation:"emoji",code:K.invalid_string,message:o.message}),t.dirty());else if("uuid"===o.kind)ye.test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{validation:"uuid",code:K.invalid_string,message:o.message}),t.dirty());else if("nanoid"===o.kind)xe.test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{validation:"nanoid",code:K.invalid_string,message:o.message}),t.dirty());else if("cuid"===o.kind)he.test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{validation:"cuid",code:K.invalid_string,message:o.message}),t.dirty());else if("cuid2"===o.kind)ge.test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{validation:"cuid2",code:K.invalid_string,message:o.message}),t.dirty());else if("ulid"===o.kind)Fe.test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{validation:"ulid",code:K.invalid_string,message:o.message}),t.dirty());else if("url"===o.kind)try{new URL(e.data)}catch(i){a=this._getOrReturnCtx(e,a),Y(a,{validation:"url",code:K.invalid_string,message:o.message}),t.dirty()}else if("regex"===o.kind){o.regex.lastIndex=0;o.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{validation:"regex",code:K.invalid_string,message:o.message}),t.dirty())}else if("trim"===o.kind)e.data=e.data.trim();else if("includes"===o.kind)e.data.includes(o.value,o.position)||(a=this._getOrReturnCtx(e,a),Y(a,{code:K.invalid_string,validation:{includes:o.value,position:o.position},message:o.message}),t.dirty());else if("toLowerCase"===o.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===o.kind)e.data=e.data.toUpperCase();else if("startsWith"===o.kind)e.data.startsWith(o.value)||(a=this._getOrReturnCtx(e,a),Y(a,{code:K.invalid_string,validation:{startsWith:o.value},message:o.message}),t.dirty());else if("endsWith"===o.kind)e.data.endsWith(o.value)||(a=this._getOrReturnCtx(e,a),Y(a,{code:K.invalid_string,validation:{endsWith:o.value},message:o.message}),t.dirty());else if("datetime"===o.kind){Me(o).test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{code:K.invalid_string,validation:"datetime",message:o.message}),t.dirty())}else if("date"===o.kind){Ae.test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{code:K.invalid_string,validation:"date",message:o.message}),t.dirty())}else if("time"===o.kind){new RegExp(`^${Be(o)}$`).test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{code:K.invalid_string,validation:"time",message:o.message}),t.dirty())}else"duration"===o.kind?be.test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{validation:"duration",code:K.invalid_string,message:o.message}),t.dirty()):"ip"===o.kind?(i=e.data,("v4"!==(n=o.version)&&n||!Ee.test(i))&&("v6"!==n&&n||!ke.test(i))&&(a=this._getOrReturnCtx(e,a),Y(a,{validation:"ip",code:K.invalid_string,message:o.message}),t.dirty())):"base64"===o.kind?we.test(e.data)||(a=this._getOrReturnCtx(e,a),Y(a,{validation:"base64",code:K.invalid_string,message:o.message}),t.dirty()):V.assertNever(o);var i,n;return{status:t.value,value:e.data}}_regex(e,t,a){return this.refinement((t=>e.test(t)),{validation:t,code:K.invalid_string,...de.errToObj(a)})}_addCheck(e){return new Pe({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...de.errToObj(e)})}url(e){return this._addCheck({kind:"url",...de.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...de.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...de.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...de.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...de.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...de.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...de.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...de.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...de.errToObj(e)})}datetime(e){var t,a;return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,offset:null!==(t=null==e?void 0:e.offset)&&void 0!==t&&t,local:null!==(a=null==e?void 0:e.local)&&void 0!==a&&a,...de.errToObj(null==e?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return"string"==typeof e?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:void 0===(null==e?void 0:e.precision)?null:null==e?void 0:e.precision,...de.errToObj(null==e?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...de.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...de.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:null==t?void 0:t.position,...de.errToObj(null==t?void 0:t.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...de.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...de.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...de.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...de.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...de.errToObj(t)})}nonempty(e){return this.min(1,de.errToObj(e))}trim(){return new Pe({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Pe({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Pe({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find((e=>"datetime"===e.kind))}get isDate(){return!!this._def.checks.find((e=>"date"===e.kind))}get isTime(){return!!this._def.checks.find((e=>"time"===e.kind))}get isDuration(){return!!this._def.checks.find((e=>"duration"===e.kind))}get isEmail(){return!!this._def.checks.find((e=>"email"===e.kind))}get isURL(){return!!this._def.checks.find((e=>"url"===e.kind))}get isEmoji(){return!!this._def.checks.find((e=>"emoji"===e.kind))}get isUUID(){return!!this._def.checks.find((e=>"uuid"===e.kind))}get isNANOID(){return!!this._def.checks.find((e=>"nanoid"===e.kind))}get isCUID(){return!!this._def.checks.find((e=>"cuid"===e.kind))}get isCUID2(){return!!this._def.checks.find((e=>"cuid2"===e.kind))}get isULID(){return!!this._def.checks.find((e=>"ulid"===e.kind))}get isIP(){return!!this._def.checks.find((e=>"ip"===e.kind))}get isBase64(){return!!this._def.checks.find((e=>"base64"===e.kind))}get minLength(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}function Te(e,t){const a=(e.toString().split(".")[1]||"").length,i=(t.toString().split(".")[1]||"").length,n=a>i?a:i;return parseInt(e.toFixed(n).replace(".",""))%parseInt(t.toFixed(n).replace(".",""))/Math.pow(10,n)}Pe.create=e=>{var t;return new Pe({checks:[],typeName:bt.ZodString,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...ve(e)})};class Oe extends fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){this._def.coerce&&(e.data=Number(e.data));if(this._getType(e)!==W.number){const t=this._getOrReturnCtx(e);return Y(t,{code:K.invalid_type,expected:W.number,received:t.parsedType}),te}let t;const a=new ee;for(const i of this._def.checks)if("int"===i.kind)V.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),Y(t,{code:K.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty());else if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),Y(t,{code:K.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),Y(t,{code:K.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty())}else"multipleOf"===i.kind?0!==Te(e.data,i.value)&&(t=this._getOrReturnCtx(e,t),Y(t,{code:K.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):"finite"===i.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),Y(t,{code:K.not_finite,message:i.message}),a.dirty()):V.assertNever(i);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,de.toString(t))}gt(e,t){return this.setLimit("min",e,!1,de.toString(t))}lte(e,t){return this.setLimit("max",e,!0,de.toString(t))}lt(e,t){return this.setLimit("max",e,!1,de.toString(t))}setLimit(e,t,a,i){return new Oe({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:de.toString(i)}]})}_addCheck(e){return new Oe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:de.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:de.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:de.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:de.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:de.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:de.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:de.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:de.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:de.toString(e)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find((e=>"int"===e.kind||"multipleOf"===e.kind&&V.isInteger(e.value)))}get isFinite(){let e=null,t=null;for(const a of this._def.checks){if("finite"===a.kind||"int"===a.kind||"multipleOf"===a.kind)return!0;"min"===a.kind?(null===t||a.value>t)&&(t=a.value):"max"===a.kind&&(null===e||a.value<e)&&(e=a.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Oe.create=e=>new Oe({checks:[],typeName:bt.ZodNumber,coerce:(null==e?void 0:e.coerce)||!1,...ve(e)});class Ie extends fe{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){this._def.coerce&&(e.data=BigInt(e.data));if(this._getType(e)!==W.bigint){const t=this._getOrReturnCtx(e);return Y(t,{code:K.invalid_type,expected:W.bigint,received:t.parsedType}),te}let t;const a=new ee;for(const i of this._def.checks)if("min"===i.kind){(i.inclusive?e.data<i.value:e.data<=i.value)&&(t=this._getOrReturnCtx(e,t),Y(t,{code:K.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty())}else if("max"===i.kind){(i.inclusive?e.data>i.value:e.data>=i.value)&&(t=this._getOrReturnCtx(e,t),Y(t,{code:K.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty())}else"multipleOf"===i.kind?e.data%i.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),Y(t,{code:K.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):V.assertNever(i);return{status:a.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,de.toString(t))}gt(e,t){return this.setLimit("min",e,!1,de.toString(t))}lte(e,t){return this.setLimit("max",e,!0,de.toString(t))}lt(e,t){return this.setLimit("max",e,!1,de.toString(t))}setLimit(e,t,a,i){return new Ie({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:a,message:de.toString(i)}]})}_addCheck(e){return new Ie({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:de.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:de.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:de.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:de.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:de.toString(t)})}get minValue(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return e}}Ie.create=e=>{var t;return new Ie({checks:[],typeName:bt.ZodBigInt,coerce:null!==(t=null==e?void 0:e.coerce)&&void 0!==t&&t,...ve(e)})};class je extends fe{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==W.boolean){const t=this._getOrReturnCtx(e);return Y(t,{code:K.invalid_type,expected:W.boolean,received:t.parsedType}),te}return ie(e.data)}}je.create=e=>new je({typeName:bt.ZodBoolean,coerce:(null==e?void 0:e.coerce)||!1,...ve(e)});class Le extends fe{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==W.date){const t=this._getOrReturnCtx(e);return Y(t,{code:K.invalid_type,expected:W.date,received:t.parsedType}),te}if(isNaN(e.data.getTime())){return Y(this._getOrReturnCtx(e),{code:K.invalid_date}),te}const t=new ee;let a;for(const i of this._def.checks)"min"===i.kind?e.data.getTime()<i.value&&(a=this._getOrReturnCtx(e,a),Y(a,{code:K.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),t.dirty()):"max"===i.kind?e.data.getTime()>i.value&&(a=this._getOrReturnCtx(e,a),Y(a,{code:K.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),t.dirty()):V.assertNever(i);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Le({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:de.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:de.toString(t)})}get minDate(){let e=null;for(const t of this._def.checks)"min"===t.kind&&(null===e||t.value>e)&&(e=t.value);return null!=e?new Date(e):null}get maxDate(){let e=null;for(const t of this._def.checks)"max"===t.kind&&(null===e||t.value<e)&&(e=t.value);return null!=e?new Date(e):null}}Le.create=e=>new Le({checks:[],coerce:(null==e?void 0:e.coerce)||!1,typeName:bt.ZodDate,...ve(e)});class Ze extends fe{_parse(e){if(this._getType(e)!==W.symbol){const t=this._getOrReturnCtx(e);return Y(t,{code:K.invalid_type,expected:W.symbol,received:t.parsedType}),te}return ie(e.data)}}Ze.create=e=>new Ze({typeName:bt.ZodSymbol,...ve(e)});class Re extends fe{_parse(e){if(this._getType(e)!==W.undefined){const t=this._getOrReturnCtx(e);return Y(t,{code:K.invalid_type,expected:W.undefined,received:t.parsedType}),te}return ie(e.data)}}Re.create=e=>new Re({typeName:bt.ZodUndefined,...ve(e)});class Ne extends fe{_parse(e){if(this._getType(e)!==W.null){const t=this._getOrReturnCtx(e);return Y(t,{code:K.invalid_type,expected:W.null,received:t.parsedType}),te}return ie(e.data)}}Ne.create=e=>new Ne({typeName:bt.ZodNull,...ve(e)});class Ve extends fe{constructor(){super(...arguments),this._any=!0}_parse(e){return ie(e.data)}}Ve.create=e=>new Ve({typeName:bt.ZodAny,...ve(e)});class ze extends fe{constructor(){super(...arguments),this._unknown=!0}_parse(e){return ie(e.data)}}ze.create=e=>new ze({typeName:bt.ZodUnknown,...ve(e)});class $e extends fe{_parse(e){const t=this._getOrReturnCtx(e);return Y(t,{code:K.invalid_type,expected:W.never,received:t.parsedType}),te}}$e.create=e=>new $e({typeName:bt.ZodNever,...ve(e)});class Ge extends fe{_parse(e){if(this._getType(e)!==W.undefined){const t=this._getOrReturnCtx(e);return Y(t,{code:K.invalid_type,expected:W.void,received:t.parsedType}),te}return ie(e.data)}}Ge.create=e=>new Ge({typeName:bt.ZodVoid,...ve(e)});class We extends fe{_parse(e){const{ctx:t,status:a}=this._processInputParams(e),i=this._def;if(t.parsedType!==W.array)return Y(t,{code:K.invalid_type,expected:W.array,received:t.parsedType}),te;if(null!==i.exactLength){const e=t.data.length>i.exactLength.value,n=t.data.length<i.exactLength.value;(e||n)&&(Y(t,{code:e?K.too_big:K.too_small,minimum:n?i.exactLength.value:void 0,maximum:e?i.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:i.exactLength.message}),a.dirty())}if(null!==i.minLength&&t.data.length<i.minLength.value&&(Y(t,{code:K.too_small,minimum:i.minLength.value,type:"array",inclusive:!0,exact:!1,message:i.minLength.message}),a.dirty()),null!==i.maxLength&&t.data.length>i.maxLength.value&&(Y(t,{code:K.too_big,maximum:i.maxLength.value,type:"array",inclusive:!0,exact:!1,message:i.maxLength.message}),a.dirty()),t.common.async)return Promise.all([...t.data].map(((e,a)=>i.type._parseAsync(new De(t,e,t.path,a))))).then((e=>ee.mergeArray(a,e)));const n=[...t.data].map(((e,a)=>i.type._parseSync(new De(t,e,t.path,a))));return ee.mergeArray(a,n)}get element(){return this._def.type}min(e,t){return new We({...this._def,minLength:{value:e,message:de.toString(t)}})}max(e,t){return new We({...this._def,maxLength:{value:e,message:de.toString(t)}})}length(e,t){return new We({...this._def,exactLength:{value:e,message:de.toString(t)}})}nonempty(e){return this.min(1,e)}}function Ue(e){if(e instanceof Ke){const t={};for(const a in e.shape){const i=e.shape[a];t[a]=ct.create(Ue(i))}return new Ke({...e._def,shape:()=>t})}return e instanceof We?new We({...e._def,type:Ue(e.element)}):e instanceof ct?ct.create(Ue(e.unwrap())):e instanceof pt?pt.create(Ue(e.unwrap())):e instanceof Ye?Ye.create(e.items.map((e=>Ue(e)))):e}We.create=(e,t)=>new We({type:e,minLength:null,maxLength:null,exactLength:null,typeName:bt.ZodArray,...ve(t)});class Ke extends fe{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(null!==this._cached)return this._cached;const e=this._def.shape(),t=V.objectKeys(e);return this._cached={shape:e,keys:t}}_parse(e){if(this._getType(e)!==W.object){const t=this._getOrReturnCtx(e);return Y(t,{code:K.invalid_type,expected:W.object,received:t.parsedType}),te}const{status:t,ctx:a}=this._processInputParams(e),{shape:i,keys:n}=this._getCached(),o=[];if(!(this._def.catchall instanceof $e&&"strip"===this._def.unknownKeys))for(const e in a.data)n.includes(e)||o.push(e);const r=[];for(const e of n){const t=i[e],n=a.data[e];r.push({key:{status:"valid",value:e},value:t._parse(new De(a,n,a.path,e)),alwaysSet:e in a.data})}if(this._def.catchall instanceof $e){const e=this._def.unknownKeys;if("passthrough"===e)for(const e of o)r.push({key:{status:"valid",value:e},value:{status:"valid",value:a.data[e]}});else if("strict"===e)o.length>0&&(Y(a,{code:K.unrecognized_keys,keys:o}),t.dirty());else if("strip"!==e)throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const e=this._def.catchall;for(const t of o){const i=a.data[t];r.push({key:{status:"valid",value:t},value:e._parse(new De(a,i,a.path,t)),alwaysSet:t in a.data})}}return a.common.async?Promise.resolve().then((async()=>{const e=[];for(const t of r){const a=await t.key,i=await t.value;e.push({key:a,value:i,alwaysSet:t.alwaysSet})}return e})).then((e=>ee.mergeObjectSync(t,e))):ee.mergeObjectSync(t,r)}get shape(){return this._def.shape()}strict(e){return de.errToObj,new Ke({...this._def,unknownKeys:"strict",...void 0!==e?{errorMap:(t,a)=>{var i,n,o,r;const u=null!==(o=null===(n=(i=this._def).errorMap)||void 0===n?void 0:n.call(i,t,a).message)&&void 0!==o?o:a.defaultError;return"unrecognized_keys"===t.code?{message:null!==(r=de.errToObj(e).message)&&void 0!==r?r:u}:{message:u}}}:{}})}strip(){return new Ke({...this._def,unknownKeys:"strip"})}passthrough(){return new Ke({...this._def,unknownKeys:"passthrough"})}extend(e){return new Ke({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new Ke({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:bt.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new Ke({...this._def,catchall:e})}pick(e){const t={};return V.objectKeys(e).forEach((a=>{e[a]&&this.shape[a]&&(t[a]=this.shape[a])})),new Ke({...this._def,shape:()=>t})}omit(e){const t={};return V.objectKeys(this.shape).forEach((a=>{e[a]||(t[a]=this.shape[a])})),new Ke({...this._def,shape:()=>t})}deepPartial(){return Ue(this)}partial(e){const t={};return V.objectKeys(this.shape).forEach((a=>{const i=this.shape[a];e&&!e[a]?t[a]=i:t[a]=i.optional()})),new Ke({...this._def,shape:()=>t})}required(e){const t={};return V.objectKeys(this.shape).forEach((a=>{if(e&&!e[a])t[a]=this.shape[a];else{let e=this.shape[a];for(;e instanceof ct;)e=e._def.innerType;t[a]=e}})),new Ke({...this._def,shape:()=>t})}keyof(){return rt(V.objectKeys(this.shape))}}Ke.create=(e,t)=>new Ke({shape:()=>e,unknownKeys:"strip",catchall:$e.create(),typeName:bt.ZodObject,...ve(t)}),Ke.strictCreate=(e,t)=>new Ke({shape:()=>e,unknownKeys:"strict",catchall:$e.create(),typeName:bt.ZodObject,...ve(t)}),Ke.lazycreate=(e,t)=>new Ke({shape:e,unknownKeys:"strip",catchall:$e.create(),typeName:bt.ZodObject,...ve(t)});class Xe extends fe{_parse(e){const{ctx:t}=this._processInputParams(e),a=this._def.options;if(t.common.async)return Promise.all(a.map((async e=>{const a={...t,common:{...t.common,issues:[]},parent:null};return{result:await e._parseAsync({data:t.data,path:t.path,parent:a}),ctx:a}}))).then((function(e){for(const t of e)if("valid"===t.result.status)return t.result;for(const a of e)if("dirty"===a.result.status)return t.common.issues.push(...a.ctx.common.issues),a.result;const a=e.map((e=>new X(e.ctx.common.issues)));return Y(t,{code:K.invalid_union,unionErrors:a}),te}));{let e;const i=[];for(const n of a){const a={...t,common:{...t.common,issues:[]},parent:null},o=n._parseSync({data:t.data,path:t.path,parent:a});if("valid"===o.status)return o;"dirty"!==o.status||e||(e={result:o,ctx:a}),a.common.issues.length&&i.push(a.common.issues)}if(e)return t.common.issues.push(...e.ctx.common.issues),e.result;const n=i.map((e=>new X(e)));return Y(t,{code:K.invalid_union,unionErrors:n}),te}}get options(){return this._def.options}}Xe.create=(e,t)=>new Xe({options:e,typeName:bt.ZodUnion,...ve(t)});const qe=e=>e instanceof nt?qe(e.schema):e instanceof dt?qe(e.innerType()):e instanceof ot?[e.value]:e instanceof ut?e.options:e instanceof st?V.objectValues(e.enum):e instanceof Dt?qe(e._def.innerType):e instanceof Re?[void 0]:e instanceof Ne?[null]:e instanceof ct?[void 0,...qe(e.unwrap())]:e instanceof pt?[null,...qe(e.unwrap())]:e instanceof ht||e instanceof Ft?qe(e.unwrap()):e instanceof mt?qe(e._def.innerType):[];class He extends fe{_parse(e){const{ctx:t}=this._processInputParams(e);if(t.parsedType!==W.object)return Y(t,{code:K.invalid_type,expected:W.object,received:t.parsedType}),te;const a=this.discriminator,i=t.data[a],n=this.optionsMap.get(i);return n?t.common.async?n._parseAsync({data:t.data,path:t.path,parent:t}):n._parseSync({data:t.data,path:t.path,parent:t}):(Y(t,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[a]}),te)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,a){const i=new Map;for(const a of t){const t=qe(a.shape[e]);if(!t.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const n of t){if(i.has(n))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(n)}`);i.set(n,a)}}return new He({typeName:bt.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:i,...ve(a)})}}function Je(e,t){const a=U(e),i=U(t);if(e===t)return{valid:!0,data:e};if(a===W.object&&i===W.object){const a=V.objectKeys(t),i=V.objectKeys(e).filter((e=>-1!==a.indexOf(e))),n={...e,...t};for(const a of i){const i=Je(e[a],t[a]);if(!i.valid)return{valid:!1};n[a]=i.data}return{valid:!0,data:n}}if(a===W.array&&i===W.array){if(e.length!==t.length)return{valid:!1};const a=[];for(let i=0;i<e.length;i++){const n=Je(e[i],t[i]);if(!n.valid)return{valid:!1};a.push(n.data)}return{valid:!0,data:a}}return a===W.date&&i===W.date&&+e==+t?{valid:!0,data:e}:{valid:!1}}class Qe extends fe{_parse(e){const{status:t,ctx:a}=this._processInputParams(e),i=(e,i)=>{if(ne(e)||ne(i))return te;const n=Je(e.value,i.value);return n.valid?((oe(e)||oe(i))&&t.dirty(),{status:t.value,value:n.data}):(Y(a,{code:K.invalid_intersection_types}),te)};return a.common.async?Promise.all([this._def.left._parseAsync({data:a.data,path:a.path,parent:a}),this._def.right._parseAsync({data:a.data,path:a.path,parent:a})]).then((([e,t])=>i(e,t))):i(this._def.left._parseSync({data:a.data,path:a.path,parent:a}),this._def.right._parseSync({data:a.data,path:a.path,parent:a}))}}Qe.create=(e,t,a)=>new Qe({left:e,right:t,typeName:bt.ZodIntersection,...ve(a)});class Ye extends fe{_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.array)return Y(a,{code:K.invalid_type,expected:W.array,received:a.parsedType}),te;if(a.data.length<this._def.items.length)return Y(a,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),te;!this._def.rest&&a.data.length>this._def.items.length&&(Y(a,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());const i=[...a.data].map(((e,t)=>{const i=this._def.items[t]||this._def.rest;return i?i._parse(new De(a,e,a.path,t)):null})).filter((e=>!!e));return a.common.async?Promise.all(i).then((e=>ee.mergeArray(t,e))):ee.mergeArray(t,i)}get items(){return this._def.items}rest(e){return new Ye({...this._def,rest:e})}}Ye.create=(e,t)=>{if(!Array.isArray(e))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Ye({items:e,typeName:bt.ZodTuple,rest:null,...ve(t)})};class et extends fe{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:t,ctx:a}=this._processInputParams(e);if(a.parsedType!==W.object)return Y(a,{code:K.invalid_type,expected:W.object,received:a.parsedType}),te;const i=[],n=this._def.keyType,o=this._def.valueType;for(const e in a.data)i.push({key:n._parse(new De(a,e,a.path,e)),value:o._parse(new De(a,a.data[e],a.path,e)),always