UNPKG

@smooth_zhz/generate_node-core

Version:

A flexible code generation tool with configurable templates and settings

1 lines 82.5 kB
import e from"fs";import t from"path";import{pathToFileURL as n,fileURLToPath as r}from"url";const s=(e=0)=>t=>`[${t+e}m`,a=(e=0)=>t=>`[${38+e};5;${t}m`,i=(e=0)=>(t,n,r)=>`[${38+e};2;${t};${n};${r}m`,o={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}};Object.keys(o.modifier);Object.keys(o.color),Object.keys(o.bgColor);const c=function(){const e=new Map;for(const[t,n]of Object.entries(o)){for(const[t,r]of Object.entries(n))o[t]={open:`[${r[0]}m`,close:`[${r[1]}m`},n[t]=o[t],e.set(r[0],r[1]);Object.defineProperty(o,t,{value:n,enumerable:!1})}return Object.defineProperty(o,"codes",{value:e,enumerable:!1}),o.color.close="",o.bgColor.close="",o.color.ansi=s(),o.color.ansi256=a(),o.color.ansi16m=i(),o.bgColor.ansi=s(10),o.bgColor.ansi256=a(10),o.bgColor.ansi16m=i(10),Object.defineProperties(o,{rgbToAnsi256:{value:(e,t,n)=>e===t&&t===n?e<8?16:e>248?231:Math.round((e-8)/247*24)+232:16+36*Math.round(e/255*5)+6*Math.round(t/255*5)+Math.round(n/255*5),enumerable:!1},hexToRgb:{value(e){const t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(e.toString(16));if(!t)return[0,0,0];let[n]=t;3===n.length&&(n=[...n].map(e=>e+e).join(""));const r=Number.parseInt(n,16);return[r>>16&255,r>>8&255,255&r]},enumerable:!1},hexToAnsi256:{value:e=>o.rgbToAnsi256(...o.hexToRgb(e)),enumerable:!1},ansi256ToAnsi:{value(e){if(e<8)return 30+e;if(e<16)return e-8+90;let t,n,r;if(e>=232)t=(10*(e-232)+8)/255,n=t,r=t;else{const s=(e-=16)%36;t=Math.floor(e/36)/5,n=Math.floor(s/6)/5,r=s%6/5}const s=2*Math.max(t,n,r);if(0===s)return 30;let a=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return 2===s&&(a+=60),a},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>o.ansi256ToAnsi(o.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>o.ansi256ToAnsi(o.hexToAnsi256(e)),enumerable:!1}}),o}(),u=(()=>{if(!("navigator"in globalThis))return 0;if(globalThis.navigator.userAgentData){const e=navigator.userAgentData.brands.find(({brand:e})=>"Chromium"===e);if(e&&e.version>93)return 3}return/\b(Chrome|Chromium)\//.test(globalThis.navigator.userAgent)?1:0})(),d=0!==u&&{level:u},l={stdout:d,stderr:d};function h(e,t,n){let r=e.indexOf(t);if(-1===r)return e;const s=t.length;let a=0,i="";do{i+=e.slice(a,r)+t+n,a=r+s,r=e.indexOf(t,a)}while(-1!==r);return i+=e.slice(a),i}const{stdout:p,stderr:f}=l,m=Symbol("GENERATOR"),g=Symbol("STYLER"),y=Symbol("IS_EMPTY"),_=["ansi","ansi","ansi256","ansi16m"],v=Object.create(null),b=e=>{const t=(...e)=>e.join(" ");return((e,t={})=>{if(t.level&&!(Number.isInteger(t.level)&&t.level>=0&&t.level<=3))throw new Error("The `level` option should be an integer from 0 to 3");const n=p?p.level:0;e.level=void 0===t.level?n:t.level})(t,e),Object.setPrototypeOf(t,w.prototype),t};function w(e){return b(e)}Object.setPrototypeOf(w.prototype,Function.prototype);for(const[e,t]of Object.entries(c))v[e]={get(){const n=C(this,$(t.open,t.close,this[g]),this[y]);return Object.defineProperty(this,e,{value:n}),n}};v.visible={get(){const e=C(this,this[g],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const x=(e,t,n,...r)=>"rgb"===e?"ansi16m"===t?c[n].ansi16m(...r):"ansi256"===t?c[n].ansi256(c.rgbToAnsi256(...r)):c[n].ansi(c.rgbToAnsi(...r)):"hex"===e?x("rgb",t,n,...c.hexToRgb(...r)):c[n][e](...r),k=["rgb","hex","ansi256"];for(const e of k){v[e]={get(){const{level:t}=this;return function(...n){const r=$(x(e,_[t],"color",...n),c.color.close,this[g]);return C(this,r,this[y])}}};v["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:t}=this;return function(...n){const r=$(x(e,_[t],"bgColor",...n),c.bgColor.close,this[g]);return C(this,r,this[y])}}}}const O=Object.defineProperties(()=>{},{...v,level:{enumerable:!0,get(){return this[m].level},set(e){this[m].level=e}}}),$=(e,t,n)=>{let r,s;return void 0===n?(r=e,s=t):(r=n.openAll+e,s=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:s,parent:n}},C=(e,t,n)=>{const r=(...e)=>T(r,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(r,O),r[m]=e,r[g]=t,r[y]=n,r},T=(e,t)=>{if(e.level<=0||!t)return e[y]?"":t;let n=e[g];if(void 0===n)return t;const{openAll:r,closeAll:s}=n;if(t.includes(""))for(;void 0!==n;)t=h(t,n.close,n.open),n=n.parent;const a=t.indexOf("\n");return-1!==a&&(t=function(e,t,n,r){let s=0,a="";do{const i="\r"===e[r-1];a+=e.slice(s,i?r-1:r)+t+(i?"\r\n":"\n")+n,s=r+1,r=e.indexOf("\n",s)}while(-1!==r);return a+=e.slice(s),a}(t,s,r,a)),r+t+s};Object.defineProperties(w.prototype,v);const S=w();w({level:f?f.level:0});"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;function A(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var j={exports:{}},N=A(j.exports=function(){var e=1e3,t=6e4,n=36e5,r="millisecond",s="second",a="minute",i="hour",o="day",c="week",u="month",d="quarter",l="year",h="date",p="Invalid Date",f=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,m=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,g={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(e){var t=["th","st","nd","rd"],n=e%100;return"["+e+(t[(n-20)%10]||t[n]||t[0])+"]"}},y=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},_={s:y,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),s=n%60;return(t<=0?"+":"-")+y(r,2,"0")+":"+y(s,2,"0")},m:function e(t,n){if(t.date()<n.date())return-e(n,t);var r=12*(n.year()-t.year())+(n.month()-t.month()),s=t.clone().add(r,u),a=n-s<0,i=t.clone().add(r+(a?-1:1),u);return+(-(r+(n-s)/(a?s-i:i-s))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:u,y:l,w:c,d:o,D:h,h:i,m:a,s,ms:r,Q:d}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},v="en",b={};b[v]=g;var w="$isDayjsObject",x=function(e){return e instanceof C||!(!e||!e[w])},k=function e(t,n,r){var s;if(!t)return v;if("string"==typeof t){var a=t.toLowerCase();b[a]&&(s=a),n&&(b[a]=n,s=a);var i=t.split("-");if(!s&&i.length>1)return e(i[0])}else{var o=t.name;b[o]=t,s=o}return!r&&s&&(v=s),s||!r&&v},O=function(e,t){if(x(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new C(n)},$=_;$.l=k,$.i=x,$.w=function(e,t){return O(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var C=function(){function g(e){this.$L=k(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[w]=!0}var y=g.prototype;return y.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if($.u(t))return new Date;if(t instanceof Date)return new Date(t);if("string"==typeof t&&!/Z$/i.test(t)){var r=t.match(f);if(r){var s=r[2]-1||0,a=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],s,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)):new Date(r[1],s,r[3]||1,r[4]||0,r[5]||0,r[6]||0,a)}}return new Date(t)}(e),this.init()},y.init=function(){var e=this.$d;this.$y=e.getFullYear(),this.$M=e.getMonth(),this.$D=e.getDate(),this.$W=e.getDay(),this.$H=e.getHours(),this.$m=e.getMinutes(),this.$s=e.getSeconds(),this.$ms=e.getMilliseconds()},y.$utils=function(){return $},y.isValid=function(){return!(this.$d.toString()===p)},y.isSame=function(e,t){var n=O(e);return this.startOf(t)<=n&&n<=this.endOf(t)},y.isAfter=function(e,t){return O(e)<this.startOf(t)},y.isBefore=function(e,t){return this.endOf(t)<O(e)},y.$g=function(e,t,n){return $.u(e)?this[t]:this.set(n,e)},y.unix=function(){return Math.floor(this.valueOf()/1e3)},y.valueOf=function(){return this.$d.getTime()},y.startOf=function(e,t){var n=this,r=!!$.u(t)||t,d=$.p(e),p=function(e,t){var s=$.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?s:s.endOf(o)},f=function(e,t){return $.w(n.toDate()[e].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(t)),n)},m=this.$W,g=this.$M,y=this.$D,_="set"+(this.$u?"UTC":"");switch(d){case l:return r?p(1,0):p(31,11);case u:return r?p(1,g):p(0,g+1);case c:var v=this.$locale().weekStart||0,b=(m<v?m+7:m)-v;return p(r?y-b:y+(6-b),g);case o:case h:return f(_+"Hours",0);case i:return f(_+"Minutes",1);case a:return f(_+"Seconds",2);case s:return f(_+"Milliseconds",3);default:return this.clone()}},y.endOf=function(e){return this.startOf(e,!1)},y.$set=function(e,t){var n,c=$.p(e),d="set"+(this.$u?"UTC":""),p=(n={},n[o]=d+"Date",n[h]=d+"Date",n[u]=d+"Month",n[l]=d+"FullYear",n[i]=d+"Hours",n[a]=d+"Minutes",n[s]=d+"Seconds",n[r]=d+"Milliseconds",n)[c],f=c===o?this.$D+(t-this.$W):t;if(c===u||c===l){var m=this.clone().set(h,1);m.$d[p](f),m.init(),this.$d=m.set(h,Math.min(this.$D,m.daysInMonth())).$d}else p&&this.$d[p](f);return this.init(),this},y.set=function(e,t){return this.clone().$set(e,t)},y.get=function(e){return this[$.p(e)]()},y.add=function(r,d){var h,p=this;r=Number(r);var f=$.p(d),m=function(e){var t=O(p);return $.w(t.date(t.date()+Math.round(e*r)),p)};if(f===u)return this.set(u,this.$M+r);if(f===l)return this.set(l,this.$y+r);if(f===o)return m(1);if(f===c)return m(7);var g=(h={},h[a]=t,h[i]=n,h[s]=e,h)[f]||1,y=this.$d.getTime()+r*g;return $.w(y,this)},y.subtract=function(e,t){return this.add(-1*e,t)},y.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||"YYYY-MM-DDTHH:mm:ssZ",s=$.z(this),a=this.$H,i=this.$m,o=this.$M,c=n.weekdays,u=n.months,d=n.meridiem,l=function(e,n,s,a){return e&&(e[n]||e(t,r))||s[n].slice(0,a)},h=function(e){return $.s(a%12||12,e,"0")},f=d||function(e,t,n){var r=e<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(m,function(e,r){return r||function(e){switch(e){case"YY":return String(t.$y).slice(-2);case"YYYY":return $.s(t.$y,4,"0");case"M":return o+1;case"MM":return $.s(o+1,2,"0");case"MMM":return l(n.monthsShort,o,u,3);case"MMMM":return l(u,o);case"D":return t.$D;case"DD":return $.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return l(n.weekdaysMin,t.$W,c,2);case"ddd":return l(n.weekdaysShort,t.$W,c,3);case"dddd":return c[t.$W];case"H":return String(a);case"HH":return $.s(a,2,"0");case"h":return h(1);case"hh":return h(2);case"a":return f(a,i,!0);case"A":return f(a,i,!1);case"m":return String(i);case"mm":return $.s(i,2,"0");case"s":return String(t.$s);case"ss":return $.s(t.$s,2,"0");case"SSS":return $.s(t.$ms,3,"0");case"Z":return s}return null}(e)||s.replace(":","")})},y.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},y.diff=function(r,h,p){var f,m=this,g=$.p(h),y=O(r),_=(y.utcOffset()-this.utcOffset())*t,v=this-y,b=function(){return $.m(m,y)};switch(g){case l:f=b()/12;break;case u:f=b();break;case d:f=b()/3;break;case c:f=(v-_)/6048e5;break;case o:f=(v-_)/864e5;break;case i:f=v/n;break;case a:f=v/t;break;case s:f=v/e;break;default:f=v}return p?f:$.a(f)},y.daysInMonth=function(){return this.endOf(u).$D},y.$locale=function(){return b[this.$L]},y.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=k(e,t,!0);return r&&(n.$L=r),n},y.clone=function(){return $.w(this.$d,this)},y.toDate=function(){return new Date(this.valueOf())},y.toJSON=function(){return this.isValid()?this.toISOString():null},y.toISOString=function(){return this.$d.toISOString()},y.toString=function(){return this.$d.toUTCString()},g}(),T=C.prototype;return O.prototype=T,[["$ms",r],["$s",s],["$m",a],["$H",i],["$W",o],["$M",u],["$y",l],["$D",h]].forEach(function(e){T[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),O.extend=function(e,t){return e.$i||(e(t,C,O),e.$i=!0),O},O.locale=k,O.isDayjs=x,O.unix=function(e){return O(1e3*e)},O.en=b[v],O.Ls=b,O.p={},O}());const E="INFO",Z="SUCCESS",M="WARN",P="ERROR",R="DEBUG";S.level=1;const I={INFO:{icon:"✨",color:S.cyan,bgColor:S.bgCyan.black,label:E},SUCCESS:{icon:"✅",color:S.green,bgColor:S.bgGreen.black,label:Z},WARN:{icon:"⚠️ ",color:S.yellow,bgColor:S.bgYellow.black,label:M},ERROR:{icon:"❌",color:S.red,bgColor:S.bgRed.white,label:P},DEBUG:{icon:"🔍",color:S.blue,bgColor:S.bgBlue.white,label:R}};var L=new class{levelConfig;constructor(){this.levelConfig=I}formatMessage(e,t){const n=this.levelConfig[e],r=S.gray(`[${N().format("HH:mm:ss")}]`);let s="";if(n){s=`${n.icon} ${n.bgColor(` ${n.label} `)} ${n.color(t)} ${r}`}else s=`${e} ${t} ${r}`;return s}log(e,t,n=""){const r=this.formatMessage(e,t);n?(console.log(r),console.log(S.gray(` └─ ${n}`))):console.log(r)}separator(e="─",t=50){console.log(S.gray(e.repeat(t)))}info(e,t=""){this.log(E,e,t)}success(e,t=""){this.log(Z,e,t)}error(e,t=""){this.log(P,e,t)}warn(e,t=""){this.log(M,e,t)}debug(e,t=""){this.log(R,e,t)}};const D=".generate";async function F(n,r){await e.promises.mkdir(r,{recursive:!0});const s=await e.promises.readdir(n);for(const a of s){const s=t.join(n,a),i=t.join(r,a);(await e.promises.stat(s)).isDirectory()?await F(s,i):(await e.promises.copyFile(s,i),L.info(`初始化文件 ${i}`))}}function z(t){try{return e.accessSync(t),!0}catch{return!1}}async function W(t){try{return await e.promises.access(t),!0}catch{return!1}}var U,B;!function(e){e.assertEqual=e=>{},e.assertIs=function(e){},e.assertNever=function(e){throw new Error},e.arrayToEnum=e=>{const t={};for(const n of e)t[n]=n;return t},e.getValidEnumValues=t=>{const n=e.objectKeys(t).filter(e=>"number"!=typeof t[t[e]]),r={};for(const e of n)r[e]=t[e];return e.objectValues(r)},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 n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.push(n);return t},e.find=(e,t)=>{for(const n of e)if(t(n))return n},e.isInteger="function"==typeof Number.isInteger?e=>Number.isInteger(e):e=>"number"==typeof e&&Number.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}(U||(U={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(B||(B={}));const V=U.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),K=e=>{switch(typeof e){case"undefined":return V.undefined;case"string":return V.string;case"number":return Number.isNaN(e)?V.nan:V.number;case"boolean":return V.boolean;case"function":return V.function;case"bigint":return V.bigint;case"symbol":return V.symbol;case"object":return Array.isArray(e)?V.array:null===e?V.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?V.promise:"undefined"!=typeof Map&&e instanceof Map?V.map:"undefined"!=typeof Set&&e instanceof Set?V.set:"undefined"!=typeof Date&&e instanceof Date?V.date:V.object;default:return V.unknown}},J=U.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 H extends Error{get errors(){return this.issues}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}format(e){const t=e||function(e){return e.message},n={_errors:[]},r=e=>{for(const s of e.issues)if("invalid_union"===s.code)s.unionErrors.map(r);else if("invalid_return_type"===s.code)r(s.returnTypeError);else if("invalid_arguments"===s.code)r(s.argumentsError);else if(0===s.path.length)n._errors.push(t(s));else{let e=n,r=0;for(;r<s.path.length;){const n=s.path[r];r===s.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(s))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(e){if(!(e instanceof H))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,U.jsonStringifyReplacer,2)}get isEmpty(){return 0===this.issues.length}flatten(e=e=>e.message){const t={},n=[];for(const r of this.issues)if(r.path.length>0){const n=r.path[0];t[n]=t[n]||[],t[n].push(e(r))}else n.push(e(r));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}}H.create=e=>new H(e);const Y=(e,t)=>{let n;switch(e.code){case J.invalid_type:n=e.received===V.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case J.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,U.jsonStringifyReplacer)}`;break;case J.unrecognized_keys:n=`Unrecognized key(s) in object: ${U.joinValues(e.keys,", ")}`;break;case J.invalid_union:n="Invalid input";break;case J.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${U.joinValues(e.options)}`;break;case J.invalid_enum_value:n=`Invalid enum value. Expected ${U.joinValues(e.options)}, received '${e.received}'`;break;case J.invalid_arguments:n="Invalid function arguments";break;case J.invalid_return_type:n="Invalid function return type";break;case J.invalid_date:n="Invalid date";break;case J.invalid_string:"object"==typeof e.validation?"includes"in e.validation?(n=`Invalid input: must include "${e.validation.includes}"`,"number"==typeof e.validation.position&&(n=`${n} at one or more positions greater than or equal to ${e.validation.position}`)):"startsWith"in e.validation?n=`Invalid input: must start with "${e.validation.startsWith}"`:"endsWith"in e.validation?n=`Invalid input: must end with "${e.validation.endsWith}"`:U.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case J.too_small:n="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||"bigint"===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 J.too_big:n="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 J.custom:n="Invalid input";break;case J.invalid_intersection_types:n="Intersection results could not be merged";break;case J.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case J.not_finite:n="Number must be finite";break;default:n=t.defaultError,U.assertNever(e)}return{message:n}};let q=Y;function G(e,t){const n=q,r=(e=>{const{data:t,path:n,errorMaps:r,issueData:s}=e,a=[...n,...s.path||[]],i={...s,path:a};if(void 0!==s.message)return{...s,path:a,message:s.message};let o="";const c=r.filter(e=>!!e).slice().reverse();for(const e of c)o=e(i,{data:t,defaultError:o}).message;return{...s,path:a,message:o}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===Y?void 0:Y].filter(e=>!!e)});e.common.issues.push(r)}class X{constructor(){this.value="valid"}dirty(){"valid"===this.value&&(this.value="dirty")}abort(){"aborted"!==this.value&&(this.value="aborted")}static mergeArray(e,t){const n=[];for(const r of t){if("aborted"===r.status)return Q;"dirty"===r.status&&e.dirty(),n.push(r.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){const n=[];for(const e of t){const t=await e.key,r=await e.value;n.push({key:t,value:r})}return X.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:t,value:s}=r;if("aborted"===t.status)return Q;if("aborted"===s.status)return Q;"dirty"===t.status&&e.dirty(),"dirty"===s.status&&e.dirty(),"__proto__"===t.value||void 0===s.value&&!r.alwaysSet||(n[t.value]=s.value)}return{status:e.value,value:n}}}const Q=Object.freeze({status:"aborted"}),ee=e=>({status:"dirty",value:e}),te=e=>({status:"valid",value:e}),ne=e=>"aborted"===e.status,re=e=>"dirty"===e.status,se=e=>"valid"===e.status,ae=e=>"undefined"!=typeof Promise&&e instanceof Promise;var ie;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(ie||(ie={}));class oe{constructor(e,t,n,r){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=r}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const ce=(e,t)=>{if(se(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 H(e.common.issues);return this._error=t,this._error}}};function ue(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:s}=e;if(t&&(n||r))throw new Error('Can\'t use "invalid_type_error" or "required_error" in conjunction with custom error map.');if(t)return{errorMap:t,description:s};return{errorMap:(t,s)=>{const{message:a}=e;return"invalid_enum_value"===t.code?{message:a??s.defaultError}:void 0===s.data?{message:a??r??s.defaultError}:"invalid_type"!==t.code?{message:s.defaultError}:{message:a??n??s.defaultError}},description:s}}class de{get description(){return this._def.description}_getType(e){return K(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:K(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new X,ctx:{common:e.parent.common,data:e.data,parsedType:K(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(ae(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){const t=this._parse(e);return Promise.resolve(t)}parse(e,t){const n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){const n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:K(e)},r=this._parseSync({data:e,path:n.path,parent:n});return ce(n,r)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:K(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return se(n)?{value:n.value}:{issues:t.common.issues}}catch(e){e?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(e=>se(e)?{value:e.value}:{issues:t.common.issues})}async parseAsync(e,t){const n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){const n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:K(e)},r=this._parse({data:e,path:n.path,parent:n}),s=await(ae(r)?r:Promise.resolve(r));return ce(n,s)}refine(e,t){const n=e=>"string"==typeof t||void 0===t?{message:t}:"function"==typeof t?t(e):t;return this._refinement((t,r)=>{const s=e(t),a=()=>r.addIssue({code:J.custom,...n(t)});return"undefined"!=typeof Promise&&s instanceof Promise?s.then(e=>!!e||(a(),!1)):!!s||(a(),!1)})}refinement(e,t){return this._refinement((n,r)=>!!e(n)||(r.addIssue("function"==typeof t?t(n,r):t),!1))}_refinement(e){return new ct({schema:this,typeName:yt.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:e=>this["~validate"](e)}}optional(){return ut.create(this,this._def)}nullable(){return dt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return Je.create(this)}promise(){return ot.create(this,this._def)}or(e){return qe.create([this,e],this._def)}and(e){return Xe.create(this,e,this._def)}transform(e){return new ct({...ue(this._def),schema:this,typeName:yt.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new lt({...ue(this._def),innerType:this,defaultValue:t,typeName:yt.ZodDefault})}brand(){return new ft({typeName:yt.ZodBranded,type:this,...ue(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new ht({...ue(this._def),innerType:this,catchValue:t,typeName:yt.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return mt.create(this,e)}readonly(){return gt.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const le=/^c[^\s-]{8,}$/i,he=/^[0-9a-z]+$/,pe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,fe=/^[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,me=/^[a-z0-9_-]{21}$/i,ge=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,ye=/^[-+]?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)?)??$/,_e=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let ve;const be=/^(?:(?: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])$/,we=/^(?:(?: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])$/,xe=/^(([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]))$/,ke=/^(([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])$/,Oe=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,$e=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Ce="((\\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])))",Te=new RegExp(`^${Ce}$`);function Se(e){let t="[0-5]\\d";e.precision?t=`${t}\\.\\d{${e.precision}}`:null==e.precision&&(t=`${t}(\\.\\d+)?`);return`([01]\\d|2[0-3]):[0-5]\\d(:${t})${e.precision?"+":"?"}`}function Ae(e){return new RegExp(`^${Se(e)}$`)}function je(e){let t=`${Ce}T${Se(e)}`;const n=[];return n.push(e.local?"Z?":"Z"),e.offset&&n.push("([+-]\\d{2}:?\\d{2})"),t=`${t}(${n.join("|")})`,new RegExp(`^${t}$`)}function Ne(e,t){return!("v4"!==t&&t||!be.test(e))||!("v6"!==t&&t||!xe.test(e))}function Ee(e,t){if(!ge.test(e))return!1;try{const[n]=e.split(".");if(!n)return!1;const r=n.replace(/-/g,"+").replace(/_/g,"/").padEnd(n.length+(4-n.length%4)%4,"="),s=JSON.parse(atob(r));return"object"==typeof s&&null!==s&&((!("typ"in s)||"JWT"===s?.typ)&&(!!s.alg&&(!t||s.alg===t)))}catch{return!1}}function Ze(e,t){return!("v4"!==t&&t||!we.test(e))||!("v6"!==t&&t||!ke.test(e))}class Me extends de{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==V.string){const t=this._getOrReturnCtx(e);return G(t,{code:J.invalid_type,expected:V.string,received:t.parsedType}),Q}const t=new X;let n;for(const r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:J.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("max"===r.kind)e.data.length>r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:J.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("length"===r.kind){const s=e.data.length>r.value,a=e.data.length<r.value;(s||a)&&(n=this._getOrReturnCtx(e,n),s?G(n,{code:J.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):a&&G(n,{code:J.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if("email"===r.kind)_e.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"email",code:J.invalid_string,message:r.message}),t.dirty());else if("emoji"===r.kind)ve||(ve=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),ve.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"emoji",code:J.invalid_string,message:r.message}),t.dirty());else if("uuid"===r.kind)fe.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"uuid",code:J.invalid_string,message:r.message}),t.dirty());else if("nanoid"===r.kind)me.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"nanoid",code:J.invalid_string,message:r.message}),t.dirty());else if("cuid"===r.kind)le.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"cuid",code:J.invalid_string,message:r.message}),t.dirty());else if("cuid2"===r.kind)he.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"cuid2",code:J.invalid_string,message:r.message}),t.dirty());else if("ulid"===r.kind)pe.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"ulid",code:J.invalid_string,message:r.message}),t.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),G(n,{validation:"url",code:J.invalid_string,message:r.message}),t.dirty()}else if("regex"===r.kind){r.regex.lastIndex=0;r.regex.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"regex",code:J.invalid_string,message:r.message}),t.dirty())}else if("trim"===r.kind)e.data=e.data.trim();else if("includes"===r.kind)e.data.includes(r.value,r.position)||(n=this._getOrReturnCtx(e,n),G(n,{code:J.invalid_string,validation:{includes:r.value,position:r.position},message:r.message}),t.dirty());else if("toLowerCase"===r.kind)e.data=e.data.toLowerCase();else if("toUpperCase"===r.kind)e.data=e.data.toUpperCase();else if("startsWith"===r.kind)e.data.startsWith(r.value)||(n=this._getOrReturnCtx(e,n),G(n,{code:J.invalid_string,validation:{startsWith:r.value},message:r.message}),t.dirty());else if("endsWith"===r.kind)e.data.endsWith(r.value)||(n=this._getOrReturnCtx(e,n),G(n,{code:J.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty());else if("datetime"===r.kind){je(r).test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:J.invalid_string,validation:"datetime",message:r.message}),t.dirty())}else if("date"===r.kind){Te.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:J.invalid_string,validation:"date",message:r.message}),t.dirty())}else if("time"===r.kind){Ae(r).test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{code:J.invalid_string,validation:"time",message:r.message}),t.dirty())}else"duration"===r.kind?ye.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"duration",code:J.invalid_string,message:r.message}),t.dirty()):"ip"===r.kind?Ne(e.data,r.version)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"ip",code:J.invalid_string,message:r.message}),t.dirty()):"jwt"===r.kind?Ee(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"jwt",code:J.invalid_string,message:r.message}),t.dirty()):"cidr"===r.kind?Ze(e.data,r.version)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"cidr",code:J.invalid_string,message:r.message}),t.dirty()):"base64"===r.kind?Oe.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"base64",code:J.invalid_string,message:r.message}),t.dirty()):"base64url"===r.kind?$e.test(e.data)||(n=this._getOrReturnCtx(e,n),G(n,{validation:"base64url",code:J.invalid_string,message:r.message}),t.dirty()):U.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:J.invalid_string,...ie.errToObj(n)})}_addCheck(e){return new Me({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ie.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ie.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ie.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ie.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ie.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ie.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ie.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ie.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ie.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ie.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ie.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ie.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ie.errToObj(e)})}datetime(e){return"string"==typeof e?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:void 0===e?.precision?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...ie.errToObj(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===e?.precision?null:e?.precision,...ie.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ie.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ie.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...ie.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ie.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ie.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ie.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ie.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ie.errToObj(t)})}nonempty(e){return this.min(1,ie.errToObj(e))}trim(){return new Me({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new Me({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new Me({...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 isCIDR(){return!!this._def.checks.find(e=>"cidr"===e.kind)}get isBase64(){return!!this._def.checks.find(e=>"base64"===e.kind)}get isBase64url(){return!!this._def.checks.find(e=>"base64url"===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 Pe(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,s=n>r?n:r;return Number.parseInt(e.toFixed(s).replace(".",""))%Number.parseInt(t.toFixed(s).replace(".",""))/10**s}Me.create=e=>new Me({checks:[],typeName:yt.ZodString,coerce:e?.coerce??!1,...ue(e)});class Re extends de{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)!==V.number){const t=this._getOrReturnCtx(e);return G(t,{code:J.invalid_type,expected:V.number,received:t.parsedType}),Q}let t;const n=new X;for(const r of this._def.checks)if("int"===r.kind)U.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),G(t,{code:J.invalid_type,expected:"integer",received:"float",message:r.message}),n.dirty());else if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:J.too_small,minimum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:J.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else"multipleOf"===r.kind?0!==Pe(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:J.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),G(t,{code:J.not_finite,message:r.message}),n.dirty()):U.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ie.toString(t))}setLimit(e,t,n,r){return new Re({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ie.toString(r)}]})}_addCheck(e){return new Re({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ie.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ie.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ie.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ie.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ie.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&&U.isInteger(e.value))}get isFinite(){let e=null,t=null;for(const n of this._def.checks){if("finite"===n.kind||"int"===n.kind||"multipleOf"===n.kind)return!0;"min"===n.kind?(null===t||n.value>t)&&(t=n.value):"max"===n.kind&&(null===e||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}}Re.create=e=>new Re({checks:[],typeName:yt.ZodNumber,coerce:e?.coerce||!1,...ue(e)});class Ie extends de{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)!==V.bigint)return this._getInvalidInput(e);let t;const n=new X;for(const r of this._def.checks)if("min"===r.kind){(r.inclusive?e.data<r.value:e.data<=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:J.too_small,type:"bigint",minimum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else if("max"===r.kind){(r.inclusive?e.data>r.value:e.data>=r.value)&&(t=this._getOrReturnCtx(e,t),G(t,{code:J.too_big,type:"bigint",maximum:r.value,inclusive:r.inclusive,message:r.message}),n.dirty())}else"multipleOf"===r.kind?e.data%r.value!==BigInt(0)&&(t=this._getOrReturnCtx(e,t),G(t,{code:J.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):U.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return G(t,{code:J.invalid_type,expected:V.bigint,received:t.parsedType}),Q}gte(e,t){return this.setLimit("min",e,!0,ie.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ie.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ie.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ie.toString(t))}setLimit(e,t,n,r){return new Ie({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ie.toString(r)}]})}_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:ie.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ie.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ie.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ie.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ie.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=>new Ie({checks:[],typeName:yt.ZodBigInt,coerce:e?.coerce??!1,...ue(e)});class Le extends de{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==V.boolean){const t=this._getOrReturnCtx(e);return G(t,{code:J.invalid_type,expected:V.boolean,received:t.parsedType}),Q}return te(e.data)}}Le.create=e=>new Le({typeName:yt.ZodBoolean,coerce:e?.coerce||!1,...ue(e)});class De extends de{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==V.date){const t=this._getOrReturnCtx(e);return G(t,{code:J.invalid_type,expected:V.date,received:t.parsedType}),Q}if(Number.isNaN(e.data.getTime())){return G(this._getOrReturnCtx(e),{code:J.invalid_date}),Q}const t=new X;let n;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:J.too_small,message:r.message,inclusive:!0,exact:!1,minimum:r.value,type:"date"}),t.dirty()):"max"===r.kind?e.data.getTime()>r.value&&(n=this._getOrReturnCtx(e,n),G(n,{code:J.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):U.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new De({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ie.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ie.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}}De.create=e=>new De({checks:[],coerce:e?.coerce||!1,typeName:yt.ZodDate,...ue(e)});class Fe extends de{_parse(e){if(this._getType(e)!==V.symbol){const t=this._getOrReturnCtx(e);return G(t,{code:J.invalid_type,expected:V.symbol,received:t.parsedType}),Q}return te(e.data)}}Fe.create=e=>new Fe({typeName:yt.ZodSymbol,...ue(e)});class ze extends de{_parse(e){if(this._getType(e)!==V.undefined){const t=this._getOrReturnCtx(e);return G(t,{code:J.invalid_type,expected:V.undefined,received:t.parsedType}),Q}return te(e.data)}}ze.create=e=>new ze({typeName:yt.ZodUndefined,...ue(e)});class We extends de{_parse(e){if(this._getType(e)!==V.null){const t=this._getOrReturnCtx(e);return G(t,{code:J.invalid_type,expected:V.null,received:t.parsedType}),Q}return te(e.data)}}We.create=e=>new We({typeName:yt.ZodNull,...ue(e)});class Ue extends de{constructor(){super(...arguments),this._any=!0}_parse(e){return te(e.data)}}Ue.create=e=>new Ue({typeName:yt.ZodAny,...ue(e)});class Be extends de{constructor(){super(...arguments),this._unknown=!0}_parse(e){return te(e.data)}}Be.create=e=>new Be({typeName:yt.ZodUnknown,...ue(e)});class Ve extends de{_parse(e){const t=this._getOrReturnCtx(e);return G(t,{code:J.invalid_type,expected:V.never,received:t.parsedType}),Q}}Ve.create=e=>new Ve({typeName:yt.ZodNever,...ue(e)});class Ke extends de{_parse(e){if(this._getType(e)!==V.undefined){const t=this._getOrReturnCtx(e);return G(t,{code:J.invalid_type,expected:V.void,received:t.parsedType}),Q}return te(e.data)}}Ke.create=e=>new Ke({typeName:yt.ZodVoid,...ue(e)});class Je extends de{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==V.array)return G(t,{code:J.invalid_type,expected:V.array,received:t.parsedType}),Q;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,s=t.data.length<r.exactLength.value;(e||s)&&(G(t,{code:e?J.too_big:J.too_small,minimum:s?r.exactLength.value:void 0,maximum:e?r.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:r.exactLength.message}),n.dirty())}if(null!==r.minLength&&t.data.length<r.minLength.value&&(G(t,{code:J.too_small,minimum:r.minLength.value,type:"array",inclusive:!0,exact:!1,message:r.minLength.message}),n.dirty()),null!==r.maxLength&&t.data.length>r.maxLength.value&&(G(t,{code:J.too_big,maximum:r.maxLength.value,type:"array",inclusive:!0,exact:!1,message:r.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((e,n)=>r.type._parseAsync(new oe(t,e,t.path,n)))).then(e=>X.mergeArray(n,e));const s=[...t.data].map((e,n)=>r.type._parseSync(new oe(t,e,t.path,n)));return X.mergeArray(n,s)}get element(){return this._def.type}min(e,t){return new Je({...this._def,minLength:{value:e,message:ie.toString(t)}})}max(e,t){return new Je({...this._def,maxLength:{value:e,message:ie.toString(t)}})}length(e,t){return new Je({...this._def,exactLength:{value:e,message:ie.toString(t)}})}nonempty(e){return this.min(1,e)}}function He(e){if(e instanceof Ye){const t={};for(const n in e.shape){const r=e.shape[n];t[n]=ut.create(He(r))}return new Ye({...e._def,shape:()=>t})}return e instanceof Je?new Je({...e._def,type:He(e.element)}):e instanceof ut?ut.create(He(e.unwrap())):e instanceof dt?dt.create(He(e.unwrap())):e instanceof Qe?Qe.create(e.items.map(e=>He(e))):e}Je.create=(e,t)=>new Je({type:e,minLength:null,maxLength:null,exactLength:null,typeName:yt.ZodArray,...ue(t)});class Ye extends de{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=U.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==V.object){const t=this._getOrReturnCtx(e);return G(t,{code:J.invalid_type,expected:V.object,received:t.parsedT