@smooth_zhz/generate_node-core
Version:
A flexible code generation tool with configurable templates and settings
2 lines • 541 kB
JavaScript
#!/usr/bin/env node
import e,{unwatchFile as t,watchFile as n,watch as r,stat as i}from"fs";import*as s from"path";import o from"path";import{pathToFileURL as a,fileURLToPath as u}from"url";import{realpath as c,stat as l,lstat as h,open as d,readdir as p}from"fs/promises";import f,{EventEmitter as m}from"events";import{lstat as g,stat as D,readdir as y,realpath as b}from"node:fs/promises";import{Readable as v}from"node:stream";import{resolve as _,join as w,relative as C,sep as E}from"node:path";import{type as x}from"os";import F from"child_process";import k from"process";import*as A from"node:readline";import S from"node:readline";import O from"stream";import B from"node:tty";import T from"node:process";import{AsyncLocalStorage as $,AsyncResource as P}from"node:async_hooks";import{stripVTControlCharacters as j}from"node:util";import I from"tty";import R from"util";import M from"buffer";import L from"string_decoder";import N from"crypto";const U=(e=0)=>t=>`[${t+e}m`,V=(e=0)=>t=>`[${38+e};5;${t}m`,W=(e=0)=>(t,n,r)=>`[${38+e};2;${t};${n};${r}m`,Z={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(Z.modifier);Object.keys(Z.color),Object.keys(Z.bgColor);const H=function(){const e=new Map;for(const[t,n]of Object.entries(Z)){for(const[t,r]of Object.entries(n))Z[t]={open:`[${r[0]}m`,close:`[${r[1]}m`},n[t]=Z[t],e.set(r[0],r[1]);Object.defineProperty(Z,t,{value:n,enumerable:!1})}return Object.defineProperty(Z,"codes",{value:e,enumerable:!1}),Z.color.close="[39m",Z.bgColor.close="[49m",Z.color.ansi=U(),Z.color.ansi256=V(),Z.color.ansi16m=W(),Z.bgColor.ansi=U(10),Z.bgColor.ansi256=V(10),Z.bgColor.ansi16m=W(10),Object.defineProperties(Z,{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=>Z.rgbToAnsi256(...Z.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 i=(e-=16)%36;t=Math.floor(e/36)/5,n=Math.floor(i/6)/5,r=i%6/5}const i=2*Math.max(t,n,r);if(0===i)return 30;let s=30+(Math.round(r)<<2|Math.round(n)<<1|Math.round(t));return 2===i&&(s+=60),s},enumerable:!1},rgbToAnsi:{value:(e,t,n)=>Z.ansi256ToAnsi(Z.rgbToAnsi256(e,t,n)),enumerable:!1},hexToAnsi:{value:e=>Z.ansi256ToAnsi(Z.hexToAnsi256(e)),enumerable:!1}}),Z}(),z=(()=>{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})(),q=0!==z&&{level:z},G={stdout:q,stderr:q};function Y(e,t,n){let r=e.indexOf(t);if(-1===r)return e;const i=t.length;let s=0,o="";do{o+=e.slice(s,r)+t+n,s=r+i,r=e.indexOf(t,s)}while(-1!==r);return o+=e.slice(s),o}const{stdout:K,stderr:J}=G,X=Symbol("GENERATOR"),Q=Symbol("STYLER"),ee=Symbol("IS_EMPTY"),te=["ansi","ansi","ansi256","ansi16m"],ne=Object.create(null),re=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=K?K.level:0;e.level=void 0===t.level?n:t.level})(t,e),Object.setPrototypeOf(t,ie.prototype),t};function ie(e){return re(e)}Object.setPrototypeOf(ie.prototype,Function.prototype);for(const[e,t]of Object.entries(H))ne[e]={get(){const n=ce(this,ue(t.open,t.close,this[Q]),this[ee]);return Object.defineProperty(this,e,{value:n}),n}};ne.visible={get(){const e=ce(this,this[Q],!0);return Object.defineProperty(this,"visible",{value:e}),e}};const se=(e,t,n,...r)=>"rgb"===e?"ansi16m"===t?H[n].ansi16m(...r):"ansi256"===t?H[n].ansi256(H.rgbToAnsi256(...r)):H[n].ansi(H.rgbToAnsi(...r)):"hex"===e?se("rgb",t,n,...H.hexToRgb(...r)):H[n][e](...r),oe=["rgb","hex","ansi256"];for(const e of oe){ne[e]={get(){const{level:t}=this;return function(...n){const r=ue(se(e,te[t],"color",...n),H.color.close,this[Q]);return ce(this,r,this[ee])}}};ne["bg"+e[0].toUpperCase()+e.slice(1)]={get(){const{level:t}=this;return function(...n){const r=ue(se(e,te[t],"bgColor",...n),H.bgColor.close,this[Q]);return ce(this,r,this[ee])}}}}const ae=Object.defineProperties(()=>{},{...ne,level:{enumerable:!0,get(){return this[X].level},set(e){this[X].level=e}}}),ue=(e,t,n)=>{let r,i;return void 0===n?(r=e,i=t):(r=n.openAll+e,i=t+n.closeAll),{open:e,close:t,openAll:r,closeAll:i,parent:n}},ce=(e,t,n)=>{const r=(...e)=>le(r,1===e.length?""+e[0]:e.join(" "));return Object.setPrototypeOf(r,ae),r[X]=e,r[Q]=t,r[ee]=n,r},le=(e,t)=>{if(e.level<=0||!t)return e[ee]?"":t;let n=e[Q];if(void 0===n)return t;const{openAll:r,closeAll:i}=n;if(t.includes(""))for(;void 0!==n;)t=Y(t,n.close,n.open),n=n.parent;const s=t.indexOf("\n");return-1!==s&&(t=function(e,t,n,r){let i=0,s="";do{const o="\r"===e[r-1];s+=e.slice(i,o?r-1:r)+t+(o?"\r\n":"\n")+n,i=r+1,r=e.indexOf("\n",i)}while(-1!==r);return s+=e.slice(i),s}(t,i,r,s)),r+t+i};Object.defineProperties(ie.prototype,ne);const he=ie();ie({level:J?J.level:0});var de="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function pe(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var fe={exports:{}};fe.exports=function(){var e=1e3,t=6e4,n=36e5,r="millisecond",i="second",s="minute",o="hour",a="day",u="week",c="month",l="quarter",h="year",d="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])+"]"}},D=function(e,t,n){var r=String(e);return!r||r.length>=t?e:""+Array(t+1-r.length).join(n)+e},y={s:D,z:function(e){var t=-e.utcOffset(),n=Math.abs(t),r=Math.floor(n/60),i=n%60;return(t<=0?"+":"-")+D(r,2,"0")+":"+D(i,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()),i=t.clone().add(r,c),s=n-i<0,o=t.clone().add(r+(s?-1:1),c);return+(-(r+(n-i)/(s?i-o:o-i))||0)},a:function(e){return e<0?Math.ceil(e)||0:Math.floor(e)},p:function(e){return{M:c,y:h,w:u,d:a,D:d,h:o,m:s,s:i,ms:r,Q:l}[e]||String(e||"").toLowerCase().replace(/s$/,"")},u:function(e){return void 0===e}},b="en",v={};v[b]=g;var _="$isDayjsObject",w=function(e){return e instanceof F||!(!e||!e[_])},C=function e(t,n,r){var i;if(!t)return b;if("string"==typeof t){var s=t.toLowerCase();v[s]&&(i=s),n&&(v[s]=n,i=s);var o=t.split("-");if(!i&&o.length>1)return e(o[0])}else{var a=t.name;v[a]=t,i=a}return!r&&i&&(b=i),i||!r&&b},E=function(e,t){if(w(e))return e.clone();var n="object"==typeof t?t:{};return n.date=e,n.args=arguments,new F(n)},x=y;x.l=C,x.i=w,x.w=function(e,t){return E(e,{locale:t.$L,utc:t.$u,x:t.$x,$offset:t.$offset})};var F=function(){function g(e){this.$L=C(e.locale,null,!0),this.parse(e),this.$x=this.$x||e.x||{},this[_]=!0}var D=g.prototype;return D.parse=function(e){this.$d=function(e){var t=e.date,n=e.utc;if(null===t)return new Date(NaN);if(x.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 i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(t)}(e),this.init()},D.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()},D.$utils=function(){return x},D.isValid=function(){return!(this.$d.toString()===p)},D.isSame=function(e,t){var n=E(e);return this.startOf(t)<=n&&n<=this.endOf(t)},D.isAfter=function(e,t){return E(e)<this.startOf(t)},D.isBefore=function(e,t){return this.endOf(t)<E(e)},D.$g=function(e,t,n){return x.u(e)?this[t]:this.set(n,e)},D.unix=function(){return Math.floor(this.valueOf()/1e3)},D.valueOf=function(){return this.$d.getTime()},D.startOf=function(e,t){var n=this,r=!!x.u(t)||t,l=x.p(e),p=function(e,t){var i=x.w(n.$u?Date.UTC(n.$y,t,e):new Date(n.$y,t,e),n);return r?i:i.endOf(a)},f=function(e,t){return x.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,D=this.$D,y="set"+(this.$u?"UTC":"");switch(l){case h:return r?p(1,0):p(31,11);case c:return r?p(1,g):p(0,g+1);case u:var b=this.$locale().weekStart||0,v=(m<b?m+7:m)-b;return p(r?D-v:D+(6-v),g);case a:case d:return f(y+"Hours",0);case o:return f(y+"Minutes",1);case s:return f(y+"Seconds",2);case i:return f(y+"Milliseconds",3);default:return this.clone()}},D.endOf=function(e){return this.startOf(e,!1)},D.$set=function(e,t){var n,u=x.p(e),l="set"+(this.$u?"UTC":""),p=(n={},n[a]=l+"Date",n[d]=l+"Date",n[c]=l+"Month",n[h]=l+"FullYear",n[o]=l+"Hours",n[s]=l+"Minutes",n[i]=l+"Seconds",n[r]=l+"Milliseconds",n)[u],f=u===a?this.$D+(t-this.$W):t;if(u===c||u===h){var m=this.clone().set(d,1);m.$d[p](f),m.init(),this.$d=m.set(d,Math.min(this.$D,m.daysInMonth())).$d}else p&&this.$d[p](f);return this.init(),this},D.set=function(e,t){return this.clone().$set(e,t)},D.get=function(e){return this[x.p(e)]()},D.add=function(r,l){var d,p=this;r=Number(r);var f=x.p(l),m=function(e){var t=E(p);return x.w(t.date(t.date()+Math.round(e*r)),p)};if(f===c)return this.set(c,this.$M+r);if(f===h)return this.set(h,this.$y+r);if(f===a)return m(1);if(f===u)return m(7);var g=(d={},d[s]=t,d[o]=n,d[i]=e,d)[f]||1,D=this.$d.getTime()+r*g;return x.w(D,this)},D.subtract=function(e,t){return this.add(-1*e,t)},D.format=function(e){var t=this,n=this.$locale();if(!this.isValid())return n.invalidDate||p;var r=e||"YYYY-MM-DDTHH:mm:ssZ",i=x.z(this),s=this.$H,o=this.$m,a=this.$M,u=n.weekdays,c=n.months,l=n.meridiem,h=function(e,n,i,s){return e&&(e[n]||e(t,r))||i[n].slice(0,s)},d=function(e){return x.s(s%12||12,e,"0")},f=l||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 x.s(t.$y,4,"0");case"M":return a+1;case"MM":return x.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return t.$D;case"DD":return x.s(t.$D,2,"0");case"d":return String(t.$W);case"dd":return h(n.weekdaysMin,t.$W,u,2);case"ddd":return h(n.weekdaysShort,t.$W,u,3);case"dddd":return u[t.$W];case"H":return String(s);case"HH":return x.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return f(s,o,!0);case"A":return f(s,o,!1);case"m":return String(o);case"mm":return x.s(o,2,"0");case"s":return String(t.$s);case"ss":return x.s(t.$s,2,"0");case"SSS":return x.s(t.$ms,3,"0");case"Z":return i}return null}(e)||i.replace(":","")})},D.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},D.diff=function(r,d,p){var f,m=this,g=x.p(d),D=E(r),y=(D.utcOffset()-this.utcOffset())*t,b=this-D,v=function(){return x.m(m,D)};switch(g){case h:f=v()/12;break;case c:f=v();break;case l:f=v()/3;break;case u:f=(b-y)/6048e5;break;case a:f=(b-y)/864e5;break;case o:f=b/n;break;case s:f=b/t;break;case i:f=b/e;break;default:f=b}return p?f:x.a(f)},D.daysInMonth=function(){return this.endOf(c).$D},D.$locale=function(){return v[this.$L]},D.locale=function(e,t){if(!e)return this.$L;var n=this.clone(),r=C(e,t,!0);return r&&(n.$L=r),n},D.clone=function(){return x.w(this.$d,this)},D.toDate=function(){return new Date(this.valueOf())},D.toJSON=function(){return this.isValid()?this.toISOString():null},D.toISOString=function(){return this.$d.toISOString()},D.toString=function(){return this.$d.toUTCString()},g}(),k=F.prototype;return E.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",o],["$W",a],["$M",c],["$y",h],["$D",d]].forEach(function(e){k[e[1]]=function(t){return this.$g(t,e[0],e[1])}}),E.extend=function(e,t){return e.$i||(e(t,F,E),e.$i=!0),E},E.locale=C,E.isDayjs=w,E.unix=function(e){return E(1e3*e)},E.en=v[b],E.Ls=v,E.p={},E}();var me=pe(fe.exports);const ge="INFO",De="SUCCESS",ye="WARN",be="ERROR",ve="DEBUG";he.level=1;const _e={INFO:{icon:"✨",color:he.cyan,bgColor:he.bgCyan.black,label:ge},SUCCESS:{icon:"✅",color:he.green,bgColor:he.bgGreen.black,label:De},WARN:{icon:"⚠️ ",color:he.yellow,bgColor:he.bgYellow.black,label:ye},ERROR:{icon:"❌",color:he.red,bgColor:he.bgRed.white,label:be},DEBUG:{icon:"🔍",color:he.blue,bgColor:he.bgBlue.white,label:ve}};var we=new class{levelConfig;constructor(){this.levelConfig=_e}formatMessage(e,t){const n=this.levelConfig[e],r=he.gray(`[${me().format("HH:mm:ss")}]`);let i="";if(n){i=`${n.icon} ${n.bgColor(` ${n.label} `)} ${n.color(t)} ${r}`}else i=`${e} ${t} ${r}`;return i}log(e,t,n=""){const r=this.formatMessage(e,t);n?(console.log(r),console.log(he.gray(` └─ ${n}`))):console.log(r)}separator(e="─",t=50){console.log(he.gray(e.repeat(t)))}info(e,t=""){this.log(ge,e,t)}success(e,t=""){this.log(De,e,t)}error(e,t=""){this.log(be,e,t)}warn(e,t=""){this.log(ye,e,t)}debug(e,t=""){this.log(ve,e,t)}};const Ce=".generate",Ee="generate.config.json",xe=[Ee,"config","template"];async function Fe(t,n){await e.promises.mkdir(n,{recursive:!0});const r=await e.promises.readdir(t);for(const i of r){const r=o.join(t,i),s=o.join(n,i);(await e.promises.stat(r)).isDirectory()?await Fe(r,s):(await e.promises.copyFile(r,s),we.info(`初始化文件 ${s}`))}}function ke(t){try{return e.accessSync(t),!0}catch{return!1}}async function Ae(t){try{return await e.promises.access(t),!0}catch{return!1}}var Se,Oe;!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}(Se||(Se={})),function(e){e.mergeShapes=(e,t)=>({...e,...t})}(Oe||(Oe={}));const Be=Se.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),Te=e=>{switch(typeof e){case"undefined":return Be.undefined;case"string":return Be.string;case"number":return Number.isNaN(e)?Be.nan:Be.number;case"boolean":return Be.boolean;case"function":return Be.function;case"bigint":return Be.bigint;case"symbol":return Be.symbol;case"object":return Array.isArray(e)?Be.array:null===e?Be.null:e.then&&"function"==typeof e.then&&e.catch&&"function"==typeof e.catch?Be.promise:"undefined"!=typeof Map&&e instanceof Map?Be.map:"undefined"!=typeof Set&&e instanceof Set?Be.set:"undefined"!=typeof Date&&e instanceof Date?Be.date:Be.object;default:return Be.unknown}},$e=Se.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 Pe 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 i of e.issues)if("invalid_union"===i.code)i.unionErrors.map(r);else if("invalid_return_type"===i.code)r(i.returnTypeError);else if("invalid_arguments"===i.code)r(i.argumentsError);else if(0===i.path.length)n._errors.push(t(i));else{let e=n,r=0;for(;r<i.path.length;){const n=i.path[r];r===i.path.length-1?(e[n]=e[n]||{_errors:[]},e[n]._errors.push(t(i))):e[n]=e[n]||{_errors:[]},e=e[n],r++}}};return r(this),n}static assert(e){if(!(e instanceof Pe))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,Se.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()}}Pe.create=e=>new Pe(e);const je=(e,t)=>{let n;switch(e.code){case $e.invalid_type:n=e.received===Be.undefined?"Required":`Expected ${e.expected}, received ${e.received}`;break;case $e.invalid_literal:n=`Invalid literal value, expected ${JSON.stringify(e.expected,Se.jsonStringifyReplacer)}`;break;case $e.unrecognized_keys:n=`Unrecognized key(s) in object: ${Se.joinValues(e.keys,", ")}`;break;case $e.invalid_union:n="Invalid input";break;case $e.invalid_union_discriminator:n=`Invalid discriminator value. Expected ${Se.joinValues(e.options)}`;break;case $e.invalid_enum_value:n=`Invalid enum value. Expected ${Se.joinValues(e.options)}, received '${e.received}'`;break;case $e.invalid_arguments:n="Invalid function arguments";break;case $e.invalid_return_type:n="Invalid function return type";break;case $e.invalid_date:n="Invalid date";break;case $e.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}"`:Se.assertNever(e.validation):n="regex"!==e.validation?`Invalid ${e.validation}`:"Invalid";break;case $e.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 $e.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 $e.custom:n="Invalid input";break;case $e.invalid_intersection_types:n="Intersection results could not be merged";break;case $e.not_multiple_of:n=`Number must be a multiple of ${e.multipleOf}`;break;case $e.not_finite:n="Number must be finite";break;default:n=t.defaultError,Se.assertNever(e)}return{message:n}};let Ie=je;function Re(e,t){const n=Ie,r=(e=>{const{data:t,path:n,errorMaps:r,issueData:i}=e,s=[...n,...i.path||[]],o={...i,path:s};if(void 0!==i.message)return{...i,path:s,message:i.message};let a="";const u=r.filter(e=>!!e).slice().reverse();for(const e of u)a=e(o,{data:t,defaultError:a}).message;return{...i,path:s,message:a}})({issueData:t,data:e.data,path:e.path,errorMaps:[e.common.contextualErrorMap,e.schemaErrorMap,n,n===je?void 0:je].filter(e=>!!e)});e.common.issues.push(r)}class Me{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 Le;"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 Me.mergeObjectSync(e,n)}static mergeObjectSync(e,t){const n={};for(const r of t){const{key:t,value:i}=r;if("aborted"===t.status)return Le;if("aborted"===i.status)return Le;"dirty"===t.status&&e.dirty(),"dirty"===i.status&&e.dirty(),"__proto__"===t.value||void 0===i.value&&!r.alwaysSet||(n[t.value]=i.value)}return{status:e.value,value:n}}}const Le=Object.freeze({status:"aborted"}),Ne=e=>({status:"dirty",value:e}),Ue=e=>({status:"valid",value:e}),Ve=e=>"aborted"===e.status,We=e=>"dirty"===e.status,Ze=e=>"valid"===e.status,He=e=>"undefined"!=typeof Promise&&e instanceof Promise;var ze;!function(e){e.errToObj=e=>"string"==typeof e?{message:e}:e||{},e.toString=e=>"string"==typeof e?e:e?.message}(ze||(ze={}));class qe{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 Ge=(e,t)=>{if(Ze(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 Pe(e.common.issues);return this._error=t,this._error}}};function Ye(e){if(!e)return{};const{errorMap:t,invalid_type_error:n,required_error:r,description:i}=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:i};return{errorMap:(t,i)=>{const{message:s}=e;return"invalid_enum_value"===t.code?{message:s??i.defaultError}:void 0===i.data?{message:s??r??i.defaultError}:"invalid_type"!==t.code?{message:i.defaultError}:{message:s??n??i.defaultError}},description:i}}class Ke{get description(){return this._def.description}_getType(e){return Te(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:Te(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new Me,ctx:{common:e.parent.common,data:e.data,parsedType:Te(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const t=this._parse(e);if(He(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:Te(e)},r=this._parseSync({data:e,path:n.path,parent:n});return Ge(n,r)}"~validate"(e){const t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:Te(e)};if(!this["~standard"].async)try{const n=this._parseSync({data:e,path:[],parent:t});return Ze(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=>Ze(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:Te(e)},r=this._parse({data:e,path:n.path,parent:n}),i=await(He(r)?r:Promise.resolve(r));return Ge(n,i)}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 i=e(t),s=()=>r.addIssue({code:$e.custom,...n(t)});return"undefined"!=typeof Promise&&i instanceof Promise?i.then(e=>!!e||(s(),!1)):!!i||(s(),!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 Gt({schema:this,typeName:rn.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 Yt.create(this,this._def)}nullable(){return Kt.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return $t.create(this)}promise(){return qt.create(this,this._def)}or(e){return It.create([this,e],this._def)}and(e){return Mt.create(this,e,this._def)}transform(e){return new Gt({...Ye(this._def),schema:this,typeName:rn.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const t="function"==typeof e?e:()=>e;return new Jt({...Ye(this._def),innerType:this,defaultValue:t,typeName:rn.ZodDefault})}brand(){return new en({typeName:rn.ZodBranded,type:this,...Ye(this._def)})}catch(e){const t="function"==typeof e?e:()=>e;return new Xt({...Ye(this._def),innerType:this,catchValue:t,typeName:rn.ZodCatch})}describe(e){return new(0,this.constructor)({...this._def,description:e})}pipe(e){return tn.create(this,e)}readonly(){return nn.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const Je=/^c[^\s-]{8,}$/i,Xe=/^[0-9a-z]+$/,Qe=/^[0-9A-HJKMNP-TV-Z]{26}$/i,et=/^[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,tt=/^[a-z0-9_-]{21}$/i,nt=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,rt=/^[-+]?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)?)??$/,it=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i;let st;const ot=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,at=/^(?:(?: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])$/,ut=/^(([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]))$/,ct=/^(([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])$/,lt=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ht=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dt="((\\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])))",pt=new RegExp(`^${dt}$`);function ft(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 mt(e){return new RegExp(`^${ft(e)}$`)}function gt(e){let t=`${dt}T${ft(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 Dt(e,t){return!("v4"!==t&&t||!ot.test(e))||!("v6"!==t&&t||!ut.test(e))}function yt(e,t){if(!nt.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,"="),i=JSON.parse(atob(r));return"object"==typeof i&&null!==i&&((!("typ"in i)||"JWT"===i?.typ)&&(!!i.alg&&(!t||i.alg===t)))}catch{return!1}}function bt(e,t){return!("v4"!==t&&t||!at.test(e))||!("v6"!==t&&t||!ct.test(e))}class vt extends Ke{_parse(e){this._def.coerce&&(e.data=String(e.data));if(this._getType(e)!==Be.string){const t=this._getOrReturnCtx(e);return Re(t,{code:$e.invalid_type,expected:Be.string,received:t.parsedType}),Le}const t=new Me;let n;for(const r of this._def.checks)if("min"===r.kind)e.data.length<r.value&&(n=this._getOrReturnCtx(e,n),Re(n,{code:$e.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),Re(n,{code:$e.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!1,message:r.message}),t.dirty());else if("length"===r.kind){const i=e.data.length>r.value,s=e.data.length<r.value;(i||s)&&(n=this._getOrReturnCtx(e,n),i?Re(n,{code:$e.too_big,maximum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}):s&&Re(n,{code:$e.too_small,minimum:r.value,type:"string",inclusive:!0,exact:!0,message:r.message}),t.dirty())}else if("email"===r.kind)it.test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"email",code:$e.invalid_string,message:r.message}),t.dirty());else if("emoji"===r.kind)st||(st=new RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u")),st.test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"emoji",code:$e.invalid_string,message:r.message}),t.dirty());else if("uuid"===r.kind)et.test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"uuid",code:$e.invalid_string,message:r.message}),t.dirty());else if("nanoid"===r.kind)tt.test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"nanoid",code:$e.invalid_string,message:r.message}),t.dirty());else if("cuid"===r.kind)Je.test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"cuid",code:$e.invalid_string,message:r.message}),t.dirty());else if("cuid2"===r.kind)Xe.test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"cuid2",code:$e.invalid_string,message:r.message}),t.dirty());else if("ulid"===r.kind)Qe.test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"ulid",code:$e.invalid_string,message:r.message}),t.dirty());else if("url"===r.kind)try{new URL(e.data)}catch{n=this._getOrReturnCtx(e,n),Re(n,{validation:"url",code:$e.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),Re(n,{validation:"regex",code:$e.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),Re(n,{code:$e.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),Re(n,{code:$e.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),Re(n,{code:$e.invalid_string,validation:{endsWith:r.value},message:r.message}),t.dirty());else if("datetime"===r.kind){gt(r).test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{code:$e.invalid_string,validation:"datetime",message:r.message}),t.dirty())}else if("date"===r.kind){pt.test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{code:$e.invalid_string,validation:"date",message:r.message}),t.dirty())}else if("time"===r.kind){mt(r).test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{code:$e.invalid_string,validation:"time",message:r.message}),t.dirty())}else"duration"===r.kind?rt.test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"duration",code:$e.invalid_string,message:r.message}),t.dirty()):"ip"===r.kind?Dt(e.data,r.version)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"ip",code:$e.invalid_string,message:r.message}),t.dirty()):"jwt"===r.kind?yt(e.data,r.alg)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"jwt",code:$e.invalid_string,message:r.message}),t.dirty()):"cidr"===r.kind?bt(e.data,r.version)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"cidr",code:$e.invalid_string,message:r.message}),t.dirty()):"base64"===r.kind?lt.test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"base64",code:$e.invalid_string,message:r.message}),t.dirty()):"base64url"===r.kind?ht.test(e.data)||(n=this._getOrReturnCtx(e,n),Re(n,{validation:"base64url",code:$e.invalid_string,message:r.message}),t.dirty()):Se.assertNever(r);return{status:t.value,value:e.data}}_regex(e,t,n){return this.refinement(t=>e.test(t),{validation:t,code:$e.invalid_string,...ze.errToObj(n)})}_addCheck(e){return new vt({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...ze.errToObj(e)})}url(e){return this._addCheck({kind:"url",...ze.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...ze.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...ze.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...ze.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...ze.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...ze.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...ze.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...ze.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...ze.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...ze.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...ze.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...ze.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,...ze.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,...ze.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...ze.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...ze.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...ze.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...ze.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...ze.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...ze.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...ze.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...ze.errToObj(t)})}nonempty(e){return this.min(1,ze.errToObj(e))}trim(){return new vt({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new vt({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new vt({...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 _t(e,t){const n=(e.toString().split(".")[1]||"").length,r=(t.toString().split(".")[1]||"").length,i=n>r?n:r;return Number.parseInt(e.toFixed(i).replace(".",""))%Number.parseInt(t.toFixed(i).replace(".",""))/10**i}vt.create=e=>new vt({checks:[],typeName:rn.ZodString,coerce:e?.coerce??!1,...Ye(e)});class wt extends Ke{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)!==Be.number){const t=this._getOrReturnCtx(e);return Re(t,{code:$e.invalid_type,expected:Be.number,received:t.parsedType}),Le}let t;const n=new Me;for(const r of this._def.checks)if("int"===r.kind)Se.isInteger(e.data)||(t=this._getOrReturnCtx(e,t),Re(t,{code:$e.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),Re(t,{code:$e.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),Re(t,{code:$e.too_big,maximum:r.value,type:"number",inclusive:r.inclusive,exact:!1,message:r.message}),n.dirty())}else"multipleOf"===r.kind?0!==_t(e.data,r.value)&&(t=this._getOrReturnCtx(e,t),Re(t,{code:$e.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):"finite"===r.kind?Number.isFinite(e.data)||(t=this._getOrReturnCtx(e,t),Re(t,{code:$e.not_finite,message:r.message}),n.dirty()):Se.assertNever(r);return{status:n.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,ze.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ze.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ze.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ze.toString(t))}setLimit(e,t,n,r){return new wt({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ze.toString(r)}]})}_addCheck(e){return new wt({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:ze.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:ze.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:ze.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:ze.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:ze.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ze.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:ze.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:ze.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:ze.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&&Se.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)}}wt.create=e=>new wt({checks:[],typeName:rn.ZodNumber,coerce:e?.coerce||!1,...Ye(e)});class Ct extends Ke{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)!==Be.bigint)return this._getInvalidInput(e);let t;const n=new Me;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),Re(t,{code:$e.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),Re(t,{code:$e.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),Re(t,{code:$e.not_multiple_of,multipleOf:r.value,message:r.message}),n.dirty()):Se.assertNever(r);return{status:n.value,value:e.data}}_getInvalidInput(e){const t=this._getOrReturnCtx(e);return Re(t,{code:$e.invalid_type,expected:Be.bigint,received:t.parsedType}),Le}gte(e,t){return this.setLimit("min",e,!0,ze.toString(t))}gt(e,t){return this.setLimit("min",e,!1,ze.toString(t))}lte(e,t){return this.setLimit("max",e,!0,ze.toString(t))}lt(e,t){return this.setLimit("max",e,!1,ze.toString(t))}setLimit(e,t,n,r){return new Ct({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:ze.toString(r)}]})}_addCheck(e){return new Ct({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:ze.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:ze.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:ze.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:ze.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:ze.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}}Ct.create=e=>new Ct({checks:[],typeName:rn.ZodBigInt,coerce:e?.coerce??!1,...Ye(e)});class Et extends Ke{_parse(e){this._def.coerce&&(e.data=Boolean(e.data));if(this._getType(e)!==Be.boolean){const t=this._getOrReturnCtx(e);return Re(t,{code:$e.invalid_type,expected:Be.boolean,received:t.parsedType}),Le}return Ue(e.data)}}Et.create=e=>new Et({typeName:rn.ZodBoolean,coerce:e?.coerce||!1,...Ye(e)});class xt extends Ke{_parse(e){this._def.coerce&&(e.data=new Date(e.data));if(this._getType(e)!==Be.date){const t=this._getOrReturnCtx(e);return Re(t,{code:$e.invalid_type,expected:Be.date,received:t.parsedType}),Le}if(Number.isNaN(e.data.getTime())){return Re(this._getOrReturnCtx(e),{code:$e.invalid_date}),Le}const t=new Me;let n;for(const r of this._def.checks)"min"===r.kind?e.data.getTime()<r.value&&(n=this._getOrReturnCtx(e,n),Re(n,{code:$e.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),Re(n,{code:$e.too_big,message:r.message,inclusive:!0,exact:!1,maximum:r.value,type:"date"}),t.dirty()):Se.assertNever(r);return{status:t.value,value:new Date(e.data.getTime())}}_addCheck(e){return new xt({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:ze.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:ze.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}}xt.create=e=>new xt({checks:[],coerce:e?.coerce||!1,typeName:rn.ZodDate,...Ye(e)});class Ft extends Ke{_parse(e){if(this._getType(e)!==Be.symbol){const t=this._getOrReturnCtx(e);return Re(t,{code:$e.invalid_type,expected:Be.symbol,received:t.parsedType}),Le}return Ue(e.data)}}Ft.create=e=>new Ft({typeName:rn.ZodSymbol,...Ye(e)});class kt extends Ke{_parse(e){if(this._getType(e)!==Be.undefined){const t=this._getOrReturnCtx(e);return Re(t,{code:$e.invalid_type,expected:Be.undefined,received:t.parsedType}),Le}return Ue(e.data)}}kt.create=e=>new kt({typeName:rn.ZodUndefined,...Ye(e)});class At extends Ke{_parse(e){if(this._getType(e)!==Be.null){const t=this._getOrReturnCtx(e);return Re(t,{code:$e.invalid_type,expected:Be.null,received:t.parsedType}),Le}return Ue(e.data)}}At.create=e=>new At({typeName:rn.ZodNull,...Ye(e)});class St extends Ke{constructor(){super(...arguments),this._any=!0}_parse(e){return Ue(e.data)}}St.create=e=>new St({typeName:rn.ZodAny,...Ye(e)});class Ot extends Ke{constructor(){super(...arguments),this._unknown=!0}_parse(e){return Ue(e.data)}}Ot.create=e=>new Ot({typeName:rn.ZodUnknown,...Ye(e)});class Bt extends Ke{_parse(e){const t=this._getOrReturnCtx(e);return Re(t,{code:$e.invalid_type,expected:Be.never,received:t.parsedType}),Le}}Bt.create=e=>new Bt({typeName:rn.ZodNever,...Ye(e)});class Tt extends Ke{_parse(e){if(this._getType(e)!==Be.undefined){const t=this._getOrReturnCtx(e);return Re(t,{code:$e.invalid_type,expected:Be.void,received:t.parsedType}),Le}return Ue(e.data)}}Tt.create=e=>new Tt({typeName:rn.ZodVoid,...Ye(e)});class $t extends Ke{_parse(e){const{ctx:t,status:n}=this._processInputParams(e),r=this._def;if(t.parsedType!==Be.array)return Re(t,{code:$e.invalid_type,expected:Be.array,received:t.parsedType}),Le;if(null!==r.exactLength){const e=t.data.length>r.exactLength.value,i=t.data.length<r.exactLength.value;(e||i)&&(Re(t,{code:e?$e.too_big:$e.too_small,minimum:i?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&&(Re(t,{code:$e.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&&(Re(t,{code:$e.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 qe(t,e,t.path,n)))).then(e=>Me.mergeArray(n,e));const i=[...t.data].map((e,n)=>r.type._parseSync