@f2c/mcp 0.2.5 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +13 -20
- package/dist/cli.js.map +18 -10
- package/dist/stdio.js +13 -20
- package/dist/stdio.js.map +18 -10
- package/dist/streamable-http.js +70 -77
- package/dist/streamable-http.js.map +18 -10
- package/package.json +23 -16
- package/dist/cli.d.mts +0 -1
- package/dist/cli.d.ts +0 -1
- package/dist/cli.mjs +0 -8
- package/dist/stdio.d.mts +0 -2
- package/dist/stdio.d.ts +0 -2
- package/dist/stdio.mjs +0 -7
- package/dist/streamableHttp.d.mts +0 -2
- package/dist/streamableHttp.d.ts +0 -2
- package/dist/streamableHttp.js +0 -83
- package/dist/streamableHttp.mjs +0 -83
package/dist/stdio.js
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
var E2=Object.create;var{getPrototypeOf:b2,defineProperty:L1,getOwnPropertyNames:v2}=Object;var k2=Object.prototype.hasOwnProperty;var c0=($,X,W)=>{W=$!=null?E2(b2($)):{};let Q=X||!$||!$.__esModule?L1(W,"default",{value:$,enumerable:!0}):W;for(let H of v2($))if(!k2.call(Q,H))L1(Q,H,{get:()=>$[H],enumerable:!0});return Q};var l6=($,X)=>()=>(X||$((X={exports:{}}).exports,X),X.exports);var n6=($,X)=>{for(var W in X)L1($,W,{get:X[W],enumerable:!0,configurable:!0,set:(Q)=>X[W]=()=>Q})};var F1=($,X)=>()=>($&&(X=$($=0)),X);function I2($){s1=$}function u0(){return s1}function A($,X){let W=u0(),Q=p0({issueData:X,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,W,W===V0?void 0:V0].filter((H)=>!!H)});$.common.issues.push(Q)}class E{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,X){let W=[];for(let Q of X){if(Q.status==="aborted")return U;if(Q.status==="dirty")$.dirty();W.push(Q.value)}return{status:$.value,value:W}}static async mergeObjectAsync($,X){let W=[];for(let Q of X){let H=await Q.key,Y=await Q.value;W.push({key:H,value:Y})}return E.mergeObjectSync($,W)}static mergeObjectSync($,X){let W={};for(let Q of X){let{key:H,value:Y}=Q;if(H.status==="aborted")return U;if(Y.status==="aborted")return U;if(H.status==="dirty")$.dirty();if(Y.status==="dirty")$.dirty();if(H.value!=="__proto__"&&(typeof Y.value!=="undefined"||Q.alwaysSet))W[H.value]=Y.value}return{status:$.value,value:W}}}function i0($,X,W,Q){if(W==="a"&&!Q)throw new TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!Q:!X.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return W==="m"?Q:W==="a"?Q.call($):Q?Q.value:X.get($)}function e1($,X,W,Q,H){if(Q==="m")throw new TypeError("Private method is not writable");if(Q==="a"&&!H)throw new TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!H:!X.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Q==="a"?H.call($,W):H?H.value=W:X.set($,W),W}class y{constructor($,X,W,Q){this._cachedPath=[],this.parent=$,this.data=X,this._path=W,this._key=Q}get path(){if(!this._cachedPath.length)if(this._key instanceof Array)this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}function N($){if(!$)return{};let{errorMap:X,invalid_type_error:W,required_error:Q,description:H}=$;if(X&&(W||Q))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(X)return{errorMap:X,description:H};return{errorMap:(G,B)=>{var w,M;let{message:q}=$;if(G.code==="invalid_enum_value")return{message:q!==null&&q!==void 0?q:B.defaultError};if(typeof B.data==="undefined")return{message:(w=q!==null&&q!==void 0?q:Q)!==null&&w!==void 0?w:B.defaultError};if(G.code!=="invalid_type")return{message:B.defaultError};return{message:(M=q!==null&&q!==void 0?q:W)!==null&&M!==void 0?M:B.defaultError}},description:H}}class K{get description(){return this._def.description}_getType($){return t($.data)}_getOrReturnCtx($,X){return X||{common:$.parent.common,data:$.data,parsedType:t($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new E,ctx:{common:$.parent.common,data:$.data,parsedType:t($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let X=this._parse($);if(k0(X))throw new Error("Synchronous parse encountered promise.");return X}_parseAsync($){let X=this._parse($);return Promise.resolve(X)}parse($,X){let W=this.safeParse($,X);if(W.success)return W.data;throw W.error}safeParse($,X){var W;let Q={common:{issues:[],async:(W=X===null||X===void 0?void 0:X.async)!==null&&W!==void 0?W:!1,contextualErrorMap:X===null||X===void 0?void 0:X.errorMap},path:(X===null||X===void 0?void 0:X.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:t($)},H=this._parseSync({data:$,path:Q.path,parent:Q});return r1(Q,H)}"~validate"($){var X,W;let Q={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:t($)};if(!this["~standard"].async)try{let H=this._parseSync({data:$,path:[],parent:Q});return J0(H)?{value:H.value}:{issues:Q.common.issues}}catch(H){if((W=(X=H===null||H===void 0?void 0:H.message)===null||X===void 0?void 0:X.toLowerCase())===null||W===void 0?void 0:W.includes("encountered"))this["~standard"].async=!0;Q.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:Q}).then((H)=>J0(H)?{value:H.value}:{issues:Q.common.issues})}async parseAsync($,X){let W=await this.safeParseAsync($,X);if(W.success)return W.data;throw W.error}async safeParseAsync($,X){let W={common:{issues:[],contextualErrorMap:X===null||X===void 0?void 0:X.errorMap,async:!0},path:(X===null||X===void 0?void 0:X.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:t($)},Q=this._parse({data:$,path:W.path,parent:W}),H=await(k0(Q)?Q:Promise.resolve(Q));return r1(W,H)}refine($,X){let W=(Q)=>{if(typeof X==="string"||typeof X==="undefined")return{message:X};else if(typeof X==="function")return X(Q);else return X};return this._refinement((Q,H)=>{let Y=$(Q),G=()=>H.addIssue({code:D.custom,...W(Q)});if(typeof Promise!=="undefined"&&Y instanceof Promise)return Y.then((B)=>{if(!B)return G(),!1;else return!0});if(!Y)return G(),!1;else return!0})}refinement($,X){return this._refinement((W,Q)=>{if(!$(W))return Q.addIssue(typeof X==="function"?X(W,Q):X),!1;else return!0})}_refinement($){return new T({schema:this,typeName:z.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,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:(X)=>this["~validate"](X)}}optional(){return I.create(this,this._def)}nullable(){return s.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return h.create(this)}promise(){return w0.create(this,this._def)}or($){return U0.create([this,$],this._def)}and($){return K0.create(this,$,this._def)}transform($){return new T({...N(this._def),schema:this,typeName:z.ZodEffects,effect:{type:"transform",transform:$}})}default($){let X=typeof $==="function"?$:()=>$;return new S0({...N(this._def),innerType:this,defaultValue:X,typeName:z.ZodDefault})}brand(){return new o0({typeName:z.ZodBranded,type:this,...N(this._def)})}catch($){let X=typeof $==="function"?$:()=>$;return new _0({...N(this._def),innerType:this,catchValue:X,typeName:z.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return g0.create(this,$)}readonly(){return R0.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function X$($){let X="([01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d";if($.precision)X=`${X}\\.\\d{${$.precision}}`;else if($.precision==null)X=`${X}(\\.\\d+)?`;return X}function r2($){return new RegExp(`^${X$($)}$`)}function W$($){let X=`${$$}T${X$($)}`,W=[];if(W.push($.local?"Z?":"Z"),$.offset)W.push("([+-]\\d{2}:?\\d{2})");return X=`${X}(${W.join("|")})`,new RegExp(`^${X}$`)}function a2($,X){if((X==="v4"||!X)&&n2.test($))return!0;if((X==="v6"||!X)&&u2.test($))return!0;return!1}function t2($,X){if(!y2.test($))return!1;try{let[W]=$.split("."),Q=W.replace(/-/g,"+").replace(/_/g,"/").padEnd(W.length+(4-W.length%4)%4,"="),H=JSON.parse(atob(Q));if(typeof H!=="object"||H===null)return!1;if(!H.typ||!H.alg)return!1;if(X&&H.alg!==X)return!1;return!0}catch(W){return!1}}function s2($,X){if((X==="v4"||!X)&&c2.test($))return!0;if((X==="v6"||!X)&&p2.test($))return!0;return!1}function e2($,X){let W=($.toString().split(".")[1]||"").length,Q=(X.toString().split(".")[1]||"").length,H=W>Q?W:Q,Y=parseInt($.toFixed(H).replace(".","")),G=parseInt(X.toFixed(H).replace(".",""));return Y%G/Math.pow(10,H)}function z0($){if($ instanceof S){let X={};for(let W in $.shape){let Q=$.shape[W];X[W]=I.create(z0(Q))}return new S({...$._def,shape:()=>X})}else if($ instanceof h)return new h({...$._def,type:z0($.element)});else if($ instanceof I)return I.create(z0($.unwrap()));else if($ instanceof s)return s.create(z0($.unwrap()));else if($ instanceof i)return i.create($.items.map((X)=>z0(X)));else return $}function b1($,X){let W=t($),Q=t(X);if($===X)return{valid:!0,data:$};else if(W===V.object&&Q===V.object){let H=F.objectKeys(X),Y=F.objectKeys($).filter((B)=>H.indexOf(B)!==-1),G={...$,...X};for(let B of Y){let w=b1($[B],X[B]);if(!w.valid)return{valid:!1};G[B]=w.data}return{valid:!0,data:G}}else if(W===V.array&&Q===V.array){if($.length!==X.length)return{valid:!1};let H=[];for(let Y=0;Y<$.length;Y++){let G=$[Y],B=X[Y],w=b1(G,B);if(!w.valid)return{valid:!1};H.push(w.data)}return{valid:!0,data:H}}else if(W===V.date&&Q===V.date&&+$===+X)return{valid:!0,data:$};else return{valid:!1}}function Q$($,X){return new W0({values:$,typeName:z.ZodEnum,...N(X)})}function a1($,X){let W=typeof $==="function"?$(X):typeof $==="string"?{message:$}:$;return typeof W==="string"?{message:W}:W}function H$($,X={},W){if($)return G0.create().superRefine((Q,H)=>{var Y,G;let B=$(Q);if(B instanceof Promise)return B.then((w)=>{var M,q;if(!w){let b=a1(X,Q),r=(q=(M=b.fatal)!==null&&M!==void 0?M:W)!==null&&q!==void 0?q:!0;H.addIssue({code:"custom",...b,fatal:r})}});if(!B){let w=a1(X,Q),M=(G=(Y=w.fatal)!==null&&Y!==void 0?Y:W)!==null&&G!==void 0?G:!0;H.addIssue({code:"custom",...w,fatal:M})}return});return G0.create()}var F,_1,V,t=($)=>{switch(typeof $){case"undefined":return V.undefined;case"string":return V.string;case"number":return isNaN($)?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":if(Array.isArray($))return V.array;if($===null)return V.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return V.promise;if(typeof Map!=="undefined"&&$ instanceof Map)return V.map;if(typeof Set!=="undefined"&&$ instanceof Set)return V.set;if(typeof Date!=="undefined"&&$ instanceof Date)return V.date;return V.object;default:return V.unknown}},D,C2=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")},C,V0=($,X)=>{let W;switch($.code){case D.invalid_type:if($.received===V.undefined)W="Required";else W=`Expected ${$.expected}, received ${$.received}`;break;case D.invalid_literal:W=`Invalid literal value, expected ${JSON.stringify($.expected,F.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:W=`Unrecognized key(s) in object: ${F.joinValues($.keys,", ")}`;break;case D.invalid_union:W="Invalid input";break;case D.invalid_union_discriminator:W=`Invalid discriminator value. Expected ${F.joinValues($.options)}`;break;case D.invalid_enum_value:W=`Invalid enum value. Expected ${F.joinValues($.options)}, received '${$.received}'`;break;case D.invalid_arguments:W="Invalid function arguments";break;case D.invalid_return_type:W="Invalid function return type";break;case D.invalid_date:W="Invalid date";break;case D.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(W=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")W=`${W} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)W=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)W=`Invalid input: must end with "${$.validation.endsWith}"`;else F.assertNever($.validation);else if($.validation!=="regex")W=`Invalid ${$.validation}`;else W="Invalid";break;case D.too_small:if($.type==="array")W=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")W=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")W=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")W=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else W="Invalid input";break;case D.too_big:if($.type==="array")W=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")W=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")W=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")W=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")W=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else W="Invalid input";break;case D.custom:W="Invalid input";break;case D.invalid_intersection_types:W="Intersection results could not be merged";break;case D.not_multiple_of:W=`Number must be a multiple of ${$.multipleOf}`;break;case D.not_finite:W="Number must be finite";break;default:W=X.defaultError,F.assertNever($)}return{message:W}},s1,p0=($)=>{let{data:X,path:W,errorMaps:Q,issueData:H}=$,Y=[...W,...H.path||[]],G={...H,path:Y};if(H.message!==void 0)return{...H,path:Y,message:H.message};let B="",w=Q.filter((M)=>!!M).slice().reverse();for(let M of w)B=M(G,{data:X,defaultError:B}).message;return{...H,path:Y,message:B}},P2,U,M0=($)=>({status:"dirty",value:$}),v=($)=>({status:"valid",value:$}),R1=($)=>$.status==="aborted",E1=($)=>$.status==="dirty",J0=($)=>$.status==="valid",k0=($)=>typeof Promise!=="undefined"&&$ instanceof Promise,j,b0,v0,r1=($,X)=>{if(J0(X))return{success:!0,data:X.value};else{if(!$.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let W=new C($.common.issues);return this._error=W,this._error}}}},f2,T2,g2,x2,h2,y2,Z2,m2,l2="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",S1,n2,c2,u2,p2,i2,d2,$$="((\\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])))",o2,x,$0,X0,j0,Y0,C0,q0,O0,G0,e,p,I0,h,S,U0,a=($)=>{if($ instanceof N0)return a($.schema);else if($ instanceof T)return a($.innerType());else if($ instanceof L0)return[$.value];else if($ instanceof W0)return $.options;else if($ instanceof F0)return F.objectValues($.enum);else if($ instanceof S0)return a($._def.innerType);else if($ instanceof q0)return[void 0];else if($ instanceof O0)return[null];else if($ instanceof I)return[void 0,...a($.unwrap())];else if($ instanceof s)return[null,...a($.unwrap())];else if($ instanceof o0)return a($.unwrap());else if($ instanceof R0)return a($.unwrap());else if($ instanceof _0)return a($._def.innerType);else return[]},d0,K0,i,P0,f0,B0,A0,N0,L0,W0,F0,w0,T,I,s,S0,_0,T0,$4,o0,g0,R0,X4,z,W4=($,X={message:`Input not instance of ${$.name}`})=>H$((W)=>W instanceof $,X),J$,Y$,Q4,H4,G$,J4,Y4,G4,B4,w4,D4,z4,M4,A4,V4,j4,q4,O4,U4,K4,N4,L4,F4,S4,_4,R4,E4,b4,v4,t1,k4,C4,I4,P4,f4=()=>J$().optional(),T4=()=>Y$().optional(),g4=()=>G$().optional(),x4,h4,J;var d=F1(()=>{(function($){$.assertEqual=(H)=>H;function X(H){}$.assertIs=X;function W(H){throw new Error}$.assertNever=W,$.arrayToEnum=(H)=>{let Y={};for(let G of H)Y[G]=G;return Y},$.getValidEnumValues=(H)=>{let Y=$.objectKeys(H).filter((B)=>typeof H[H[B]]!=="number"),G={};for(let B of Y)G[B]=H[B];return $.objectValues(G)},$.objectValues=(H)=>{return $.objectKeys(H).map(function(Y){return H[Y]})},$.objectKeys=typeof Object.keys==="function"?(H)=>Object.keys(H):(H)=>{let Y=[];for(let G in H)if(Object.prototype.hasOwnProperty.call(H,G))Y.push(G);return Y},$.find=(H,Y)=>{for(let G of H)if(Y(G))return G;return},$.isInteger=typeof Number.isInteger==="function"?(H)=>Number.isInteger(H):(H)=>typeof H==="number"&&isFinite(H)&&Math.floor(H)===H;function Q(H,Y=" | "){return H.map((G)=>typeof G==="string"?`'${G}'`:G).join(Y)}$.joinValues=Q,$.jsonStringifyReplacer=(H,Y)=>{if(typeof Y==="bigint")return Y.toString();return Y}})(F||(F={}));(function($){$.mergeShapes=(X,W)=>{return{...X,...W}}})(_1||(_1={}));V=F.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D=F.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"]);C=class C extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(W)=>{this.issues=[...this.issues,W]},this.addIssues=(W=[])=>{this.issues=[...this.issues,...W]};let X=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,X);else this.__proto__=X;this.name="ZodError",this.issues=$}format($){let X=$||function(H){return H.message},W={_errors:[]},Q=(H)=>{for(let Y of H.issues)if(Y.code==="invalid_union")Y.unionErrors.map(Q);else if(Y.code==="invalid_return_type")Q(Y.returnTypeError);else if(Y.code==="invalid_arguments")Q(Y.argumentsError);else if(Y.path.length===0)W._errors.push(X(Y));else{let G=W,B=0;while(B<Y.path.length){let w=Y.path[B];if(B!==Y.path.length-1)G[w]=G[w]||{_errors:[]};else G[w]=G[w]||{_errors:[]},G[w]._errors.push(X(Y));G=G[w],B++}}};return Q(this),W}static assert($){if(!($ instanceof C))throw new Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,F.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(X)=>X.message){let X={},W=[];for(let Q of this.issues)if(Q.path.length>0)X[Q.path[0]]=X[Q.path[0]]||[],X[Q.path[0]].push($(Q));else W.push($(Q));return{formErrors:W,fieldErrors:X}}get formErrors(){return this.flatten()}};C.create=($)=>{return new C($)};s1=V0;P2=[];U=Object.freeze({status:"aborted"});(function($){$.errToObj=(X)=>typeof X==="string"?{message:X}:X||{},$.toString=(X)=>typeof X==="string"?X:X===null||X===void 0?void 0:X.message})(j||(j={}));f2=/^c[^\s-]{8,}$/i,T2=/^[0-9a-z]+$/,g2=/^[0-9A-HJKMNP-TV-Z]{26}$/i,x2=/^[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,h2=/^[a-z0-9_-]{21}$/i,y2=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,Z2=/^[-+]?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)?)??$/,m2=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,n2=/^(?:(?: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])$/,c2=/^(?:(?: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])$/,u2=/^(([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]))$/,p2=/^(([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])$/,i2=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,d2=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,o2=new RegExp(`^${$$}$`);x=class x extends K{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==V.string){let H=this._getOrReturnCtx($);return A(H,{code:D.invalid_type,expected:V.string,received:H.parsedType}),U}let W=new E,Q=void 0;for(let H of this._def.checks)if(H.kind==="min"){if($.data.length<H.value)Q=this._getOrReturnCtx($,Q),A(Q,{code:D.too_small,minimum:H.value,type:"string",inclusive:!0,exact:!1,message:H.message}),W.dirty()}else if(H.kind==="max"){if($.data.length>H.value)Q=this._getOrReturnCtx($,Q),A(Q,{code:D.too_big,maximum:H.value,type:"string",inclusive:!0,exact:!1,message:H.message}),W.dirty()}else if(H.kind==="length"){let Y=$.data.length>H.value,G=$.data.length<H.value;if(Y||G){if(Q=this._getOrReturnCtx($,Q),Y)A(Q,{code:D.too_big,maximum:H.value,type:"string",inclusive:!0,exact:!0,message:H.message});else if(G)A(Q,{code:D.too_small,minimum:H.value,type:"string",inclusive:!0,exact:!0,message:H.message});W.dirty()}}else if(H.kind==="email"){if(!m2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"email",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="emoji"){if(!S1)S1=new RegExp(l2,"u");if(!S1.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"emoji",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="uuid"){if(!x2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"uuid",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="nanoid"){if(!h2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"nanoid",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="cuid"){if(!f2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"cuid",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="cuid2"){if(!T2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"cuid2",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="ulid"){if(!g2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"ulid",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="url")try{new URL($.data)}catch(Y){Q=this._getOrReturnCtx($,Q),A(Q,{validation:"url",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="regex"){if(H.regex.lastIndex=0,!H.regex.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"regex",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="trim")$.data=$.data.trim();else if(H.kind==="includes"){if(!$.data.includes(H.value,H.position))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:{includes:H.value,position:H.position},message:H.message}),W.dirty()}else if(H.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(H.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(H.kind==="startsWith"){if(!$.data.startsWith(H.value))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:{startsWith:H.value},message:H.message}),W.dirty()}else if(H.kind==="endsWith"){if(!$.data.endsWith(H.value))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:{endsWith:H.value},message:H.message}),W.dirty()}else if(H.kind==="datetime"){if(!W$(H).test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:"datetime",message:H.message}),W.dirty()}else if(H.kind==="date"){if(!o2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:"date",message:H.message}),W.dirty()}else if(H.kind==="time"){if(!r2(H).test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{code:D.invalid_string,validation:"time",message:H.message}),W.dirty()}else if(H.kind==="duration"){if(!Z2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"duration",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="ip"){if(!a2($.data,H.version))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"ip",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="jwt"){if(!t2($.data,H.alg))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"jwt",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="cidr"){if(!s2($.data,H.version))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"cidr",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="base64"){if(!i2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"base64",code:D.invalid_string,message:H.message}),W.dirty()}else if(H.kind==="base64url"){if(!d2.test($.data))Q=this._getOrReturnCtx($,Q),A(Q,{validation:"base64url",code:D.invalid_string,message:H.message}),W.dirty()}else F.assertNever(H);return{status:W.value,value:$.data}}_regex($,X,W){return this.refinement((Q)=>$.test(Q),{validation:X,code:D.invalid_string,...j.errToObj(W)})}_addCheck($){return new x({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...j.errToObj($)})}url($){return this._addCheck({kind:"url",...j.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...j.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...j.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...j.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...j.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...j.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...j.errToObj($)})}base64($){return this._addCheck({kind:"base64",...j.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...j.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...j.errToObj($)})}ip($){return this._addCheck({kind:"ip",...j.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...j.errToObj($)})}datetime($){var X,W;if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof($===null||$===void 0?void 0:$.precision)==="undefined"?null:$===null||$===void 0?void 0:$.precision,offset:(X=$===null||$===void 0?void 0:$.offset)!==null&&X!==void 0?X:!1,local:(W=$===null||$===void 0?void 0:$.local)!==null&&W!==void 0?W:!1,...j.errToObj($===null||$===void 0?void 0:$.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof($===null||$===void 0?void 0:$.precision)==="undefined"?null:$===null||$===void 0?void 0:$.precision,...j.errToObj($===null||$===void 0?void 0:$.message)})}duration($){return this._addCheck({kind:"duration",...j.errToObj($)})}regex($,X){return this._addCheck({kind:"regex",regex:$,...j.errToObj(X)})}includes($,X){return this._addCheck({kind:"includes",value:$,position:X===null||X===void 0?void 0:X.position,...j.errToObj(X===null||X===void 0?void 0:X.message)})}startsWith($,X){return this._addCheck({kind:"startsWith",value:$,...j.errToObj(X)})}endsWith($,X){return this._addCheck({kind:"endsWith",value:$,...j.errToObj(X)})}min($,X){return this._addCheck({kind:"min",value:$,...j.errToObj(X)})}max($,X){return this._addCheck({kind:"max",value:$,...j.errToObj(X)})}length($,X){return this._addCheck({kind:"length",value:$,...j.errToObj(X)})}nonempty($){return this.min(1,j.errToObj($))}trim(){return new x({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new x({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new x({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxLength(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}};x.create=($)=>{var X;return new x({checks:[],typeName:z.ZodString,coerce:(X=$===null||$===void 0?void 0:$.coerce)!==null&&X!==void 0?X:!1,...N($)})};$0=class $0 extends K{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==V.number){let H=this._getOrReturnCtx($);return A(H,{code:D.invalid_type,expected:V.number,received:H.parsedType}),U}let W=void 0,Q=new E;for(let H of this._def.checks)if(H.kind==="int"){if(!F.isInteger($.data))W=this._getOrReturnCtx($,W),A(W,{code:D.invalid_type,expected:"integer",received:"float",message:H.message}),Q.dirty()}else if(H.kind==="min"){if(H.inclusive?$.data<H.value:$.data<=H.value)W=this._getOrReturnCtx($,W),A(W,{code:D.too_small,minimum:H.value,type:"number",inclusive:H.inclusive,exact:!1,message:H.message}),Q.dirty()}else if(H.kind==="max"){if(H.inclusive?$.data>H.value:$.data>=H.value)W=this._getOrReturnCtx($,W),A(W,{code:D.too_big,maximum:H.value,type:"number",inclusive:H.inclusive,exact:!1,message:H.message}),Q.dirty()}else if(H.kind==="multipleOf"){if(e2($.data,H.value)!==0)W=this._getOrReturnCtx($,W),A(W,{code:D.not_multiple_of,multipleOf:H.value,message:H.message}),Q.dirty()}else if(H.kind==="finite"){if(!Number.isFinite($.data))W=this._getOrReturnCtx($,W),A(W,{code:D.not_finite,message:H.message}),Q.dirty()}else F.assertNever(H);return{status:Q.value,value:$.data}}gte($,X){return this.setLimit("min",$,!0,j.toString(X))}gt($,X){return this.setLimit("min",$,!1,j.toString(X))}lte($,X){return this.setLimit("max",$,!0,j.toString(X))}lt($,X){return this.setLimit("max",$,!1,j.toString(X))}setLimit($,X,W,Q){return new $0({...this._def,checks:[...this._def.checks,{kind:$,value:X,inclusive:W,message:j.toString(Q)}]})}_addCheck($){return new $0({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:j.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:j.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:j.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:j.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:j.toString($)})}multipleOf($,X){return this._addCheck({kind:"multipleOf",value:$,message:j.toString(X)})}finite($){return this._addCheck({kind:"finite",message:j.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:j.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:j.toString($)})}get minValue(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxValue(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&F.isInteger($.value))}get isFinite(){let $=null,X=null;for(let W of this._def.checks)if(W.kind==="finite"||W.kind==="int"||W.kind==="multipleOf")return!0;else if(W.kind==="min"){if(X===null||W.value>X)X=W.value}else if(W.kind==="max"){if($===null||W.value<$)$=W.value}return Number.isFinite(X)&&Number.isFinite($)}};$0.create=($)=>{return new $0({checks:[],typeName:z.ZodNumber,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...N($)})};X0=class X0 extends K{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch(H){return this._getInvalidInput($)}if(this._getType($)!==V.bigint)return this._getInvalidInput($);let W=void 0,Q=new E;for(let H of this._def.checks)if(H.kind==="min"){if(H.inclusive?$.data<H.value:$.data<=H.value)W=this._getOrReturnCtx($,W),A(W,{code:D.too_small,type:"bigint",minimum:H.value,inclusive:H.inclusive,message:H.message}),Q.dirty()}else if(H.kind==="max"){if(H.inclusive?$.data>H.value:$.data>=H.value)W=this._getOrReturnCtx($,W),A(W,{code:D.too_big,type:"bigint",maximum:H.value,inclusive:H.inclusive,message:H.message}),Q.dirty()}else if(H.kind==="multipleOf"){if($.data%H.value!==BigInt(0))W=this._getOrReturnCtx($,W),A(W,{code:D.not_multiple_of,multipleOf:H.value,message:H.message}),Q.dirty()}else F.assertNever(H);return{status:Q.value,value:$.data}}_getInvalidInput($){let X=this._getOrReturnCtx($);return A(X,{code:D.invalid_type,expected:V.bigint,received:X.parsedType}),U}gte($,X){return this.setLimit("min",$,!0,j.toString(X))}gt($,X){return this.setLimit("min",$,!1,j.toString(X))}lte($,X){return this.setLimit("max",$,!0,j.toString(X))}lt($,X){return this.setLimit("max",$,!1,j.toString(X))}setLimit($,X,W,Q){return new X0({...this._def,checks:[...this._def.checks,{kind:$,value:X,inclusive:W,message:j.toString(Q)}]})}_addCheck($){return new X0({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:j.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:j.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:j.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:j.toString($)})}multipleOf($,X){return this._addCheck({kind:"multipleOf",value:$,message:j.toString(X)})}get minValue(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxValue(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}};X0.create=($)=>{var X;return new X0({checks:[],typeName:z.ZodBigInt,coerce:(X=$===null||$===void 0?void 0:$.coerce)!==null&&X!==void 0?X:!1,...N($)})};j0=class j0 extends K{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==V.boolean){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.boolean,received:W.parsedType}),U}return v($.data)}};j0.create=($)=>{return new j0({typeName:z.ZodBoolean,coerce:($===null||$===void 0?void 0:$.coerce)||!1,...N($)})};Y0=class Y0 extends K{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==V.date){let H=this._getOrReturnCtx($);return A(H,{code:D.invalid_type,expected:V.date,received:H.parsedType}),U}if(isNaN($.data.getTime())){let H=this._getOrReturnCtx($);return A(H,{code:D.invalid_date}),U}let W=new E,Q=void 0;for(let H of this._def.checks)if(H.kind==="min"){if($.data.getTime()<H.value)Q=this._getOrReturnCtx($,Q),A(Q,{code:D.too_small,message:H.message,inclusive:!0,exact:!1,minimum:H.value,type:"date"}),W.dirty()}else if(H.kind==="max"){if($.data.getTime()>H.value)Q=this._getOrReturnCtx($,Q),A(Q,{code:D.too_big,message:H.message,inclusive:!0,exact:!1,maximum:H.value,type:"date"}),W.dirty()}else F.assertNever(H);return{status:W.value,value:new Date($.data.getTime())}}_addCheck($){return new Y0({...this._def,checks:[...this._def.checks,$]})}min($,X){return this._addCheck({kind:"min",value:$.getTime(),message:j.toString(X)})}max($,X){return this._addCheck({kind:"max",value:$.getTime(),message:j.toString(X)})}get minDate(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $!=null?new Date($):null}};Y0.create=($)=>{return new Y0({checks:[],coerce:($===null||$===void 0?void 0:$.coerce)||!1,typeName:z.ZodDate,...N($)})};C0=class C0 extends K{_parse($){if(this._getType($)!==V.symbol){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.symbol,received:W.parsedType}),U}return v($.data)}};C0.create=($)=>{return new C0({typeName:z.ZodSymbol,...N($)})};q0=class q0 extends K{_parse($){if(this._getType($)!==V.undefined){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.undefined,received:W.parsedType}),U}return v($.data)}};q0.create=($)=>{return new q0({typeName:z.ZodUndefined,...N($)})};O0=class O0 extends K{_parse($){if(this._getType($)!==V.null){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.null,received:W.parsedType}),U}return v($.data)}};O0.create=($)=>{return new O0({typeName:z.ZodNull,...N($)})};G0=class G0 extends K{constructor(){super(...arguments);this._any=!0}_parse($){return v($.data)}};G0.create=($)=>{return new G0({typeName:z.ZodAny,...N($)})};e=class e extends K{constructor(){super(...arguments);this._unknown=!0}_parse($){return v($.data)}};e.create=($)=>{return new e({typeName:z.ZodUnknown,...N($)})};p=class p extends K{_parse($){let X=this._getOrReturnCtx($);return A(X,{code:D.invalid_type,expected:V.never,received:X.parsedType}),U}};p.create=($)=>{return new p({typeName:z.ZodNever,...N($)})};I0=class I0 extends K{_parse($){if(this._getType($)!==V.undefined){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.void,received:W.parsedType}),U}return v($.data)}};I0.create=($)=>{return new I0({typeName:z.ZodVoid,...N($)})};h=class h extends K{_parse($){let{ctx:X,status:W}=this._processInputParams($),Q=this._def;if(X.parsedType!==V.array)return A(X,{code:D.invalid_type,expected:V.array,received:X.parsedType}),U;if(Q.exactLength!==null){let Y=X.data.length>Q.exactLength.value,G=X.data.length<Q.exactLength.value;if(Y||G)A(X,{code:Y?D.too_big:D.too_small,minimum:G?Q.exactLength.value:void 0,maximum:Y?Q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:Q.exactLength.message}),W.dirty()}if(Q.minLength!==null){if(X.data.length<Q.minLength.value)A(X,{code:D.too_small,minimum:Q.minLength.value,type:"array",inclusive:!0,exact:!1,message:Q.minLength.message}),W.dirty()}if(Q.maxLength!==null){if(X.data.length>Q.maxLength.value)A(X,{code:D.too_big,maximum:Q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:Q.maxLength.message}),W.dirty()}if(X.common.async)return Promise.all([...X.data].map((Y,G)=>{return Q.type._parseAsync(new y(X,Y,X.path,G))})).then((Y)=>{return E.mergeArray(W,Y)});let H=[...X.data].map((Y,G)=>{return Q.type._parseSync(new y(X,Y,X.path,G))});return E.mergeArray(W,H)}get element(){return this._def.type}min($,X){return new h({...this._def,minLength:{value:$,message:j.toString(X)}})}max($,X){return new h({...this._def,maxLength:{value:$,message:j.toString(X)}})}length($,X){return new h({...this._def,exactLength:{value:$,message:j.toString(X)}})}nonempty($){return this.min(1,$)}};h.create=($,X)=>{return new h({type:$,minLength:null,maxLength:null,exactLength:null,typeName:z.ZodArray,...N(X)})};S=class S extends K{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),X=F.objectKeys($);return this._cached={shape:$,keys:X}}_parse($){if(this._getType($)!==V.object){let w=this._getOrReturnCtx($);return A(w,{code:D.invalid_type,expected:V.object,received:w.parsedType}),U}let{status:W,ctx:Q}=this._processInputParams($),{shape:H,keys:Y}=this._getCached(),G=[];if(!(this._def.catchall instanceof p&&this._def.unknownKeys==="strip")){for(let w in Q.data)if(!Y.includes(w))G.push(w)}let B=[];for(let w of Y){let M=H[w],q=Q.data[w];B.push({key:{status:"valid",value:w},value:M._parse(new y(Q,q,Q.path,w)),alwaysSet:w in Q.data})}if(this._def.catchall instanceof p){let w=this._def.unknownKeys;if(w==="passthrough")for(let M of G)B.push({key:{status:"valid",value:M},value:{status:"valid",value:Q.data[M]}});else if(w==="strict"){if(G.length>0)A(Q,{code:D.unrecognized_keys,keys:G}),W.dirty()}else if(w==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let w=this._def.catchall;for(let M of G){let q=Q.data[M];B.push({key:{status:"valid",value:M},value:w._parse(new y(Q,q,Q.path,M)),alwaysSet:M in Q.data})}}if(Q.common.async)return Promise.resolve().then(async()=>{let w=[];for(let M of B){let q=await M.key,b=await M.value;w.push({key:q,value:b,alwaysSet:M.alwaysSet})}return w}).then((w)=>{return E.mergeObjectSync(W,w)});else return E.mergeObjectSync(W,B)}get shape(){return this._def.shape()}strict($){return j.errToObj,new S({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(X,W)=>{var Q,H,Y,G;let B=(Y=(H=(Q=this._def).errorMap)===null||H===void 0?void 0:H.call(Q,X,W).message)!==null&&Y!==void 0?Y:W.defaultError;if(X.code==="unrecognized_keys")return{message:(G=j.errToObj($).message)!==null&&G!==void 0?G:B};return{message:B}}}:{}})}strip(){return new S({...this._def,unknownKeys:"strip"})}passthrough(){return new S({...this._def,unknownKeys:"passthrough"})}extend($){return new S({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new S({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:z.ZodObject})}setKey($,X){return this.augment({[$]:X})}catchall($){return new S({...this._def,catchall:$})}pick($){let X={};return F.objectKeys($).forEach((W)=>{if($[W]&&this.shape[W])X[W]=this.shape[W]}),new S({...this._def,shape:()=>X})}omit($){let X={};return F.objectKeys(this.shape).forEach((W)=>{if(!$[W])X[W]=this.shape[W]}),new S({...this._def,shape:()=>X})}deepPartial(){return z0(this)}partial($){let X={};return F.objectKeys(this.shape).forEach((W)=>{let Q=this.shape[W];if($&&!$[W])X[W]=Q;else X[W]=Q.optional()}),new S({...this._def,shape:()=>X})}required($){let X={};return F.objectKeys(this.shape).forEach((W)=>{if($&&!$[W])X[W]=this.shape[W];else{let H=this.shape[W];while(H instanceof I)H=H._def.innerType;X[W]=H}}),new S({...this._def,shape:()=>X})}keyof(){return Q$(F.objectKeys(this.shape))}};S.create=($,X)=>{return new S({shape:()=>$,unknownKeys:"strip",catchall:p.create(),typeName:z.ZodObject,...N(X)})};S.strictCreate=($,X)=>{return new S({shape:()=>$,unknownKeys:"strict",catchall:p.create(),typeName:z.ZodObject,...N(X)})};S.lazycreate=($,X)=>{return new S({shape:$,unknownKeys:"strip",catchall:p.create(),typeName:z.ZodObject,...N(X)})};U0=class U0 extends K{_parse($){let{ctx:X}=this._processInputParams($),W=this._def.options;function Q(H){for(let G of H)if(G.result.status==="valid")return G.result;for(let G of H)if(G.result.status==="dirty")return X.common.issues.push(...G.ctx.common.issues),G.result;let Y=H.map((G)=>new C(G.ctx.common.issues));return A(X,{code:D.invalid_union,unionErrors:Y}),U}if(X.common.async)return Promise.all(W.map(async(H)=>{let Y={...X,common:{...X.common,issues:[]},parent:null};return{result:await H._parseAsync({data:X.data,path:X.path,parent:Y}),ctx:Y}})).then(Q);else{let H=void 0,Y=[];for(let B of W){let w={...X,common:{...X.common,issues:[]},parent:null},M=B._parseSync({data:X.data,path:X.path,parent:w});if(M.status==="valid")return M;else if(M.status==="dirty"&&!H)H={result:M,ctx:w};if(w.common.issues.length)Y.push(w.common.issues)}if(H)return X.common.issues.push(...H.ctx.common.issues),H.result;let G=Y.map((B)=>new C(B));return A(X,{code:D.invalid_union,unionErrors:G}),U}}get options(){return this._def.options}};U0.create=($,X)=>{return new U0({options:$,typeName:z.ZodUnion,...N(X)})};d0=class d0 extends K{_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==V.object)return A(X,{code:D.invalid_type,expected:V.object,received:X.parsedType}),U;let W=this.discriminator,Q=X.data[W],H=this.optionsMap.get(Q);if(!H)return A(X,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[W]}),U;if(X.common.async)return H._parseAsync({data:X.data,path:X.path,parent:X});else return H._parseSync({data:X.data,path:X.path,parent:X})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,X,W){let Q=new Map;for(let H of X){let Y=a(H.shape[$]);if(!Y.length)throw new Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let G of Y){if(Q.has(G))throw new Error(`Discriminator property ${String($)} has duplicate value ${String(G)}`);Q.set(G,H)}}return new d0({typeName:z.ZodDiscriminatedUnion,discriminator:$,options:X,optionsMap:Q,...N(W)})}};K0=class K0 extends K{_parse($){let{status:X,ctx:W}=this._processInputParams($),Q=(H,Y)=>{if(R1(H)||R1(Y))return U;let G=b1(H.value,Y.value);if(!G.valid)return A(W,{code:D.invalid_intersection_types}),U;if(E1(H)||E1(Y))X.dirty();return{status:X.value,value:G.data}};if(W.common.async)return Promise.all([this._def.left._parseAsync({data:W.data,path:W.path,parent:W}),this._def.right._parseAsync({data:W.data,path:W.path,parent:W})]).then(([H,Y])=>Q(H,Y));else return Q(this._def.left._parseSync({data:W.data,path:W.path,parent:W}),this._def.right._parseSync({data:W.data,path:W.path,parent:W}))}};K0.create=($,X,W)=>{return new K0({left:$,right:X,typeName:z.ZodIntersection,...N(W)})};i=class i extends K{_parse($){let{status:X,ctx:W}=this._processInputParams($);if(W.parsedType!==V.array)return A(W,{code:D.invalid_type,expected:V.array,received:W.parsedType}),U;if(W.data.length<this._def.items.length)return A(W,{code:D.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),U;if(!this._def.rest&&W.data.length>this._def.items.length)A(W,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),X.dirty();let H=[...W.data].map((Y,G)=>{let B=this._def.items[G]||this._def.rest;if(!B)return null;return B._parse(new y(W,Y,W.path,G))}).filter((Y)=>!!Y);if(W.common.async)return Promise.all(H).then((Y)=>{return E.mergeArray(X,Y)});else return E.mergeArray(X,H)}get items(){return this._def.items}rest($){return new i({...this._def,rest:$})}};i.create=($,X)=>{if(!Array.isArray($))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new i({items:$,typeName:z.ZodTuple,rest:null,...N(X)})};P0=class P0 extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:X,ctx:W}=this._processInputParams($);if(W.parsedType!==V.object)return A(W,{code:D.invalid_type,expected:V.object,received:W.parsedType}),U;let Q=[],H=this._def.keyType,Y=this._def.valueType;for(let G in W.data)Q.push({key:H._parse(new y(W,G,W.path,G)),value:Y._parse(new y(W,W.data[G],W.path,G)),alwaysSet:G in W.data});if(W.common.async)return E.mergeObjectAsync(X,Q);else return E.mergeObjectSync(X,Q)}get element(){return this._def.valueType}static create($,X,W){if(X instanceof K)return new P0({keyType:$,valueType:X,typeName:z.ZodRecord,...N(W)});return new P0({keyType:x.create(),valueType:$,typeName:z.ZodRecord,...N(X)})}};f0=class f0 extends K{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:X,ctx:W}=this._processInputParams($);if(W.parsedType!==V.map)return A(W,{code:D.invalid_type,expected:V.map,received:W.parsedType}),U;let Q=this._def.keyType,H=this._def.valueType,Y=[...W.data.entries()].map(([G,B],w)=>{return{key:Q._parse(new y(W,G,W.path,[w,"key"])),value:H._parse(new y(W,B,W.path,[w,"value"]))}});if(W.common.async){let G=new Map;return Promise.resolve().then(async()=>{for(let B of Y){let w=await B.key,M=await B.value;if(w.status==="aborted"||M.status==="aborted")return U;if(w.status==="dirty"||M.status==="dirty")X.dirty();G.set(w.value,M.value)}return{status:X.value,value:G}})}else{let G=new Map;for(let B of Y){let{key:w,value:M}=B;if(w.status==="aborted"||M.status==="aborted")return U;if(w.status==="dirty"||M.status==="dirty")X.dirty();G.set(w.value,M.value)}return{status:X.value,value:G}}}};f0.create=($,X,W)=>{return new f0({valueType:X,keyType:$,typeName:z.ZodMap,...N(W)})};B0=class B0 extends K{_parse($){let{status:X,ctx:W}=this._processInputParams($);if(W.parsedType!==V.set)return A(W,{code:D.invalid_type,expected:V.set,received:W.parsedType}),U;let Q=this._def;if(Q.minSize!==null){if(W.data.size<Q.minSize.value)A(W,{code:D.too_small,minimum:Q.minSize.value,type:"set",inclusive:!0,exact:!1,message:Q.minSize.message}),X.dirty()}if(Q.maxSize!==null){if(W.data.size>Q.maxSize.value)A(W,{code:D.too_big,maximum:Q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:Q.maxSize.message}),X.dirty()}let H=this._def.valueType;function Y(B){let w=new Set;for(let M of B){if(M.status==="aborted")return U;if(M.status==="dirty")X.dirty();w.add(M.value)}return{status:X.value,value:w}}let G=[...W.data.values()].map((B,w)=>H._parse(new y(W,B,W.path,w)));if(W.common.async)return Promise.all(G).then((B)=>Y(B));else return Y(G)}min($,X){return new B0({...this._def,minSize:{value:$,message:j.toString(X)}})}max($,X){return new B0({...this._def,maxSize:{value:$,message:j.toString(X)}})}size($,X){return this.min($,X).max($,X)}nonempty($){return this.min(1,$)}};B0.create=($,X)=>{return new B0({valueType:$,minSize:null,maxSize:null,typeName:z.ZodSet,...N(X)})};A0=class A0 extends K{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==V.function)return A(X,{code:D.invalid_type,expected:V.function,received:X.parsedType}),U;function W(G,B){return p0({data:G,path:X.path,errorMaps:[X.common.contextualErrorMap,X.schemaErrorMap,u0(),V0].filter((w)=>!!w),issueData:{code:D.invalid_arguments,argumentsError:B}})}function Q(G,B){return p0({data:G,path:X.path,errorMaps:[X.common.contextualErrorMap,X.schemaErrorMap,u0(),V0].filter((w)=>!!w),issueData:{code:D.invalid_return_type,returnTypeError:B}})}let H={errorMap:X.common.contextualErrorMap},Y=X.data;if(this._def.returns instanceof w0){let G=this;return v(async function(...B){let w=new C([]),M=await G._def.args.parseAsync(B,H).catch((r)=>{throw w.addIssue(W(B,r)),w}),q=await Reflect.apply(Y,this,M);return await G._def.returns._def.type.parseAsync(q,H).catch((r)=>{throw w.addIssue(Q(q,r)),w})})}else{let G=this;return v(function(...B){let w=G._def.args.safeParse(B,H);if(!w.success)throw new C([W(B,w.error)]);let M=Reflect.apply(Y,this,w.data),q=G._def.returns.safeParse(M,H);if(!q.success)throw new C([Q(M,q.error)]);return q.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new A0({...this._def,args:i.create($).rest(e.create())})}returns($){return new A0({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,X,W){return new A0({args:$?$:i.create([]).rest(e.create()),returns:X||e.create(),typeName:z.ZodFunction,...N(W)})}};N0=class N0 extends K{get schema(){return this._def.getter()}_parse($){let{ctx:X}=this._processInputParams($);return this._def.getter()._parse({data:X.data,path:X.path,parent:X})}};N0.create=($,X)=>{return new N0({getter:$,typeName:z.ZodLazy,...N(X)})};L0=class L0 extends K{_parse($){if($.data!==this._def.value){let X=this._getOrReturnCtx($);return A(X,{received:X.data,code:D.invalid_literal,expected:this._def.value}),U}return{status:"valid",value:$.data}}get value(){return this._def.value}};L0.create=($,X)=>{return new L0({value:$,typeName:z.ZodLiteral,...N(X)})};W0=class W0 extends K{constructor(){super(...arguments);b0.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let X=this._getOrReturnCtx($),W=this._def.values;return A(X,{expected:F.joinValues(W),received:X.parsedType,code:D.invalid_type}),U}if(!i0(this,b0,"f"))e1(this,b0,new Set(this._def.values),"f");if(!i0(this,b0,"f").has($.data)){let X=this._getOrReturnCtx($),W=this._def.values;return A(X,{received:X.data,code:D.invalid_enum_value,options:W}),U}return v($.data)}get options(){return this._def.values}get enum(){let $={};for(let X of this._def.values)$[X]=X;return $}get Values(){let $={};for(let X of this._def.values)$[X]=X;return $}get Enum(){let $={};for(let X of this._def.values)$[X]=X;return $}extract($,X=this._def){return W0.create($,{...this._def,...X})}exclude($,X=this._def){return W0.create(this.options.filter((W)=>!$.includes(W)),{...this._def,...X})}};b0=new WeakMap;W0.create=Q$;F0=class F0 extends K{constructor(){super(...arguments);v0.set(this,void 0)}_parse($){let X=F.getValidEnumValues(this._def.values),W=this._getOrReturnCtx($);if(W.parsedType!==V.string&&W.parsedType!==V.number){let Q=F.objectValues(X);return A(W,{expected:F.joinValues(Q),received:W.parsedType,code:D.invalid_type}),U}if(!i0(this,v0,"f"))e1(this,v0,new Set(F.getValidEnumValues(this._def.values)),"f");if(!i0(this,v0,"f").has($.data)){let Q=F.objectValues(X);return A(W,{received:W.data,code:D.invalid_enum_value,options:Q}),U}return v($.data)}get enum(){return this._def.values}};v0=new WeakMap;F0.create=($,X)=>{return new F0({values:$,typeName:z.ZodNativeEnum,...N(X)})};w0=class w0 extends K{unwrap(){return this._def.type}_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==V.promise&&X.common.async===!1)return A(X,{code:D.invalid_type,expected:V.promise,received:X.parsedType}),U;let W=X.parsedType===V.promise?X.data:Promise.resolve(X.data);return v(W.then((Q)=>{return this._def.type.parseAsync(Q,{path:X.path,errorMap:X.common.contextualErrorMap})}))}};w0.create=($,X)=>{return new w0({type:$,typeName:z.ZodPromise,...N(X)})};T=class T extends K{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===z.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:X,ctx:W}=this._processInputParams($),Q=this._def.effect||null,H={addIssue:(Y)=>{if(A(W,Y),Y.fatal)X.abort();else X.dirty()},get path(){return W.path}};if(H.addIssue=H.addIssue.bind(H),Q.type==="preprocess"){let Y=Q.transform(W.data,H);if(W.common.async)return Promise.resolve(Y).then(async(G)=>{if(X.value==="aborted")return U;let B=await this._def.schema._parseAsync({data:G,path:W.path,parent:W});if(B.status==="aborted")return U;if(B.status==="dirty")return M0(B.value);if(X.value==="dirty")return M0(B.value);return B});else{if(X.value==="aborted")return U;let G=this._def.schema._parseSync({data:Y,path:W.path,parent:W});if(G.status==="aborted")return U;if(G.status==="dirty")return M0(G.value);if(X.value==="dirty")return M0(G.value);return G}}if(Q.type==="refinement"){let Y=(G)=>{let B=Q.refinement(G,H);if(W.common.async)return Promise.resolve(B);if(B instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return G};if(W.common.async===!1){let G=this._def.schema._parseSync({data:W.data,path:W.path,parent:W});if(G.status==="aborted")return U;if(G.status==="dirty")X.dirty();return Y(G.value),{status:X.value,value:G.value}}else return this._def.schema._parseAsync({data:W.data,path:W.path,parent:W}).then((G)=>{if(G.status==="aborted")return U;if(G.status==="dirty")X.dirty();return Y(G.value).then(()=>{return{status:X.value,value:G.value}})})}if(Q.type==="transform")if(W.common.async===!1){let Y=this._def.schema._parseSync({data:W.data,path:W.path,parent:W});if(!J0(Y))return Y;let G=Q.transform(Y.value,H);if(G instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:X.value,value:G}}else return this._def.schema._parseAsync({data:W.data,path:W.path,parent:W}).then((Y)=>{if(!J0(Y))return Y;return Promise.resolve(Q.transform(Y.value,H)).then((G)=>({status:X.value,value:G}))});F.assertNever(Q)}};T.create=($,X,W)=>{return new T({schema:$,typeName:z.ZodEffects,effect:X,...N(W)})};T.createWithPreprocess=($,X,W)=>{return new T({schema:X,effect:{type:"preprocess",transform:$},typeName:z.ZodEffects,...N(W)})};I=class I extends K{_parse($){if(this._getType($)===V.undefined)return v(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}};I.create=($,X)=>{return new I({innerType:$,typeName:z.ZodOptional,...N(X)})};s=class s extends K{_parse($){if(this._getType($)===V.null)return v(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}};s.create=($,X)=>{return new s({innerType:$,typeName:z.ZodNullable,...N(X)})};S0=class S0 extends K{_parse($){let{ctx:X}=this._processInputParams($),W=X.data;if(X.parsedType===V.undefined)W=this._def.defaultValue();return this._def.innerType._parse({data:W,path:X.path,parent:X})}removeDefault(){return this._def.innerType}};S0.create=($,X)=>{return new S0({innerType:$,typeName:z.ZodDefault,defaultValue:typeof X.default==="function"?X.default:()=>X.default,...N(X)})};_0=class _0 extends K{_parse($){let{ctx:X}=this._processInputParams($),W={...X,common:{...X.common,issues:[]}},Q=this._def.innerType._parse({data:W.data,path:W.path,parent:{...W}});if(k0(Q))return Q.then((H)=>{return{status:"valid",value:H.status==="valid"?H.value:this._def.catchValue({get error(){return new C(W.common.issues)},input:W.data})}});else return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new C(W.common.issues)},input:W.data})}}removeCatch(){return this._def.innerType}};_0.create=($,X)=>{return new _0({innerType:$,typeName:z.ZodCatch,catchValue:typeof X.catch==="function"?X.catch:()=>X.catch,...N(X)})};T0=class T0 extends K{_parse($){if(this._getType($)!==V.nan){let W=this._getOrReturnCtx($);return A(W,{code:D.invalid_type,expected:V.nan,received:W.parsedType}),U}return{status:"valid",value:$.data}}};T0.create=($)=>{return new T0({typeName:z.ZodNaN,...N($)})};$4=Symbol("zod_brand");o0=class o0 extends K{_parse($){let{ctx:X}=this._processInputParams($),W=X.data;return this._def.type._parse({data:W,path:X.path,parent:X})}unwrap(){return this._def.type}};g0=class g0 extends K{_parse($){let{status:X,ctx:W}=this._processInputParams($);if(W.common.async)return(async()=>{let H=await this._def.in._parseAsync({data:W.data,path:W.path,parent:W});if(H.status==="aborted")return U;if(H.status==="dirty")return X.dirty(),M0(H.value);else return this._def.out._parseAsync({data:H.value,path:W.path,parent:W})})();else{let Q=this._def.in._parseSync({data:W.data,path:W.path,parent:W});if(Q.status==="aborted")return U;if(Q.status==="dirty")return X.dirty(),{status:"dirty",value:Q.value};else return this._def.out._parseSync({data:Q.value,path:W.path,parent:W})}}static create($,X){return new g0({in:$,out:X,typeName:z.ZodPipeline})}};R0=class R0 extends K{_parse($){let X=this._def.innerType._parse($),W=(Q)=>{if(J0(Q))Q.value=Object.freeze(Q.value);return Q};return k0(X)?X.then((Q)=>W(Q)):W(X)}unwrap(){return this._def.innerType}};R0.create=($,X)=>{return new R0({innerType:$,typeName:z.ZodReadonly,...N(X)})};X4={object:S.lazycreate};(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(z||(z={}));J$=x.create,Y$=$0.create,Q4=T0.create,H4=X0.create,G$=j0.create,J4=Y0.create,Y4=C0.create,G4=q0.create,B4=O0.create,w4=G0.create,D4=e.create,z4=p.create,M4=I0.create,A4=h.create,V4=S.create,j4=S.strictCreate,q4=U0.create,O4=d0.create,U4=K0.create,K4=i.create,N4=P0.create,L4=f0.create,F4=B0.create,S4=A0.create,_4=N0.create,R4=L0.create,E4=W0.create,b4=F0.create,v4=w0.create,t1=T.create,k4=I.create,C4=s.create,I4=T.createWithPreprocess,P4=g0.create,x4={string:($)=>x.create({...$,coerce:!0}),number:($)=>$0.create({...$,coerce:!0}),boolean:($)=>j0.create({...$,coerce:!0}),bigint:($)=>X0.create({...$,coerce:!0}),date:($)=>Y0.create({...$,coerce:!0})},h4=U,J=Object.freeze({__proto__:null,defaultErrorMap:V0,setErrorMap:I2,getErrorMap:u0,makeIssue:p0,EMPTY_PATH:P2,addIssueToContext:A,ParseStatus:E,INVALID:U,DIRTY:M0,OK:v,isAborted:R1,isDirty:E1,isValid:J0,isAsync:k0,get util(){return F},get objectUtil(){return _1},ZodParsedType:V,getParsedType:t,ZodType:K,datetimeRegex:W$,ZodString:x,ZodNumber:$0,ZodBigInt:X0,ZodBoolean:j0,ZodDate:Y0,ZodSymbol:C0,ZodUndefined:q0,ZodNull:O0,ZodAny:G0,ZodUnknown:e,ZodNever:p,ZodVoid:I0,ZodArray:h,ZodObject:S,ZodUnion:U0,ZodDiscriminatedUnion:d0,ZodIntersection:K0,ZodTuple:i,ZodRecord:P0,ZodMap:f0,ZodSet:B0,ZodFunction:A0,ZodLazy:N0,ZodLiteral:L0,ZodEnum:W0,ZodNativeEnum:F0,ZodPromise:w0,ZodEffects:T,ZodTransformer:T,ZodOptional:I,ZodNullable:s,ZodDefault:S0,ZodCatch:_0,ZodNaN:T0,BRAND:$4,ZodBranded:o0,ZodPipeline:g0,ZodReadonly:R0,custom:H$,Schema:K,ZodSchema:K,late:X4,get ZodFirstPartyTypeKind(){return z},coerce:x4,any:w4,array:A4,bigint:H4,boolean:G$,date:J4,discriminatedUnion:O4,effect:t1,enum:E4,function:S4,instanceof:W4,intersection:U4,lazy:_4,literal:R4,map:L4,nan:Q4,nativeEnum:b4,never:z4,null:B4,nullable:C4,number:Y$,object:V4,oboolean:g4,onumber:T4,optional:k4,ostring:f4,pipeline:P4,preprocess:I4,promise:v4,record:N4,set:F4,strictObject:j4,string:J$,symbol:Y4,transformer:t1,tuple:K4,undefined:G4,union:q4,unknown:D4,void:M4,NEVER:h4,ZodIssueCode:D,quotelessJson:C2,ZodError:C})});var v1="2025-03-26",B$,r0="2.0",w$,D$,y4,Z,P,x0,o,m,a0,z$,M$=($)=>z$.safeParse($).success,A$,V$=($)=>A$.safeParse($).success,j$,k1=($)=>j$.safeParse($).success,_,q$,O$=($)=>q$.safeParse($).success,U$,t0,s0,K$,Z4,e0,i6=($)=>e0.safeParse($).success,m4,l4,C1,$1,n4,X1,W1,Q1,N$,L$,F$,c4,u4,H1,p4,J1,i4,Y1,d4,o4,r4,a4,t4,s4,e4,G1,$6,B1,w1,D1,z1,S$,X6,W6,Q6,H6,J6,M1,Y6,_$,d6,A1,G6,R$,B6,w6,D6,z6,M6,A6,I1,V6,j6,V1,q6,O6,U6,P1,K6,o6,r6,a6,t6,s6,e6,R;var h0=F1(()=>{d();B$=[v1,"2024-11-05","2024-10-07"],w$=J.union([J.string(),J.number().int()]),D$=J.string(),y4=J.object({progressToken:J.optional(w$)}).passthrough(),Z=J.object({_meta:J.optional(y4)}).passthrough(),P=J.object({method:J.string(),params:J.optional(Z)}),x0=J.object({_meta:J.optional(J.object({}).passthrough())}).passthrough(),o=J.object({method:J.string(),params:J.optional(x0)}),m=J.object({_meta:J.optional(J.object({}).passthrough())}).passthrough(),a0=J.union([J.string(),J.number().int()]),z$=J.object({jsonrpc:J.literal(r0),id:a0}).merge(P).strict(),A$=J.object({jsonrpc:J.literal(r0)}).merge(o).strict(),j$=J.object({jsonrpc:J.literal(r0),id:a0,result:m}).strict();(function($){$[$.ConnectionClosed=-32000]="ConnectionClosed",$[$.RequestTimeout=-32001]="RequestTimeout",$[$.ParseError=-32700]="ParseError",$[$.InvalidRequest=-32600]="InvalidRequest",$[$.MethodNotFound=-32601]="MethodNotFound",$[$.InvalidParams=-32602]="InvalidParams",$[$.InternalError=-32603]="InternalError"})(_||(_={}));q$=J.object({jsonrpc:J.literal(r0),id:a0,error:J.object({code:J.number().int(),message:J.string(),data:J.optional(J.unknown())})}).strict(),U$=J.union([z$,A$,j$,q$]),t0=m.strict(),s0=o.extend({method:J.literal("notifications/cancelled"),params:x0.extend({requestId:a0,reason:J.string().optional()})}),K$=J.object({name:J.string(),version:J.string()}).passthrough(),Z4=J.object({experimental:J.optional(J.object({}).passthrough()),sampling:J.optional(J.object({}).passthrough()),roots:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough())}).passthrough(),e0=P.extend({method:J.literal("initialize"),params:Z.extend({protocolVersion:J.string(),capabilities:Z4,clientInfo:K$})}),m4=J.object({experimental:J.optional(J.object({}).passthrough()),logging:J.optional(J.object({}).passthrough()),completions:J.optional(J.object({}).passthrough()),prompts:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough()),resources:J.optional(J.object({subscribe:J.optional(J.boolean()),listChanged:J.optional(J.boolean())}).passthrough()),tools:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough())}).passthrough(),l4=m.extend({protocolVersion:J.string(),capabilities:m4,serverInfo:K$,instructions:J.optional(J.string())}),C1=o.extend({method:J.literal("notifications/initialized")}),$1=P.extend({method:J.literal("ping")}),n4=J.object({progress:J.number(),total:J.optional(J.number()),message:J.optional(J.string())}).passthrough(),X1=o.extend({method:J.literal("notifications/progress"),params:x0.merge(n4).extend({progressToken:w$})}),W1=P.extend({params:Z.extend({cursor:J.optional(D$)}).optional()}),Q1=m.extend({nextCursor:J.optional(D$)}),N$=J.object({uri:J.string(),mimeType:J.optional(J.string())}).passthrough(),L$=N$.extend({text:J.string()}),F$=N$.extend({blob:J.string().base64()}),c4=J.object({uri:J.string(),name:J.string(),description:J.optional(J.string()),mimeType:J.optional(J.string())}).passthrough(),u4=J.object({uriTemplate:J.string(),name:J.string(),description:J.optional(J.string()),mimeType:J.optional(J.string())}).passthrough(),H1=W1.extend({method:J.literal("resources/list")}),p4=Q1.extend({resources:J.array(c4)}),J1=W1.extend({method:J.literal("resources/templates/list")}),i4=Q1.extend({resourceTemplates:J.array(u4)}),Y1=P.extend({method:J.literal("resources/read"),params:Z.extend({uri:J.string()})}),d4=m.extend({contents:J.array(J.union([L$,F$]))}),o4=o.extend({method:J.literal("notifications/resources/list_changed")}),r4=P.extend({method:J.literal("resources/subscribe"),params:Z.extend({uri:J.string()})}),a4=P.extend({method:J.literal("resources/unsubscribe"),params:Z.extend({uri:J.string()})}),t4=o.extend({method:J.literal("notifications/resources/updated"),params:x0.extend({uri:J.string()})}),s4=J.object({name:J.string(),description:J.optional(J.string()),required:J.optional(J.boolean())}).passthrough(),e4=J.object({name:J.string(),description:J.optional(J.string()),arguments:J.optional(J.array(s4))}).passthrough(),G1=W1.extend({method:J.literal("prompts/list")}),$6=Q1.extend({prompts:J.array(e4)}),B1=P.extend({method:J.literal("prompts/get"),params:Z.extend({name:J.string(),arguments:J.optional(J.record(J.string()))})}),w1=J.object({type:J.literal("text"),text:J.string()}).passthrough(),D1=J.object({type:J.literal("image"),data:J.string().base64(),mimeType:J.string()}).passthrough(),z1=J.object({type:J.literal("audio"),data:J.string().base64(),mimeType:J.string()}).passthrough(),S$=J.object({type:J.literal("resource"),resource:J.union([L$,F$])}).passthrough(),X6=J.object({role:J.enum(["user","assistant"]),content:J.union([w1,D1,z1,S$])}).passthrough(),W6=m.extend({description:J.optional(J.string()),messages:J.array(X6)}),Q6=o.extend({method:J.literal("notifications/prompts/list_changed")}),H6=J.object({title:J.optional(J.string()),readOnlyHint:J.optional(J.boolean()),destructiveHint:J.optional(J.boolean()),idempotentHint:J.optional(J.boolean()),openWorldHint:J.optional(J.boolean())}).passthrough(),J6=J.object({name:J.string(),description:J.optional(J.string()),inputSchema:J.object({type:J.literal("object"),properties:J.optional(J.object({}).passthrough()),required:J.optional(J.array(J.string()))}).passthrough(),outputSchema:J.optional(J.object({type:J.literal("object"),properties:J.optional(J.object({}).passthrough()),required:J.optional(J.array(J.string()))}).passthrough()),annotations:J.optional(H6)}).passthrough(),M1=W1.extend({method:J.literal("tools/list")}),Y6=Q1.extend({tools:J.array(J6)}),_$=m.extend({content:J.array(J.union([w1,D1,z1,S$])).default([]),structuredContent:J.object({}).passthrough().optional(),isError:J.optional(J.boolean())}),d6=_$.or(m.extend({toolResult:J.unknown()})),A1=P.extend({method:J.literal("tools/call"),params:Z.extend({name:J.string(),arguments:J.optional(J.record(J.unknown()))})}),G6=o.extend({method:J.literal("notifications/tools/list_changed")}),R$=J.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),B6=P.extend({method:J.literal("logging/setLevel"),params:Z.extend({level:R$})}),w6=o.extend({method:J.literal("notifications/message"),params:x0.extend({level:R$,logger:J.optional(J.string()),data:J.unknown()})}),D6=J.object({name:J.string().optional()}).passthrough(),z6=J.object({hints:J.optional(J.array(D6)),costPriority:J.optional(J.number().min(0).max(1)),speedPriority:J.optional(J.number().min(0).max(1)),intelligencePriority:J.optional(J.number().min(0).max(1))}).passthrough(),M6=J.object({role:J.enum(["user","assistant"]),content:J.union([w1,D1,z1])}).passthrough(),A6=P.extend({method:J.literal("sampling/createMessage"),params:Z.extend({messages:J.array(M6),systemPrompt:J.optional(J.string()),includeContext:J.optional(J.enum(["none","thisServer","allServers"])),temperature:J.optional(J.number()),maxTokens:J.number().int(),stopSequences:J.optional(J.array(J.string())),metadata:J.optional(J.object({}).passthrough()),modelPreferences:J.optional(z6)})}),I1=m.extend({model:J.string(),stopReason:J.optional(J.enum(["endTurn","stopSequence","maxTokens"]).or(J.string())),role:J.enum(["user","assistant"]),content:J.discriminatedUnion("type",[w1,D1,z1])}),V6=J.object({type:J.literal("ref/resource"),uri:J.string()}).passthrough(),j6=J.object({type:J.literal("ref/prompt"),name:J.string()}).passthrough(),V1=P.extend({method:J.literal("completion/complete"),params:Z.extend({ref:J.union([j6,V6]),argument:J.object({name:J.string(),value:J.string()}).passthrough()})}),q6=m.extend({completion:J.object({values:J.array(J.string()).max(100),total:J.optional(J.number().int()),hasMore:J.optional(J.boolean())}).passthrough()}),O6=J.object({uri:J.string().startsWith("file://"),name:J.optional(J.string())}).passthrough(),U6=P.extend({method:J.literal("roots/list")}),P1=m.extend({roots:J.array(O6)}),K6=o.extend({method:J.literal("notifications/roots/list_changed")}),o6=J.union([$1,e0,V1,B6,B1,G1,H1,J1,Y1,r4,a4,A1,M1]),r6=J.union([s0,X1,C1,K6]),a6=J.union([t0,I1,P1]),t6=J.union([$1,A6,U6]),s6=J.union([s0,X1,w6,t4,o4,G6,Q6]),e6=J.union([t0,l4,q6,W6,$6,p4,i4,d4,_$,Y6]);R=class R extends Error{constructor($,X,W){super(`MCP error ${$}: ${X}`);this.code=$,this.data=W,this.name="McpError"}}});function T6(){let $=process.argv.join(" ");return $.includes("streamable-http.js")||$.includes("streamable-http.ts")}class D2{context;level;constructor($,X=1){this.context=$,this.level=X}setLevel($){this.level=$}log(...$){if(w2)console.log(...$);else console.error(...$)}logWarn(...$){if(w2)console.warn(...$);else console.error(...$)}debug(...$){if(this.level<=0)this.log(`[DEBUG] [${this.context}]`,...$)}info(...$){if(this.level<=1)this.log(`[INFO] [${this.context}]`,...$)}warn(...$){if(this.level<=2)this.logWarn(`[WARN] [${this.context}]`,...$)}error(...$){if(this.level<=3)console.error(`[ERROR] [${this.context}]`,...$)}}var w2,g=($,X=1)=>new D2($,X);var D0=F1(()=>{w2=T6()});h0();var N6=60000;class f1{constructor($){this._options=$,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this.setNotificationHandler(s0,(X)=>{let W=this._requestHandlerAbortControllers.get(X.params.requestId);W===null||W===void 0||W.abort(X.params.reason)}),this.setNotificationHandler(X1,(X)=>{this._onprogress(X)}),this.setRequestHandler($1,(X)=>({}))}_setupTimeout($,X,W,Q,H=!1){this._timeoutInfo.set($,{timeoutId:setTimeout(Q,X),startTime:Date.now(),timeout:X,maxTotalTimeout:W,resetTimeoutOnProgress:H,onTimeout:Q})}_resetTimeout($){let X=this._timeoutInfo.get($);if(!X)return!1;let W=Date.now()-X.startTime;if(X.maxTotalTimeout&&W>=X.maxTotalTimeout)throw this._timeoutInfo.delete($),new R(_.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:X.maxTotalTimeout,totalElapsed:W});return clearTimeout(X.timeoutId),X.timeoutId=setTimeout(X.onTimeout,X.timeout),!0}_cleanupTimeout($){let X=this._timeoutInfo.get($);if(X)clearTimeout(X.timeoutId),this._timeoutInfo.delete($)}async connect($){this._transport=$,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=(X)=>{this._onerror(X)},this._transport.onmessage=(X,W)=>{if(k1(X)||O$(X))this._onresponse(X);else if(M$(X))this._onrequest(X,W);else if(V$(X))this._onnotification(X);else this._onerror(new Error(`Unknown message type: ${JSON.stringify(X)}`))},await this._transport.start()}_onclose(){var $;let X=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,($=this.onclose)===null||$===void 0||$.call(this);let W=new R(_.ConnectionClosed,"Connection closed");for(let Q of X.values())Q(W)}_onerror($){var X;(X=this.onerror)===null||X===void 0||X.call(this,$)}_onnotification($){var X;let W=(X=this._notificationHandlers.get($.method))!==null&&X!==void 0?X:this.fallbackNotificationHandler;if(W===void 0)return;Promise.resolve().then(()=>W($)).catch((Q)=>this._onerror(new Error(`Uncaught error in notification handler: ${Q}`)))}_onrequest($,X){var W,Q,H,Y;let G=(W=this._requestHandlers.get($.method))!==null&&W!==void 0?W:this.fallbackRequestHandler;if(G===void 0){(Q=this._transport)===null||Q===void 0||Q.send({jsonrpc:"2.0",id:$.id,error:{code:_.MethodNotFound,message:"Method not found"}}).catch((M)=>this._onerror(new Error(`Failed to send an error response: ${M}`)));return}let B=new AbortController;this._requestHandlerAbortControllers.set($.id,B);let w={signal:B.signal,sessionId:(H=this._transport)===null||H===void 0?void 0:H.sessionId,_meta:(Y=$.params)===null||Y===void 0?void 0:Y._meta,sendNotification:(M)=>this.notification(M,{relatedRequestId:$.id}),sendRequest:(M,q,b)=>this.request(M,q,{...b,relatedRequestId:$.id}),authInfo:X===null||X===void 0?void 0:X.authInfo,requestId:$.id};Promise.resolve().then(()=>G($,w)).then((M)=>{var q;if(B.signal.aborted)return;return(q=this._transport)===null||q===void 0?void 0:q.send({result:M,jsonrpc:"2.0",id:$.id})},(M)=>{var q,b;if(B.signal.aborted)return;return(q=this._transport)===null||q===void 0?void 0:q.send({jsonrpc:"2.0",id:$.id,error:{code:Number.isSafeInteger(M.code)?M.code:_.InternalError,message:(b=M.message)!==null&&b!==void 0?b:"Internal error"}})}).catch((M)=>this._onerror(new Error(`Failed to send response: ${M}`))).finally(()=>{this._requestHandlerAbortControllers.delete($.id)})}_onprogress($){let{progressToken:X,...W}=$.params,Q=Number(X),H=this._progressHandlers.get(Q);if(!H){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify($)}`));return}let Y=this._responseHandlers.get(Q),G=this._timeoutInfo.get(Q);if(G&&Y&&G.resetTimeoutOnProgress)try{this._resetTimeout(Q)}catch(B){Y(B);return}H(W)}_onresponse($){let X=Number($.id),W=this._responseHandlers.get(X);if(W===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify($)}`));return}if(this._responseHandlers.delete(X),this._progressHandlers.delete(X),this._cleanupTimeout(X),k1($))W($);else{let Q=new R($.error.code,$.error.message,$.error.data);W(Q)}}get transport(){return this._transport}async close(){var $;await(($=this._transport)===null||$===void 0?void 0:$.close())}request($,X,W){let{relatedRequestId:Q,resumptionToken:H,onresumptiontoken:Y}=W!==null&&W!==void 0?W:{};return new Promise((G,B)=>{var w,M,q,b,r,N1;if(!this._transport){B(new Error("Not connected"));return}if(((w=this._options)===null||w===void 0?void 0:w.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod($.method);(M=W===null||W===void 0?void 0:W.signal)===null||M===void 0||M.throwIfAborted();let u=this._requestMessageId++,i1={...$,jsonrpc:"2.0",id:u};if(W===null||W===void 0?void 0:W.onprogress)this._progressHandlers.set(u,W.onprogress),i1.params={...$.params,_meta:{...((q=$.params)===null||q===void 0?void 0:q._meta)||{},progressToken:u}};let d1=(f)=>{var H0;this._responseHandlers.delete(u),this._progressHandlers.delete(u),this._cleanupTimeout(u),(H0=this._transport)===null||H0===void 0||H0.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:u,reason:String(f)}},{relatedRequestId:Q,resumptionToken:H,onresumptiontoken:Y}).catch((E0)=>this._onerror(new Error(`Failed to send cancellation: ${E0}`))),B(f)};this._responseHandlers.set(u,(f)=>{var H0;if((H0=W===null||W===void 0?void 0:W.signal)===null||H0===void 0?void 0:H0.aborted)return;if(f instanceof Error)return B(f);try{let E0=X.parse(f.result);G(E0)}catch(E0){B(E0)}}),(b=W===null||W===void 0?void 0:W.signal)===null||b===void 0||b.addEventListener("abort",()=>{var f;d1((f=W===null||W===void 0?void 0:W.signal)===null||f===void 0?void 0:f.reason)});let o1=(r=W===null||W===void 0?void 0:W.timeout)!==null&&r!==void 0?r:N6,R2=()=>d1(new R(_.RequestTimeout,"Request timed out",{timeout:o1}));this._setupTimeout(u,o1,W===null||W===void 0?void 0:W.maxTotalTimeout,R2,(N1=W===null||W===void 0?void 0:W.resetTimeoutOnProgress)!==null&&N1!==void 0?N1:!1),this._transport.send(i1,{relatedRequestId:Q,resumptionToken:H,onresumptiontoken:Y}).catch((f)=>{this._cleanupTimeout(u),B(f)})})}async notification($,X){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability($.method);let W={...$,jsonrpc:"2.0"};await this._transport.send(W,X)}setRequestHandler($,X){let W=$.shape.method.value;this.assertRequestHandlerCapability(W),this._requestHandlers.set(W,(Q,H)=>{return Promise.resolve(X($.parse(Q),H))})}removeRequestHandler($){this._requestHandlers.delete($)}assertCanSetRequestHandler($){if(this._requestHandlers.has($))throw new Error(`A request handler for ${$} already exists, which would be overridden`)}setNotificationHandler($,X){this._notificationHandlers.set($.shape.method.value,(W)=>Promise.resolve(X($.parse(W))))}removeNotificationHandler($){this._notificationHandlers.delete($)}}function E$($,X){return Object.entries(X).reduce((W,[Q,H])=>{if(H&&typeof H==="object")W[Q]=W[Q]?{...W[Q],...H}:H;else W[Q]=H;return W},{...$})}h0();class T1 extends f1{constructor($,X){var W;super(X);this._serverInfo=$,this._capabilities=(W=X===null||X===void 0?void 0:X.capabilities)!==null&&W!==void 0?W:{},this._instructions=X===null||X===void 0?void 0:X.instructions,this.setRequestHandler(e0,(Q)=>this._oninitialize(Q)),this.setNotificationHandler(C1,()=>{var Q;return(Q=this.oninitialized)===null||Q===void 0?void 0:Q.call(this)})}registerCapabilities($){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=E$(this._capabilities,$)}assertCapabilityForMethod($){var X,W;switch($){case"sampling/createMessage":if(!((X=this._clientCapabilities)===null||X===void 0?void 0:X.sampling))throw new Error(`Client does not support sampling (required for ${$})`);break;case"roots/list":if(!((W=this._clientCapabilities)===null||W===void 0?void 0:W.roots))throw new Error(`Client does not support listing roots (required for ${$})`);break;case"ping":break}}assertNotificationCapability($){switch($){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${$})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${$})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${$})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${$})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability($){switch($){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Server does not support sampling (required for ${$})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${$})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${$})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${$})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${$})`);break;case"ping":case"initialize":break}}async _oninitialize($){let X=$.params.protocolVersion;return this._clientCapabilities=$.params.capabilities,this._clientVersion=$.params.clientInfo,{protocolVersion:B$.includes(X)?X:v1,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},t0)}async createMessage($,X){return this.request({method:"sampling/createMessage",params:$},I1,X)}async listRoots($,X){return this.request({method:"roots/list",params:$},P1,X)}async sendLoggingMessage($){return this.notification({method:"notifications/message",params:$})}async sendResourceUpdated($){return this.notification({method:"notifications/resources/updated",params:$})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}var v$=Symbol("Let zodToJsonSchema decide on which parser to use");var b$={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},k$=($)=>typeof $==="string"?{...b$,name:$}:{...b$,...$};var C$=($)=>{let X=k$($),W=X.name!==void 0?[...X.basePath,X.definitionPath,X.name]:X.basePath;return{...X,currentPath:W,propertyPath:void 0,seen:new Map(Object.entries(X.definitions).map(([Q,H])=>[H._def,{def:H._def,path:[...X.basePath,X.definitionPath,Q],jsonSchema:void 0}]))}};function g1($,X,W,Q){if(!Q?.errorMessages)return;if(W)$.errorMessage={...$.errorMessage,[X]:W}}function L($,X,W,Q,H){$[X]=W,g1($,X,Q,H)}d();function I$(){return{}}d();function P$($,X){let W={type:"array"};if($.type?._def&&$.type?._def?.typeName!==z.ZodAny)W.items=O($.type._def,{...X,currentPath:[...X.currentPath,"items"]});if($.minLength)L(W,"minItems",$.minLength.value,$.minLength.message,X);if($.maxLength)L(W,"maxItems",$.maxLength.value,$.maxLength.message,X);if($.exactLength)L(W,"minItems",$.exactLength.value,$.exactLength.message,X),L(W,"maxItems",$.exactLength.value,$.exactLength.message,X);return W}function f$($,X){let W={type:"integer",format:"int64"};if(!$.checks)return W;for(let Q of $.checks)switch(Q.kind){case"min":if(X.target==="jsonSchema7")if(Q.inclusive)L(W,"minimum",Q.value,Q.message,X);else L(W,"exclusiveMinimum",Q.value,Q.message,X);else{if(!Q.inclusive)W.exclusiveMinimum=!0;L(W,"minimum",Q.value,Q.message,X)}break;case"max":if(X.target==="jsonSchema7")if(Q.inclusive)L(W,"maximum",Q.value,Q.message,X);else L(W,"exclusiveMaximum",Q.value,Q.message,X);else{if(!Q.inclusive)W.exclusiveMaximum=!0;L(W,"maximum",Q.value,Q.message,X)}break;case"multipleOf":L(W,"multipleOf",Q.value,Q.message,X);break}return W}function T$(){return{type:"boolean"}}function j1($,X){return O($.type._def,X)}var g$=($,X)=>{return O($.innerType._def,X)};function x1($,X,W){let Q=W??X.dateStrategy;if(Array.isArray(Q))return{anyOf:Q.map((H,Y)=>x1($,X,H))};switch(Q){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return L6($,X)}}var L6=($,X)=>{let W={type:"integer",format:"unix-time"};if(X.target==="openApi3")return W;for(let Q of $.checks)switch(Q.kind){case"min":L(W,"minimum",Q.value,Q.message,X);break;case"max":L(W,"maximum",Q.value,Q.message,X);break}return W};function x$($,X){return{...O($.innerType._def,X),default:$.defaultValue()}}function h$($,X){return X.effectStrategy==="input"?O($.schema._def,X):{}}function y$($){return{type:"string",enum:Array.from($.values)}}var F6=($)=>{if("type"in $&&$.type==="string")return!1;return"allOf"in $};function Z$($,X){let W=[O($.left._def,{...X,currentPath:[...X.currentPath,"allOf","0"]}),O($.right._def,{...X,currentPath:[...X.currentPath,"allOf","1"]})].filter((Y)=>!!Y),Q=X.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,H=[];return W.forEach((Y)=>{if(F6(Y)){if(H.push(...Y.allOf),Y.unevaluatedProperties===void 0)Q=void 0}else{let G=Y;if("additionalProperties"in Y&&Y.additionalProperties===!1){let{additionalProperties:B,...w}=Y;G=w}else Q=void 0;H.push(G)}}),H.length?{allOf:H,...Q}:void 0}function m$($,X){let W=typeof $.value;if(W!=="bigint"&&W!=="number"&&W!=="boolean"&&W!=="string")return{type:Array.isArray($.value)?"array":"object"};if(X.target==="openApi3")return{type:W==="bigint"?"integer":W,enum:[$.value]};return{type:W==="bigint"?"integer":W,const:$.value}}d();var h1=void 0,l={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(h1===void 0)h1=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return h1},uuid:/^[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}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function q1($,X){let W={type:"string"};if($.checks)for(let Q of $.checks)switch(Q.kind){case"min":L(W,"minLength",typeof W.minLength==="number"?Math.max(W.minLength,Q.value):Q.value,Q.message,X);break;case"max":L(W,"maxLength",typeof W.maxLength==="number"?Math.min(W.maxLength,Q.value):Q.value,Q.message,X);break;case"email":switch(X.emailStrategy){case"format:email":n(W,"email",Q.message,X);break;case"format:idn-email":n(W,"idn-email",Q.message,X);break;case"pattern:zod":k(W,l.email,Q.message,X);break}break;case"url":n(W,"uri",Q.message,X);break;case"uuid":n(W,"uuid",Q.message,X);break;case"regex":k(W,Q.regex,Q.message,X);break;case"cuid":k(W,l.cuid,Q.message,X);break;case"cuid2":k(W,l.cuid2,Q.message,X);break;case"startsWith":k(W,RegExp(`^${y1(Q.value,X)}`),Q.message,X);break;case"endsWith":k(W,RegExp(`${y1(Q.value,X)}$`),Q.message,X);break;case"datetime":n(W,"date-time",Q.message,X);break;case"date":n(W,"date",Q.message,X);break;case"time":n(W,"time",Q.message,X);break;case"duration":n(W,"duration",Q.message,X);break;case"length":L(W,"minLength",typeof W.minLength==="number"?Math.max(W.minLength,Q.value):Q.value,Q.message,X),L(W,"maxLength",typeof W.maxLength==="number"?Math.min(W.maxLength,Q.value):Q.value,Q.message,X);break;case"includes":{k(W,RegExp(y1(Q.value,X)),Q.message,X);break}case"ip":{if(Q.version!=="v6")n(W,"ipv4",Q.message,X);if(Q.version!=="v4")n(W,"ipv6",Q.message,X);break}case"base64url":k(W,l.base64url,Q.message,X);break;case"jwt":k(W,l.jwt,Q.message,X);break;case"cidr":{if(Q.version!=="v6")k(W,l.ipv4Cidr,Q.message,X);if(Q.version!=="v4")k(W,l.ipv6Cidr,Q.message,X);break}case"emoji":k(W,l.emoji(),Q.message,X);break;case"ulid":{k(W,l.ulid,Q.message,X);break}case"base64":{switch(X.base64Strategy){case"format:binary":{n(W,"binary",Q.message,X);break}case"contentEncoding:base64":{L(W,"contentEncoding","base64",Q.message,X);break}case"pattern:zod":{k(W,l.base64,Q.message,X);break}}break}case"nanoid":k(W,l.nanoid,Q.message,X);case"toLowerCase":case"toUpperCase":case"trim":break;default:((H)=>{})(Q)}return W}function y1($,X){return X.patternStrategy==="escape"?_6($):$}var S6=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function _6($){let X="";for(let W=0;W<$.length;W++){if(!S6.has($[W]))X+="\\";X+=$[W]}return X}function n($,X,W,Q){if($.format||$.anyOf?.some((H)=>H.format)){if(!$.anyOf)$.anyOf=[];if($.format){if($.anyOf.push({format:$.format,...$.errorMessage&&Q.errorMessages&&{errorMessage:{format:$.errorMessage.format}}}),delete $.format,$.errorMessage){if(delete $.errorMessage.format,Object.keys($.errorMessage).length===0)delete $.errorMessage}}$.anyOf.push({format:X,...W&&Q.errorMessages&&{errorMessage:{format:W}}})}else L($,"format",X,W,Q)}function k($,X,W,Q){if($.pattern||$.allOf?.some((H)=>H.pattern)){if(!$.allOf)$.allOf=[];if($.pattern){if($.allOf.push({pattern:$.pattern,...$.errorMessage&&Q.errorMessages&&{errorMessage:{pattern:$.errorMessage.pattern}}}),delete $.pattern,$.errorMessage){if(delete $.errorMessage.pattern,Object.keys($.errorMessage).length===0)delete $.errorMessage}}$.allOf.push({pattern:l$(X,Q),...W&&Q.errorMessages&&{errorMessage:{pattern:W}}})}else L($,"pattern",l$(X,Q),W,Q)}function l$($,X){if(!X.applyRegexFlags||!$.flags)return $.source;let W={i:$.flags.includes("i"),m:$.flags.includes("m"),s:$.flags.includes("s")},Q=W.i?$.source.toLowerCase():$.source,H="",Y=!1,G=!1,B=!1;for(let w=0;w<Q.length;w++){if(Y){H+=Q[w],Y=!1;continue}if(W.i){if(G){if(Q[w].match(/[a-z]/)){if(B)H+=Q[w],H+=`${Q[w-2]}-${Q[w]}`.toUpperCase(),B=!1;else if(Q[w+1]==="-"&&Q[w+2]?.match(/[a-z]/))H+=Q[w],B=!0;else H+=`${Q[w]}${Q[w].toUpperCase()}`;continue}}else if(Q[w].match(/[a-z]/)){H+=`[${Q[w]}${Q[w].toUpperCase()}]`;continue}}if(W.m){if(Q[w]==="^"){H+=`(^|(?<=[\r
|
2
|
-
]))`;continue}else if(Q[
|
3
|
-
]))`;continue}}if(
|
4
|
-
`:`[${Q[
|
5
|
-
]`;continue}if(H+=Q[w],Q[w]==="\\")Y=!0;else if(G&&Q[w]==="]")G=!1;else if(!G&&Q[w]==="[")G=!0}try{new RegExp(H)}catch{return console.warn(`Could not convert regex pattern at ${X.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),$.source}return H}function O1($,X){if(X.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(X.target==="openApi3"&&$.keyType?._def.typeName===z.ZodEnum)return{type:"object",required:$.keyType._def.values,properties:$.keyType._def.values.reduce((Q,H)=>({...Q,[H]:O($.valueType._def,{...X,currentPath:[...X.currentPath,"properties",H]})??{}}),{}),additionalProperties:X.rejectedAdditionalProperties};let W={type:"object",additionalProperties:O($.valueType._def,{...X,currentPath:[...X.currentPath,"additionalProperties"]})??X.allowedAdditionalProperties};if(X.target==="openApi3")return W;if($.keyType?._def.typeName===z.ZodString&&$.keyType._def.checks?.length){let{type:Q,...H}=q1($.keyType._def,X);return{...W,propertyNames:H}}else if($.keyType?._def.typeName===z.ZodEnum)return{...W,propertyNames:{enum:$.keyType._def.values}};else if($.keyType?._def.typeName===z.ZodBranded&&$.keyType._def.type._def.typeName===z.ZodString&&$.keyType._def.type._def.checks?.length){let{type:Q,...H}=j1($.keyType._def,X);return{...W,propertyNames:H}}return W}function n$($,X){if(X.mapStrategy==="record")return O1($,X);let W=O($.keyType._def,{...X,currentPath:[...X.currentPath,"items","items","0"]})||{},Q=O($.valueType._def,{...X,currentPath:[...X.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[W,Q],minItems:2,maxItems:2}}}function c$($){let X=$.values,Q=Object.keys($.values).filter((Y)=>{return typeof X[X[Y]]!=="number"}).map((Y)=>X[Y]),H=Array.from(new Set(Q.map((Y)=>typeof Y)));return{type:H.length===1?H[0]==="string"?"string":"number":["string","number"],enum:Q}}function u$(){return{not:{}}}function p$($){return $.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var y0={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function d$($,X){if(X.target==="openApi3")return i$($,X);let W=$.options instanceof Map?Array.from($.options.values()):$.options;if(W.every((Q)=>(Q._def.typeName in y0)&&(!Q._def.checks||!Q._def.checks.length))){let Q=W.reduce((H,Y)=>{let G=y0[Y._def.typeName];return G&&!H.includes(G)?[...H,G]:H},[]);return{type:Q.length>1?Q:Q[0]}}else if(W.every((Q)=>Q._def.typeName==="ZodLiteral"&&!Q.description)){let Q=W.reduce((H,Y)=>{let G=typeof Y._def.value;switch(G){case"string":case"number":case"boolean":return[...H,G];case"bigint":return[...H,"integer"];case"object":if(Y._def.value===null)return[...H,"null"];case"symbol":case"undefined":case"function":default:return H}},[]);if(Q.length===W.length){let H=Q.filter((Y,G,B)=>B.indexOf(Y)===G);return{type:H.length>1?H:H[0],enum:W.reduce((Y,G)=>{return Y.includes(G._def.value)?Y:[...Y,G._def.value]},[])}}}else if(W.every((Q)=>Q._def.typeName==="ZodEnum"))return{type:"string",enum:W.reduce((Q,H)=>[...Q,...H._def.values.filter((Y)=>!Q.includes(Y))],[])};return i$($,X)}var i$=($,X)=>{let W=($.options instanceof Map?Array.from($.options.values()):$.options).map((Q,H)=>O(Q._def,{...X,currentPath:[...X.currentPath,"anyOf",`${H}`]})).filter((Q)=>!!Q&&(!X.strictUnions||typeof Q==="object"&&Object.keys(Q).length>0));return W.length?{anyOf:W}:void 0};function o$($,X){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes($.innerType._def.typeName)&&(!$.innerType._def.checks||!$.innerType._def.checks.length)){if(X.target==="openApi3")return{type:y0[$.innerType._def.typeName],nullable:!0};return{type:[y0[$.innerType._def.typeName],"null"]}}if(X.target==="openApi3"){let Q=O($.innerType._def,{...X,currentPath:[...X.currentPath]});if(Q&&"$ref"in Q)return{allOf:[Q],nullable:!0};return Q&&{...Q,nullable:!0}}let W=O($.innerType._def,{...X,currentPath:[...X.currentPath,"anyOf","0"]});return W&&{anyOf:[W,{type:"null"}]}}function r$($,X){let W={type:"number"};if(!$.checks)return W;for(let Q of $.checks)switch(Q.kind){case"int":W.type="integer",g1(W,"type",Q.message,X);break;case"min":if(X.target==="jsonSchema7")if(Q.inclusive)L(W,"minimum",Q.value,Q.message,X);else L(W,"exclusiveMinimum",Q.value,Q.message,X);else{if(!Q.inclusive)W.exclusiveMinimum=!0;L(W,"minimum",Q.value,Q.message,X)}break;case"max":if(X.target==="jsonSchema7")if(Q.inclusive)L(W,"maximum",Q.value,Q.message,X);else L(W,"exclusiveMaximum",Q.value,Q.message,X);else{if(!Q.inclusive)W.exclusiveMaximum=!0;L(W,"maximum",Q.value,Q.message,X)}break;case"multipleOf":L(W,"multipleOf",Q.value,Q.message,X);break}return W}d();function a$($,X){let W=X.target==="openAi",Q={type:"object",properties:{}},H=[],Y=$.shape();for(let B in Y){let w=Y[B];if(w===void 0||w._def===void 0)continue;let M=E6(w);if(M&&W){if(w instanceof I)w=w._def.innerType;if(!w.isNullable())w=w.nullable();M=!1}let q=O(w._def,{...X,currentPath:[...X.currentPath,"properties",B],propertyPath:[...X.currentPath,"properties",B]});if(q===void 0)continue;if(Q.properties[B]=q,!M)H.push(B)}if(H.length)Q.required=H;let G=R6($,X);if(G!==void 0)Q.additionalProperties=G;return Q}function R6($,X){if($.catchall._def.typeName!=="ZodNever")return O($.catchall._def,{...X,currentPath:[...X.currentPath,"additionalProperties"]});switch($.unknownKeys){case"passthrough":return X.allowedAdditionalProperties;case"strict":return X.rejectedAdditionalProperties;case"strip":return X.removeAdditionalStrategy==="strict"?X.allowedAdditionalProperties:X.rejectedAdditionalProperties}}function E6($){try{return $.isOptional()}catch{return!0}}var t$=($,X)=>{if(X.currentPath.toString()===X.propertyPath?.toString())return O($.innerType._def,X);let W=O($.innerType._def,{...X,currentPath:[...X.currentPath,"anyOf","1"]});return W?{anyOf:[{not:{}},W]}:{}};var s$=($,X)=>{if(X.pipeStrategy==="input")return O($.in._def,X);else if(X.pipeStrategy==="output")return O($.out._def,X);let W=O($.in._def,{...X,currentPath:[...X.currentPath,"allOf","0"]}),Q=O($.out._def,{...X,currentPath:[...X.currentPath,"allOf",W?"1":"0"]});return{allOf:[W,Q].filter((H)=>H!==void 0)}};function e$($,X){return O($.type._def,X)}function $2($,X){let Q={type:"array",uniqueItems:!0,items:O($.valueType._def,{...X,currentPath:[...X.currentPath,"items"]})};if($.minSize)L(Q,"minItems",$.minSize.value,$.minSize.message,X);if($.maxSize)L(Q,"maxItems",$.maxSize.value,$.maxSize.message,X);return Q}function X2($,X){if($.rest)return{type:"array",minItems:$.items.length,items:$.items.map((W,Q)=>O(W._def,{...X,currentPath:[...X.currentPath,"items",`${Q}`]})).reduce((W,Q)=>Q===void 0?W:[...W,Q],[]),additionalItems:O($.rest._def,{...X,currentPath:[...X.currentPath,"additionalItems"]})};else return{type:"array",minItems:$.items.length,maxItems:$.items.length,items:$.items.map((W,Q)=>O(W._def,{...X,currentPath:[...X.currentPath,"items",`${Q}`]})).reduce((W,Q)=>Q===void 0?W:[...W,Q],[])}}function W2(){return{not:{}}}function Q2(){return{}}var H2=($,X)=>{return O($.innerType._def,X)};var J2=($,X,W)=>{switch(X){case z.ZodString:return q1($,W);case z.ZodNumber:return r$($,W);case z.ZodObject:return a$($,W);case z.ZodBigInt:return f$($,W);case z.ZodBoolean:return T$();case z.ZodDate:return x1($,W);case z.ZodUndefined:return W2();case z.ZodNull:return p$(W);case z.ZodArray:return P$($,W);case z.ZodUnion:case z.ZodDiscriminatedUnion:return d$($,W);case z.ZodIntersection:return Z$($,W);case z.ZodTuple:return X2($,W);case z.ZodRecord:return O1($,W);case z.ZodLiteral:return m$($,W);case z.ZodEnum:return y$($);case z.ZodNativeEnum:return c$($);case z.ZodNullable:return o$($,W);case z.ZodOptional:return t$($,W);case z.ZodMap:return n$($,W);case z.ZodSet:return $2($,W);case z.ZodLazy:return()=>$.getter()._def;case z.ZodPromise:return e$($,W);case z.ZodNaN:case z.ZodNever:return u$();case z.ZodEffects:return h$($,W);case z.ZodAny:return I$();case z.ZodUnknown:return Q2();case z.ZodDefault:return x$($,W);case z.ZodBranded:return j1($,W);case z.ZodReadonly:return H2($,W);case z.ZodCatch:return g$($,W);case z.ZodPipeline:return s$($,W);case z.ZodFunction:case z.ZodVoid:case z.ZodSymbol:return;default:return((Q)=>{return})(X)}};function O($,X,W=!1){let Q=X.seen.get($);if(X.override){let B=X.override?.($,X,Q,W);if(B!==v$)return B}if(Q&&!W){let B=b6(Q,X);if(B!==void 0)return B}let H={def:$,path:X.currentPath,jsonSchema:void 0};X.seen.set($,H);let Y=J2($,$.typeName,X),G=typeof Y==="function"?O(Y(),X):Y;if(G)k6($,X,G);if(X.postProcess){let B=X.postProcess(G,$,X);return H.jsonSchema=G,B}return H.jsonSchema=G,G}var b6=($,X)=>{switch(X.$refStrategy){case"root":return{$ref:$.path.join("/")};case"relative":return{$ref:v6(X.currentPath,$.path)};case"none":case"seen":{if($.path.length<X.currentPath.length&&$.path.every((W,Q)=>X.currentPath[Q]===W))return console.warn(`Recursive reference detected at ${X.currentPath.join("/")}! Defaulting to any`),{};return X.$refStrategy==="seen"?{}:void 0}}},v6=($,X)=>{let W=0;for(;W<$.length&&W<X.length;W++)if($[W]!==X[W])break;return[($.length-W).toString(),...X.slice(W)].join("/")},k6=($,X,W)=>{if($.description){if(W.description=$.description,X.markdownDescription)W.markdownDescription=$.description}return W};var U1=($,X)=>{let W=C$(X),Q=typeof X==="object"&&X.definitions?Object.entries(X.definitions).reduce((w,[M,q])=>({...w,[M]:O(q._def,{...W,currentPath:[...W.basePath,W.definitionPath,M]},!0)??{}}),{}):void 0,H=typeof X==="string"?X:X?.nameStrategy==="title"?void 0:X?.name,Y=O($._def,H===void 0?W:{...W,currentPath:[...W.basePath,W.definitionPath,H]},!1)??{},G=typeof X==="object"&&X.name!==void 0&&X.nameStrategy==="title"?X.name:void 0;if(G!==void 0)Y.title=G;let B=H===void 0?Q?{...Y,[W.definitionPath]:Q}:Y:{$ref:[...W.$refStrategy==="relative"?[]:W.basePath,W.definitionPath,H].join("/"),[W.definitionPath]:{...Q,[H]:Y}};if(W.target==="jsonSchema7")B.$schema="http://json-schema.org/draft-07/schema#";else if(W.target==="jsonSchema2019-09"||W.target==="openAi")B.$schema="https://json-schema.org/draft/2019-09/schema#";if(W.target==="openAi"&&(("anyOf"in B)||("oneOf"in B)||("allOf"in B)||("type"in B)&&Array.isArray(B.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return B};d();h0();d();var Z1;(function($){$.Completable="McpCompletable"})(Z1||(Z1={}));class Z0 extends K{_parse($){let{ctx:X}=this._processInputParams($),W=X.data;return this._def.type._parse({data:W,path:X.path,parent:X})}unwrap(){return this._def.type}}Z0.create=($,X)=>{return new Z0({type:$,typeName:Z1.Completable,complete:X.complete,...C6(X)})};function C6($){if(!$)return{};let{errorMap:X,invalid_type_error:W,required_error:Q,description:H}=$;if(X&&(W||Q))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(X)return{errorMap:X,description:H};return{errorMap:(G,B)=>{var w,M;let{message:q}=$;if(G.code==="invalid_enum_value")return{message:q!==null&&q!==void 0?q:B.defaultError};if(typeof B.data==="undefined")return{message:(w=q!==null&&q!==void 0?q:Q)!==null&&w!==void 0?w:B.defaultError};if(G.code!=="invalid_type")return{message:B.defaultError};return{message:(M=q!==null&&q!==void 0?q:W)!==null&&M!==void 0?M:B.defaultError}},description:H}}class m1{constructor($,X){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new T1($,X)}async connect($){return await this.server.connect($)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(M1.shape.method.value),this.server.assertCanSetRequestHandler(A1.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(M1,()=>({tools:Object.entries(this._registeredTools).filter(([,$])=>$.enabled).map(([$,X])=>{let W={name:$,description:X.description,inputSchema:X.inputSchema?U1(X.inputSchema,{strictUnions:!0}):I6,annotations:X.annotations};if(X.outputSchema)W.outputSchema=U1(X.outputSchema,{strictUnions:!0});return W})})),this.server.setRequestHandler(A1,async($,X)=>{let W=this._registeredTools[$.params.name];if(!W)throw new R(_.InvalidParams,`Tool ${$.params.name} not found`);if(!W.enabled)throw new R(_.InvalidParams,`Tool ${$.params.name} disabled`);let Q;if(W.inputSchema){let H=await W.inputSchema.safeParseAsync($.params.arguments);if(!H.success)throw new R(_.InvalidParams,`Invalid arguments for tool ${$.params.name}: ${H.error.message}`);let Y=H.data,G=W.callback;try{Q=await Promise.resolve(G(Y,X))}catch(B){Q={content:[{type:"text",text:B instanceof Error?B.message:String(B)}],isError:!0}}}else{let H=W.callback;try{Q=await Promise.resolve(H(X))}catch(Y){Q={content:[{type:"text",text:Y instanceof Error?Y.message:String(Y)}],isError:!0}}}if(W.outputSchema){if(!Q.structuredContent)throw new R(_.InvalidParams,`Tool ${$.params.name} has an output schema but no structured content was provided`);let H=await W.outputSchema.safeParseAsync(Q.structuredContent);if(!H.success)throw new R(_.InvalidParams,`Invalid structured content for tool ${$.params.name}: ${H.error.message}`)}return Q}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(V1.shape.method.value),this.server.setRequestHandler(V1,async($)=>{switch($.params.ref.type){case"ref/prompt":return this.handlePromptCompletion($,$.params.ref);case"ref/resource":return this.handleResourceCompletion($,$.params.ref);default:throw new R(_.InvalidParams,`Invalid completion reference: ${$.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion($,X){let W=this._registeredPrompts[X.name];if(!W)throw new R(_.InvalidParams,`Prompt ${X.name} not found`);if(!W.enabled)throw new R(_.InvalidParams,`Prompt ${X.name} disabled`);if(!W.argsSchema)return K1;let Q=W.argsSchema.shape[$.params.argument.name];if(!(Q instanceof Z0))return K1;let Y=await Q._def.complete($.params.argument.value);return G2(Y)}async handleResourceCompletion($,X){let W=Object.values(this._registeredResourceTemplates).find((Y)=>Y.resourceTemplate.uriTemplate.toString()===X.uri);if(!W){if(this._registeredResources[X.uri])return K1;throw new R(_.InvalidParams,`Resource template ${$.params.ref.uri} not found`)}let Q=W.resourceTemplate.completeCallback($.params.argument.name);if(!Q)return K1;let H=await Q($.params.argument.value);return G2(H)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(H1.shape.method.value),this.server.assertCanSetRequestHandler(J1.shape.method.value),this.server.assertCanSetRequestHandler(Y1.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(H1,async($,X)=>{let W=Object.entries(this._registeredResources).filter(([H,Y])=>Y.enabled).map(([H,Y])=>({uri:H,name:Y.name,...Y.metadata})),Q=[];for(let H of Object.values(this._registeredResourceTemplates)){if(!H.resourceTemplate.listCallback)continue;let Y=await H.resourceTemplate.listCallback(X);for(let G of Y.resources)Q.push({...G,...H.metadata})}return{resources:[...W,...Q]}}),this.server.setRequestHandler(J1,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([X,W])=>({name:X,uriTemplate:W.resourceTemplate.uriTemplate.toString(),...W.metadata}))}}),this.server.setRequestHandler(Y1,async($,X)=>{let W=new URL($.params.uri),Q=this._registeredResources[W.toString()];if(Q){if(!Q.enabled)throw new R(_.InvalidParams,`Resource ${W} disabled`);return Q.readCallback(W,X)}for(let H of Object.values(this._registeredResourceTemplates)){let Y=H.resourceTemplate.uriTemplate.match(W.toString());if(Y)return H.readCallback(W,Y,X)}throw new R(_.InvalidParams,`Resource ${W} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler(G1.shape.method.value),this.server.assertCanSetRequestHandler(B1.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(G1,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,$])=>$.enabled).map(([$,X])=>{return{name:$,description:X.description,arguments:X.argsSchema?f6(X.argsSchema):void 0}})})),this.server.setRequestHandler(B1,async($,X)=>{let W=this._registeredPrompts[$.params.name];if(!W)throw new R(_.InvalidParams,`Prompt ${$.params.name} not found`);if(!W.enabled)throw new R(_.InvalidParams,`Prompt ${$.params.name} disabled`);if(W.argsSchema){let Q=await W.argsSchema.safeParseAsync($.params.arguments);if(!Q.success)throw new R(_.InvalidParams,`Invalid arguments for prompt ${$.params.name}: ${Q.error.message}`);let H=Q.data,Y=W.callback;return await Promise.resolve(Y(H,X))}else{let Q=W.callback;return await Promise.resolve(Q(X))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource($,X,...W){let Q;if(typeof W[0]==="object")Q=W.shift();let H=W[0];if(typeof X==="string"){if(this._registeredResources[X])throw new Error(`Resource ${X} is already registered`);let Y={name:$,metadata:Q,readCallback:H,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({uri:null}),update:(G)=>{if(typeof G.uri!=="undefined"&&G.uri!==X){if(delete this._registeredResources[X],G.uri)this._registeredResources[G.uri]=Y}if(typeof G.name!=="undefined")Y.name=G.name;if(typeof G.metadata!=="undefined")Y.metadata=G.metadata;if(typeof G.callback!=="undefined")Y.readCallback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendResourceListChanged()}};return this._registeredResources[X]=Y,this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}else{if(this._registeredResourceTemplates[$])throw new Error(`Resource template ${$} is already registered`);let Y={resourceTemplate:X,metadata:Q,readCallback:H,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(G)=>{if(typeof G.name!=="undefined"&&G.name!==$){if(delete this._registeredResourceTemplates[$],G.name)this._registeredResourceTemplates[G.name]=Y}if(typeof G.template!=="undefined")Y.resourceTemplate=G.template;if(typeof G.metadata!=="undefined")Y.metadata=G.metadata;if(typeof G.callback!=="undefined")Y.readCallback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendResourceListChanged()}};return this._registeredResourceTemplates[$]=Y,this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}}_createRegisteredTool($,X,W,Q,H,Y){let G={description:X,inputSchema:W===void 0?void 0:J.object(W),outputSchema:Q===void 0?void 0:J.object(Q),annotations:H,callback:Y,enabled:!0,disable:()=>G.update({enabled:!1}),enable:()=>G.update({enabled:!0}),remove:()=>G.update({name:null}),update:(B)=>{if(typeof B.name!=="undefined"&&B.name!==$){if(delete this._registeredTools[$],B.name)this._registeredTools[B.name]=G}if(typeof B.description!=="undefined")G.description=B.description;if(typeof B.paramsSchema!=="undefined")G.inputSchema=J.object(B.paramsSchema);if(typeof B.callback!=="undefined")G.callback=B.callback;if(typeof B.annotations!=="undefined")G.annotations=B.annotations;if(typeof B.enabled!=="undefined")G.enabled=B.enabled;this.sendToolListChanged()}};return this._registeredTools[$]=G,this.setToolRequestHandlers(),this.sendToolListChanged(),G}tool($,...X){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let W,Q,H,Y;if(typeof X[0]==="string")W=X.shift();if(X.length>1){let B=X[0];if(Y2(B)){if(Q=X.shift(),X.length>1&&typeof X[0]==="object"&&X[0]!==null&&!Y2(X[0]))Y=X.shift()}else if(typeof B==="object"&&B!==null)Y=X.shift()}let G=X[0];return this._createRegisteredTool($,W,Q,H,Y,G)}registerTool($,X,W){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let{description:Q,inputSchema:H,outputSchema:Y,annotations:G}=X;return this._createRegisteredTool($,Q,H,Y,G,W)}prompt($,...X){if(this._registeredPrompts[$])throw new Error(`Prompt ${$} is already registered`);let W;if(typeof X[0]==="string")W=X.shift();let Q;if(X.length>1)Q=X.shift();let H=X[0],Y={description:W,argsSchema:Q===void 0?void 0:J.object(Q),callback:H,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(G)=>{if(typeof G.name!=="undefined"&&G.name!==$){if(delete this._registeredPrompts[$],G.name)this._registeredPrompts[G.name]=Y}if(typeof G.description!=="undefined")Y.description=G.description;if(typeof G.argsSchema!=="undefined")Y.argsSchema=J.object(G.argsSchema);if(typeof G.callback!=="undefined")Y.callback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendPromptListChanged()}};return this._registeredPrompts[$]=Y,this.setPromptRequestHandlers(),this.sendPromptListChanged(),Y}isConnected(){return this.server.transport!==void 0}sendResourceListChanged(){if(this.isConnected())this.server.sendResourceListChanged()}sendToolListChanged(){if(this.isConnected())this.server.sendToolListChanged()}sendPromptListChanged(){if(this.isConnected())this.server.sendPromptListChanged()}}var I6={type:"object"};function Y2($){if(typeof $!=="object"||$===null)return!1;return Object.keys($).length===0||Object.values($).some(P6)}function P6($){return $!==null&&typeof $==="object"&&"parse"in $&&typeof $.parse==="function"&&"safeParse"in $&&typeof $.safeParse==="function"}function f6($){return Object.entries($.shape).map(([X,W])=>({name:X,description:W.description,required:!W.isOptional()}))}function G2($){return{completion:{values:$.slice(0,100),total:$.length,hasMore:$.length>100}}}var K1={completion:{values:[],hasMore:!1}};function B2($,X){let W=process.argv,Q=`--${$}=`;for(let H of W)if(H.startsWith(Q))return H.substring(Q.length);return X}D0();var x6=g("FigmaConfig",1),m0=B2("figma-api-key")||process.env.FIGMA_API_KEY||"",z2="F2C MCP",M2=process.env.FIGMA_VERSION||"0.0.1";x6.debug("DEFAULT_PERSONAL_TOKEN",m0);D0();var A2=g("F2cApi",1);class V2{f2cHost="https://f2c-figma-api.yy.com/api";personalToken=m0;async nodeToCode($){let X={fileKey:$.fileKey,nodeIds:$.ids,personal_token:$.personalToken||this.personalToken,option:{cssFramework:"inlinecss",imgFormat:$.imgFormat||"png",scaleSize:$.scaleSize||2},format:"files"};if($.format==="react-cssmodules")X.option.cssFramework="cssmodules";else if($.format==="react-tailwind")X.option.cssFramework="tailwindcss";let W=this.opToUrl(`${this.f2cHost}/nodes`,X);return this.fetch(W,"json")}async fetch($,X="json"){try{let W={method:"GET"};A2.debug("fetch",$);let Q=await fetch($,W);if(!Q.ok)throw new Error(`HTTP error! status: ${Q.status}`);return X==="text"?await Q.text():await Q.json()}catch(W){throw A2.error("HTTP error",W),W}}opToUrl($,X={}){if(Object.keys(X).length===0)return $;let W=new URL($);for(let[Q,H]of Object.entries(X))if(typeof H==="object"&&H!==null)for(let[Y,G]of Object.entries(H))W.searchParams.append(`${Q}[${Y}]`,G);else W.searchParams.append(Q,H);return W.toString()}}var j2=new V2;D0();d();var l0=c0(require("fs")),Q0=c0(require("path")),l1=c0(require("fs/promises"));D0();var c=g("Downloader");class q2{op;assetsPath="";savePath="";setup($){if(this.op=$,this.op.localPath)this.assetsPath=Q0.default.join(this.op.localPath,"assets"),this.savePath=this.op.localPath}async downloadImage($,X){let{imgFormat:W}=this.op,Q=this.assetsPath;try{if(!l0.default.existsSync(Q))l0.default.mkdirSync(Q,{recursive:!0});let H=`${X}.${W}`,Y=Q0.default.join(Q,H),G=await fetch($);if(!G.ok)throw new Error(`下载失败: ${G.status} ${G.statusText}`);let B=await G.arrayBuffer();return l0.default.writeFileSync(Y,new Uint8Array(B)),Q0.default.join(Q0.default.basename(Q),H).replace(/\\/g,"/")}catch(H){throw c.error("图片下载错误:",H),H}}async downLoadImageAndReplaceContent($){try{let X=/https:\/\/figma-alpha-api\.s3\.us-west-2\.amazonaws\.com\/images\/[a-f0-9-]+/g,W=$.match(X);if(!W)return $;let Q=[...new Set(W)],H=new Map;await Promise.all(Q.map(async(G)=>{let B=Q0.default.basename(G),w=await this.downloadImage(G,B);H.set(G,w)}));let Y=$;for(let[G,B]of H.entries()){let w=new RegExp(G.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");Y=Y.replace(w,B)}return Y}catch(X){throw c.error("内容处理错误:",X),X}}async checkLocalAndDownload($){if(!this.op.localPath)return;await Promise.all($.map(async(X)=>{X.content=await this.downLoadImageAndReplaceContent(X.content)}));for(let X of $)try{let W=await this.saveContentToFile(X.content,X.path);c.debug(`Successfully saved: ${W}`)}catch(W){c.error(`Failed to save file ${X.path}:`,W)}}async ensureDirectoryExists($){if(!l0.default.existsSync($))c.debug(`Creating directory: ${$}`),await l1.default.mkdir($,{recursive:!0})}async saveContentToFile($,X){try{let W=Q0.default.join(this.savePath,X),Q=Q0.default.dirname(W);if(c.debug(`Full path: ${W}, directory: ${Q}`),await this.ensureDirectoryExists(Q),X.endsWith(".html"))c.debug("Wrapping content with HTML template"),$=this.wrapHtmlContent($);return c.debug(`Writing ${$.length} bytes to file`),await l1.default.writeFile(W,$),c.info(`File saved: ${W}`),W}catch(W){throw c.error("File save error:",X,W),W}}wrapHtmlContent($){return c.debug("Wrapping content with HTML template"),`<!DOCTYPE html>
|
1
|
+
var g2=Object.create;var{getPrototypeOf:T2,defineProperty:R0,getOwnPropertyNames:y2}=Object;var x2=Object.prototype.hasOwnProperty;var p$=($,W,X)=>{X=$!=null?g2(T2($)):{};let Q=W||!$||!$.__esModule?R0(X,"default",{value:$,enumerable:!0}):X;for(let H of y2($))if(!x2.call(Q,H))R0(Q,H,{get:()=>$[H],enumerable:!0});return Q};var s6=($,W)=>()=>(W||$((W={exports:{}}).exports,W),W.exports);var h2=($,W)=>{for(var X in W)R0($,X,{get:W[X],enumerable:!0,configurable:!0,set:(Q)=>W[X]=()=>Q})};var f=($,W)=>()=>($&&(W=$($=0)),W);var U,v0,z,p=($)=>{switch(typeof $){case"undefined":return z.undefined;case"string":return z.string;case"number":return Number.isNaN($)?z.nan:z.number;case"boolean":return z.boolean;case"function":return z.function;case"bigint":return z.bigint;case"symbol":return z.symbol;case"object":if(Array.isArray($))return z.array;if($===null)return z.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return z.promise;if(typeof Map!=="undefined"&&$ instanceof Map)return z.map;if(typeof Set!=="undefined"&&$ instanceof Set)return z.set;if(typeof Date!=="undefined"&&$ instanceof Date)return z.date;return z.object;default:return z.unknown}};var f$=f(()=>{(function($){$.assertEqual=(H)=>{};function W(H){}$.assertIs=W;function X(H){throw new Error}$.assertNever=X,$.arrayToEnum=(H)=>{let Y={};for(let G of H)Y[G]=G;return Y},$.getValidEnumValues=(H)=>{let Y=$.objectKeys(H).filter((B)=>typeof H[H[B]]!=="number"),G={};for(let B of Y)G[B]=H[B];return $.objectValues(G)},$.objectValues=(H)=>{return $.objectKeys(H).map(function(Y){return H[Y]})},$.objectKeys=typeof Object.keys==="function"?(H)=>Object.keys(H):(H)=>{let Y=[];for(let G in H)if(Object.prototype.hasOwnProperty.call(H,G))Y.push(G);return Y},$.find=(H,Y)=>{for(let G of H)if(Y(G))return G;return},$.isInteger=typeof Number.isInteger==="function"?(H)=>Number.isInteger(H):(H)=>typeof H==="number"&&Number.isFinite(H)&&Math.floor(H)===H;function Q(H,Y=" | "){return H.map((G)=>typeof G==="string"?`'${G}'`:G).join(Y)}$.joinValues=Q,$.jsonStringifyReplacer=(H,Y)=>{if(typeof Y==="bigint")return Y.toString();return Y}})(U||(U={}));(function($){$.mergeShapes=(W,X)=>{return{...W,...X}}})(v0||(v0={}));z=U.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"])});var w,Z2=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")},k;var d$=f(()=>{f$();w=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"]);k=class k extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(X)=>{this.issues=[...this.issues,X]},this.addIssues=(X=[])=>{this.issues=[...this.issues,...X]};let W=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,W);else this.__proto__=W;this.name="ZodError",this.issues=$}format($){let W=$||function(H){return H.message},X={_errors:[]},Q=(H)=>{for(let Y of H.issues)if(Y.code==="invalid_union")Y.unionErrors.map(Q);else if(Y.code==="invalid_return_type")Q(Y.returnTypeError);else if(Y.code==="invalid_arguments")Q(Y.argumentsError);else if(Y.path.length===0)X._errors.push(W(Y));else{let G=X,B=0;while(B<Y.path.length){let D=Y.path[B];if(B!==Y.path.length-1)G[D]=G[D]||{_errors:[]};else G[D]=G[D]||{_errors:[]},G[D]._errors.push(W(Y));G=G[D],B++}}};return Q(this),X}static assert($){if(!($ instanceof k))throw new Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,U.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(W)=>W.message){let W={},X=[];for(let Q of this.issues)if(Q.path.length>0)W[Q.path[0]]=W[Q.path[0]]||[],W[Q.path[0]].push($(Q));else X.push($(Q));return{formErrors:X,fieldErrors:W}}get formErrors(){return this.flatten()}};k.create=($)=>{return new k($)}});var m2=($,W)=>{let X;switch($.code){case w.invalid_type:if($.received===z.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case w.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,U.jsonStringifyReplacer)}`;break;case w.unrecognized_keys:X=`Unrecognized key(s) in object: ${U.joinValues($.keys,", ")}`;break;case w.invalid_union:X="Invalid input";break;case w.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${U.joinValues($.options)}`;break;case w.invalid_enum_value:X=`Invalid enum value. Expected ${U.joinValues($.options)}, received '${$.received}'`;break;case w.invalid_arguments:X="Invalid function arguments";break;case w.invalid_return_type:X="Invalid function return type";break;case w.invalid_date:X="Invalid date";break;case w.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(X=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")X=`${X} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)X=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)X=`Invalid input: must end with "${$.validation.endsWith}"`;else U.assertNever($.validation);else if($.validation!=="regex")X=`Invalid ${$.validation}`;else X="Invalid";break;case w.too_small:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else X="Invalid input";break;case w.too_big:if($.type==="array")X=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")X=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")X=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")X=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")X=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else X="Invalid input";break;case w.custom:X="Invalid input";break;case w.invalid_intersection_types:X="Intersection results could not be merged";break;case w.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case w.not_finite:X="Number must be finite";break;default:X=W.defaultError,U.assertNever($)}return{message:X}},a;var k0=f(()=>{d$();f$();a=m2});function l2($){W3=$}function A$(){return W3}var W3;var o$=f(()=>{k0();W3=a});function j($,W){let X=A$(),Q=I$({issueData:W,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===a?void 0:a].filter((H)=>!!H)});$.common.issues.push(Q)}class E{constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,W){let X=[];for(let Q of W){if(Q.status==="aborted")return b;if(Q.status==="dirty")$.dirty();X.push(Q.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,W){let X=[];for(let Q of W){let H=await Q.key,Y=await Q.value;X.push({key:H,value:Y})}return E.mergeObjectSync($,X)}static mergeObjectSync($,W){let X={};for(let Q of W){let{key:H,value:Y}=Q;if(H.status==="aborted")return b;if(Y.status==="aborted")return b;if(H.status==="dirty")$.dirty();if(Y.status==="dirty")$.dirty();if(H.value!=="__proto__"&&(typeof Y.value!=="undefined"||Q.alwaysSet))X[H.value]=Y.value}return{status:$.value,value:X}}}var I$=($)=>{let{data:W,path:X,errorMaps:Q,issueData:H}=$,Y=[...X,...H.path||[]],G={...H,path:Y};if(H.message!==void 0)return{...H,path:Y,message:H.message};let B="",D=Q.filter((A)=>!!A).slice().reverse();for(let A of D)B=A(G,{data:W,defaultError:B}).message;return{...H,path:Y,message:B}},n2,b,B$=($)=>({status:"dirty",value:$}),R=($)=>({status:"valid",value:$}),r$=($)=>$.status==="aborted",a$=($)=>$.status==="dirty",$$=($)=>$.status==="valid",V$=($)=>typeof Promise!=="undefined"&&$ instanceof Promise;var f0=f(()=>{o$();k0();n2=[];b=Object.freeze({status:"aborted"})});var X3=()=>{};var V;var Q3=f(()=>{(function($){$.errToObj=(W)=>typeof W==="string"?{message:W}:W||{},$.toString=(W)=>typeof W==="string"?W:W?.message})(V||(V={}))});class h{constructor($,W,X,Q){this._cachedPath=[],this.parent=$,this.data=W,this._path=X,this._key=Q}get path(){if(!this._cachedPath.length)if(Array.isArray(this._key))this._cachedPath.push(...this._path,...this._key);else this._cachedPath.push(...this._path,this._key);return this._cachedPath}}function O($){if(!$)return{};let{errorMap:W,invalid_type_error:X,required_error:Q,description:H}=$;if(W&&(X||Q))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(W)return{errorMap:W,description:H};return{errorMap:(G,B)=>{let{message:D}=$;if(G.code==="invalid_enum_value")return{message:D??B.defaultError};if(typeof B.data==="undefined")return{message:D??Q??B.defaultError};if(G.code!=="invalid_type")return{message:B.defaultError};return{message:D??X??B.defaultError}},description:H}}class _{get description(){return this._def.description}_getType($){return p($.data)}_getOrReturnCtx($,W){return W||{common:$.parent.common,data:$.data,parsedType:p($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new E,ctx:{common:$.parent.common,data:$.data,parsedType:p($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let W=this._parse($);if(V$(W))throw new Error("Synchronous parse encountered promise.");return W}_parseAsync($){let W=this._parse($);return Promise.resolve(W)}parse($,W){let X=this.safeParse($,W);if(X.success)return X.data;throw X.error}safeParse($,W){let X={common:{issues:[],async:W?.async??!1,contextualErrorMap:W?.errorMap},path:W?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:p($)},Q=this._parseSync({data:$,path:X.path,parent:X});return H3(X,Q)}"~validate"($){let W={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:p($)};if(!this["~standard"].async)try{let X=this._parseSync({data:$,path:[],parent:W});return $$(X)?{value:X.value}:{issues:W.common.issues}}catch(X){if(X?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;W.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:W}).then((X)=>$$(X)?{value:X.value}:{issues:W.common.issues})}async parseAsync($,W){let X=await this.safeParseAsync($,W);if(X.success)return X.data;throw X.error}async safeParseAsync($,W){let X={common:{issues:[],contextualErrorMap:W?.errorMap,async:!0},path:W?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:p($)},Q=this._parse({data:$,path:X.path,parent:X}),H=await(V$(Q)?Q:Promise.resolve(Q));return H3(X,H)}refine($,W){let X=(Q)=>{if(typeof W==="string"||typeof W==="undefined")return{message:W};else if(typeof W==="function")return W(Q);else return W};return this._refinement((Q,H)=>{let Y=$(Q),G=()=>H.addIssue({code:w.custom,...X(Q)});if(typeof Promise!=="undefined"&&Y instanceof Promise)return Y.then((B)=>{if(!B)return G(),!1;else return!0});if(!Y)return G(),!1;else return!0})}refinement($,W){return this._refinement((X,Q)=>{if(!$(X))return Q.addIssue(typeof W==="function"?W(X,Q):W),!1;else return!0})}_refinement($){return new Z({schema:this,typeName:M.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,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:(W)=>this["~validate"](W)}}optional(){return I.create(this,this._def)}nullable(){return s.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return x.create(this)}promise(){return z$.create(this,this._def)}or($){return U$.create([this,$],this._def)}and($){return K$.create(this,$,this._def)}transform($){return new Z({...O(this._def),schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:$}})}default($){let W=typeof $==="function"?$:()=>$;return new E$({...O(this._def),innerType:this,defaultValue:W,typeName:M.ZodDefault})}brand(){return new e$({typeName:M.ZodBranded,type:this,...O(this._def)})}catch($){let W=typeof $==="function"?$:()=>$;return new R$({...O(this._def),innerType:this,catchValue:W,typeName:M.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return Z$.create(this,$)}readonly(){return v$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}function B3($){let W="[0-5]\\d";if($.precision)W=`${W}\\.\\d{${$.precision}}`;else if($.precision==null)W=`${W}(\\.\\d+)?`;let X=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${W})${X}`}function J1($){return new RegExp(`^${B3($)}$`)}function D3($){let W=`${G3}T${B3($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return W=`${W}(${X.join("|")})`,new RegExp(`^${W}$`)}function Y1($,W){if((W==="v4"||!W)&&s2.test($))return!0;if((W==="v6"||!W)&&$1.test($))return!0;return!1}function G1($,W){if(!o2.test($))return!1;try{let[X]=$.split("."),Q=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),H=JSON.parse(atob(Q));if(typeof H!=="object"||H===null)return!1;if("typ"in H&&H?.typ!=="JWT")return!1;if(!H.alg)return!1;if(W&&H.alg!==W)return!1;return!0}catch{return!1}}function B1($,W){if((W==="v4"||!W)&&e2.test($))return!0;if((W==="v6"||!W)&&W1.test($))return!0;return!1}function D1($,W){let X=($.toString().split(".")[1]||"").length,Q=(W.toString().split(".")[1]||"").length,H=X>Q?X:Q,Y=Number.parseInt($.toFixed(H).replace(".","")),G=Number.parseInt(W.toFixed(H).replace(".",""));return Y%G/10**H}function b$($){if($ instanceof S){let W={};for(let X in $.shape){let Q=$.shape[X];W[X]=I.create(b$(Q))}return new S({...$._def,shape:()=>W})}else if($ instanceof x)return new x({...$._def,type:b$($.element)});else if($ instanceof I)return I.create(b$($.unwrap()));else if($ instanceof s)return s.create(b$($.unwrap()));else if($ instanceof o)return o.create($.items.map((W)=>b$(W)));else return $}function C0($,W){let X=p($),Q=p(W);if($===W)return{valid:!0,data:$};else if(X===z.object&&Q===z.object){let H=U.objectKeys(W),Y=U.objectKeys($).filter((B)=>H.indexOf(B)!==-1),G={...$,...W};for(let B of Y){let D=C0($[B],W[B]);if(!D.valid)return{valid:!1};G[B]=D.data}return{valid:!0,data:G}}else if(X===z.array&&Q===z.array){if($.length!==W.length)return{valid:!1};let H=[];for(let Y=0;Y<$.length;Y++){let G=$[Y],B=W[Y],D=C0(G,B);if(!D.valid)return{valid:!1};H.push(D.data)}return{valid:!0,data:H}}else if(X===z.date&&Q===z.date&&+$===+W)return{valid:!0,data:$};else return{valid:!1}}function w3($,W){return new H$({values:$,typeName:M.ZodEnum,...O(W)})}function J3($,W){let X=typeof $==="function"?$(W):typeof $==="string"?{message:$}:$;return typeof X==="string"?{message:X}:X}function M3($,W={},X){if($)return w$.create().superRefine((Q,H)=>{let Y=$(Q);if(Y instanceof Promise)return Y.then((G)=>{if(!G){let B=J3(W,Q),D=B.fatal??X??!0;H.addIssue({code:"custom",...B,fatal:D})}});if(!Y){let G=J3(W,Q),B=G.fatal??X??!0;H.addIssue({code:"custom",...G,fatal:B})}return});return w$.create()}var t$=function($,W,X,Q){if(X==="a"&&!Q)throw new TypeError("Private accessor was defined without a getter");if(typeof W==="function"?$!==W||!Q:!W.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?Q:X==="a"?Q.call($):Q?Q.value:W.get($)},Y3=function($,W,X,Q,H){if(Q==="m")throw new TypeError("Private method is not writable");if(Q==="a"&&!H)throw new TypeError("Private accessor was defined without a setter");if(typeof W==="function"?$!==W||!H:!W.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return Q==="a"?H.call($,X):H?H.value=X:W.set($,X),X},C$,P$,H3=($,W)=>{if($$(W))return{success:!0,data:W.value};else{if(!$.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let X=new k($.common.issues);return this._error=X,this._error}}}},u2,c2,i2,p2,d2,o2,r2,a2,t2="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",I0,s2,e2,$1,W1,X1,Q1,G3="((\\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])))",H1,y,X$,Q$,O$,D$,g$,q$,_$,w$,W$,d,T$,x,S,U$,t=($)=>{if($ instanceof S$)return t($.schema);else if($ instanceof Z)return t($.innerType());else if($ instanceof L$)return[$.value];else if($ instanceof H$)return $.options;else if($ instanceof F$)return U.objectValues($.enum);else if($ instanceof E$)return t($._def.innerType);else if($ instanceof q$)return[void 0];else if($ instanceof _$)return[null];else if($ instanceof I)return[void 0,...t($.unwrap())];else if($ instanceof s)return[null,...t($.unwrap())];else if($ instanceof e$)return t($.unwrap());else if($ instanceof v$)return t($.unwrap());else if($ instanceof R$)return t($._def.innerType);else return[]},s$,K$,o,y$,x$,M$,N$,S$,L$,H$,F$,z$,Z,I,s,E$,R$,h$,w1,e$,Z$,v$,M1,M,z1=($,W={message:`Input not instance of ${$.name}`})=>M3((X)=>X instanceof $,W),z3,j3,j1,A1,A3,V1,b1,N1,O1,q1,_1,U1,K1,S1,L1,F1,E1,R1,v1,k1,f1,I1,C1,P1,g1,T1,y1,x1,h1,Z1,m1,l1,n1,u1,c1=()=>z3().optional(),i1=()=>j3().optional(),p1=()=>A3().optional(),d1,o1;var V3=f(()=>{d$();o$();Q3();f0();f$();u2=/^c[^\s-]{8,}$/i,c2=/^[0-9a-z]+$/,i2=/^[0-9A-HJKMNP-TV-Z]{26}$/i,p2=/^[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,d2=/^[a-z0-9_-]{21}$/i,o2=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,r2=/^[-+]?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)?)??$/,a2=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,s2=/^(?:(?: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])$/,e2=/^(?:(?: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])$/,$1=/^(([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]))$/,W1=/^(([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])$/,X1=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,Q1=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,H1=new RegExp(`^${G3}$`);y=class y extends _{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==z.string){let H=this._getOrReturnCtx($);return j(H,{code:w.invalid_type,expected:z.string,received:H.parsedType}),b}let X=new E,Q=void 0;for(let H of this._def.checks)if(H.kind==="min"){if($.data.length<H.value)Q=this._getOrReturnCtx($,Q),j(Q,{code:w.too_small,minimum:H.value,type:"string",inclusive:!0,exact:!1,message:H.message}),X.dirty()}else if(H.kind==="max"){if($.data.length>H.value)Q=this._getOrReturnCtx($,Q),j(Q,{code:w.too_big,maximum:H.value,type:"string",inclusive:!0,exact:!1,message:H.message}),X.dirty()}else if(H.kind==="length"){let Y=$.data.length>H.value,G=$.data.length<H.value;if(Y||G){if(Q=this._getOrReturnCtx($,Q),Y)j(Q,{code:w.too_big,maximum:H.value,type:"string",inclusive:!0,exact:!0,message:H.message});else if(G)j(Q,{code:w.too_small,minimum:H.value,type:"string",inclusive:!0,exact:!0,message:H.message});X.dirty()}}else if(H.kind==="email"){if(!a2.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"email",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="emoji"){if(!I0)I0=new RegExp(t2,"u");if(!I0.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"emoji",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="uuid"){if(!p2.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"uuid",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="nanoid"){if(!d2.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"nanoid",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="cuid"){if(!u2.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"cuid",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="cuid2"){if(!c2.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"cuid2",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="ulid"){if(!i2.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"ulid",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="url")try{new URL($.data)}catch{Q=this._getOrReturnCtx($,Q),j(Q,{validation:"url",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="regex"){if(H.regex.lastIndex=0,!H.regex.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"regex",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="trim")$.data=$.data.trim();else if(H.kind==="includes"){if(!$.data.includes(H.value,H.position))Q=this._getOrReturnCtx($,Q),j(Q,{code:w.invalid_string,validation:{includes:H.value,position:H.position},message:H.message}),X.dirty()}else if(H.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(H.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(H.kind==="startsWith"){if(!$.data.startsWith(H.value))Q=this._getOrReturnCtx($,Q),j(Q,{code:w.invalid_string,validation:{startsWith:H.value},message:H.message}),X.dirty()}else if(H.kind==="endsWith"){if(!$.data.endsWith(H.value))Q=this._getOrReturnCtx($,Q),j(Q,{code:w.invalid_string,validation:{endsWith:H.value},message:H.message}),X.dirty()}else if(H.kind==="datetime"){if(!D3(H).test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{code:w.invalid_string,validation:"datetime",message:H.message}),X.dirty()}else if(H.kind==="date"){if(!H1.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{code:w.invalid_string,validation:"date",message:H.message}),X.dirty()}else if(H.kind==="time"){if(!J1(H).test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{code:w.invalid_string,validation:"time",message:H.message}),X.dirty()}else if(H.kind==="duration"){if(!r2.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"duration",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="ip"){if(!Y1($.data,H.version))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"ip",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="jwt"){if(!G1($.data,H.alg))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"jwt",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="cidr"){if(!B1($.data,H.version))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"cidr",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="base64"){if(!X1.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"base64",code:w.invalid_string,message:H.message}),X.dirty()}else if(H.kind==="base64url"){if(!Q1.test($.data))Q=this._getOrReturnCtx($,Q),j(Q,{validation:"base64url",code:w.invalid_string,message:H.message}),X.dirty()}else U.assertNever(H);return{status:X.value,value:$.data}}_regex($,W,X){return this.refinement((Q)=>$.test(Q),{validation:W,code:w.invalid_string,...V.errToObj(X)})}_addCheck($){return new y({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...V.errToObj($)})}url($){return this._addCheck({kind:"url",...V.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...V.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...V.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...V.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...V.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...V.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...V.errToObj($)})}base64($){return this._addCheck({kind:"base64",...V.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...V.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...V.errToObj($)})}ip($){return this._addCheck({kind:"ip",...V.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...V.errToObj($)})}datetime($){if(typeof $==="string")return this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:$});return this._addCheck({kind:"datetime",precision:typeof $?.precision==="undefined"?null:$?.precision,offset:$?.offset??!1,local:$?.local??!1,...V.errToObj($?.message)})}date($){return this._addCheck({kind:"date",message:$})}time($){if(typeof $==="string")return this._addCheck({kind:"time",precision:null,message:$});return this._addCheck({kind:"time",precision:typeof $?.precision==="undefined"?null:$?.precision,...V.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...V.errToObj($)})}regex($,W){return this._addCheck({kind:"regex",regex:$,...V.errToObj(W)})}includes($,W){return this._addCheck({kind:"includes",value:$,position:W?.position,...V.errToObj(W?.message)})}startsWith($,W){return this._addCheck({kind:"startsWith",value:$,...V.errToObj(W)})}endsWith($,W){return this._addCheck({kind:"endsWith",value:$,...V.errToObj(W)})}min($,W){return this._addCheck({kind:"min",value:$,...V.errToObj(W)})}max($,W){return this._addCheck({kind:"max",value:$,...V.errToObj(W)})}length($,W){return this._addCheck({kind:"length",value:$,...V.errToObj(W)})}nonempty($){return this.min(1,V.errToObj($))}trim(){return new y({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new y({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new y({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxLength(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}};y.create=($)=>{return new y({checks:[],typeName:M.ZodString,coerce:$?.coerce??!1,...O($)})};X$=class X$ extends _{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse($){if(this._def.coerce)$.data=Number($.data);if(this._getType($)!==z.number){let H=this._getOrReturnCtx($);return j(H,{code:w.invalid_type,expected:z.number,received:H.parsedType}),b}let X=void 0,Q=new E;for(let H of this._def.checks)if(H.kind==="int"){if(!U.isInteger($.data))X=this._getOrReturnCtx($,X),j(X,{code:w.invalid_type,expected:"integer",received:"float",message:H.message}),Q.dirty()}else if(H.kind==="min"){if(H.inclusive?$.data<H.value:$.data<=H.value)X=this._getOrReturnCtx($,X),j(X,{code:w.too_small,minimum:H.value,type:"number",inclusive:H.inclusive,exact:!1,message:H.message}),Q.dirty()}else if(H.kind==="max"){if(H.inclusive?$.data>H.value:$.data>=H.value)X=this._getOrReturnCtx($,X),j(X,{code:w.too_big,maximum:H.value,type:"number",inclusive:H.inclusive,exact:!1,message:H.message}),Q.dirty()}else if(H.kind==="multipleOf"){if(D1($.data,H.value)!==0)X=this._getOrReturnCtx($,X),j(X,{code:w.not_multiple_of,multipleOf:H.value,message:H.message}),Q.dirty()}else if(H.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),j(X,{code:w.not_finite,message:H.message}),Q.dirty()}else U.assertNever(H);return{status:Q.value,value:$.data}}gte($,W){return this.setLimit("min",$,!0,V.toString(W))}gt($,W){return this.setLimit("min",$,!1,V.toString(W))}lte($,W){return this.setLimit("max",$,!0,V.toString(W))}lt($,W){return this.setLimit("max",$,!1,V.toString(W))}setLimit($,W,X,Q){return new X$({...this._def,checks:[...this._def.checks,{kind:$,value:W,inclusive:X,message:V.toString(Q)}]})}_addCheck($){return new X$({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:V.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:V.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:V.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:V.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:V.toString($)})}multipleOf($,W){return this._addCheck({kind:"multipleOf",value:$,message:V.toString(W)})}finite($){return this._addCheck({kind:"finite",message:V.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:V.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:V.toString($)})}get minValue(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxValue(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&U.isInteger($.value))}get isFinite(){let $=null,W=null;for(let X of this._def.checks)if(X.kind==="finite"||X.kind==="int"||X.kind==="multipleOf")return!0;else if(X.kind==="min"){if(W===null||X.value>W)W=X.value}else if(X.kind==="max"){if($===null||X.value<$)$=X.value}return Number.isFinite(W)&&Number.isFinite($)}};X$.create=($)=>{return new X$({checks:[],typeName:M.ZodNumber,coerce:$?.coerce||!1,...O($)})};Q$=class Q$ extends _{constructor(){super(...arguments);this.min=this.gte,this.max=this.lte}_parse($){if(this._def.coerce)try{$.data=BigInt($.data)}catch{return this._getInvalidInput($)}if(this._getType($)!==z.bigint)return this._getInvalidInput($);let X=void 0,Q=new E;for(let H of this._def.checks)if(H.kind==="min"){if(H.inclusive?$.data<H.value:$.data<=H.value)X=this._getOrReturnCtx($,X),j(X,{code:w.too_small,type:"bigint",minimum:H.value,inclusive:H.inclusive,message:H.message}),Q.dirty()}else if(H.kind==="max"){if(H.inclusive?$.data>H.value:$.data>=H.value)X=this._getOrReturnCtx($,X),j(X,{code:w.too_big,type:"bigint",maximum:H.value,inclusive:H.inclusive,message:H.message}),Q.dirty()}else if(H.kind==="multipleOf"){if($.data%H.value!==BigInt(0))X=this._getOrReturnCtx($,X),j(X,{code:w.not_multiple_of,multipleOf:H.value,message:H.message}),Q.dirty()}else U.assertNever(H);return{status:Q.value,value:$.data}}_getInvalidInput($){let W=this._getOrReturnCtx($);return j(W,{code:w.invalid_type,expected:z.bigint,received:W.parsedType}),b}gte($,W){return this.setLimit("min",$,!0,V.toString(W))}gt($,W){return this.setLimit("min",$,!1,V.toString(W))}lte($,W){return this.setLimit("max",$,!0,V.toString(W))}lt($,W){return this.setLimit("max",$,!1,V.toString(W))}setLimit($,W,X,Q){return new Q$({...this._def,checks:[...this._def.checks,{kind:$,value:W,inclusive:X,message:V.toString(Q)}]})}_addCheck($){return new Q$({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:V.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:V.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:V.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:V.toString($)})}multipleOf($,W){return this._addCheck({kind:"multipleOf",value:$,message:V.toString(W)})}get minValue(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $}get maxValue(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $}};Q$.create=($)=>{return new Q$({checks:[],typeName:M.ZodBigInt,coerce:$?.coerce??!1,...O($)})};O$=class O$ extends _{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==z.boolean){let X=this._getOrReturnCtx($);return j(X,{code:w.invalid_type,expected:z.boolean,received:X.parsedType}),b}return R($.data)}};O$.create=($)=>{return new O$({typeName:M.ZodBoolean,coerce:$?.coerce||!1,...O($)})};D$=class D$ extends _{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==z.date){let H=this._getOrReturnCtx($);return j(H,{code:w.invalid_type,expected:z.date,received:H.parsedType}),b}if(Number.isNaN($.data.getTime())){let H=this._getOrReturnCtx($);return j(H,{code:w.invalid_date}),b}let X=new E,Q=void 0;for(let H of this._def.checks)if(H.kind==="min"){if($.data.getTime()<H.value)Q=this._getOrReturnCtx($,Q),j(Q,{code:w.too_small,message:H.message,inclusive:!0,exact:!1,minimum:H.value,type:"date"}),X.dirty()}else if(H.kind==="max"){if($.data.getTime()>H.value)Q=this._getOrReturnCtx($,Q),j(Q,{code:w.too_big,message:H.message,inclusive:!0,exact:!1,maximum:H.value,type:"date"}),X.dirty()}else U.assertNever(H);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new D$({...this._def,checks:[...this._def.checks,$]})}min($,W){return this._addCheck({kind:"min",value:$.getTime(),message:V.toString(W)})}max($,W){return this._addCheck({kind:"max",value:$.getTime(),message:V.toString(W)})}get minDate(){let $=null;for(let W of this._def.checks)if(W.kind==="min"){if($===null||W.value>$)$=W.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let W of this._def.checks)if(W.kind==="max"){if($===null||W.value<$)$=W.value}return $!=null?new Date($):null}};D$.create=($)=>{return new D$({checks:[],coerce:$?.coerce||!1,typeName:M.ZodDate,...O($)})};g$=class g$ extends _{_parse($){if(this._getType($)!==z.symbol){let X=this._getOrReturnCtx($);return j(X,{code:w.invalid_type,expected:z.symbol,received:X.parsedType}),b}return R($.data)}};g$.create=($)=>{return new g$({typeName:M.ZodSymbol,...O($)})};q$=class q$ extends _{_parse($){if(this._getType($)!==z.undefined){let X=this._getOrReturnCtx($);return j(X,{code:w.invalid_type,expected:z.undefined,received:X.parsedType}),b}return R($.data)}};q$.create=($)=>{return new q$({typeName:M.ZodUndefined,...O($)})};_$=class _$ extends _{_parse($){if(this._getType($)!==z.null){let X=this._getOrReturnCtx($);return j(X,{code:w.invalid_type,expected:z.null,received:X.parsedType}),b}return R($.data)}};_$.create=($)=>{return new _$({typeName:M.ZodNull,...O($)})};w$=class w$ extends _{constructor(){super(...arguments);this._any=!0}_parse($){return R($.data)}};w$.create=($)=>{return new w$({typeName:M.ZodAny,...O($)})};W$=class W$ extends _{constructor(){super(...arguments);this._unknown=!0}_parse($){return R($.data)}};W$.create=($)=>{return new W$({typeName:M.ZodUnknown,...O($)})};d=class d extends _{_parse($){let W=this._getOrReturnCtx($);return j(W,{code:w.invalid_type,expected:z.never,received:W.parsedType}),b}};d.create=($)=>{return new d({typeName:M.ZodNever,...O($)})};T$=class T$ extends _{_parse($){if(this._getType($)!==z.undefined){let X=this._getOrReturnCtx($);return j(X,{code:w.invalid_type,expected:z.void,received:X.parsedType}),b}return R($.data)}};T$.create=($)=>{return new T$({typeName:M.ZodVoid,...O($)})};x=class x extends _{_parse($){let{ctx:W,status:X}=this._processInputParams($),Q=this._def;if(W.parsedType!==z.array)return j(W,{code:w.invalid_type,expected:z.array,received:W.parsedType}),b;if(Q.exactLength!==null){let Y=W.data.length>Q.exactLength.value,G=W.data.length<Q.exactLength.value;if(Y||G)j(W,{code:Y?w.too_big:w.too_small,minimum:G?Q.exactLength.value:void 0,maximum:Y?Q.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:Q.exactLength.message}),X.dirty()}if(Q.minLength!==null){if(W.data.length<Q.minLength.value)j(W,{code:w.too_small,minimum:Q.minLength.value,type:"array",inclusive:!0,exact:!1,message:Q.minLength.message}),X.dirty()}if(Q.maxLength!==null){if(W.data.length>Q.maxLength.value)j(W,{code:w.too_big,maximum:Q.maxLength.value,type:"array",inclusive:!0,exact:!1,message:Q.maxLength.message}),X.dirty()}if(W.common.async)return Promise.all([...W.data].map((Y,G)=>{return Q.type._parseAsync(new h(W,Y,W.path,G))})).then((Y)=>{return E.mergeArray(X,Y)});let H=[...W.data].map((Y,G)=>{return Q.type._parseSync(new h(W,Y,W.path,G))});return E.mergeArray(X,H)}get element(){return this._def.type}min($,W){return new x({...this._def,minLength:{value:$,message:V.toString(W)}})}max($,W){return new x({...this._def,maxLength:{value:$,message:V.toString(W)}})}length($,W){return new x({...this._def,exactLength:{value:$,message:V.toString(W)}})}nonempty($){return this.min(1,$)}};x.create=($,W)=>{return new x({type:$,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...O(W)})};S=class S extends _{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),W=U.objectKeys($);return this._cached={shape:$,keys:W},this._cached}_parse($){if(this._getType($)!==z.object){let D=this._getOrReturnCtx($);return j(D,{code:w.invalid_type,expected:z.object,received:D.parsedType}),b}let{status:X,ctx:Q}=this._processInputParams($),{shape:H,keys:Y}=this._getCached(),G=[];if(!(this._def.catchall instanceof d&&this._def.unknownKeys==="strip")){for(let D in Q.data)if(!Y.includes(D))G.push(D)}let B=[];for(let D of Y){let A=H[D],q=Q.data[D];B.push({key:{status:"valid",value:D},value:A._parse(new h(Q,q,Q.path,D)),alwaysSet:D in Q.data})}if(this._def.catchall instanceof d){let D=this._def.unknownKeys;if(D==="passthrough")for(let A of G)B.push({key:{status:"valid",value:A},value:{status:"valid",value:Q.data[A]}});else if(D==="strict"){if(G.length>0)j(Q,{code:w.unrecognized_keys,keys:G}),X.dirty()}else if(D==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let D=this._def.catchall;for(let A of G){let q=Q.data[A];B.push({key:{status:"valid",value:A},value:D._parse(new h(Q,q,Q.path,A)),alwaysSet:A in Q.data})}}if(Q.common.async)return Promise.resolve().then(async()=>{let D=[];for(let A of B){let q=await A.key,P=await A.value;D.push({key:q,value:P,alwaysSet:A.alwaysSet})}return D}).then((D)=>{return E.mergeObjectSync(X,D)});else return E.mergeObjectSync(X,B)}get shape(){return this._def.shape()}strict($){return V.errToObj,new S({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(W,X)=>{let Q=this._def.errorMap?.(W,X).message??X.defaultError;if(W.code==="unrecognized_keys")return{message:V.errToObj($).message??Q};return{message:Q}}}:{}})}strip(){return new S({...this._def,unknownKeys:"strip"})}passthrough(){return new S({...this._def,unknownKeys:"passthrough"})}extend($){return new S({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new S({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:M.ZodObject})}setKey($,W){return this.augment({[$]:W})}catchall($){return new S({...this._def,catchall:$})}pick($){let W={};for(let X of U.objectKeys($))if($[X]&&this.shape[X])W[X]=this.shape[X];return new S({...this._def,shape:()=>W})}omit($){let W={};for(let X of U.objectKeys(this.shape))if(!$[X])W[X]=this.shape[X];return new S({...this._def,shape:()=>W})}deepPartial(){return b$(this)}partial($){let W={};for(let X of U.objectKeys(this.shape)){let Q=this.shape[X];if($&&!$[X])W[X]=Q;else W[X]=Q.optional()}return new S({...this._def,shape:()=>W})}required($){let W={};for(let X of U.objectKeys(this.shape))if($&&!$[X])W[X]=this.shape[X];else{let H=this.shape[X];while(H instanceof I)H=H._def.innerType;W[X]=H}return new S({...this._def,shape:()=>W})}keyof(){return w3(U.objectKeys(this.shape))}};S.create=($,W)=>{return new S({shape:()=>$,unknownKeys:"strip",catchall:d.create(),typeName:M.ZodObject,...O(W)})};S.strictCreate=($,W)=>{return new S({shape:()=>$,unknownKeys:"strict",catchall:d.create(),typeName:M.ZodObject,...O(W)})};S.lazycreate=($,W)=>{return new S({shape:$,unknownKeys:"strip",catchall:d.create(),typeName:M.ZodObject,...O(W)})};U$=class U$ extends _{_parse($){let{ctx:W}=this._processInputParams($),X=this._def.options;function Q(H){for(let G of H)if(G.result.status==="valid")return G.result;for(let G of H)if(G.result.status==="dirty")return W.common.issues.push(...G.ctx.common.issues),G.result;let Y=H.map((G)=>new k(G.ctx.common.issues));return j(W,{code:w.invalid_union,unionErrors:Y}),b}if(W.common.async)return Promise.all(X.map(async(H)=>{let Y={...W,common:{...W.common,issues:[]},parent:null};return{result:await H._parseAsync({data:W.data,path:W.path,parent:Y}),ctx:Y}})).then(Q);else{let H=void 0,Y=[];for(let B of X){let D={...W,common:{...W.common,issues:[]},parent:null},A=B._parseSync({data:W.data,path:W.path,parent:D});if(A.status==="valid")return A;else if(A.status==="dirty"&&!H)H={result:A,ctx:D};if(D.common.issues.length)Y.push(D.common.issues)}if(H)return W.common.issues.push(...H.ctx.common.issues),H.result;let G=Y.map((B)=>new k(B));return j(W,{code:w.invalid_union,unionErrors:G}),b}}get options(){return this._def.options}};U$.create=($,W)=>{return new U$({options:$,typeName:M.ZodUnion,...O(W)})};s$=class s$ extends _{_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==z.object)return j(W,{code:w.invalid_type,expected:z.object,received:W.parsedType}),b;let X=this.discriminator,Q=W.data[X],H=this.optionsMap.get(Q);if(!H)return j(W,{code:w.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),b;if(W.common.async)return H._parseAsync({data:W.data,path:W.path,parent:W});else return H._parseSync({data:W.data,path:W.path,parent:W})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,W,X){let Q=new Map;for(let H of W){let Y=t(H.shape[$]);if(!Y.length)throw new Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let G of Y){if(Q.has(G))throw new Error(`Discriminator property ${String($)} has duplicate value ${String(G)}`);Q.set(G,H)}}return new s$({typeName:M.ZodDiscriminatedUnion,discriminator:$,options:W,optionsMap:Q,...O(X)})}};K$=class K$ extends _{_parse($){let{status:W,ctx:X}=this._processInputParams($),Q=(H,Y)=>{if(r$(H)||r$(Y))return b;let G=C0(H.value,Y.value);if(!G.valid)return j(X,{code:w.invalid_intersection_types}),b;if(a$(H)||a$(Y))W.dirty();return{status:W.value,value:G.data}};if(X.common.async)return Promise.all([this._def.left._parseAsync({data:X.data,path:X.path,parent:X}),this._def.right._parseAsync({data:X.data,path:X.path,parent:X})]).then(([H,Y])=>Q(H,Y));else return Q(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}};K$.create=($,W,X)=>{return new K$({left:$,right:W,typeName:M.ZodIntersection,...O(X)})};o=class o extends _{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==z.array)return j(X,{code:w.invalid_type,expected:z.array,received:X.parsedType}),b;if(X.data.length<this._def.items.length)return j(X,{code:w.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),b;if(!this._def.rest&&X.data.length>this._def.items.length)j(X,{code:w.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),W.dirty();let H=[...X.data].map((Y,G)=>{let B=this._def.items[G]||this._def.rest;if(!B)return null;return B._parse(new h(X,Y,X.path,G))}).filter((Y)=>!!Y);if(X.common.async)return Promise.all(H).then((Y)=>{return E.mergeArray(W,Y)});else return E.mergeArray(W,H)}get items(){return this._def.items}rest($){return new o({...this._def,rest:$})}};o.create=($,W)=>{if(!Array.isArray($))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new o({items:$,typeName:M.ZodTuple,rest:null,...O(W)})};y$=class y$ extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==z.object)return j(X,{code:w.invalid_type,expected:z.object,received:X.parsedType}),b;let Q=[],H=this._def.keyType,Y=this._def.valueType;for(let G in X.data)Q.push({key:H._parse(new h(X,G,X.path,G)),value:Y._parse(new h(X,X.data[G],X.path,G)),alwaysSet:G in X.data});if(X.common.async)return E.mergeObjectAsync(W,Q);else return E.mergeObjectSync(W,Q)}get element(){return this._def.valueType}static create($,W,X){if(W instanceof _)return new y$({keyType:$,valueType:W,typeName:M.ZodRecord,...O(X)});return new y$({keyType:y.create(),valueType:$,typeName:M.ZodRecord,...O(W)})}};x$=class x$ extends _{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==z.map)return j(X,{code:w.invalid_type,expected:z.map,received:X.parsedType}),b;let Q=this._def.keyType,H=this._def.valueType,Y=[...X.data.entries()].map(([G,B],D)=>{return{key:Q._parse(new h(X,G,X.path,[D,"key"])),value:H._parse(new h(X,B,X.path,[D,"value"]))}});if(X.common.async){let G=new Map;return Promise.resolve().then(async()=>{for(let B of Y){let D=await B.key,A=await B.value;if(D.status==="aborted"||A.status==="aborted")return b;if(D.status==="dirty"||A.status==="dirty")W.dirty();G.set(D.value,A.value)}return{status:W.value,value:G}})}else{let G=new Map;for(let B of Y){let{key:D,value:A}=B;if(D.status==="aborted"||A.status==="aborted")return b;if(D.status==="dirty"||A.status==="dirty")W.dirty();G.set(D.value,A.value)}return{status:W.value,value:G}}}};x$.create=($,W,X)=>{return new x$({valueType:W,keyType:$,typeName:M.ZodMap,...O(X)})};M$=class M$ extends _{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==z.set)return j(X,{code:w.invalid_type,expected:z.set,received:X.parsedType}),b;let Q=this._def;if(Q.minSize!==null){if(X.data.size<Q.minSize.value)j(X,{code:w.too_small,minimum:Q.minSize.value,type:"set",inclusive:!0,exact:!1,message:Q.minSize.message}),W.dirty()}if(Q.maxSize!==null){if(X.data.size>Q.maxSize.value)j(X,{code:w.too_big,maximum:Q.maxSize.value,type:"set",inclusive:!0,exact:!1,message:Q.maxSize.message}),W.dirty()}let H=this._def.valueType;function Y(B){let D=new Set;for(let A of B){if(A.status==="aborted")return b;if(A.status==="dirty")W.dirty();D.add(A.value)}return{status:W.value,value:D}}let G=[...X.data.values()].map((B,D)=>H._parse(new h(X,B,X.path,D)));if(X.common.async)return Promise.all(G).then((B)=>Y(B));else return Y(G)}min($,W){return new M$({...this._def,minSize:{value:$,message:V.toString(W)}})}max($,W){return new M$({...this._def,maxSize:{value:$,message:V.toString(W)}})}size($,W){return this.min($,W).max($,W)}nonempty($){return this.min(1,$)}};M$.create=($,W)=>{return new M$({valueType:$,minSize:null,maxSize:null,typeName:M.ZodSet,...O(W)})};N$=class N$ extends _{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==z.function)return j(W,{code:w.invalid_type,expected:z.function,received:W.parsedType}),b;function X(G,B){return I$({data:G,path:W.path,errorMaps:[W.common.contextualErrorMap,W.schemaErrorMap,A$(),a].filter((D)=>!!D),issueData:{code:w.invalid_arguments,argumentsError:B}})}function Q(G,B){return I$({data:G,path:W.path,errorMaps:[W.common.contextualErrorMap,W.schemaErrorMap,A$(),a].filter((D)=>!!D),issueData:{code:w.invalid_return_type,returnTypeError:B}})}let H={errorMap:W.common.contextualErrorMap},Y=W.data;if(this._def.returns instanceof z$){let G=this;return R(async function(...B){let D=new k([]),A=await G._def.args.parseAsync(B,H).catch((Y$)=>{throw D.addIssue(X(B,Y$)),D}),q=await Reflect.apply(Y,this,A);return await G._def.returns._def.type.parseAsync(q,H).catch((Y$)=>{throw D.addIssue(Q(q,Y$)),D})})}else{let G=this;return R(function(...B){let D=G._def.args.safeParse(B,H);if(!D.success)throw new k([X(B,D.error)]);let A=Reflect.apply(Y,this,D.data),q=G._def.returns.safeParse(A,H);if(!q.success)throw new k([Q(A,q.error)]);return q.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new N$({...this._def,args:o.create($).rest(W$.create())})}returns($){return new N$({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,W,X){return new N$({args:$?$:o.create([]).rest(W$.create()),returns:W||W$.create(),typeName:M.ZodFunction,...O(X)})}};S$=class S$ extends _{get schema(){return this._def.getter()}_parse($){let{ctx:W}=this._processInputParams($);return this._def.getter()._parse({data:W.data,path:W.path,parent:W})}};S$.create=($,W)=>{return new S$({getter:$,typeName:M.ZodLazy,...O(W)})};L$=class L$ extends _{_parse($){if($.data!==this._def.value){let W=this._getOrReturnCtx($);return j(W,{received:W.data,code:w.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:$.data}}get value(){return this._def.value}};L$.create=($,W)=>{return new L$({value:$,typeName:M.ZodLiteral,...O(W)})};H$=class H$ extends _{constructor(){super(...arguments);C$.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let W=this._getOrReturnCtx($),X=this._def.values;return j(W,{expected:U.joinValues(X),received:W.parsedType,code:w.invalid_type}),b}if(!t$(this,C$,"f"))Y3(this,C$,new Set(this._def.values),"f");if(!t$(this,C$,"f").has($.data)){let W=this._getOrReturnCtx($),X=this._def.values;return j(W,{received:W.data,code:w.invalid_enum_value,options:X}),b}return R($.data)}get options(){return this._def.values}get enum(){let $={};for(let W of this._def.values)$[W]=W;return $}get Values(){let $={};for(let W of this._def.values)$[W]=W;return $}get Enum(){let $={};for(let W of this._def.values)$[W]=W;return $}extract($,W=this._def){return H$.create($,{...this._def,...W})}exclude($,W=this._def){return H$.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...W})}};C$=new WeakMap;H$.create=w3;F$=class F$ extends _{constructor(){super(...arguments);P$.set(this,void 0)}_parse($){let W=U.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==z.string&&X.parsedType!==z.number){let Q=U.objectValues(W);return j(X,{expected:U.joinValues(Q),received:X.parsedType,code:w.invalid_type}),b}if(!t$(this,P$,"f"))Y3(this,P$,new Set(U.getValidEnumValues(this._def.values)),"f");if(!t$(this,P$,"f").has($.data)){let Q=U.objectValues(W);return j(X,{received:X.data,code:w.invalid_enum_value,options:Q}),b}return R($.data)}get enum(){return this._def.values}};P$=new WeakMap;F$.create=($,W)=>{return new F$({values:$,typeName:M.ZodNativeEnum,...O(W)})};z$=class z$ extends _{unwrap(){return this._def.type}_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==z.promise&&W.common.async===!1)return j(W,{code:w.invalid_type,expected:z.promise,received:W.parsedType}),b;let X=W.parsedType===z.promise?W.data:Promise.resolve(W.data);return R(X.then((Q)=>{return this._def.type.parseAsync(Q,{path:W.path,errorMap:W.common.contextualErrorMap})}))}};z$.create=($,W)=>{return new z$({type:$,typeName:M.ZodPromise,...O(W)})};Z=class Z extends _{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===M.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:W,ctx:X}=this._processInputParams($),Q=this._def.effect||null,H={addIssue:(Y)=>{if(j(X,Y),Y.fatal)W.abort();else W.dirty()},get path(){return X.path}};if(H.addIssue=H.addIssue.bind(H),Q.type==="preprocess"){let Y=Q.transform(X.data,H);if(X.common.async)return Promise.resolve(Y).then(async(G)=>{if(W.value==="aborted")return b;let B=await this._def.schema._parseAsync({data:G,path:X.path,parent:X});if(B.status==="aborted")return b;if(B.status==="dirty")return B$(B.value);if(W.value==="dirty")return B$(B.value);return B});else{if(W.value==="aborted")return b;let G=this._def.schema._parseSync({data:Y,path:X.path,parent:X});if(G.status==="aborted")return b;if(G.status==="dirty")return B$(G.value);if(W.value==="dirty")return B$(G.value);return G}}if(Q.type==="refinement"){let Y=(G)=>{let B=Q.refinement(G,H);if(X.common.async)return Promise.resolve(B);if(B instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return G};if(X.common.async===!1){let G=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(G.status==="aborted")return b;if(G.status==="dirty")W.dirty();return Y(G.value),{status:W.value,value:G.value}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((G)=>{if(G.status==="aborted")return b;if(G.status==="dirty")W.dirty();return Y(G.value).then(()=>{return{status:W.value,value:G.value}})})}if(Q.type==="transform")if(X.common.async===!1){let Y=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!$$(Y))return Y;let G=Q.transform(Y.value,H);if(G instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:W.value,value:G}}else return this._def.schema._parseAsync({data:X.data,path:X.path,parent:X}).then((Y)=>{if(!$$(Y))return Y;return Promise.resolve(Q.transform(Y.value,H)).then((G)=>({status:W.value,value:G}))});U.assertNever(Q)}};Z.create=($,W,X)=>{return new Z({schema:$,typeName:M.ZodEffects,effect:W,...O(X)})};Z.createWithPreprocess=($,W,X)=>{return new Z({schema:W,effect:{type:"preprocess",transform:$},typeName:M.ZodEffects,...O(X)})};I=class I extends _{_parse($){if(this._getType($)===z.undefined)return R(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}};I.create=($,W)=>{return new I({innerType:$,typeName:M.ZodOptional,...O(W)})};s=class s extends _{_parse($){if(this._getType($)===z.null)return R(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}};s.create=($,W)=>{return new s({innerType:$,typeName:M.ZodNullable,...O(W)})};E$=class E$ extends _{_parse($){let{ctx:W}=this._processInputParams($),X=W.data;if(W.parsedType===z.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:W.path,parent:W})}removeDefault(){return this._def.innerType}};E$.create=($,W)=>{return new E$({innerType:$,typeName:M.ZodDefault,defaultValue:typeof W.default==="function"?W.default:()=>W.default,...O(W)})};R$=class R$ extends _{_parse($){let{ctx:W}=this._processInputParams($),X={...W,common:{...W.common,issues:[]}},Q=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(V$(Q))return Q.then((H)=>{return{status:"valid",value:H.status==="valid"?H.value:this._def.catchValue({get error(){return new k(X.common.issues)},input:X.data})}});else return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new k(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}};R$.create=($,W)=>{return new R$({innerType:$,typeName:M.ZodCatch,catchValue:typeof W.catch==="function"?W.catch:()=>W.catch,...O(W)})};h$=class h$ extends _{_parse($){if(this._getType($)!==z.nan){let X=this._getOrReturnCtx($);return j(X,{code:w.invalid_type,expected:z.nan,received:X.parsedType}),b}return{status:"valid",value:$.data}}};h$.create=($)=>{return new h$({typeName:M.ZodNaN,...O($)})};w1=Symbol("zod_brand");e$=class e$ extends _{_parse($){let{ctx:W}=this._processInputParams($),X=W.data;return this._def.type._parse({data:X,path:W.path,parent:W})}unwrap(){return this._def.type}};Z$=class Z$ extends _{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let H=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(H.status==="aborted")return b;if(H.status==="dirty")return W.dirty(),B$(H.value);else return this._def.out._parseAsync({data:H.value,path:X.path,parent:X})})();else{let Q=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(Q.status==="aborted")return b;if(Q.status==="dirty")return W.dirty(),{status:"dirty",value:Q.value};else return this._def.out._parseSync({data:Q.value,path:X.path,parent:X})}}static create($,W){return new Z$({in:$,out:W,typeName:M.ZodPipeline})}};v$=class v$ extends _{_parse($){let W=this._def.innerType._parse($),X=(Q)=>{if($$(Q))Q.value=Object.freeze(Q.value);return Q};return V$(W)?W.then((Q)=>X(Q)):X(W)}unwrap(){return this._def.innerType}};v$.create=($,W)=>{return new v$({innerType:$,typeName:M.ZodReadonly,...O(W)})};M1={object:S.lazycreate};(function($){$.ZodString="ZodString",$.ZodNumber="ZodNumber",$.ZodNaN="ZodNaN",$.ZodBigInt="ZodBigInt",$.ZodBoolean="ZodBoolean",$.ZodDate="ZodDate",$.ZodSymbol="ZodSymbol",$.ZodUndefined="ZodUndefined",$.ZodNull="ZodNull",$.ZodAny="ZodAny",$.ZodUnknown="ZodUnknown",$.ZodNever="ZodNever",$.ZodVoid="ZodVoid",$.ZodArray="ZodArray",$.ZodObject="ZodObject",$.ZodUnion="ZodUnion",$.ZodDiscriminatedUnion="ZodDiscriminatedUnion",$.ZodIntersection="ZodIntersection",$.ZodTuple="ZodTuple",$.ZodRecord="ZodRecord",$.ZodMap="ZodMap",$.ZodSet="ZodSet",$.ZodFunction="ZodFunction",$.ZodLazy="ZodLazy",$.ZodLiteral="ZodLiteral",$.ZodEnum="ZodEnum",$.ZodEffects="ZodEffects",$.ZodNativeEnum="ZodNativeEnum",$.ZodOptional="ZodOptional",$.ZodNullable="ZodNullable",$.ZodDefault="ZodDefault",$.ZodCatch="ZodCatch",$.ZodPromise="ZodPromise",$.ZodBranded="ZodBranded",$.ZodPipeline="ZodPipeline",$.ZodReadonly="ZodReadonly"})(M||(M={}));z3=y.create,j3=X$.create,j1=h$.create,A1=Q$.create,A3=O$.create,V1=D$.create,b1=g$.create,N1=q$.create,O1=_$.create,q1=w$.create,_1=W$.create,U1=d.create,K1=T$.create,S1=x.create,L1=S.create,F1=S.strictCreate,E1=U$.create,R1=s$.create,v1=K$.create,k1=o.create,f1=y$.create,I1=x$.create,C1=M$.create,P1=N$.create,g1=S$.create,T1=L$.create,y1=H$.create,x1=F$.create,h1=z$.create,Z1=Z.create,m1=I.create,l1=s.create,n1=Z.createWithPreprocess,u1=Z$.create,d1={string:($)=>y.create({...$,coerce:!0}),number:($)=>X$.create({...$,coerce:!0}),boolean:($)=>O$.create({...$,coerce:!0}),bigint:($)=>Q$.create({...$,coerce:!0}),date:($)=>D$.create({...$,coerce:!0})},o1=b});var J={};h2(J,{void:()=>K1,util:()=>U,unknown:()=>_1,union:()=>E1,undefined:()=>N1,tuple:()=>k1,transformer:()=>Z1,symbol:()=>b1,string:()=>z3,strictObject:()=>F1,setErrorMap:()=>l2,set:()=>C1,record:()=>f1,quotelessJson:()=>Z2,promise:()=>h1,preprocess:()=>n1,pipeline:()=>u1,ostring:()=>c1,optional:()=>m1,onumber:()=>i1,oboolean:()=>p1,objectUtil:()=>v0,object:()=>L1,number:()=>j3,nullable:()=>l1,null:()=>O1,never:()=>U1,nativeEnum:()=>x1,nan:()=>j1,map:()=>I1,makeIssue:()=>I$,literal:()=>T1,lazy:()=>g1,late:()=>M1,isValid:()=>$$,isDirty:()=>a$,isAsync:()=>V$,isAborted:()=>r$,intersection:()=>v1,instanceof:()=>z1,getParsedType:()=>p,getErrorMap:()=>A$,function:()=>P1,enum:()=>y1,effect:()=>Z1,discriminatedUnion:()=>R1,defaultErrorMap:()=>a,datetimeRegex:()=>D3,date:()=>V1,custom:()=>M3,coerce:()=>d1,boolean:()=>A3,bigint:()=>A1,array:()=>S1,any:()=>q1,addIssueToContext:()=>j,ZodVoid:()=>T$,ZodUnknown:()=>W$,ZodUnion:()=>U$,ZodUndefined:()=>q$,ZodType:()=>_,ZodTuple:()=>o,ZodTransformer:()=>Z,ZodSymbol:()=>g$,ZodString:()=>y,ZodSet:()=>M$,ZodSchema:()=>_,ZodRecord:()=>y$,ZodReadonly:()=>v$,ZodPromise:()=>z$,ZodPipeline:()=>Z$,ZodParsedType:()=>z,ZodOptional:()=>I,ZodObject:()=>S,ZodNumber:()=>X$,ZodNullable:()=>s,ZodNull:()=>_$,ZodNever:()=>d,ZodNativeEnum:()=>F$,ZodNaN:()=>h$,ZodMap:()=>x$,ZodLiteral:()=>L$,ZodLazy:()=>S$,ZodIssueCode:()=>w,ZodIntersection:()=>K$,ZodFunction:()=>N$,ZodFirstPartyTypeKind:()=>M,ZodError:()=>k,ZodEnum:()=>H$,ZodEffects:()=>Z,ZodDiscriminatedUnion:()=>s$,ZodDefault:()=>E$,ZodDate:()=>D$,ZodCatch:()=>R$,ZodBranded:()=>e$,ZodBoolean:()=>O$,ZodBigInt:()=>Q$,ZodArray:()=>x,ZodAny:()=>w$,Schema:()=>_,ParseStatus:()=>E,OK:()=>R,NEVER:()=>o1,INVALID:()=>b,EMPTY_PATH:()=>n2,DIRTY:()=>B$,BRAND:()=>w1});var P0=f(()=>{o$();f0();X3();f$();V3();d$()});var b3=f(()=>{P0();P0()});var e=f(()=>{b3()});var g0="2025-03-26",N3,$0="2.0",O3,q3,r1,m,C,m$,r,l,W0,_3,U3=($)=>_3.safeParse($).success,K3,S3=($)=>K3.safeParse($).success,L3,T0=($)=>L3.safeParse($).success,L,F3,E3=($)=>F3.safeParse($).success,R3,X0,Q0,v3,a1,H0,k9=($)=>H0.safeParse($).success,t1,s1,y0,J0,e1,Y0,G0,B0,k3,f3,I3,$6,W6,D0,X6,w0,Q6,M0,H6,J6,Y6,G6,B6,D6,w6,z0,M6,j0,A0,V0,b0,C3,z6,j6,A6,V6,b6,N0,N6,P3,f9,O0,O6,g3,q6,_6,U6,K6,S6,L6,x0,F6,E6,q0,R6,v6,k6,h0,f6,I9,C9,P9,g9,T9,y9,F;var l$=f(()=>{e();N3=[g0,"2024-11-05","2024-10-07"],O3=J.union([J.string(),J.number().int()]),q3=J.string(),r1=J.object({progressToken:J.optional(O3)}).passthrough(),m=J.object({_meta:J.optional(r1)}).passthrough(),C=J.object({method:J.string(),params:J.optional(m)}),m$=J.object({_meta:J.optional(J.object({}).passthrough())}).passthrough(),r=J.object({method:J.string(),params:J.optional(m$)}),l=J.object({_meta:J.optional(J.object({}).passthrough())}).passthrough(),W0=J.union([J.string(),J.number().int()]),_3=J.object({jsonrpc:J.literal($0),id:W0}).merge(C).strict(),K3=J.object({jsonrpc:J.literal($0)}).merge(r).strict(),L3=J.object({jsonrpc:J.literal($0),id:W0,result:l}).strict();(function($){$[$.ConnectionClosed=-32000]="ConnectionClosed",$[$.RequestTimeout=-32001]="RequestTimeout",$[$.ParseError=-32700]="ParseError",$[$.InvalidRequest=-32600]="InvalidRequest",$[$.MethodNotFound=-32601]="MethodNotFound",$[$.InvalidParams=-32602]="InvalidParams",$[$.InternalError=-32603]="InternalError"})(L||(L={}));F3=J.object({jsonrpc:J.literal($0),id:W0,error:J.object({code:J.number().int(),message:J.string(),data:J.optional(J.unknown())})}).strict(),R3=J.union([_3,K3,L3,F3]),X0=l.strict(),Q0=r.extend({method:J.literal("notifications/cancelled"),params:m$.extend({requestId:W0,reason:J.string().optional()})}),v3=J.object({name:J.string(),version:J.string()}).passthrough(),a1=J.object({experimental:J.optional(J.object({}).passthrough()),sampling:J.optional(J.object({}).passthrough()),roots:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough())}).passthrough(),H0=C.extend({method:J.literal("initialize"),params:m.extend({protocolVersion:J.string(),capabilities:a1,clientInfo:v3})}),t1=J.object({experimental:J.optional(J.object({}).passthrough()),logging:J.optional(J.object({}).passthrough()),completions:J.optional(J.object({}).passthrough()),prompts:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough()),resources:J.optional(J.object({subscribe:J.optional(J.boolean()),listChanged:J.optional(J.boolean())}).passthrough()),tools:J.optional(J.object({listChanged:J.optional(J.boolean())}).passthrough())}).passthrough(),s1=l.extend({protocolVersion:J.string(),capabilities:t1,serverInfo:v3,instructions:J.optional(J.string())}),y0=r.extend({method:J.literal("notifications/initialized")}),J0=C.extend({method:J.literal("ping")}),e1=J.object({progress:J.number(),total:J.optional(J.number()),message:J.optional(J.string())}).passthrough(),Y0=r.extend({method:J.literal("notifications/progress"),params:m$.merge(e1).extend({progressToken:O3})}),G0=C.extend({params:m.extend({cursor:J.optional(q3)}).optional()}),B0=l.extend({nextCursor:J.optional(q3)}),k3=J.object({uri:J.string(),mimeType:J.optional(J.string())}).passthrough(),f3=k3.extend({text:J.string()}),I3=k3.extend({blob:J.string().base64()}),$6=J.object({uri:J.string(),name:J.string(),description:J.optional(J.string()),mimeType:J.optional(J.string())}).passthrough(),W6=J.object({uriTemplate:J.string(),name:J.string(),description:J.optional(J.string()),mimeType:J.optional(J.string())}).passthrough(),D0=G0.extend({method:J.literal("resources/list")}),X6=B0.extend({resources:J.array($6)}),w0=G0.extend({method:J.literal("resources/templates/list")}),Q6=B0.extend({resourceTemplates:J.array(W6)}),M0=C.extend({method:J.literal("resources/read"),params:m.extend({uri:J.string()})}),H6=l.extend({contents:J.array(J.union([f3,I3]))}),J6=r.extend({method:J.literal("notifications/resources/list_changed")}),Y6=C.extend({method:J.literal("resources/subscribe"),params:m.extend({uri:J.string()})}),G6=C.extend({method:J.literal("resources/unsubscribe"),params:m.extend({uri:J.string()})}),B6=r.extend({method:J.literal("notifications/resources/updated"),params:m$.extend({uri:J.string()})}),D6=J.object({name:J.string(),description:J.optional(J.string()),required:J.optional(J.boolean())}).passthrough(),w6=J.object({name:J.string(),description:J.optional(J.string()),arguments:J.optional(J.array(D6))}).passthrough(),z0=G0.extend({method:J.literal("prompts/list")}),M6=B0.extend({prompts:J.array(w6)}),j0=C.extend({method:J.literal("prompts/get"),params:m.extend({name:J.string(),arguments:J.optional(J.record(J.string()))})}),A0=J.object({type:J.literal("text"),text:J.string()}).passthrough(),V0=J.object({type:J.literal("image"),data:J.string().base64(),mimeType:J.string()}).passthrough(),b0=J.object({type:J.literal("audio"),data:J.string().base64(),mimeType:J.string()}).passthrough(),C3=J.object({type:J.literal("resource"),resource:J.union([f3,I3])}).passthrough(),z6=J.object({role:J.enum(["user","assistant"]),content:J.union([A0,V0,b0,C3])}).passthrough(),j6=l.extend({description:J.optional(J.string()),messages:J.array(z6)}),A6=r.extend({method:J.literal("notifications/prompts/list_changed")}),V6=J.object({title:J.optional(J.string()),readOnlyHint:J.optional(J.boolean()),destructiveHint:J.optional(J.boolean()),idempotentHint:J.optional(J.boolean()),openWorldHint:J.optional(J.boolean())}).passthrough(),b6=J.object({name:J.string(),description:J.optional(J.string()),inputSchema:J.object({type:J.literal("object"),properties:J.optional(J.object({}).passthrough()),required:J.optional(J.array(J.string()))}).passthrough(),outputSchema:J.optional(J.object({type:J.literal("object"),properties:J.optional(J.object({}).passthrough()),required:J.optional(J.array(J.string()))}).passthrough()),annotations:J.optional(V6)}).passthrough(),N0=G0.extend({method:J.literal("tools/list")}),N6=B0.extend({tools:J.array(b6)}),P3=l.extend({content:J.array(J.union([A0,V0,b0,C3])).default([]),structuredContent:J.object({}).passthrough().optional(),isError:J.optional(J.boolean())}),f9=P3.or(l.extend({toolResult:J.unknown()})),O0=C.extend({method:J.literal("tools/call"),params:m.extend({name:J.string(),arguments:J.optional(J.record(J.unknown()))})}),O6=r.extend({method:J.literal("notifications/tools/list_changed")}),g3=J.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),q6=C.extend({method:J.literal("logging/setLevel"),params:m.extend({level:g3})}),_6=r.extend({method:J.literal("notifications/message"),params:m$.extend({level:g3,logger:J.optional(J.string()),data:J.unknown()})}),U6=J.object({name:J.string().optional()}).passthrough(),K6=J.object({hints:J.optional(J.array(U6)),costPriority:J.optional(J.number().min(0).max(1)),speedPriority:J.optional(J.number().min(0).max(1)),intelligencePriority:J.optional(J.number().min(0).max(1))}).passthrough(),S6=J.object({role:J.enum(["user","assistant"]),content:J.union([A0,V0,b0])}).passthrough(),L6=C.extend({method:J.literal("sampling/createMessage"),params:m.extend({messages:J.array(S6),systemPrompt:J.optional(J.string()),includeContext:J.optional(J.enum(["none","thisServer","allServers"])),temperature:J.optional(J.number()),maxTokens:J.number().int(),stopSequences:J.optional(J.array(J.string())),metadata:J.optional(J.object({}).passthrough()),modelPreferences:J.optional(K6)})}),x0=l.extend({model:J.string(),stopReason:J.optional(J.enum(["endTurn","stopSequence","maxTokens"]).or(J.string())),role:J.enum(["user","assistant"]),content:J.discriminatedUnion("type",[A0,V0,b0])}),F6=J.object({type:J.literal("ref/resource"),uri:J.string()}).passthrough(),E6=J.object({type:J.literal("ref/prompt"),name:J.string()}).passthrough(),q0=C.extend({method:J.literal("completion/complete"),params:m.extend({ref:J.union([E6,F6]),argument:J.object({name:J.string(),value:J.string()}).passthrough()})}),R6=l.extend({completion:J.object({values:J.array(J.string()).max(100),total:J.optional(J.number().int()),hasMore:J.optional(J.boolean())}).passthrough()}),v6=J.object({uri:J.string().startsWith("file://"),name:J.optional(J.string())}).passthrough(),k6=C.extend({method:J.literal("roots/list")}),h0=l.extend({roots:J.array(v6)}),f6=r.extend({method:J.literal("notifications/roots/list_changed")}),I9=J.union([J0,H0,q0,q6,j0,z0,D0,w0,M0,Y6,G6,O0,N0]),C9=J.union([Q0,Y0,y0,f6]),P9=J.union([X0,x0,h0]),g9=J.union([J0,L6,k6]),T9=J.union([Q0,Y0,_6,B6,J6,O6,A6]),y9=J.union([X0,s1,R6,j6,M6,X6,Q6,H6,P3,N6]);F=class F extends Error{constructor($,W,X){super(`MCP error ${$}: ${W}`);this.code=$,this.data=X,this.name="McpError"}}});function i6(){let $=process.argv.join(" ");return $.includes("streamable-http.js")||$.includes("streamable-http.ts")}class q2{context;level;constructor($,W=1){this.context=$,this.level=W}setLevel($){this.level=$}log(...$){if(O2)console.log(...$);else console.error(...$)}logWarn(...$){if(O2)console.warn(...$);else console.error(...$)}debug(...$){if(this.level<=0)this.log(`[DEBUG] [${this.context}]`,...$)}info(...$){if(this.level<=1)this.log(`[INFO] [${this.context}]`,...$)}warn(...$){if(this.level<=2)this.logWarn(`[WARN] [${this.context}]`,...$)}error(...$){if(this.level<=3)console.error(`[ERROR] [${this.context}]`,...$)}}var O2,T=($,W=1)=>new q2($,W);var j$=f(()=>{O2=i6()});l$();var I6=60000;class Z0{constructor($){this._options=$,this._requestMessageId=0,this._requestHandlers=new Map,this._requestHandlerAbortControllers=new Map,this._notificationHandlers=new Map,this._responseHandlers=new Map,this._progressHandlers=new Map,this._timeoutInfo=new Map,this.setNotificationHandler(Q0,(W)=>{let X=this._requestHandlerAbortControllers.get(W.params.requestId);X===null||X===void 0||X.abort(W.params.reason)}),this.setNotificationHandler(Y0,(W)=>{this._onprogress(W)}),this.setRequestHandler(J0,(W)=>({}))}_setupTimeout($,W,X,Q,H=!1){this._timeoutInfo.set($,{timeoutId:setTimeout(Q,W),startTime:Date.now(),timeout:W,maxTotalTimeout:X,resetTimeoutOnProgress:H,onTimeout:Q})}_resetTimeout($){let W=this._timeoutInfo.get($);if(!W)return!1;let X=Date.now()-W.startTime;if(W.maxTotalTimeout&&X>=W.maxTotalTimeout)throw this._timeoutInfo.delete($),new F(L.RequestTimeout,"Maximum total timeout exceeded",{maxTotalTimeout:W.maxTotalTimeout,totalElapsed:X});return clearTimeout(W.timeoutId),W.timeoutId=setTimeout(W.onTimeout,W.timeout),!0}_cleanupTimeout($){let W=this._timeoutInfo.get($);if(W)clearTimeout(W.timeoutId),this._timeoutInfo.delete($)}async connect($){this._transport=$,this._transport.onclose=()=>{this._onclose()},this._transport.onerror=(W)=>{this._onerror(W)},this._transport.onmessage=(W,X)=>{if(T0(W)||E3(W))this._onresponse(W);else if(U3(W))this._onrequest(W,X);else if(S3(W))this._onnotification(W);else this._onerror(new Error(`Unknown message type: ${JSON.stringify(W)}`))},await this._transport.start()}_onclose(){var $;let W=this._responseHandlers;this._responseHandlers=new Map,this._progressHandlers.clear(),this._transport=void 0,($=this.onclose)===null||$===void 0||$.call(this);let X=new F(L.ConnectionClosed,"Connection closed");for(let Q of W.values())Q(X)}_onerror($){var W;(W=this.onerror)===null||W===void 0||W.call(this,$)}_onnotification($){var W;let X=(W=this._notificationHandlers.get($.method))!==null&&W!==void 0?W:this.fallbackNotificationHandler;if(X===void 0)return;Promise.resolve().then(()=>X($)).catch((Q)=>this._onerror(new Error(`Uncaught error in notification handler: ${Q}`)))}_onrequest($,W){var X,Q,H,Y;let G=(X=this._requestHandlers.get($.method))!==null&&X!==void 0?X:this.fallbackRequestHandler;if(G===void 0){(Q=this._transport)===null||Q===void 0||Q.send({jsonrpc:"2.0",id:$.id,error:{code:L.MethodNotFound,message:"Method not found"}}).catch((A)=>this._onerror(new Error(`Failed to send an error response: ${A}`)));return}let B=new AbortController;this._requestHandlerAbortControllers.set($.id,B);let D={signal:B.signal,sessionId:(H=this._transport)===null||H===void 0?void 0:H.sessionId,_meta:(Y=$.params)===null||Y===void 0?void 0:Y._meta,sendNotification:(A)=>this.notification(A,{relatedRequestId:$.id}),sendRequest:(A,q,P)=>this.request(A,q,{...P,relatedRequestId:$.id}),authInfo:W===null||W===void 0?void 0:W.authInfo,requestId:$.id};Promise.resolve().then(()=>G($,D)).then((A)=>{var q;if(B.signal.aborted)return;return(q=this._transport)===null||q===void 0?void 0:q.send({result:A,jsonrpc:"2.0",id:$.id})},(A)=>{var q,P;if(B.signal.aborted)return;return(q=this._transport)===null||q===void 0?void 0:q.send({jsonrpc:"2.0",id:$.id,error:{code:Number.isSafeInteger(A.code)?A.code:L.InternalError,message:(P=A.message)!==null&&P!==void 0?P:"Internal error"}})}).catch((A)=>this._onerror(new Error(`Failed to send response: ${A}`))).finally(()=>{this._requestHandlerAbortControllers.delete($.id)})}_onprogress($){let{progressToken:W,...X}=$.params,Q=Number(W),H=this._progressHandlers.get(Q);if(!H){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify($)}`));return}let Y=this._responseHandlers.get(Q),G=this._timeoutInfo.get(Q);if(G&&Y&&G.resetTimeoutOnProgress)try{this._resetTimeout(Q)}catch(B){Y(B);return}H(X)}_onresponse($){let W=Number($.id),X=this._responseHandlers.get(W);if(X===void 0){this._onerror(new Error(`Received a response for an unknown message ID: ${JSON.stringify($)}`));return}if(this._responseHandlers.delete(W),this._progressHandlers.delete(W),this._cleanupTimeout(W),T0($))X($);else{let Q=new F($.error.code,$.error.message,$.error.data);X(Q)}}get transport(){return this._transport}async close(){var $;await(($=this._transport)===null||$===void 0?void 0:$.close())}request($,W,X){let{relatedRequestId:Q,resumptionToken:H,onresumptiontoken:Y}=X!==null&&X!==void 0?X:{};return new Promise((G,B)=>{var D,A,q,P,Y$,E0;if(!this._transport){B(new Error("Not connected"));return}if(((D=this._options)===null||D===void 0?void 0:D.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod($.method);(A=X===null||X===void 0?void 0:X.signal)===null||A===void 0||A.throwIfAborted();let i=this._requestMessageId++,s0={...$,jsonrpc:"2.0",id:i};if(X===null||X===void 0?void 0:X.onprogress)this._progressHandlers.set(i,X.onprogress),s0.params={...$.params,_meta:{...((q=$.params)===null||q===void 0?void 0:q._meta)||{},progressToken:i}};let e0=(g)=>{var G$;this._responseHandlers.delete(i),this._progressHandlers.delete(i),this._cleanupTimeout(i),(G$=this._transport)===null||G$===void 0||G$.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:i,reason:String(g)}},{relatedRequestId:Q,resumptionToken:H,onresumptiontoken:Y}).catch((k$)=>this._onerror(new Error(`Failed to send cancellation: ${k$}`))),B(g)};this._responseHandlers.set(i,(g)=>{var G$;if((G$=X===null||X===void 0?void 0:X.signal)===null||G$===void 0?void 0:G$.aborted)return;if(g instanceof Error)return B(g);try{let k$=W.parse(g.result);G(k$)}catch(k$){B(k$)}}),(P=X===null||X===void 0?void 0:X.signal)===null||P===void 0||P.addEventListener("abort",()=>{var g;e0((g=X===null||X===void 0?void 0:X.signal)===null||g===void 0?void 0:g.reason)});let $3=(Y$=X===null||X===void 0?void 0:X.timeout)!==null&&Y$!==void 0?Y$:I6,P2=()=>e0(new F(L.RequestTimeout,"Request timed out",{timeout:$3}));this._setupTimeout(i,$3,X===null||X===void 0?void 0:X.maxTotalTimeout,P2,(E0=X===null||X===void 0?void 0:X.resetTimeoutOnProgress)!==null&&E0!==void 0?E0:!1),this._transport.send(s0,{relatedRequestId:Q,resumptionToken:H,onresumptiontoken:Y}).catch((g)=>{this._cleanupTimeout(i),B(g)})})}async notification($,W){if(!this._transport)throw new Error("Not connected");this.assertNotificationCapability($.method);let X={...$,jsonrpc:"2.0"};await this._transport.send(X,W)}setRequestHandler($,W){let X=$.shape.method.value;this.assertRequestHandlerCapability(X),this._requestHandlers.set(X,(Q,H)=>{return Promise.resolve(W($.parse(Q),H))})}removeRequestHandler($){this._requestHandlers.delete($)}assertCanSetRequestHandler($){if(this._requestHandlers.has($))throw new Error(`A request handler for ${$} already exists, which would be overridden`)}setNotificationHandler($,W){this._notificationHandlers.set($.shape.method.value,(X)=>Promise.resolve(W($.parse(X))))}removeNotificationHandler($){this._notificationHandlers.delete($)}}function T3($,W){return Object.entries(W).reduce((X,[Q,H])=>{if(H&&typeof H==="object")X[Q]=X[Q]?{...X[Q],...H}:H;else X[Q]=H;return X},{...$})}l$();class m0 extends Z0{constructor($,W){var X;super(W);this._serverInfo=$,this._capabilities=(X=W===null||W===void 0?void 0:W.capabilities)!==null&&X!==void 0?X:{},this._instructions=W===null||W===void 0?void 0:W.instructions,this.setRequestHandler(H0,(Q)=>this._oninitialize(Q)),this.setNotificationHandler(y0,()=>{var Q;return(Q=this.oninitialized)===null||Q===void 0?void 0:Q.call(this)})}registerCapabilities($){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=T3(this._capabilities,$)}assertCapabilityForMethod($){var W,X;switch($){case"sampling/createMessage":if(!((W=this._clientCapabilities)===null||W===void 0?void 0:W.sampling))throw new Error(`Client does not support sampling (required for ${$})`);break;case"roots/list":if(!((X=this._clientCapabilities)===null||X===void 0?void 0:X.roots))throw new Error(`Client does not support listing roots (required for ${$})`);break;case"ping":break}}assertNotificationCapability($){switch($){case"notifications/message":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${$})`);break;case"notifications/resources/updated":case"notifications/resources/list_changed":if(!this._capabilities.resources)throw new Error(`Server does not support notifying about resources (required for ${$})`);break;case"notifications/tools/list_changed":if(!this._capabilities.tools)throw new Error(`Server does not support notifying of tool list changes (required for ${$})`);break;case"notifications/prompts/list_changed":if(!this._capabilities.prompts)throw new Error(`Server does not support notifying of prompt list changes (required for ${$})`);break;case"notifications/cancelled":break;case"notifications/progress":break}}assertRequestHandlerCapability($){switch($){case"sampling/createMessage":if(!this._capabilities.sampling)throw new Error(`Server does not support sampling (required for ${$})`);break;case"logging/setLevel":if(!this._capabilities.logging)throw new Error(`Server does not support logging (required for ${$})`);break;case"prompts/get":case"prompts/list":if(!this._capabilities.prompts)throw new Error(`Server does not support prompts (required for ${$})`);break;case"resources/list":case"resources/templates/list":case"resources/read":if(!this._capabilities.resources)throw new Error(`Server does not support resources (required for ${$})`);break;case"tools/call":case"tools/list":if(!this._capabilities.tools)throw new Error(`Server does not support tools (required for ${$})`);break;case"ping":case"initialize":break}}async _oninitialize($){let W=$.params.protocolVersion;return this._clientCapabilities=$.params.capabilities,this._clientVersion=$.params.clientInfo,{protocolVersion:N3.includes(W)?W:g0,capabilities:this.getCapabilities(),serverInfo:this._serverInfo,...this._instructions&&{instructions:this._instructions}}}getClientCapabilities(){return this._clientCapabilities}getClientVersion(){return this._clientVersion}getCapabilities(){return this._capabilities}async ping(){return this.request({method:"ping"},X0)}async createMessage($,W){return this.request({method:"sampling/createMessage",params:$},x0,W)}async listRoots($,W){return this.request({method:"roots/list",params:$},h0,W)}async sendLoggingMessage($){return this.notification({method:"notifications/message",params:$})}async sendResourceUpdated($){return this.notification({method:"notifications/resources/updated",params:$})}async sendResourceListChanged(){return this.notification({method:"notifications/resources/list_changed"})}async sendToolListChanged(){return this.notification({method:"notifications/tools/list_changed"})}async sendPromptListChanged(){return this.notification({method:"notifications/prompts/list_changed"})}}var x3=Symbol("Let zodToJsonSchema decide on which parser to use");var y3={name:void 0,$refStrategy:"root",basePath:["#"],effectStrategy:"input",pipeStrategy:"all",dateStrategy:"format:date-time",mapStrategy:"entries",removeAdditionalStrategy:"passthrough",allowedAdditionalProperties:!0,rejectedAdditionalProperties:!1,definitionPath:"definitions",target:"jsonSchema7",strictUnions:!1,definitions:{},errorMessages:!1,markdownDescription:!1,patternStrategy:"escape",applyRegexFlags:!1,emailStrategy:"format:email",base64Strategy:"contentEncoding:base64",nameStrategy:"ref"},h3=($)=>typeof $==="string"?{...y3,name:$}:{...y3,...$};var Z3=($)=>{let W=h3($),X=W.name!==void 0?[...W.basePath,W.definitionPath,W.name]:W.basePath;return{...W,currentPath:X,propertyPath:void 0,seen:new Map(Object.entries(W.definitions).map(([Q,H])=>[H._def,{def:H._def,path:[...W.basePath,W.definitionPath,Q],jsonSchema:void 0}]))}};function l0($,W,X,Q){if(!Q?.errorMessages)return;if(X)$.errorMessage={...$.errorMessage,[W]:X}}function K($,W,X,Q,H){$[W]=X,l0($,W,Q,H)}e();function m3(){return{}}e();function l3($,W){let X={type:"array"};if($.type?._def&&$.type?._def?.typeName!==M.ZodAny)X.items=N($.type._def,{...W,currentPath:[...W.currentPath,"items"]});if($.minLength)K(X,"minItems",$.minLength.value,$.minLength.message,W);if($.maxLength)K(X,"maxItems",$.maxLength.value,$.maxLength.message,W);if($.exactLength)K(X,"minItems",$.exactLength.value,$.exactLength.message,W),K(X,"maxItems",$.exactLength.value,$.exactLength.message,W);return X}function n3($,W){let X={type:"integer",format:"int64"};if(!$.checks)return X;for(let Q of $.checks)switch(Q.kind){case"min":if(W.target==="jsonSchema7")if(Q.inclusive)K(X,"minimum",Q.value,Q.message,W);else K(X,"exclusiveMinimum",Q.value,Q.message,W);else{if(!Q.inclusive)X.exclusiveMinimum=!0;K(X,"minimum",Q.value,Q.message,W)}break;case"max":if(W.target==="jsonSchema7")if(Q.inclusive)K(X,"maximum",Q.value,Q.message,W);else K(X,"exclusiveMaximum",Q.value,Q.message,W);else{if(!Q.inclusive)X.exclusiveMaximum=!0;K(X,"maximum",Q.value,Q.message,W)}break;case"multipleOf":K(X,"multipleOf",Q.value,Q.message,W);break}return X}function u3(){return{type:"boolean"}}function _0($,W){return N($.type._def,W)}var c3=($,W)=>{return N($.innerType._def,W)};function n0($,W,X){let Q=X??W.dateStrategy;if(Array.isArray(Q))return{anyOf:Q.map((H,Y)=>n0($,W,H))};switch(Q){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return C6($,W)}}var C6=($,W)=>{let X={type:"integer",format:"unix-time"};if(W.target==="openApi3")return X;for(let Q of $.checks)switch(Q.kind){case"min":K(X,"minimum",Q.value,Q.message,W);break;case"max":K(X,"maximum",Q.value,Q.message,W);break}return X};function i3($,W){return{...N($.innerType._def,W),default:$.defaultValue()}}function p3($,W){return W.effectStrategy==="input"?N($.schema._def,W):{}}function d3($){return{type:"string",enum:Array.from($.values)}}var P6=($)=>{if("type"in $&&$.type==="string")return!1;return"allOf"in $};function o3($,W){let X=[N($.left._def,{...W,currentPath:[...W.currentPath,"allOf","0"]}),N($.right._def,{...W,currentPath:[...W.currentPath,"allOf","1"]})].filter((Y)=>!!Y),Q=W.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,H=[];return X.forEach((Y)=>{if(P6(Y)){if(H.push(...Y.allOf),Y.unevaluatedProperties===void 0)Q=void 0}else{let G=Y;if("additionalProperties"in Y&&Y.additionalProperties===!1){let{additionalProperties:B,...D}=Y;G=D}else Q=void 0;H.push(G)}}),H.length?{allOf:H,...Q}:void 0}function r3($,W){let X=typeof $.value;if(X!=="bigint"&&X!=="number"&&X!=="boolean"&&X!=="string")return{type:Array.isArray($.value)?"array":"object"};if(W.target==="openApi3")return{type:X==="bigint"?"integer":X,enum:[$.value]};return{type:X==="bigint"?"integer":X,const:$.value}}e();var u0=void 0,n={cuid:/^[cC][^\s-]{8,}$/,cuid2:/^[0-9a-z]+$/,ulid:/^[0-9A-HJKMNP-TV-Z]{26}$/,email:/^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,emoji:()=>{if(u0===void 0)u0=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return u0},uuid:/^[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}$/,ipv4:/^(?:(?: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])$/,ipv4Cidr:/^(?:(?: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])$/,ipv6:/^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,ipv6Cidr:/^(([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])$/,base64:/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,base64url:/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,nanoid:/^[a-zA-Z0-9_-]{21}$/,jwt:/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/};function U0($,W){let X={type:"string"};if($.checks)for(let Q of $.checks)switch(Q.kind){case"min":K(X,"minLength",typeof X.minLength==="number"?Math.max(X.minLength,Q.value):Q.value,Q.message,W);break;case"max":K(X,"maxLength",typeof X.maxLength==="number"?Math.min(X.maxLength,Q.value):Q.value,Q.message,W);break;case"email":switch(W.emailStrategy){case"format:email":u(X,"email",Q.message,W);break;case"format:idn-email":u(X,"idn-email",Q.message,W);break;case"pattern:zod":v(X,n.email,Q.message,W);break}break;case"url":u(X,"uri",Q.message,W);break;case"uuid":u(X,"uuid",Q.message,W);break;case"regex":v(X,Q.regex,Q.message,W);break;case"cuid":v(X,n.cuid,Q.message,W);break;case"cuid2":v(X,n.cuid2,Q.message,W);break;case"startsWith":v(X,RegExp(`^${c0(Q.value,W)}`),Q.message,W);break;case"endsWith":v(X,RegExp(`${c0(Q.value,W)}$`),Q.message,W);break;case"datetime":u(X,"date-time",Q.message,W);break;case"date":u(X,"date",Q.message,W);break;case"time":u(X,"time",Q.message,W);break;case"duration":u(X,"duration",Q.message,W);break;case"length":K(X,"minLength",typeof X.minLength==="number"?Math.max(X.minLength,Q.value):Q.value,Q.message,W),K(X,"maxLength",typeof X.maxLength==="number"?Math.min(X.maxLength,Q.value):Q.value,Q.message,W);break;case"includes":{v(X,RegExp(c0(Q.value,W)),Q.message,W);break}case"ip":{if(Q.version!=="v6")u(X,"ipv4",Q.message,W);if(Q.version!=="v4")u(X,"ipv6",Q.message,W);break}case"base64url":v(X,n.base64url,Q.message,W);break;case"jwt":v(X,n.jwt,Q.message,W);break;case"cidr":{if(Q.version!=="v6")v(X,n.ipv4Cidr,Q.message,W);if(Q.version!=="v4")v(X,n.ipv6Cidr,Q.message,W);break}case"emoji":v(X,n.emoji(),Q.message,W);break;case"ulid":{v(X,n.ulid,Q.message,W);break}case"base64":{switch(W.base64Strategy){case"format:binary":{u(X,"binary",Q.message,W);break}case"contentEncoding:base64":{K(X,"contentEncoding","base64",Q.message,W);break}case"pattern:zod":{v(X,n.base64,Q.message,W);break}}break}case"nanoid":v(X,n.nanoid,Q.message,W);case"toLowerCase":case"toUpperCase":case"trim":break;default:((H)=>{})(Q)}return X}function c0($,W){return W.patternStrategy==="escape"?T6($):$}var g6=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function T6($){let W="";for(let X=0;X<$.length;X++){if(!g6.has($[X]))W+="\\";W+=$[X]}return W}function u($,W,X,Q){if($.format||$.anyOf?.some((H)=>H.format)){if(!$.anyOf)$.anyOf=[];if($.format){if($.anyOf.push({format:$.format,...$.errorMessage&&Q.errorMessages&&{errorMessage:{format:$.errorMessage.format}}}),delete $.format,$.errorMessage){if(delete $.errorMessage.format,Object.keys($.errorMessage).length===0)delete $.errorMessage}}$.anyOf.push({format:W,...X&&Q.errorMessages&&{errorMessage:{format:X}}})}else K($,"format",W,X,Q)}function v($,W,X,Q){if($.pattern||$.allOf?.some((H)=>H.pattern)){if(!$.allOf)$.allOf=[];if($.pattern){if($.allOf.push({pattern:$.pattern,...$.errorMessage&&Q.errorMessages&&{errorMessage:{pattern:$.errorMessage.pattern}}}),delete $.pattern,$.errorMessage){if(delete $.errorMessage.pattern,Object.keys($.errorMessage).length===0)delete $.errorMessage}}$.allOf.push({pattern:a3(W,Q),...X&&Q.errorMessages&&{errorMessage:{pattern:X}}})}else K($,"pattern",a3(W,Q),X,Q)}function a3($,W){if(!W.applyRegexFlags||!$.flags)return $.source;let X={i:$.flags.includes("i"),m:$.flags.includes("m"),s:$.flags.includes("s")},Q=X.i?$.source.toLowerCase():$.source,H="",Y=!1,G=!1,B=!1;for(let D=0;D<Q.length;D++){if(Y){H+=Q[D],Y=!1;continue}if(X.i){if(G){if(Q[D].match(/[a-z]/)){if(B)H+=Q[D],H+=`${Q[D-2]}-${Q[D]}`.toUpperCase(),B=!1;else if(Q[D+1]==="-"&&Q[D+2]?.match(/[a-z]/))H+=Q[D],B=!0;else H+=`${Q[D]}${Q[D].toUpperCase()}`;continue}}else if(Q[D].match(/[a-z]/)){H+=`[${Q[D]}${Q[D].toUpperCase()}]`;continue}}if(X.m){if(Q[D]==="^"){H+=`(^|(?<=[\r
|
2
|
+
]))`;continue}else if(Q[D]==="$"){H+=`($|(?=[\r
|
3
|
+
]))`;continue}}if(X.s&&Q[D]==="."){H+=G?`${Q[D]}\r
|
4
|
+
`:`[${Q[D]}\r
|
5
|
+
]`;continue}if(H+=Q[D],Q[D]==="\\")Y=!0;else if(G&&Q[D]==="]")G=!1;else if(!G&&Q[D]==="[")G=!0}try{new RegExp(H)}catch{return console.warn(`Could not convert regex pattern at ${W.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),$.source}return H}function K0($,W){if(W.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(W.target==="openApi3"&&$.keyType?._def.typeName===M.ZodEnum)return{type:"object",required:$.keyType._def.values,properties:$.keyType._def.values.reduce((Q,H)=>({...Q,[H]:N($.valueType._def,{...W,currentPath:[...W.currentPath,"properties",H]})??{}}),{}),additionalProperties:W.rejectedAdditionalProperties};let X={type:"object",additionalProperties:N($.valueType._def,{...W,currentPath:[...W.currentPath,"additionalProperties"]})??W.allowedAdditionalProperties};if(W.target==="openApi3")return X;if($.keyType?._def.typeName===M.ZodString&&$.keyType._def.checks?.length){let{type:Q,...H}=U0($.keyType._def,W);return{...X,propertyNames:H}}else if($.keyType?._def.typeName===M.ZodEnum)return{...X,propertyNames:{enum:$.keyType._def.values}};else if($.keyType?._def.typeName===M.ZodBranded&&$.keyType._def.type._def.typeName===M.ZodString&&$.keyType._def.type._def.checks?.length){let{type:Q,...H}=_0($.keyType._def,W);return{...X,propertyNames:H}}return X}function t3($,W){if(W.mapStrategy==="record")return K0($,W);let X=N($.keyType._def,{...W,currentPath:[...W.currentPath,"items","items","0"]})||{},Q=N($.valueType._def,{...W,currentPath:[...W.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[X,Q],minItems:2,maxItems:2}}}function s3($){let W=$.values,Q=Object.keys($.values).filter((Y)=>{return typeof W[W[Y]]!=="number"}).map((Y)=>W[Y]),H=Array.from(new Set(Q.map((Y)=>typeof Y)));return{type:H.length===1?H[0]==="string"?"string":"number":["string","number"],enum:Q}}function e3(){return{not:{}}}function $2($){return $.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var n$={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function X2($,W){if(W.target==="openApi3")return W2($,W);let X=$.options instanceof Map?Array.from($.options.values()):$.options;if(X.every((Q)=>(Q._def.typeName in n$)&&(!Q._def.checks||!Q._def.checks.length))){let Q=X.reduce((H,Y)=>{let G=n$[Y._def.typeName];return G&&!H.includes(G)?[...H,G]:H},[]);return{type:Q.length>1?Q:Q[0]}}else if(X.every((Q)=>Q._def.typeName==="ZodLiteral"&&!Q.description)){let Q=X.reduce((H,Y)=>{let G=typeof Y._def.value;switch(G){case"string":case"number":case"boolean":return[...H,G];case"bigint":return[...H,"integer"];case"object":if(Y._def.value===null)return[...H,"null"];case"symbol":case"undefined":case"function":default:return H}},[]);if(Q.length===X.length){let H=Q.filter((Y,G,B)=>B.indexOf(Y)===G);return{type:H.length>1?H:H[0],enum:X.reduce((Y,G)=>{return Y.includes(G._def.value)?Y:[...Y,G._def.value]},[])}}}else if(X.every((Q)=>Q._def.typeName==="ZodEnum"))return{type:"string",enum:X.reduce((Q,H)=>[...Q,...H._def.values.filter((Y)=>!Q.includes(Y))],[])};return W2($,W)}var W2=($,W)=>{let X=($.options instanceof Map?Array.from($.options.values()):$.options).map((Q,H)=>N(Q._def,{...W,currentPath:[...W.currentPath,"anyOf",`${H}`]})).filter((Q)=>!!Q&&(!W.strictUnions||typeof Q==="object"&&Object.keys(Q).length>0));return X.length?{anyOf:X}:void 0};function Q2($,W){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes($.innerType._def.typeName)&&(!$.innerType._def.checks||!$.innerType._def.checks.length)){if(W.target==="openApi3")return{type:n$[$.innerType._def.typeName],nullable:!0};return{type:[n$[$.innerType._def.typeName],"null"]}}if(W.target==="openApi3"){let Q=N($.innerType._def,{...W,currentPath:[...W.currentPath]});if(Q&&"$ref"in Q)return{allOf:[Q],nullable:!0};return Q&&{...Q,nullable:!0}}let X=N($.innerType._def,{...W,currentPath:[...W.currentPath,"anyOf","0"]});return X&&{anyOf:[X,{type:"null"}]}}function H2($,W){let X={type:"number"};if(!$.checks)return X;for(let Q of $.checks)switch(Q.kind){case"int":X.type="integer",l0(X,"type",Q.message,W);break;case"min":if(W.target==="jsonSchema7")if(Q.inclusive)K(X,"minimum",Q.value,Q.message,W);else K(X,"exclusiveMinimum",Q.value,Q.message,W);else{if(!Q.inclusive)X.exclusiveMinimum=!0;K(X,"minimum",Q.value,Q.message,W)}break;case"max":if(W.target==="jsonSchema7")if(Q.inclusive)K(X,"maximum",Q.value,Q.message,W);else K(X,"exclusiveMaximum",Q.value,Q.message,W);else{if(!Q.inclusive)X.exclusiveMaximum=!0;K(X,"maximum",Q.value,Q.message,W)}break;case"multipleOf":K(X,"multipleOf",Q.value,Q.message,W);break}return X}e();function J2($,W){let X=W.target==="openAi",Q={type:"object",properties:{}},H=[],Y=$.shape();for(let B in Y){let D=Y[B];if(D===void 0||D._def===void 0)continue;let A=x6(D);if(A&&X){if(D instanceof I)D=D._def.innerType;if(!D.isNullable())D=D.nullable();A=!1}let q=N(D._def,{...W,currentPath:[...W.currentPath,"properties",B],propertyPath:[...W.currentPath,"properties",B]});if(q===void 0)continue;if(Q.properties[B]=q,!A)H.push(B)}if(H.length)Q.required=H;let G=y6($,W);if(G!==void 0)Q.additionalProperties=G;return Q}function y6($,W){if($.catchall._def.typeName!=="ZodNever")return N($.catchall._def,{...W,currentPath:[...W.currentPath,"additionalProperties"]});switch($.unknownKeys){case"passthrough":return W.allowedAdditionalProperties;case"strict":return W.rejectedAdditionalProperties;case"strip":return W.removeAdditionalStrategy==="strict"?W.allowedAdditionalProperties:W.rejectedAdditionalProperties}}function x6($){try{return $.isOptional()}catch{return!0}}var Y2=($,W)=>{if(W.currentPath.toString()===W.propertyPath?.toString())return N($.innerType._def,W);let X=N($.innerType._def,{...W,currentPath:[...W.currentPath,"anyOf","1"]});return X?{anyOf:[{not:{}},X]}:{}};var G2=($,W)=>{if(W.pipeStrategy==="input")return N($.in._def,W);else if(W.pipeStrategy==="output")return N($.out._def,W);let X=N($.in._def,{...W,currentPath:[...W.currentPath,"allOf","0"]}),Q=N($.out._def,{...W,currentPath:[...W.currentPath,"allOf",X?"1":"0"]});return{allOf:[X,Q].filter((H)=>H!==void 0)}};function B2($,W){return N($.type._def,W)}function D2($,W){let Q={type:"array",uniqueItems:!0,items:N($.valueType._def,{...W,currentPath:[...W.currentPath,"items"]})};if($.minSize)K(Q,"minItems",$.minSize.value,$.minSize.message,W);if($.maxSize)K(Q,"maxItems",$.maxSize.value,$.maxSize.message,W);return Q}function w2($,W){if($.rest)return{type:"array",minItems:$.items.length,items:$.items.map((X,Q)=>N(X._def,{...W,currentPath:[...W.currentPath,"items",`${Q}`]})).reduce((X,Q)=>Q===void 0?X:[...X,Q],[]),additionalItems:N($.rest._def,{...W,currentPath:[...W.currentPath,"additionalItems"]})};else return{type:"array",minItems:$.items.length,maxItems:$.items.length,items:$.items.map((X,Q)=>N(X._def,{...W,currentPath:[...W.currentPath,"items",`${Q}`]})).reduce((X,Q)=>Q===void 0?X:[...X,Q],[])}}function M2(){return{not:{}}}function z2(){return{}}var j2=($,W)=>{return N($.innerType._def,W)};var A2=($,W,X)=>{switch(W){case M.ZodString:return U0($,X);case M.ZodNumber:return H2($,X);case M.ZodObject:return J2($,X);case M.ZodBigInt:return n3($,X);case M.ZodBoolean:return u3();case M.ZodDate:return n0($,X);case M.ZodUndefined:return M2();case M.ZodNull:return $2(X);case M.ZodArray:return l3($,X);case M.ZodUnion:case M.ZodDiscriminatedUnion:return X2($,X);case M.ZodIntersection:return o3($,X);case M.ZodTuple:return w2($,X);case M.ZodRecord:return K0($,X);case M.ZodLiteral:return r3($,X);case M.ZodEnum:return d3($);case M.ZodNativeEnum:return s3($);case M.ZodNullable:return Q2($,X);case M.ZodOptional:return Y2($,X);case M.ZodMap:return t3($,X);case M.ZodSet:return D2($,X);case M.ZodLazy:return()=>$.getter()._def;case M.ZodPromise:return B2($,X);case M.ZodNaN:case M.ZodNever:return e3();case M.ZodEffects:return p3($,X);case M.ZodAny:return m3();case M.ZodUnknown:return z2();case M.ZodDefault:return i3($,X);case M.ZodBranded:return _0($,X);case M.ZodReadonly:return j2($,X);case M.ZodCatch:return c3($,X);case M.ZodPipeline:return G2($,X);case M.ZodFunction:case M.ZodVoid:case M.ZodSymbol:return;default:return((Q)=>{return})(W)}};function N($,W,X=!1){let Q=W.seen.get($);if(W.override){let B=W.override?.($,W,Q,X);if(B!==x3)return B}if(Q&&!X){let B=h6(Q,W);if(B!==void 0)return B}let H={def:$,path:W.currentPath,jsonSchema:void 0};W.seen.set($,H);let Y=A2($,$.typeName,W),G=typeof Y==="function"?N(Y(),W):Y;if(G)m6($,W,G);if(W.postProcess){let B=W.postProcess(G,$,W);return H.jsonSchema=G,B}return H.jsonSchema=G,G}var h6=($,W)=>{switch(W.$refStrategy){case"root":return{$ref:$.path.join("/")};case"relative":return{$ref:Z6(W.currentPath,$.path)};case"none":case"seen":{if($.path.length<W.currentPath.length&&$.path.every((X,Q)=>W.currentPath[Q]===X))return console.warn(`Recursive reference detected at ${W.currentPath.join("/")}! Defaulting to any`),{};return W.$refStrategy==="seen"?{}:void 0}}},Z6=($,W)=>{let X=0;for(;X<$.length&&X<W.length;X++)if($[X]!==W[X])break;return[($.length-X).toString(),...W.slice(X)].join("/")},m6=($,W,X)=>{if($.description){if(X.description=$.description,W.markdownDescription)X.markdownDescription=$.description}return X};var S0=($,W)=>{let X=Z3(W),Q=typeof W==="object"&&W.definitions?Object.entries(W.definitions).reduce((D,[A,q])=>({...D,[A]:N(q._def,{...X,currentPath:[...X.basePath,X.definitionPath,A]},!0)??{}}),{}):void 0,H=typeof W==="string"?W:W?.nameStrategy==="title"?void 0:W?.name,Y=N($._def,H===void 0?X:{...X,currentPath:[...X.basePath,X.definitionPath,H]},!1)??{},G=typeof W==="object"&&W.name!==void 0&&W.nameStrategy==="title"?W.name:void 0;if(G!==void 0)Y.title=G;let B=H===void 0?Q?{...Y,[X.definitionPath]:Q}:Y:{$ref:[...X.$refStrategy==="relative"?[]:X.basePath,X.definitionPath,H].join("/"),[X.definitionPath]:{...Q,[H]:Y}};if(X.target==="jsonSchema7")B.$schema="http://json-schema.org/draft-07/schema#";else if(X.target==="jsonSchema2019-09"||X.target==="openAi")B.$schema="https://json-schema.org/draft/2019-09/schema#";if(X.target==="openAi"&&(("anyOf"in B)||("oneOf"in B)||("allOf"in B)||("type"in B)&&Array.isArray(B.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return B};e();l$();e();var i0;(function($){$.Completable="McpCompletable"})(i0||(i0={}));class u$ extends _{_parse($){let{ctx:W}=this._processInputParams($),X=W.data;return this._def.type._parse({data:X,path:W.path,parent:W})}unwrap(){return this._def.type}}u$.create=($,W)=>{return new u$({type:$,typeName:i0.Completable,complete:W.complete,...l6(W)})};function l6($){if(!$)return{};let{errorMap:W,invalid_type_error:X,required_error:Q,description:H}=$;if(W&&(X||Q))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(W)return{errorMap:W,description:H};return{errorMap:(G,B)=>{var D,A;let{message:q}=$;if(G.code==="invalid_enum_value")return{message:q!==null&&q!==void 0?q:B.defaultError};if(typeof B.data==="undefined")return{message:(D=q!==null&&q!==void 0?q:Q)!==null&&D!==void 0?D:B.defaultError};if(G.code!=="invalid_type")return{message:B.defaultError};return{message:(A=q!==null&&q!==void 0?q:X)!==null&&A!==void 0?A:B.defaultError}},description:H}}class p0{constructor($,W){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new m0($,W)}async connect($){return await this.server.connect($)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(N0.shape.method.value),this.server.assertCanSetRequestHandler(O0.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(N0,()=>({tools:Object.entries(this._registeredTools).filter(([,$])=>$.enabled).map(([$,W])=>{let X={name:$,description:W.description,inputSchema:W.inputSchema?S0(W.inputSchema,{strictUnions:!0}):n6,annotations:W.annotations};if(W.outputSchema)X.outputSchema=S0(W.outputSchema,{strictUnions:!0});return X})})),this.server.setRequestHandler(O0,async($,W)=>{let X=this._registeredTools[$.params.name];if(!X)throw new F(L.InvalidParams,`Tool ${$.params.name} not found`);if(!X.enabled)throw new F(L.InvalidParams,`Tool ${$.params.name} disabled`);let Q;if(X.inputSchema){let H=await X.inputSchema.safeParseAsync($.params.arguments);if(!H.success)throw new F(L.InvalidParams,`Invalid arguments for tool ${$.params.name}: ${H.error.message}`);let Y=H.data,G=X.callback;try{Q=await Promise.resolve(G(Y,W))}catch(B){Q={content:[{type:"text",text:B instanceof Error?B.message:String(B)}],isError:!0}}}else{let H=X.callback;try{Q=await Promise.resolve(H(W))}catch(Y){Q={content:[{type:"text",text:Y instanceof Error?Y.message:String(Y)}],isError:!0}}}if(X.outputSchema){if(!Q.structuredContent)throw new F(L.InvalidParams,`Tool ${$.params.name} has an output schema but no structured content was provided`);let H=await X.outputSchema.safeParseAsync(Q.structuredContent);if(!H.success)throw new F(L.InvalidParams,`Invalid structured content for tool ${$.params.name}: ${H.error.message}`)}return Q}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(q0.shape.method.value),this.server.setRequestHandler(q0,async($)=>{switch($.params.ref.type){case"ref/prompt":return this.handlePromptCompletion($,$.params.ref);case"ref/resource":return this.handleResourceCompletion($,$.params.ref);default:throw new F(L.InvalidParams,`Invalid completion reference: ${$.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion($,W){let X=this._registeredPrompts[W.name];if(!X)throw new F(L.InvalidParams,`Prompt ${W.name} not found`);if(!X.enabled)throw new F(L.InvalidParams,`Prompt ${W.name} disabled`);if(!X.argsSchema)return L0;let Q=X.argsSchema.shape[$.params.argument.name];if(!(Q instanceof u$))return L0;let Y=await Q._def.complete($.params.argument.value);return b2(Y)}async handleResourceCompletion($,W){let X=Object.values(this._registeredResourceTemplates).find((Y)=>Y.resourceTemplate.uriTemplate.toString()===W.uri);if(!X){if(this._registeredResources[W.uri])return L0;throw new F(L.InvalidParams,`Resource template ${$.params.ref.uri} not found`)}let Q=X.resourceTemplate.completeCallback($.params.argument.name);if(!Q)return L0;let H=await Q($.params.argument.value);return b2(H)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(D0.shape.method.value),this.server.assertCanSetRequestHandler(w0.shape.method.value),this.server.assertCanSetRequestHandler(M0.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(D0,async($,W)=>{let X=Object.entries(this._registeredResources).filter(([H,Y])=>Y.enabled).map(([H,Y])=>({uri:H,name:Y.name,...Y.metadata})),Q=[];for(let H of Object.values(this._registeredResourceTemplates)){if(!H.resourceTemplate.listCallback)continue;let Y=await H.resourceTemplate.listCallback(W);for(let G of Y.resources)Q.push({...G,...H.metadata})}return{resources:[...X,...Q]}}),this.server.setRequestHandler(w0,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([W,X])=>({name:W,uriTemplate:X.resourceTemplate.uriTemplate.toString(),...X.metadata}))}}),this.server.setRequestHandler(M0,async($,W)=>{let X=new URL($.params.uri),Q=this._registeredResources[X.toString()];if(Q){if(!Q.enabled)throw new F(L.InvalidParams,`Resource ${X} disabled`);return Q.readCallback(X,W)}for(let H of Object.values(this._registeredResourceTemplates)){let Y=H.resourceTemplate.uriTemplate.match(X.toString());if(Y)return H.readCallback(X,Y,W)}throw new F(L.InvalidParams,`Resource ${X} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler(z0.shape.method.value),this.server.assertCanSetRequestHandler(j0.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(z0,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,$])=>$.enabled).map(([$,W])=>{return{name:$,description:W.description,arguments:W.argsSchema?c6(W.argsSchema):void 0}})})),this.server.setRequestHandler(j0,async($,W)=>{let X=this._registeredPrompts[$.params.name];if(!X)throw new F(L.InvalidParams,`Prompt ${$.params.name} not found`);if(!X.enabled)throw new F(L.InvalidParams,`Prompt ${$.params.name} disabled`);if(X.argsSchema){let Q=await X.argsSchema.safeParseAsync($.params.arguments);if(!Q.success)throw new F(L.InvalidParams,`Invalid arguments for prompt ${$.params.name}: ${Q.error.message}`);let H=Q.data,Y=X.callback;return await Promise.resolve(Y(H,W))}else{let Q=X.callback;return await Promise.resolve(Q(W))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource($,W,...X){let Q;if(typeof X[0]==="object")Q=X.shift();let H=X[0];if(typeof W==="string"){if(this._registeredResources[W])throw new Error(`Resource ${W} is already registered`);let Y={name:$,metadata:Q,readCallback:H,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({uri:null}),update:(G)=>{if(typeof G.uri!=="undefined"&&G.uri!==W){if(delete this._registeredResources[W],G.uri)this._registeredResources[G.uri]=Y}if(typeof G.name!=="undefined")Y.name=G.name;if(typeof G.metadata!=="undefined")Y.metadata=G.metadata;if(typeof G.callback!=="undefined")Y.readCallback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendResourceListChanged()}};return this._registeredResources[W]=Y,this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}else{if(this._registeredResourceTemplates[$])throw new Error(`Resource template ${$} is already registered`);let Y={resourceTemplate:W,metadata:Q,readCallback:H,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(G)=>{if(typeof G.name!=="undefined"&&G.name!==$){if(delete this._registeredResourceTemplates[$],G.name)this._registeredResourceTemplates[G.name]=Y}if(typeof G.template!=="undefined")Y.resourceTemplate=G.template;if(typeof G.metadata!=="undefined")Y.metadata=G.metadata;if(typeof G.callback!=="undefined")Y.readCallback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendResourceListChanged()}};return this._registeredResourceTemplates[$]=Y,this.setResourceRequestHandlers(),this.sendResourceListChanged(),Y}}_createRegisteredTool($,W,X,Q,H,Y){let G={description:W,inputSchema:X===void 0?void 0:J.object(X),outputSchema:Q===void 0?void 0:J.object(Q),annotations:H,callback:Y,enabled:!0,disable:()=>G.update({enabled:!1}),enable:()=>G.update({enabled:!0}),remove:()=>G.update({name:null}),update:(B)=>{if(typeof B.name!=="undefined"&&B.name!==$){if(delete this._registeredTools[$],B.name)this._registeredTools[B.name]=G}if(typeof B.description!=="undefined")G.description=B.description;if(typeof B.paramsSchema!=="undefined")G.inputSchema=J.object(B.paramsSchema);if(typeof B.callback!=="undefined")G.callback=B.callback;if(typeof B.annotations!=="undefined")G.annotations=B.annotations;if(typeof B.enabled!=="undefined")G.enabled=B.enabled;this.sendToolListChanged()}};return this._registeredTools[$]=G,this.setToolRequestHandlers(),this.sendToolListChanged(),G}tool($,...W){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let X,Q,H,Y;if(typeof W[0]==="string")X=W.shift();if(W.length>1){let B=W[0];if(V2(B)){if(Q=W.shift(),W.length>1&&typeof W[0]==="object"&&W[0]!==null&&!V2(W[0]))Y=W.shift()}else if(typeof B==="object"&&B!==null)Y=W.shift()}let G=W[0];return this._createRegisteredTool($,X,Q,H,Y,G)}registerTool($,W,X){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let{description:Q,inputSchema:H,outputSchema:Y,annotations:G}=W;return this._createRegisteredTool($,Q,H,Y,G,X)}prompt($,...W){if(this._registeredPrompts[$])throw new Error(`Prompt ${$} is already registered`);let X;if(typeof W[0]==="string")X=W.shift();let Q;if(W.length>1)Q=W.shift();let H=W[0],Y={description:X,argsSchema:Q===void 0?void 0:J.object(Q),callback:H,enabled:!0,disable:()=>Y.update({enabled:!1}),enable:()=>Y.update({enabled:!0}),remove:()=>Y.update({name:null}),update:(G)=>{if(typeof G.name!=="undefined"&&G.name!==$){if(delete this._registeredPrompts[$],G.name)this._registeredPrompts[G.name]=Y}if(typeof G.description!=="undefined")Y.description=G.description;if(typeof G.argsSchema!=="undefined")Y.argsSchema=J.object(G.argsSchema);if(typeof G.callback!=="undefined")Y.callback=G.callback;if(typeof G.enabled!=="undefined")Y.enabled=G.enabled;this.sendPromptListChanged()}};return this._registeredPrompts[$]=Y,this.setPromptRequestHandlers(),this.sendPromptListChanged(),Y}isConnected(){return this.server.transport!==void 0}sendResourceListChanged(){if(this.isConnected())this.server.sendResourceListChanged()}sendToolListChanged(){if(this.isConnected())this.server.sendToolListChanged()}sendPromptListChanged(){if(this.isConnected())this.server.sendPromptListChanged()}}var n6={type:"object"};function V2($){if(typeof $!=="object"||$===null)return!1;return Object.keys($).length===0||Object.values($).some(u6)}function u6($){return $!==null&&typeof $==="object"&&"parse"in $&&typeof $.parse==="function"&&"safeParse"in $&&typeof $.safeParse==="function"}function c6($){return Object.entries($.shape).map(([W,X])=>({name:W,description:X.description,required:!X.isOptional()}))}function b2($){return{completion:{values:$.slice(0,100),total:$.length,hasMore:$.length>100}}}var L0={completion:{values:[],hasMore:!1}};function N2($,W){let X=process.argv,Q=`--${$}=`;for(let H of X)if(H.startsWith(Q))return H.substring(Q.length);return W}j$();var d6=T("FigmaConfig",1),c$=N2("figma-api-key")||process.env.FIGMA_API_KEY||"",_2="F2C MCP",U2=process.env.FIGMA_VERSION||"0.0.1";d6.debug("DEFAULT_PERSONAL_TOKEN",c$);var K2=($)=>{};var S2=($)=>{K2($)};j$();var L2=T("F2cApi",1);class F2{f2cHost="https://f2c-figma-api.yy.com/api";personalToken=c$;async nodeToCode($){let W={fileKey:$.fileKey,nodeIds:$.ids,personal_token:$.personalToken||this.personalToken,option:{cssFramework:"inlinecss",imgFormat:$.imgFormat||"png",scaleSize:$.scaleSize||2},format:"files"};if($.format==="react-cssmodules")W.option.cssFramework="cssmodules";else if($.format==="react-tailwind")W.option.cssFramework="tailwindcss";let X=this.opToUrl(`${this.f2cHost}/nodes`,W);return this.fetch(X,"json")}async fetch($,W="json"){try{let X={method:"GET"};L2.debug("fetch",$);let Q=await fetch($,X);if(!Q.ok)throw new Error(`HTTP error! status: ${Q.status}`);return W==="text"?await Q.text():await Q.json()}catch(X){throw L2.error("HTTP error",X),X}}opToUrl($,W={}){if(Object.keys(W).length===0)return $;let X=new URL($);for(let[Q,H]of Object.entries(W))if(typeof H==="object"&&H!==null)for(let[Y,G]of Object.entries(H))X.searchParams.append(`${Q}[${Y}]`,G);else X.searchParams.append(Q,H);return X.toString()}}var E2=new F2;j$();var o6=T("FigmaRestApi");class R2{figmaHost="https://api.figma.com/v1";personalToken=c$;async files($){let W;if($.ids)W=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/nodes`,$);else W=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}`,$);return this.fetch(W)}async images($){let W=this.opToUrl(`${this.figmaHost}/images/${$.fileKey}`,$);return this.fetch(W)}async imageFills($){let W=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/images`,$);return this.fetch(W)}async meta($){let W=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/meta`,$);return this.fetch(W)}async fetch($,W="json"){try{let X={method:"GET",headers:{"X-FIGMA-TOKEN":this.personalToken}},Q=await fetch($,X);if(!Q.ok)throw new Error(`HTTP error! status: ${Q.status}`);return W==="text"?await Q.text():await Q.json()}catch(X){throw o6.error("HTTP error",X),X}}opToUrl($,W={},X=["fileKey","personalToken"]){if(Object.keys(W).length===0)return $;if(W.personalToken)this.personalToken=W.personalToken;let Q=new URL($);for(let[H,Y]of Object.entries(W))if(!X.includes(H))Q.searchParams.append(H,Y);return Q.toString()}}var v2=new R2;j$();e();var i$=p$(require("fs")),J$=p$(require("path")),d0=p$(require("fs/promises"));j$();var c=T("Downloader");class k2{op;assetsPath="";savePath="";setup($){if(this.op=$,this.op.localPath)this.assetsPath=J$.default.join(this.op.localPath,"assets"),this.savePath=this.op.localPath}async downloadImage($,W){let{imgFormat:X}=this.op,Q=this.assetsPath;try{if(!i$.default.existsSync(Q))i$.default.mkdirSync(Q,{recursive:!0});let H=`${W}.${X}`,Y=J$.default.join(Q,H),G=await fetch($);if(!G.ok)throw new Error(`下载失败: ${G.status} ${G.statusText}`);let B=await G.arrayBuffer();return i$.default.writeFileSync(Y,new Uint8Array(B)),J$.default.join(J$.default.basename(Q),H).replace(/\\/g,"/")}catch(H){throw c.error("图片下载错误:",H),H}}async downLoadImageAndReplaceContent($){try{let W=/https:\/\/figma-alpha-api\.s3\.us-west-2\.amazonaws\.com\/images\/[a-f0-9-]+/g,X=$.match(W);if(!X)return $;let Q=[...new Set(X)],H=new Map;await Promise.all(Q.map(async(G)=>{let B=J$.default.basename(G),D=await this.downloadImage(G,B);H.set(G,D)}));let Y=$;for(let[G,B]of H.entries()){let D=new RegExp(G.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");Y=Y.replace(D,B)}return Y}catch(W){throw c.error("内容处理错误:",W),W}}async checkLocalAndDownload($){if(!this.op.localPath)return;await Promise.all($.map(async(W)=>{W.content=await this.downLoadImageAndReplaceContent(W.content)}));for(let W of $)try{let X=await this.saveContentToFile(W.content,W.path);c.debug(`Successfully saved: ${X}`)}catch(X){c.error(`Failed to save file ${W.path}:`,X)}}async ensureDirectoryExists($){if(!i$.default.existsSync($))c.debug(`Creating directory: ${$}`),await d0.default.mkdir($,{recursive:!0})}async saveContentToFile($,W){try{let X=J$.default.join(this.savePath,W),Q=J$.default.dirname(X);if(c.debug(`Full path: ${X}, directory: ${Q}`),await this.ensureDirectoryExists(Q),W.endsWith(".html"))c.debug("Wrapping content with HTML template"),$=this.wrapHtmlContent($);return c.debug(`Writing ${$.length} bytes to file`),await d0.default.writeFile(X,$),c.info(`File saved: ${X}`),X}catch(X){throw c.error("File save error:",W,X),X}}wrapHtmlContent($){return c.debug("Wrapping content with HTML template"),`<!DOCTYPE html>
|
6
6
|
<html>
|
7
7
|
<head>
|
8
8
|
<meta charset="UTF-8">
|
@@ -12,25 +12,18 @@ var E2=Object.create;var{getPrototypeOf:b2,defineProperty:L1,getOwnPropertyNames
|
|
12
12
|
<body>
|
13
13
|
${$}
|
14
14
|
</body>
|
15
|
-
</html>`}}var
|
16
|
-
`);if(
|
15
|
+
</html>`}}var o0=new k2;var r6=T("V3Tool"),f2=($)=>{$.tool("get_code","Generate UI code for a given node or the currently selected node in the Figma desktop app. Use the nodeId parameter to specify a node id. If no node id is provided, the currently selected node will be used. If a URL is provided, extract the node id from the URL, for example, if given the URL https://figma.com/design/:fileKey/:fileName?node-id=1-2, the extracted nodeId would be 1:2. IMPORTANT: After you call this tool, you should call get_image to get an image of the node for context.",{fileKey:J.string().describe("The Figma file identifier found in the file URL (e.g., https://www.figma.com/file/XXXXXXXXXXXX/). Extract the XXXXXXXXXXXX portion as the fileKey."),ids:J.string().describe('Comma-separated list of Figma node IDs for conversion. To obtain node IDs, select elements in Figma, right-click and select "Copy/Paste as" → "Copy ID".'),personalToken:J.string().optional().describe("Figma personal access token for API authentication.The parameters are not required when the tool is called."),localPath:J.string().optional().describe("Absolute path for asset(e.g., images) and code storage. Directory will be created if non-existent. Path must follow OS-specific format without special character escaping. When this path is set, all code-related static resources are stored in this directory, while other assets (e.g., images) will be saved into the subdirectory named assets under this path."),imgFormat:J.enum(["png","jpg","svg"]).default("png").describe('Export format for image assets: "png" for lossless quality, "jpg" for compressed files, or "svg" for vector graphics.'),scaleSize:J.number().min(1).max(4).default(2).describe("Image export scale factor (1-4). Higher values yield better quality at the cost of larger file sizes.")},async(W)=>{o0.setup(W);try{let X=await E2.nodeToCode({...W,format:"react-tailwind"})||[];if(await o0.checkLocalAndDownload(X),!X)return{content:[{type:"text",text:"Failed to generate any code. Please check if the provided Figma node IDs are correct or if the nodes can be converted to code."}]};let Q=Array.isArray(X)?X:[X];if(Q.length===0)return{content:[{type:"text",text:"Conversion succeeded but no files were generated. Please check if the selected Figma nodes contain convertible content."}]};let H=Q.filter((G)=>!G.path.endsWith("/index.scss")).map((G,B)=>`${B+1}. ${G.path}`).join(`
|
16
|
+
`);if(W.localPath)return{content:[{type:"text",text:`# Files Saved Locally
|
17
17
|
|
18
18
|
## Save Location
|
19
|
-
${
|
19
|
+
${W.localPath}
|
20
20
|
|
21
21
|
## Generated Files
|
22
|
-
${H}. Convert the Tailwind to vanilla CSS if not already used in the codebase. Do not install any dependencies.`}]};
|
23
|
-
\`\`\`${w}
|
24
|
-
${G.content}
|
25
|
-
\`\`\``}).join(`
|
22
|
+
${H}. Convert the Tailwind to vanilla CSS if not already used in the codebase. Do not install any dependencies.`}]};return{content:[{type:"text",text:`${Q.filter((G)=>G.path.endsWith(".tsx")).map((G)=>G.content).join(`
|
26
23
|
|
27
|
-
`);return{content:[{type:"text",text
|
28
|
-
${
|
24
|
+
`)} Convert the Tailwind to vanilla CSS if not already used in the codebase. Do not install any dependencies.`}]}}catch(X){return r6.error("Tool execution error:",X),{content:[{type:"text",text:`Error: ${X.message}`}]}}}),$.tool("get_image","Generate an image for a given node or the currently selected node in the Figma desktop app. Use the nodeId parameter to specify a node id. If no node id is provided, the currently selected node will be used. If a URL is provided, extract the node id from the URL, for example, if given the URL https://figma.com/design/:fileKey/:fileName?node-id=1-2, the extracted nodeId would be 1:2. Also export Figma design images for visual verification and design fidelity validation. Essential for comparing generated code output against original designs, ensuring pixel-perfect implementation and catching visual discrepancies during the design-to-code process.",{fileKey:J.string().describe("Figma file identifier from the URL for accessing the design source"),ids:J.string().describe('Comma-separated node IDs to export. Use "Copy ID" from Figma context menu to get precise element references for comparison'),format:J.enum(["jpg","png","svg","pdf"]).optional().describe('Export format for verification: "png" for pixel-perfect comparison with transparency, "jpg" for quick previews, "svg" for scalable reference, "pdf" for print validation'),scale:J.number().optional().describe("Scale factor (1-4x) for high-resolution comparison. Use 2x+ for detailed fidelity checks on retina displays"),svg_include_id:J.boolean().optional().describe("Include element IDs in SVG for precise element mapping during code validation"),svg_simplify_stroke:J.boolean().optional().describe("Simplify stroke paths for cleaner reference images during visual comparison"),use_absolute_bounds:J.boolean().optional().describe("Use absolute positioning for accurate layout verification against implemented code"),version:J.string().optional().describe("Specific design version for consistent comparison baseline"),personalToken:J.string().optional().describe("Figma personal access token for authenticated access to design files")},async(W)=>{try{let X=await v2.images(W);return{content:[{type:"text",text:JSON.stringify(X)}]}}catch(X){return{content:[{type:"text",text:`Error: ${X.message}`}]}}})};var F0=new p0({name:_2,version:U2},{capabilities:{logging:{}}});S2(F0);f2(F0);var a0=p$(require("node:process"));l$();class r0{append($){this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){if(!this._buffer)return null;let $=this._buffer.indexOf(`
|
25
|
+
`);if($===-1)return null;let W=this._buffer.toString("utf8",0,$).replace(/\r$/,"");return this._buffer=this._buffer.subarray($+1),a6(W)}clear(){this._buffer=void 0}}function a6($){return R3.parse(JSON.parse($))}function I2($){return JSON.stringify($)+`
|
26
|
+
`}class t0{constructor($=a0.default.stdin,W=a0.default.stdout){this._stdin=$,this._stdout=W,this._readBuffer=new r0,this._started=!1,this._ondata=(X)=>{this._readBuffer.append(X),this.processReadBuffer()},this._onerror=(X)=>{var Q;(Q=this.onerror)===null||Q===void 0||Q.call(this,X)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){var $,W;while(!0)try{let X=this._readBuffer.readMessage();if(X===null)break;($=this.onmessage)===null||$===void 0||$.call(this,X)}catch(X){(W=this.onerror)===null||W===void 0||W.call(this,X)}}async close(){var $;if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),($=this.onclose)===null||$===void 0||$.call(this)}send($){return new Promise((W)=>{let X=I2($);if(this._stdout.write(X))W();else this._stdout.once("drain",W)})}}j$();var t6=T("StdioTransport");async function C2($){try{let W=new t0;await $.connect(W)}catch(W){t6.info(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32000,message:`Server startup failed: ${W.message}`}})),process.exit(1)}}C2(F0);
|
29
27
|
|
30
|
-
|
31
|
-
${Y}. Convert the Tailwind to vanilla CSS if not already used in the codebase. Do not install any dependencies.`}]}}catch(W){return h6.error("Tool execution error:",W),{content:[{type:"text",text:`Error: ${W.message}`}]}}})};D0();var y6=g("FigmaRestApi");class U2{figmaHost="https://api.figma.com/v1";personalToken=m0;async files($){let X;if($.ids)X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/nodes`,$);else X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}`,$);return this.fetch(X)}async images($){let X=this.opToUrl(`${this.figmaHost}/images/${$.fileKey}`,$);return this.fetch(X)}async imageFills($){let X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/images`,$);return this.fetch(X)}async meta($){let X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/meta`,$);return this.fetch(X)}async fetch($,X="json"){try{let W={method:"GET",headers:{"X-FIGMA-TOKEN":this.personalToken}},Q=await fetch($,W);if(!Q.ok)throw new Error(`HTTP error! status: ${Q.status}`);return X==="text"?await Q.text():await Q.json()}catch(W){throw y6.error("HTTP error",W),W}}opToUrl($,X={},W=["fileKey","personalToken"]){if(Object.keys(X).length===0)return $;if(X.personalToken)this.personalToken=X.personalToken;let Q=new URL($);for(let[H,Y]of Object.entries(X))if(!W.includes(H))Q.searchParams.append(H,Y);return Q.toString()}}var K2=new U2;d();var N2=($)=>{$.tool("figma_get_images","Get images of Figma nodes",{fileKey:J.string().describe("Unique identifier of the Figma file"),ids:J.string().describe("Node IDs to get images for, comma separated"),format:J.enum(["jpg","png","svg","pdf"]).optional().describe("Image format, e.g., png, jpg, svg"),scale:J.number().optional().describe("Image scale factor"),svg_include_id:J.boolean().optional().describe("Whether SVG includes ID"),svg_simplify_stroke:J.boolean().optional().describe("Whether to simplify SVG strokes"),use_absolute_bounds:J.boolean().optional().describe("Whether to use absolute bounds"),version:J.string().optional().describe("Specify the version to return"),personalToken:J.string().optional().describe("Your Figma personal access token, The parameters are not required when the tool is called.")},async(X)=>{try{let W=await K2.images(X);return{content:[{type:"text",text:JSON.stringify(W)}]}}catch(W){return{content:[{type:"text",text:`Error: ${W.message}`}]}}})};var L2=($)=>{};var F2=($)=>{L2($)};var n0=new m1({name:z2,version:M2},{capabilities:{logging:{}}});F2(n0);N2(n0);O2(n0);var u1=c0(require("node:process"));h0();class c1{append($){this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){if(!this._buffer)return null;let $=this._buffer.indexOf(`
|
32
|
-
`);if($===-1)return null;let X=this._buffer.toString("utf8",0,$).replace(/\r$/,"");return this._buffer=this._buffer.subarray($+1),Z6(X)}clear(){this._buffer=void 0}}function Z6($){return U$.parse(JSON.parse($))}function S2($){return JSON.stringify($)+`
|
33
|
-
`}class p1{constructor($=u1.default.stdin,X=u1.default.stdout){this._stdin=$,this._stdout=X,this._readBuffer=new c1,this._started=!1,this._ondata=(W)=>{this._readBuffer.append(W),this.processReadBuffer()},this._onerror=(W)=>{var Q;(Q=this.onerror)===null||Q===void 0||Q.call(this,W)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){var $,X;while(!0)try{let W=this._readBuffer.readMessage();if(W===null)break;($=this.onmessage)===null||$===void 0||$.call(this,W)}catch(W){(X=this.onerror)===null||X===void 0||X.call(this,W)}}async close(){var $;if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),($=this.onclose)===null||$===void 0||$.call(this)}send($){return new Promise((X)=>{let W=S2($);if(this._stdout.write(W))X();else this._stdout.once("drain",X)})}}D0();var m6=g("StdioTransport");async function _2($){try{let X=new p1;await $.connect(X)}catch(X){m6.info(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32000,message:`Server startup failed: ${X.message}`}})),process.exit(1)}}_2(n0);
|
34
|
-
|
35
|
-
//# debugId=4BDFE662267DA2DD64756E2164756E21
|
28
|
+
//# debugId=CF04ECA407BC615164756E2164756E21
|
36
29
|
//# sourceMappingURL=stdio.js.map
|