@f2c/mcp 0.2.2 → 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 +28 -9
- package/dist/cli.js.map +20 -14
- package/dist/stdio.js +28 -9
- package/dist/stdio.js.map +20 -14
- package/dist/streamable-http.js +97 -78
- package/dist/streamable-http.js.map +33 -25
- package/package.json +1 -1
package/dist/stdio.js
CHANGED
@@ -1,10 +1,29 @@
|
|
1
|
-
var z1=Object.create;var{getPrototypeOf:V1,defineProperty:N2,getOwnPropertyNames:A1}=Object;var b1=Object.prototype.hasOwnProperty;var O2=($,W,X)=>{X=$!=null?z1(V1($)):{};let H=W||!$||!$.__esModule?N2(X,"default",{value:$,enumerable:!0}):X;for(let Q of A1($))if(!b1.call(H,Q))N2(H,Q,{get:()=>$[Q],enumerable:!0});return H};var E4=($,W)=>()=>(W||$((W={exports:{}}).exports,W),W.exports);var N1=($,W)=>{for(var X in W)N2($,X,{get:W[X],enumerable:!0,configurable:!0,set:(H)=>W[X]=()=>H})};var J={};N1(J,{void:()=>WW,util:()=>U,unknown:()=>e1,union:()=>JW,undefined:()=>a1,tuple:()=>wW,transformer:()=>OW,symbol:()=>r1,string:()=>s2,strictObject:()=>QW,setErrorMap:()=>q1,set:()=>MW,record:()=>BW,quotelessJson:()=>O1,promise:()=>NW,preprocess:()=>UW,pipeline:()=>LW,ostring:()=>KW,optional:()=>_W,onumber:()=>FW,oboolean:()=>SW,objectUtil:()=>_2,object:()=>HW,number:()=>e2,nullable:()=>qW,null:()=>t1,never:()=>$W,nativeEnum:()=>bW,nan:()=>p1,map:()=>DW,makeIssue:()=>S$,literal:()=>VW,lazy:()=>zW,late:()=>i1,isValid:()=>a,isDirty:()=>h$,isAsync:()=>B$,isAborted:()=>x$,intersection:()=>GW,instanceof:()=>c1,getParsedType:()=>u,getErrorMap:()=>w$,function:()=>jW,enum:()=>AW,effect:()=>OW,discriminatedUnion:()=>YW,defaultErrorMap:()=>d,datetimeRegex:()=>r2,date:()=>o1,custom:()=>t2,coerce:()=>EW,boolean:()=>$0,bigint:()=>d1,array:()=>XW,any:()=>s1,addIssueToContext:()=>z,ZodVoid:()=>f$,ZodUnknown:()=>t,ZodUnion:()=>A$,ZodUndefined:()=>z$,ZodType:()=>q,ZodTuple:()=>c,ZodTransformer:()=>x,ZodSymbol:()=>v$,ZodString:()=>g,ZodSet:()=>Y$,ZodSchema:()=>q,ZodRecord:()=>k$,ZodReadonly:()=>L$,ZodPromise:()=>G$,ZodPipeline:()=>C$,ZodParsedType:()=>j,ZodOptional:()=>k,ZodObject:()=>K,ZodNumber:()=>s,ZodNullable:()=>r,ZodNull:()=>V$,ZodNever:()=>i,ZodNativeEnum:()=>_$,ZodNaN:()=>P$,ZodMap:()=>I$,ZodLiteral:()=>O$,ZodLazy:()=>N$,ZodIssueCode:()=>D,ZodIntersection:()=>b$,ZodFunction:()=>M$,ZodFirstPartyTypeKind:()=>M,ZodError:()=>f,ZodEnum:()=>$$,ZodEffects:()=>x,ZodDiscriminatedUnion:()=>l$,ZodDefault:()=>q$,ZodDate:()=>Q$,ZodCatch:()=>U$,ZodBranded:()=>m$,ZodBoolean:()=>j$,ZodBigInt:()=>e,ZodArray:()=>T,ZodAny:()=>J$,Schema:()=>q,ParseStatus:()=>E,OK:()=>R,NEVER:()=>RW,INVALID:()=>b,EMPTY_PATH:()=>U1,DIRTY:()=>H$,BRAND:()=>u1});var U;(function($){$.assertEqual=(Q)=>{};function W(Q){}$.assertIs=W;function X(Q){throw new Error}$.assertNever=X,$.arrayToEnum=(Q)=>{let Y={};for(let G of Q)Y[G]=G;return Y},$.getValidEnumValues=(Q)=>{let Y=$.objectKeys(Q).filter((w)=>typeof Q[Q[w]]!=="number"),G={};for(let w of Y)G[w]=Q[w];return $.objectValues(G)},$.objectValues=(Q)=>{return $.objectKeys(Q).map(function(Y){return Q[Y]})},$.objectKeys=typeof Object.keys==="function"?(Q)=>Object.keys(Q):(Q)=>{let Y=[];for(let G in Q)if(Object.prototype.hasOwnProperty.call(Q,G))Y.push(G);return Y},$.find=(Q,Y)=>{for(let G of Q)if(Y(G))return G;return},$.isInteger=typeof Number.isInteger==="function"?(Q)=>Number.isInteger(Q):(Q)=>typeof Q==="number"&&Number.isFinite(Q)&&Math.floor(Q)===Q;function H(Q,Y=" | "){return Q.map((G)=>typeof G==="string"?`'${G}'`:G).join(Y)}$.joinValues=H,$.jsonStringifyReplacer=(Q,Y)=>{if(typeof Y==="bigint")return Y.toString();return Y}})(U||(U={}));var _2;(function($){$.mergeShapes=(W,X)=>{return{...W,...X}}})(_2||(_2={}));var j=U.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),u=($)=>{switch(typeof $){case"undefined":return j.undefined;case"string":return j.string;case"number":return Number.isNaN($)?j.nan:j.number;case"boolean":return j.boolean;case"function":return j.function;case"bigint":return j.bigint;case"symbol":return j.symbol;case"object":if(Array.isArray($))return j.array;if($===null)return j.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return j.promise;if(typeof Map!=="undefined"&&$ instanceof Map)return j.map;if(typeof Set!=="undefined"&&$ instanceof Set)return j.set;if(typeof Date!=="undefined"&&$ instanceof Date)return j.date;return j.object;default:return j.unknown}};var D=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"]),O1=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class f 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(Q){return Q.message},X={_errors:[]},H=(Q)=>{for(let Y of Q.issues)if(Y.code==="invalid_union")Y.unionErrors.map(H);else if(Y.code==="invalid_return_type")H(Y.returnTypeError);else if(Y.code==="invalid_arguments")H(Y.argumentsError);else if(Y.path.length===0)X._errors.push(W(Y));else{let G=X,w=0;while(w<Y.path.length){let B=Y.path[w];if(w!==Y.path.length-1)G[B]=G[B]||{_errors:[]};else G[B]=G[B]||{_errors:[]},G[B]._errors.push(W(Y));G=G[B],w++}}};return H(this),X}static assert($){if(!($ instanceof f))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 H of this.issues)if(H.path.length>0)W[H.path[0]]=W[H.path[0]]||[],W[H.path[0]].push($(H));else X.push($(H));return{formErrors:X,fieldErrors:W}}get formErrors(){return this.flatten()}}f.create=($)=>{return new f($)};var _1=($,W)=>{let X;switch($.code){case D.invalid_type:if($.received===j.undefined)X="Required";else X=`Expected ${$.expected}, received ${$.received}`;break;case D.invalid_literal:X=`Invalid literal value, expected ${JSON.stringify($.expected,U.jsonStringifyReplacer)}`;break;case D.unrecognized_keys:X=`Unrecognized key(s) in object: ${U.joinValues($.keys,", ")}`;break;case D.invalid_union:X="Invalid input";break;case D.invalid_union_discriminator:X=`Invalid discriminator value. Expected ${U.joinValues($.options)}`;break;case D.invalid_enum_value:X=`Invalid enum value. Expected ${U.joinValues($.options)}, received '${$.received}'`;break;case D.invalid_arguments:X="Invalid function arguments";break;case D.invalid_return_type:X="Invalid function return type";break;case D.invalid_date:X="Invalid date";break;case D.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 D.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 D.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 D.custom:X="Invalid input";break;case D.invalid_intersection_types:X="Intersection results could not be merged";break;case D.not_multiple_of:X=`Number must be a multiple of ${$.multipleOf}`;break;case D.not_finite:X="Number must be finite";break;default:X=W.defaultError,U.assertNever($)}return{message:X}},d=_1;var u2=d;function q1($){u2=$}function w$(){return u2}var S$=($)=>{let{data:W,path:X,errorMaps:H,issueData:Q}=$,Y=[...X,...Q.path||[]],G={...Q,path:Y};if(Q.message!==void 0)return{...Q,path:Y,message:Q.message};let w="",B=H.filter((V)=>!!V).slice().reverse();for(let V of B)w=V(G,{data:W,defaultError:w}).message;return{...Q,path:Y,message:w}},U1=[];function z($,W){let X=w$(),H=S$({issueData:W,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,X,X===d?void 0:d].filter((Q)=>!!Q)});$.common.issues.push(H)}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 H of W){if(H.status==="aborted")return b;if(H.status==="dirty")$.dirty();X.push(H.value)}return{status:$.value,value:X}}static async mergeObjectAsync($,W){let X=[];for(let H of W){let Q=await H.key,Y=await H.value;X.push({key:Q,value:Y})}return E.mergeObjectSync($,X)}static mergeObjectSync($,W){let X={};for(let H of W){let{key:Q,value:Y}=H;if(Q.status==="aborted")return b;if(Y.status==="aborted")return b;if(Q.status==="dirty")$.dirty();if(Y.status==="dirty")$.dirty();if(Q.value!=="__proto__"&&(typeof Y.value!=="undefined"||H.alwaysSet))X[Q.value]=Y.value}return{status:$.value,value:X}}}var b=Object.freeze({status:"aborted"}),H$=($)=>({status:"dirty",value:$}),R=($)=>({status:"valid",value:$}),x$=($)=>$.status==="aborted",h$=($)=>$.status==="dirty",a=($)=>$.status==="valid",B$=($)=>typeof Promise!=="undefined"&&$ instanceof Promise;var A;(function($){$.errToObj=(W)=>typeof W==="string"?{message:W}:W||{},$.toString=(W)=>typeof W==="string"?W:W?.message})(A||(A={}));var Z$=function($,W,X,H){if(X==="a"&&!H)throw new TypeError("Private accessor was defined without a getter");if(typeof W==="function"?$!==W||!H:!W.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return X==="m"?H:X==="a"?H.call($):H?H.value:W.get($)},p2=function($,W,X,H,Q){if(H==="m")throw new TypeError("Private method is not writable");if(H==="a"&&!Q)throw new TypeError("Private accessor was defined without a setter");if(typeof W==="function"?$!==W||!Q:!W.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return H==="a"?Q.call($,X):Q?Q.value=X:W.set($,X),X},E$,R$;class y{constructor($,W,X,H){this._cachedPath=[],this.parent=$,this.data=W,this._path=X,this._key=H}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}}var i2=($,W)=>{if(a(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 f($.common.issues);return this._error=X,this._error}}}};function O($){if(!$)return{};let{errorMap:W,invalid_type_error:X,required_error:H,description:Q}=$;if(W&&(X||H))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(W)return{errorMap:W,description:Q};return{errorMap:(G,w)=>{let{message:B}=$;if(G.code==="invalid_enum_value")return{message:B??w.defaultError};if(typeof w.data==="undefined")return{message:B??H??w.defaultError};if(G.code!=="invalid_type")return{message:w.defaultError};return{message:B??X??w.defaultError}},description:Q}}class q{get description(){return this._def.description}_getType($){return u($.data)}_getOrReturnCtx($,W){return W||{common:$.parent.common,data:$.data,parsedType:u($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new E,ctx:{common:$.parent.common,data:$.data,parsedType:u($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let W=this._parse($);if(B$(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:u($)},H=this._parseSync({data:$,path:X.path,parent:X});return i2(X,H)}"~validate"($){let W={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:u($)};if(!this["~standard"].async)try{let X=this._parseSync({data:$,path:[],parent:W});return a(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)=>a(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:u($)},H=this._parse({data:$,path:X.path,parent:X}),Q=await(B$(H)?H:Promise.resolve(H));return i2(X,Q)}refine($,W){let X=(H)=>{if(typeof W==="string"||typeof W==="undefined")return{message:W};else if(typeof W==="function")return W(H);else return W};return this._refinement((H,Q)=>{let Y=$(H),G=()=>Q.addIssue({code:D.custom,...X(H)});if(typeof Promise!=="undefined"&&Y instanceof Promise)return Y.then((w)=>{if(!w)return G(),!1;else return!0});if(!Y)return G(),!1;else return!0})}refinement($,W){return this._refinement((X,H)=>{if(!$(X))return H.addIssue(typeof W==="function"?W(X,H):W),!1;else return!0})}_refinement($){return new x({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 k.create(this,this._def)}nullable(){return r.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return T.create(this)}promise(){return G$.create(this,this._def)}or($){return A$.create([this,$],this._def)}and($){return b$.create(this,$,this._def)}transform($){return new x({...O(this._def),schema:this,typeName:M.ZodEffects,effect:{type:"transform",transform:$}})}default($){let W=typeof $==="function"?$:()=>$;return new q$({...O(this._def),innerType:this,defaultValue:W,typeName:M.ZodDefault})}brand(){return new m$({typeName:M.ZodBranded,type:this,...O(this._def)})}catch($){let W=typeof $==="function"?$:()=>$;return new U$({...O(this._def),innerType:this,catchValue:W,typeName:M.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return C$.create(this,$)}readonly(){return L$.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var L1=/^c[^\s-]{8,}$/i,K1=/^[0-9a-z]+$/,F1=/^[0-9A-HJKMNP-TV-Z]{26}$/i,S1=/^[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,E1=/^[a-z0-9_-]{21}$/i,R1=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,v1=/^[-+]?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)?)??$/,f1=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,k1="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",q2,I1=/^(?:(?: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])$/,P1=/^(?:(?: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])$/,C1=/^(([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]))$/,g1=/^(([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])$/,T1=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,y1=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,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])))",x1=new RegExp(`^${d2}$`);function o2($){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 h1($){return new RegExp(`^${o2($)}$`)}function r2($){let W=`${d2}T${o2($)}`,X=[];if(X.push($.local?"Z?":"Z"),$.offset)X.push("([+-]\\d{2}:?\\d{2})");return W=`${W}(${X.join("|")})`,new RegExp(`^${W}$`)}function Z1($,W){if((W==="v4"||!W)&&I1.test($))return!0;if((W==="v6"||!W)&&C1.test($))return!0;return!1}function l1($,W){if(!R1.test($))return!1;try{let[X]=$.split("."),H=X.replace(/-/g,"+").replace(/_/g,"/").padEnd(X.length+(4-X.length%4)%4,"="),Q=JSON.parse(atob(H));if(typeof Q!=="object"||Q===null)return!1;if("typ"in Q&&Q?.typ!=="JWT")return!1;if(!Q.alg)return!1;if(W&&Q.alg!==W)return!1;return!0}catch{return!1}}function m1($,W){if((W==="v4"||!W)&&P1.test($))return!0;if((W==="v6"||!W)&&g1.test($))return!0;return!1}class g extends q{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==j.string){let Q=this._getOrReturnCtx($);return z(Q,{code:D.invalid_type,expected:j.string,received:Q.parsedType}),b}let X=new E,H=void 0;for(let Q of this._def.checks)if(Q.kind==="min"){if($.data.length<Q.value)H=this._getOrReturnCtx($,H),z(H,{code:D.too_small,minimum:Q.value,type:"string",inclusive:!0,exact:!1,message:Q.message}),X.dirty()}else if(Q.kind==="max"){if($.data.length>Q.value)H=this._getOrReturnCtx($,H),z(H,{code:D.too_big,maximum:Q.value,type:"string",inclusive:!0,exact:!1,message:Q.message}),X.dirty()}else if(Q.kind==="length"){let Y=$.data.length>Q.value,G=$.data.length<Q.value;if(Y||G){if(H=this._getOrReturnCtx($,H),Y)z(H,{code:D.too_big,maximum:Q.value,type:"string",inclusive:!0,exact:!0,message:Q.message});else if(G)z(H,{code:D.too_small,minimum:Q.value,type:"string",inclusive:!0,exact:!0,message:Q.message});X.dirty()}}else if(Q.kind==="email"){if(!f1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"email",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="emoji"){if(!q2)q2=new RegExp(k1,"u");if(!q2.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"emoji",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="uuid"){if(!S1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"uuid",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="nanoid"){if(!E1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"nanoid",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cuid"){if(!L1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"cuid",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cuid2"){if(!K1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"cuid2",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="ulid"){if(!F1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"ulid",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="url")try{new URL($.data)}catch{H=this._getOrReturnCtx($,H),z(H,{validation:"url",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="regex"){if(Q.regex.lastIndex=0,!Q.regex.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"regex",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="trim")$.data=$.data.trim();else if(Q.kind==="includes"){if(!$.data.includes(Q.value,Q.position))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:{includes:Q.value,position:Q.position},message:Q.message}),X.dirty()}else if(Q.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(Q.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(Q.kind==="startsWith"){if(!$.data.startsWith(Q.value))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:{startsWith:Q.value},message:Q.message}),X.dirty()}else if(Q.kind==="endsWith"){if(!$.data.endsWith(Q.value))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:{endsWith:Q.value},message:Q.message}),X.dirty()}else if(Q.kind==="datetime"){if(!r2(Q).test($.data))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:"datetime",message:Q.message}),X.dirty()}else if(Q.kind==="date"){if(!x1.test($.data))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:"date",message:Q.message}),X.dirty()}else if(Q.kind==="time"){if(!h1(Q).test($.data))H=this._getOrReturnCtx($,H),z(H,{code:D.invalid_string,validation:"time",message:Q.message}),X.dirty()}else if(Q.kind==="duration"){if(!v1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"duration",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="ip"){if(!Z1($.data,Q.version))H=this._getOrReturnCtx($,H),z(H,{validation:"ip",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="jwt"){if(!l1($.data,Q.alg))H=this._getOrReturnCtx($,H),z(H,{validation:"jwt",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="cidr"){if(!m1($.data,Q.version))H=this._getOrReturnCtx($,H),z(H,{validation:"cidr",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="base64"){if(!T1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"base64",code:D.invalid_string,message:Q.message}),X.dirty()}else if(Q.kind==="base64url"){if(!y1.test($.data))H=this._getOrReturnCtx($,H),z(H,{validation:"base64url",code:D.invalid_string,message:Q.message}),X.dirty()}else U.assertNever(Q);return{status:X.value,value:$.data}}_regex($,W,X){return this.refinement((H)=>$.test(H),{validation:W,code:D.invalid_string,...A.errToObj(X)})}_addCheck($){return new g({...this._def,checks:[...this._def.checks,$]})}email($){return this._addCheck({kind:"email",...A.errToObj($)})}url($){return this._addCheck({kind:"url",...A.errToObj($)})}emoji($){return this._addCheck({kind:"emoji",...A.errToObj($)})}uuid($){return this._addCheck({kind:"uuid",...A.errToObj($)})}nanoid($){return this._addCheck({kind:"nanoid",...A.errToObj($)})}cuid($){return this._addCheck({kind:"cuid",...A.errToObj($)})}cuid2($){return this._addCheck({kind:"cuid2",...A.errToObj($)})}ulid($){return this._addCheck({kind:"ulid",...A.errToObj($)})}base64($){return this._addCheck({kind:"base64",...A.errToObj($)})}base64url($){return this._addCheck({kind:"base64url",...A.errToObj($)})}jwt($){return this._addCheck({kind:"jwt",...A.errToObj($)})}ip($){return this._addCheck({kind:"ip",...A.errToObj($)})}cidr($){return this._addCheck({kind:"cidr",...A.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,...A.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,...A.errToObj($?.message)})}duration($){return this._addCheck({kind:"duration",...A.errToObj($)})}regex($,W){return this._addCheck({kind:"regex",regex:$,...A.errToObj(W)})}includes($,W){return this._addCheck({kind:"includes",value:$,position:W?.position,...A.errToObj(W?.message)})}startsWith($,W){return this._addCheck({kind:"startsWith",value:$,...A.errToObj(W)})}endsWith($,W){return this._addCheck({kind:"endsWith",value:$,...A.errToObj(W)})}min($,W){return this._addCheck({kind:"min",value:$,...A.errToObj(W)})}max($,W){return this._addCheck({kind:"max",value:$,...A.errToObj(W)})}length($,W){return this._addCheck({kind:"length",value:$,...A.errToObj(W)})}nonempty($){return this.min(1,A.errToObj($))}trim(){return new g({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new g({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new g({...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 $}}g.create=($)=>{return new g({checks:[],typeName:M.ZodString,coerce:$?.coerce??!1,...O($)})};function n1($,W){let X=($.toString().split(".")[1]||"").length,H=(W.toString().split(".")[1]||"").length,Q=X>H?X:H,Y=Number.parseInt($.toFixed(Q).replace(".","")),G=Number.parseInt(W.toFixed(Q).replace(".",""));return Y%G/10**Q}class s extends q{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($)!==j.number){let Q=this._getOrReturnCtx($);return z(Q,{code:D.invalid_type,expected:j.number,received:Q.parsedType}),b}let X=void 0,H=new E;for(let Q of this._def.checks)if(Q.kind==="int"){if(!U.isInteger($.data))X=this._getOrReturnCtx($,X),z(X,{code:D.invalid_type,expected:"integer",received:"float",message:Q.message}),H.dirty()}else if(Q.kind==="min"){if(Q.inclusive?$.data<Q.value:$.data<=Q.value)X=this._getOrReturnCtx($,X),z(X,{code:D.too_small,minimum:Q.value,type:"number",inclusive:Q.inclusive,exact:!1,message:Q.message}),H.dirty()}else if(Q.kind==="max"){if(Q.inclusive?$.data>Q.value:$.data>=Q.value)X=this._getOrReturnCtx($,X),z(X,{code:D.too_big,maximum:Q.value,type:"number",inclusive:Q.inclusive,exact:!1,message:Q.message}),H.dirty()}else if(Q.kind==="multipleOf"){if(n1($.data,Q.value)!==0)X=this._getOrReturnCtx($,X),z(X,{code:D.not_multiple_of,multipleOf:Q.value,message:Q.message}),H.dirty()}else if(Q.kind==="finite"){if(!Number.isFinite($.data))X=this._getOrReturnCtx($,X),z(X,{code:D.not_finite,message:Q.message}),H.dirty()}else U.assertNever(Q);return{status:H.value,value:$.data}}gte($,W){return this.setLimit("min",$,!0,A.toString(W))}gt($,W){return this.setLimit("min",$,!1,A.toString(W))}lte($,W){return this.setLimit("max",$,!0,A.toString(W))}lt($,W){return this.setLimit("max",$,!1,A.toString(W))}setLimit($,W,X,H){return new s({...this._def,checks:[...this._def.checks,{kind:$,value:W,inclusive:X,message:A.toString(H)}]})}_addCheck($){return new s({...this._def,checks:[...this._def.checks,$]})}int($){return this._addCheck({kind:"int",message:A.toString($)})}positive($){return this._addCheck({kind:"min",value:0,inclusive:!1,message:A.toString($)})}negative($){return this._addCheck({kind:"max",value:0,inclusive:!1,message:A.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:0,inclusive:!0,message:A.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:0,inclusive:!0,message:A.toString($)})}multipleOf($,W){return this._addCheck({kind:"multipleOf",value:$,message:A.toString(W)})}finite($){return this._addCheck({kind:"finite",message:A.toString($)})}safe($){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:A.toString($)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:A.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($)}}s.create=($)=>{return new s({checks:[],typeName:M.ZodNumber,coerce:$?.coerce||!1,...O($)})};class e extends q{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($)!==j.bigint)return this._getInvalidInput($);let X=void 0,H=new E;for(let Q of this._def.checks)if(Q.kind==="min"){if(Q.inclusive?$.data<Q.value:$.data<=Q.value)X=this._getOrReturnCtx($,X),z(X,{code:D.too_small,type:"bigint",minimum:Q.value,inclusive:Q.inclusive,message:Q.message}),H.dirty()}else if(Q.kind==="max"){if(Q.inclusive?$.data>Q.value:$.data>=Q.value)X=this._getOrReturnCtx($,X),z(X,{code:D.too_big,type:"bigint",maximum:Q.value,inclusive:Q.inclusive,message:Q.message}),H.dirty()}else if(Q.kind==="multipleOf"){if($.data%Q.value!==BigInt(0))X=this._getOrReturnCtx($,X),z(X,{code:D.not_multiple_of,multipleOf:Q.value,message:Q.message}),H.dirty()}else U.assertNever(Q);return{status:H.value,value:$.data}}_getInvalidInput($){let W=this._getOrReturnCtx($);return z(W,{code:D.invalid_type,expected:j.bigint,received:W.parsedType}),b}gte($,W){return this.setLimit("min",$,!0,A.toString(W))}gt($,W){return this.setLimit("min",$,!1,A.toString(W))}lte($,W){return this.setLimit("max",$,!0,A.toString(W))}lt($,W){return this.setLimit("max",$,!1,A.toString(W))}setLimit($,W,X,H){return new e({...this._def,checks:[...this._def.checks,{kind:$,value:W,inclusive:X,message:A.toString(H)}]})}_addCheck($){return new e({...this._def,checks:[...this._def.checks,$]})}positive($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:A.toString($)})}negative($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:A.toString($)})}nonpositive($){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:A.toString($)})}nonnegative($){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:A.toString($)})}multipleOf($,W){return this._addCheck({kind:"multipleOf",value:$,message:A.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 $}}e.create=($)=>{return new e({checks:[],typeName:M.ZodBigInt,coerce:$?.coerce??!1,...O($)})};class j$ extends q{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==j.boolean){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.boolean,received:X.parsedType}),b}return R($.data)}}j$.create=($)=>{return new j$({typeName:M.ZodBoolean,coerce:$?.coerce||!1,...O($)})};class Q$ extends q{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==j.date){let Q=this._getOrReturnCtx($);return z(Q,{code:D.invalid_type,expected:j.date,received:Q.parsedType}),b}if(Number.isNaN($.data.getTime())){let Q=this._getOrReturnCtx($);return z(Q,{code:D.invalid_date}),b}let X=new E,H=void 0;for(let Q of this._def.checks)if(Q.kind==="min"){if($.data.getTime()<Q.value)H=this._getOrReturnCtx($,H),z(H,{code:D.too_small,message:Q.message,inclusive:!0,exact:!1,minimum:Q.value,type:"date"}),X.dirty()}else if(Q.kind==="max"){if($.data.getTime()>Q.value)H=this._getOrReturnCtx($,H),z(H,{code:D.too_big,message:Q.message,inclusive:!0,exact:!1,maximum:Q.value,type:"date"}),X.dirty()}else U.assertNever(Q);return{status:X.value,value:new Date($.data.getTime())}}_addCheck($){return new Q$({...this._def,checks:[...this._def.checks,$]})}min($,W){return this._addCheck({kind:"min",value:$.getTime(),message:A.toString(W)})}max($,W){return this._addCheck({kind:"max",value:$.getTime(),message:A.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}}Q$.create=($)=>{return new Q$({checks:[],coerce:$?.coerce||!1,typeName:M.ZodDate,...O($)})};class v$ extends q{_parse($){if(this._getType($)!==j.symbol){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.symbol,received:X.parsedType}),b}return R($.data)}}v$.create=($)=>{return new v$({typeName:M.ZodSymbol,...O($)})};class z$ extends q{_parse($){if(this._getType($)!==j.undefined){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.undefined,received:X.parsedType}),b}return R($.data)}}z$.create=($)=>{return new z$({typeName:M.ZodUndefined,...O($)})};class V$ extends q{_parse($){if(this._getType($)!==j.null){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.null,received:X.parsedType}),b}return R($.data)}}V$.create=($)=>{return new V$({typeName:M.ZodNull,...O($)})};class J$ extends q{constructor(){super(...arguments);this._any=!0}_parse($){return R($.data)}}J$.create=($)=>{return new J$({typeName:M.ZodAny,...O($)})};class t extends q{constructor(){super(...arguments);this._unknown=!0}_parse($){return R($.data)}}t.create=($)=>{return new t({typeName:M.ZodUnknown,...O($)})};class i extends q{_parse($){let W=this._getOrReturnCtx($);return z(W,{code:D.invalid_type,expected:j.never,received:W.parsedType}),b}}i.create=($)=>{return new i({typeName:M.ZodNever,...O($)})};class f$ extends q{_parse($){if(this._getType($)!==j.undefined){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.void,received:X.parsedType}),b}return R($.data)}}f$.create=($)=>{return new f$({typeName:M.ZodVoid,...O($)})};class T extends q{_parse($){let{ctx:W,status:X}=this._processInputParams($),H=this._def;if(W.parsedType!==j.array)return z(W,{code:D.invalid_type,expected:j.array,received:W.parsedType}),b;if(H.exactLength!==null){let Y=W.data.length>H.exactLength.value,G=W.data.length<H.exactLength.value;if(Y||G)z(W,{code:Y?D.too_big:D.too_small,minimum:G?H.exactLength.value:void 0,maximum:Y?H.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:H.exactLength.message}),X.dirty()}if(H.minLength!==null){if(W.data.length<H.minLength.value)z(W,{code:D.too_small,minimum:H.minLength.value,type:"array",inclusive:!0,exact:!1,message:H.minLength.message}),X.dirty()}if(H.maxLength!==null){if(W.data.length>H.maxLength.value)z(W,{code:D.too_big,maximum:H.maxLength.value,type:"array",inclusive:!0,exact:!1,message:H.maxLength.message}),X.dirty()}if(W.common.async)return Promise.all([...W.data].map((Y,G)=>{return H.type._parseAsync(new y(W,Y,W.path,G))})).then((Y)=>{return E.mergeArray(X,Y)});let Q=[...W.data].map((Y,G)=>{return H.type._parseSync(new y(W,Y,W.path,G))});return E.mergeArray(X,Q)}get element(){return this._def.type}min($,W){return new T({...this._def,minLength:{value:$,message:A.toString(W)}})}max($,W){return new T({...this._def,maxLength:{value:$,message:A.toString(W)}})}length($,W){return new T({...this._def,exactLength:{value:$,message:A.toString(W)}})}nonempty($){return this.min(1,$)}}T.create=($,W)=>{return new T({type:$,minLength:null,maxLength:null,exactLength:null,typeName:M.ZodArray,...O(W)})};function D$($){if($ instanceof K){let W={};for(let X in $.shape){let H=$.shape[X];W[X]=k.create(D$(H))}return new K({...$._def,shape:()=>W})}else if($ instanceof T)return new T({...$._def,type:D$($.element)});else if($ instanceof k)return k.create(D$($.unwrap()));else if($ instanceof r)return r.create(D$($.unwrap()));else if($ instanceof c)return c.create($.items.map((W)=>D$(W)));else return $}class K extends q{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($)!==j.object){let B=this._getOrReturnCtx($);return z(B,{code:D.invalid_type,expected:j.object,received:B.parsedType}),b}let{status:X,ctx:H}=this._processInputParams($),{shape:Q,keys:Y}=this._getCached(),G=[];if(!(this._def.catchall instanceof i&&this._def.unknownKeys==="strip")){for(let B in H.data)if(!Y.includes(B))G.push(B)}let w=[];for(let B of Y){let V=Q[B],_=H.data[B];w.push({key:{status:"valid",value:B},value:V._parse(new y(H,_,H.path,B)),alwaysSet:B in H.data})}if(this._def.catchall instanceof i){let B=this._def.unknownKeys;if(B==="passthrough")for(let V of G)w.push({key:{status:"valid",value:V},value:{status:"valid",value:H.data[V]}});else if(B==="strict"){if(G.length>0)z(H,{code:D.unrecognized_keys,keys:G}),X.dirty()}else if(B==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let B=this._def.catchall;for(let V of G){let _=H.data[V];w.push({key:{status:"valid",value:V},value:B._parse(new y(H,_,H.path,V)),alwaysSet:V in H.data})}}if(H.common.async)return Promise.resolve().then(async()=>{let B=[];for(let V of w){let _=await V.key,P=await V.value;B.push({key:_,value:P,alwaysSet:V.alwaysSet})}return B}).then((B)=>{return E.mergeObjectSync(X,B)});else return E.mergeObjectSync(X,w)}get shape(){return this._def.shape()}strict($){return A.errToObj,new K({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(W,X)=>{let H=this._def.errorMap?.(W,X).message??X.defaultError;if(W.code==="unrecognized_keys")return{message:A.errToObj($).message??H};return{message:H}}}:{}})}strip(){return new K({...this._def,unknownKeys:"strip"})}passthrough(){return new K({...this._def,unknownKeys:"passthrough"})}extend($){return new K({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new K({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:M.ZodObject})}setKey($,W){return this.augment({[$]:W})}catchall($){return new K({...this._def,catchall:$})}pick($){let W={};for(let X of U.objectKeys($))if($[X]&&this.shape[X])W[X]=this.shape[X];return new K({...this._def,shape:()=>W})}omit($){let W={};for(let X of U.objectKeys(this.shape))if(!$[X])W[X]=this.shape[X];return new K({...this._def,shape:()=>W})}deepPartial(){return D$(this)}partial($){let W={};for(let X of U.objectKeys(this.shape)){let H=this.shape[X];if($&&!$[X])W[X]=H;else W[X]=H.optional()}return new K({...this._def,shape:()=>W})}required($){let W={};for(let X of U.objectKeys(this.shape))if($&&!$[X])W[X]=this.shape[X];else{let Q=this.shape[X];while(Q instanceof k)Q=Q._def.innerType;W[X]=Q}return new K({...this._def,shape:()=>W})}keyof(){return a2(U.objectKeys(this.shape))}}K.create=($,W)=>{return new K({shape:()=>$,unknownKeys:"strip",catchall:i.create(),typeName:M.ZodObject,...O(W)})};K.strictCreate=($,W)=>{return new K({shape:()=>$,unknownKeys:"strict",catchall:i.create(),typeName:M.ZodObject,...O(W)})};K.lazycreate=($,W)=>{return new K({shape:$,unknownKeys:"strip",catchall:i.create(),typeName:M.ZodObject,...O(W)})};class A$ extends q{_parse($){let{ctx:W}=this._processInputParams($),X=this._def.options;function H(Q){for(let G of Q)if(G.result.status==="valid")return G.result;for(let G of Q)if(G.result.status==="dirty")return W.common.issues.push(...G.ctx.common.issues),G.result;let Y=Q.map((G)=>new f(G.ctx.common.issues));return z(W,{code:D.invalid_union,unionErrors:Y}),b}if(W.common.async)return Promise.all(X.map(async(Q)=>{let Y={...W,common:{...W.common,issues:[]},parent:null};return{result:await Q._parseAsync({data:W.data,path:W.path,parent:Y}),ctx:Y}})).then(H);else{let Q=void 0,Y=[];for(let w of X){let B={...W,common:{...W.common,issues:[]},parent:null},V=w._parseSync({data:W.data,path:W.path,parent:B});if(V.status==="valid")return V;else if(V.status==="dirty"&&!Q)Q={result:V,ctx:B};if(B.common.issues.length)Y.push(B.common.issues)}if(Q)return W.common.issues.push(...Q.ctx.common.issues),Q.result;let G=Y.map((w)=>new f(w));return z(W,{code:D.invalid_union,unionErrors:G}),b}}get options(){return this._def.options}}A$.create=($,W)=>{return new A$({options:$,typeName:M.ZodUnion,...O(W)})};var o=($)=>{if($ instanceof N$)return o($.schema);else if($ instanceof x)return o($.innerType());else if($ instanceof O$)return[$.value];else if($ instanceof $$)return $.options;else if($ instanceof _$)return U.objectValues($.enum);else if($ instanceof q$)return o($._def.innerType);else if($ instanceof z$)return[void 0];else if($ instanceof V$)return[null];else if($ instanceof k)return[void 0,...o($.unwrap())];else if($ instanceof r)return[null,...o($.unwrap())];else if($ instanceof m$)return o($.unwrap());else if($ instanceof L$)return o($.unwrap());else if($ instanceof U$)return o($._def.innerType);else return[]};class l$ extends q{_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==j.object)return z(W,{code:D.invalid_type,expected:j.object,received:W.parsedType}),b;let X=this.discriminator,H=W.data[X],Q=this.optionsMap.get(H);if(!Q)return z(W,{code:D.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[X]}),b;if(W.common.async)return Q._parseAsync({data:W.data,path:W.path,parent:W});else return Q._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 H=new Map;for(let Q of W){let Y=o(Q.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(H.has(G))throw new Error(`Discriminator property ${String($)} has duplicate value ${String(G)}`);H.set(G,Q)}}return new l$({typeName:M.ZodDiscriminatedUnion,discriminator:$,options:W,optionsMap:H,...O(X)})}}function U2($,W){let X=u($),H=u(W);if($===W)return{valid:!0,data:$};else if(X===j.object&&H===j.object){let Q=U.objectKeys(W),Y=U.objectKeys($).filter((w)=>Q.indexOf(w)!==-1),G={...$,...W};for(let w of Y){let B=U2($[w],W[w]);if(!B.valid)return{valid:!1};G[w]=B.data}return{valid:!0,data:G}}else if(X===j.array&&H===j.array){if($.length!==W.length)return{valid:!1};let Q=[];for(let Y=0;Y<$.length;Y++){let G=$[Y],w=W[Y],B=U2(G,w);if(!B.valid)return{valid:!1};Q.push(B.data)}return{valid:!0,data:Q}}else if(X===j.date&&H===j.date&&+$===+W)return{valid:!0,data:$};else return{valid:!1}}class b$ extends q{_parse($){let{status:W,ctx:X}=this._processInputParams($),H=(Q,Y)=>{if(x$(Q)||x$(Y))return b;let G=U2(Q.value,Y.value);if(!G.valid)return z(X,{code:D.invalid_intersection_types}),b;if(h$(Q)||h$(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(([Q,Y])=>H(Q,Y));else return H(this._def.left._parseSync({data:X.data,path:X.path,parent:X}),this._def.right._parseSync({data:X.data,path:X.path,parent:X}))}}b$.create=($,W,X)=>{return new b$({left:$,right:W,typeName:M.ZodIntersection,...O(X)})};class c extends q{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==j.array)return z(X,{code:D.invalid_type,expected:j.array,received:X.parsedType}),b;if(X.data.length<this._def.items.length)return z(X,{code:D.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)z(X,{code:D.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),W.dirty();let Q=[...X.data].map((Y,G)=>{let w=this._def.items[G]||this._def.rest;if(!w)return null;return w._parse(new y(X,Y,X.path,G))}).filter((Y)=>!!Y);if(X.common.async)return Promise.all(Q).then((Y)=>{return E.mergeArray(W,Y)});else return E.mergeArray(W,Q)}get items(){return this._def.items}rest($){return new c({...this._def,rest:$})}}c.create=($,W)=>{if(!Array.isArray($))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new c({items:$,typeName:M.ZodTuple,rest:null,...O(W)})};class k$ extends q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==j.object)return z(X,{code:D.invalid_type,expected:j.object,received:X.parsedType}),b;let H=[],Q=this._def.keyType,Y=this._def.valueType;for(let G in X.data)H.push({key:Q._parse(new y(X,G,X.path,G)),value:Y._parse(new y(X,X.data[G],X.path,G)),alwaysSet:G in X.data});if(X.common.async)return E.mergeObjectAsync(W,H);else return E.mergeObjectSync(W,H)}get element(){return this._def.valueType}static create($,W,X){if(W instanceof q)return new k$({keyType:$,valueType:W,typeName:M.ZodRecord,...O(X)});return new k$({keyType:g.create(),valueType:$,typeName:M.ZodRecord,...O(W)})}}class I$ extends q{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==j.map)return z(X,{code:D.invalid_type,expected:j.map,received:X.parsedType}),b;let H=this._def.keyType,Q=this._def.valueType,Y=[...X.data.entries()].map(([G,w],B)=>{return{key:H._parse(new y(X,G,X.path,[B,"key"])),value:Q._parse(new y(X,w,X.path,[B,"value"]))}});if(X.common.async){let G=new Map;return Promise.resolve().then(async()=>{for(let w of Y){let B=await w.key,V=await w.value;if(B.status==="aborted"||V.status==="aborted")return b;if(B.status==="dirty"||V.status==="dirty")W.dirty();G.set(B.value,V.value)}return{status:W.value,value:G}})}else{let G=new Map;for(let w of Y){let{key:B,value:V}=w;if(B.status==="aborted"||V.status==="aborted")return b;if(B.status==="dirty"||V.status==="dirty")W.dirty();G.set(B.value,V.value)}return{status:W.value,value:G}}}}I$.create=($,W,X)=>{return new I$({valueType:W,keyType:$,typeName:M.ZodMap,...O(X)})};class Y$ extends q{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.parsedType!==j.set)return z(X,{code:D.invalid_type,expected:j.set,received:X.parsedType}),b;let H=this._def;if(H.minSize!==null){if(X.data.size<H.minSize.value)z(X,{code:D.too_small,minimum:H.minSize.value,type:"set",inclusive:!0,exact:!1,message:H.minSize.message}),W.dirty()}if(H.maxSize!==null){if(X.data.size>H.maxSize.value)z(X,{code:D.too_big,maximum:H.maxSize.value,type:"set",inclusive:!0,exact:!1,message:H.maxSize.message}),W.dirty()}let Q=this._def.valueType;function Y(w){let B=new Set;for(let V of w){if(V.status==="aborted")return b;if(V.status==="dirty")W.dirty();B.add(V.value)}return{status:W.value,value:B}}let G=[...X.data.values()].map((w,B)=>Q._parse(new y(X,w,X.path,B)));if(X.common.async)return Promise.all(G).then((w)=>Y(w));else return Y(G)}min($,W){return new Y$({...this._def,minSize:{value:$,message:A.toString(W)}})}max($,W){return new Y$({...this._def,maxSize:{value:$,message:A.toString(W)}})}size($,W){return this.min($,W).max($,W)}nonempty($){return this.min(1,$)}}Y$.create=($,W)=>{return new Y$({valueType:$,minSize:null,maxSize:null,typeName:M.ZodSet,...O(W)})};class M$ extends q{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==j.function)return z(W,{code:D.invalid_type,expected:j.function,received:W.parsedType}),b;function X(G,w){return S$({data:G,path:W.path,errorMaps:[W.common.contextualErrorMap,W.schemaErrorMap,w$(),d].filter((B)=>!!B),issueData:{code:D.invalid_arguments,argumentsError:w}})}function H(G,w){return S$({data:G,path:W.path,errorMaps:[W.common.contextualErrorMap,W.schemaErrorMap,w$(),d].filter((B)=>!!B),issueData:{code:D.invalid_return_type,returnTypeError:w}})}let Q={errorMap:W.common.contextualErrorMap},Y=W.data;if(this._def.returns instanceof G$){let G=this;return R(async function(...w){let B=new f([]),V=await G._def.args.parseAsync(w,Q).catch((W$)=>{throw B.addIssue(X(w,W$)),B}),_=await Reflect.apply(Y,this,V);return await G._def.returns._def.type.parseAsync(_,Q).catch((W$)=>{throw B.addIssue(H(_,W$)),B})})}else{let G=this;return R(function(...w){let B=G._def.args.safeParse(w,Q);if(!B.success)throw new f([X(w,B.error)]);let V=Reflect.apply(Y,this,B.data),_=G._def.returns.safeParse(V,Q);if(!_.success)throw new f([H(V,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new M$({...this._def,args:c.create($).rest(t.create())})}returns($){return new M$({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,W,X){return new M$({args:$?$:c.create([]).rest(t.create()),returns:W||t.create(),typeName:M.ZodFunction,...O(X)})}}class N$ extends q{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})}}N$.create=($,W)=>{return new N$({getter:$,typeName:M.ZodLazy,...O(W)})};class O$ extends q{_parse($){if($.data!==this._def.value){let W=this._getOrReturnCtx($);return z(W,{received:W.data,code:D.invalid_literal,expected:this._def.value}),b}return{status:"valid",value:$.data}}get value(){return this._def.value}}O$.create=($,W)=>{return new O$({value:$,typeName:M.ZodLiteral,...O(W)})};function a2($,W){return new $$({values:$,typeName:M.ZodEnum,...O(W)})}class $$ extends q{constructor(){super(...arguments);E$.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let W=this._getOrReturnCtx($),X=this._def.values;return z(W,{expected:U.joinValues(X),received:W.parsedType,code:D.invalid_type}),b}if(!Z$(this,E$,"f"))p2(this,E$,new Set(this._def.values),"f");if(!Z$(this,E$,"f").has($.data)){let W=this._getOrReturnCtx($),X=this._def.values;return z(W,{received:W.data,code:D.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 $$.create($,{...this._def,...W})}exclude($,W=this._def){return $$.create(this.options.filter((X)=>!$.includes(X)),{...this._def,...W})}}E$=new WeakMap;$$.create=a2;class _$ extends q{constructor(){super(...arguments);R$.set(this,void 0)}_parse($){let W=U.getValidEnumValues(this._def.values),X=this._getOrReturnCtx($);if(X.parsedType!==j.string&&X.parsedType!==j.number){let H=U.objectValues(W);return z(X,{expected:U.joinValues(H),received:X.parsedType,code:D.invalid_type}),b}if(!Z$(this,R$,"f"))p2(this,R$,new Set(U.getValidEnumValues(this._def.values)),"f");if(!Z$(this,R$,"f").has($.data)){let H=U.objectValues(W);return z(X,{received:X.data,code:D.invalid_enum_value,options:H}),b}return R($.data)}get enum(){return this._def.values}}R$=new WeakMap;_$.create=($,W)=>{return new _$({values:$,typeName:M.ZodNativeEnum,...O(W)})};class G$ extends q{unwrap(){return this._def.type}_parse($){let{ctx:W}=this._processInputParams($);if(W.parsedType!==j.promise&&W.common.async===!1)return z(W,{code:D.invalid_type,expected:j.promise,received:W.parsedType}),b;let X=W.parsedType===j.promise?W.data:Promise.resolve(W.data);return R(X.then((H)=>{return this._def.type.parseAsync(H,{path:W.path,errorMap:W.common.contextualErrorMap})}))}}G$.create=($,W)=>{return new G$({type:$,typeName:M.ZodPromise,...O(W)})};class x extends q{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($),H=this._def.effect||null,Q={addIssue:(Y)=>{if(z(X,Y),Y.fatal)W.abort();else W.dirty()},get path(){return X.path}};if(Q.addIssue=Q.addIssue.bind(Q),H.type==="preprocess"){let Y=H.transform(X.data,Q);if(X.common.async)return Promise.resolve(Y).then(async(G)=>{if(W.value==="aborted")return b;let w=await this._def.schema._parseAsync({data:G,path:X.path,parent:X});if(w.status==="aborted")return b;if(w.status==="dirty")return H$(w.value);if(W.value==="dirty")return H$(w.value);return w});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 H$(G.value);if(W.value==="dirty")return H$(G.value);return G}}if(H.type==="refinement"){let Y=(G)=>{let w=H.refinement(G,Q);if(X.common.async)return Promise.resolve(w);if(w 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(H.type==="transform")if(X.common.async===!1){let Y=this._def.schema._parseSync({data:X.data,path:X.path,parent:X});if(!a(Y))return Y;let G=H.transform(Y.value,Q);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(!a(Y))return Y;return Promise.resolve(H.transform(Y.value,Q)).then((G)=>({status:W.value,value:G}))});U.assertNever(H)}}x.create=($,W,X)=>{return new x({schema:$,typeName:M.ZodEffects,effect:W,...O(X)})};x.createWithPreprocess=($,W,X)=>{return new x({schema:W,effect:{type:"preprocess",transform:$},typeName:M.ZodEffects,...O(X)})};class k extends q{_parse($){if(this._getType($)===j.undefined)return R(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}k.create=($,W)=>{return new k({innerType:$,typeName:M.ZodOptional,...O(W)})};class r extends q{_parse($){if(this._getType($)===j.null)return R(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}r.create=($,W)=>{return new r({innerType:$,typeName:M.ZodNullable,...O(W)})};class q$ extends q{_parse($){let{ctx:W}=this._processInputParams($),X=W.data;if(W.parsedType===j.undefined)X=this._def.defaultValue();return this._def.innerType._parse({data:X,path:W.path,parent:W})}removeDefault(){return this._def.innerType}}q$.create=($,W)=>{return new q$({innerType:$,typeName:M.ZodDefault,defaultValue:typeof W.default==="function"?W.default:()=>W.default,...O(W)})};class U$ extends q{_parse($){let{ctx:W}=this._processInputParams($),X={...W,common:{...W.common,issues:[]}},H=this._def.innerType._parse({data:X.data,path:X.path,parent:{...X}});if(B$(H))return H.then((Q)=>{return{status:"valid",value:Q.status==="valid"?Q.value:this._def.catchValue({get error(){return new f(X.common.issues)},input:X.data})}});else return{status:"valid",value:H.status==="valid"?H.value:this._def.catchValue({get error(){return new f(X.common.issues)},input:X.data})}}removeCatch(){return this._def.innerType}}U$.create=($,W)=>{return new U$({innerType:$,typeName:M.ZodCatch,catchValue:typeof W.catch==="function"?W.catch:()=>W.catch,...O(W)})};class P$ extends q{_parse($){if(this._getType($)!==j.nan){let X=this._getOrReturnCtx($);return z(X,{code:D.invalid_type,expected:j.nan,received:X.parsedType}),b}return{status:"valid",value:$.data}}}P$.create=($)=>{return new P$({typeName:M.ZodNaN,...O($)})};var u1=Symbol("zod_brand");class m$ extends q{_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}}class C$ extends q{_parse($){let{status:W,ctx:X}=this._processInputParams($);if(X.common.async)return(async()=>{let Q=await this._def.in._parseAsync({data:X.data,path:X.path,parent:X});if(Q.status==="aborted")return b;if(Q.status==="dirty")return W.dirty(),H$(Q.value);else return this._def.out._parseAsync({data:Q.value,path:X.path,parent:X})})();else{let H=this._def.in._parseSync({data:X.data,path:X.path,parent:X});if(H.status==="aborted")return b;if(H.status==="dirty")return W.dirty(),{status:"dirty",value:H.value};else return this._def.out._parseSync({data:H.value,path:X.path,parent:X})}}static create($,W){return new C$({in:$,out:W,typeName:M.ZodPipeline})}}class L$ extends q{_parse($){let W=this._def.innerType._parse($),X=(H)=>{if(a(H))H.value=Object.freeze(H.value);return H};return B$(W)?W.then((H)=>X(H)):X(W)}unwrap(){return this._def.innerType}}L$.create=($,W)=>{return new L$({innerType:$,typeName:M.ZodReadonly,...O(W)})};function c2($,W){let X=typeof $==="function"?$(W):typeof $==="string"?{message:$}:$;return typeof X==="string"?{message:X}:X}function t2($,W={},X){if($)return J$.create().superRefine((H,Q)=>{let Y=$(H);if(Y instanceof Promise)return Y.then((G)=>{if(!G){let w=c2(W,H),B=w.fatal??X??!0;Q.addIssue({code:"custom",...w,fatal:B})}});if(!Y){let G=c2(W,H),w=G.fatal??X??!0;Q.addIssue({code:"custom",...G,fatal:w})}return});return J$.create()}var i1={object:K.lazycreate},M;(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={}));var c1=($,W={message:`Input not instance of ${$.name}`})=>t2((X)=>X instanceof $,W),s2=g.create,e2=s.create,p1=P$.create,d1=e.create,$0=j$.create,o1=Q$.create,r1=v$.create,a1=z$.create,t1=V$.create,s1=J$.create,e1=t.create,$W=i.create,WW=f$.create,XW=T.create,HW=K.create,QW=K.strictCreate,JW=A$.create,YW=l$.create,GW=b$.create,wW=c.create,BW=k$.create,DW=I$.create,MW=Y$.create,jW=M$.create,zW=N$.create,VW=O$.create,AW=$$.create,bW=_$.create,NW=G$.create,OW=x.create,_W=k.create,qW=r.create,UW=x.createWithPreprocess,LW=C$.create,KW=()=>s2().optional(),FW=()=>e2().optional(),SW=()=>$0().optional(),EW={string:($)=>g.create({...$,coerce:!0}),number:($)=>s.create({...$,coerce:!0}),boolean:($)=>j$.create({...$,coerce:!0}),bigint:($)=>e.create({...$,coerce:!0}),date:($)=>Q$.create({...$,coerce:!0})};var RW=b;var L2="2025-03-26",W0=[L2,"2024-11-05","2024-10-07"],n$="2.0",X0=J.union([J.string(),J.number().int()]),H0=J.string(),vW=J.object({progressToken:J.optional(X0)}).passthrough(),h=J.object({_meta:J.optional(vW)}).passthrough(),I=J.object({method:J.string(),params:J.optional(h)}),g$=J.object({_meta:J.optional(J.object({}).passthrough())}).passthrough(),p=J.object({method:J.string(),params:J.optional(g$)}),Z=J.object({_meta:J.optional(J.object({}).passthrough())}).passthrough(),u$=J.union([J.string(),J.number().int()]),Q0=J.object({jsonrpc:J.literal(n$),id:u$}).merge(I).strict(),J0=($)=>Q0.safeParse($).success,Y0=J.object({jsonrpc:J.literal(n$)}).merge(p).strict(),G0=($)=>Y0.safeParse($).success,w0=J.object({jsonrpc:J.literal(n$),id:u$,result:Z}).strict(),K2=($)=>w0.safeParse($).success,F;(function($){$[$.ConnectionClosed=-32000]="ConnectionClosed",$[$.RequestTimeout=-32001]="RequestTimeout",$[$.ParseError=-32700]="ParseError",$[$.InvalidRequest=-32600]="InvalidRequest",$[$.MethodNotFound=-32601]="MethodNotFound",$[$.InvalidParams=-32602]="InvalidParams",$[$.InternalError=-32603]="InternalError"})(F||(F={}));var B0=J.object({jsonrpc:J.literal(n$),id:u$,error:J.object({code:J.number().int(),message:J.string(),data:J.optional(J.unknown())})}).strict(),D0=($)=>B0.safeParse($).success,M0=J.union([Q0,Y0,w0,B0]),i$=Z.strict(),c$=p.extend({method:J.literal("notifications/cancelled"),params:g$.extend({requestId:u$,reason:J.string().optional()})}),j0=J.object({name:J.string(),version:J.string()}).passthrough(),fW=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(),p$=I.extend({method:J.literal("initialize"),params:h.extend({protocolVersion:J.string(),capabilities:fW,clientInfo:j0})}),W6=($)=>p$.safeParse($).success,kW=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(),IW=Z.extend({protocolVersion:J.string(),capabilities:kW,serverInfo:j0,instructions:J.optional(J.string())}),F2=p.extend({method:J.literal("notifications/initialized")});var d$=I.extend({method:J.literal("ping")}),PW=J.object({progress:J.number(),total:J.optional(J.number()),message:J.optional(J.string())}).passthrough(),o$=p.extend({method:J.literal("notifications/progress"),params:g$.merge(PW).extend({progressToken:X0})}),r$=I.extend({params:h.extend({cursor:J.optional(H0)}).optional()}),a$=Z.extend({nextCursor:J.optional(H0)}),z0=J.object({uri:J.string(),mimeType:J.optional(J.string())}).passthrough(),V0=z0.extend({text:J.string()}),A0=z0.extend({blob:J.string().base64()}),CW=J.object({uri:J.string(),name:J.string(),description:J.optional(J.string()),mimeType:J.optional(J.string())}).passthrough(),gW=J.object({uriTemplate:J.string(),name:J.string(),description:J.optional(J.string()),mimeType:J.optional(J.string())}).passthrough(),t$=r$.extend({method:J.literal("resources/list")}),TW=a$.extend({resources:J.array(CW)}),s$=r$.extend({method:J.literal("resources/templates/list")}),yW=a$.extend({resourceTemplates:J.array(gW)}),e$=I.extend({method:J.literal("resources/read"),params:h.extend({uri:J.string()})}),xW=Z.extend({contents:J.array(J.union([V0,A0]))}),hW=p.extend({method:J.literal("notifications/resources/list_changed")}),ZW=I.extend({method:J.literal("resources/subscribe"),params:h.extend({uri:J.string()})}),lW=I.extend({method:J.literal("resources/unsubscribe"),params:h.extend({uri:J.string()})}),mW=p.extend({method:J.literal("notifications/resources/updated"),params:g$.extend({uri:J.string()})}),nW=J.object({name:J.string(),description:J.optional(J.string()),required:J.optional(J.boolean())}).passthrough(),uW=J.object({name:J.string(),description:J.optional(J.string()),arguments:J.optional(J.array(nW))}).passthrough(),$2=r$.extend({method:J.literal("prompts/list")}),iW=a$.extend({prompts:J.array(uW)}),W2=I.extend({method:J.literal("prompts/get"),params:h.extend({name:J.string(),arguments:J.optional(J.record(J.string()))})}),X2=J.object({type:J.literal("text"),text:J.string()}).passthrough(),H2=J.object({type:J.literal("image"),data:J.string().base64(),mimeType:J.string()}).passthrough(),Q2=J.object({type:J.literal("audio"),data:J.string().base64(),mimeType:J.string()}).passthrough(),b0=J.object({type:J.literal("resource"),resource:J.union([V0,A0])}).passthrough(),cW=J.object({role:J.enum(["user","assistant"]),content:J.union([X2,H2,Q2,b0])}).passthrough(),pW=Z.extend({description:J.optional(J.string()),messages:J.array(cW)}),dW=p.extend({method:J.literal("notifications/prompts/list_changed")}),oW=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(),rW=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(oW)}).passthrough(),J2=r$.extend({method:J.literal("tools/list")}),aW=a$.extend({tools:J.array(rW)}),N0=Z.extend({content:J.array(J.union([X2,H2,Q2,b0])).default([]),structuredContent:J.object({}).passthrough().optional(),isError:J.optional(J.boolean())}),X6=N0.or(Z.extend({toolResult:J.unknown()})),Y2=I.extend({method:J.literal("tools/call"),params:h.extend({name:J.string(),arguments:J.optional(J.record(J.unknown()))})}),tW=p.extend({method:J.literal("notifications/tools/list_changed")}),O0=J.enum(["debug","info","notice","warning","error","critical","alert","emergency"]),sW=I.extend({method:J.literal("logging/setLevel"),params:h.extend({level:O0})}),eW=p.extend({method:J.literal("notifications/message"),params:g$.extend({level:O0,logger:J.optional(J.string()),data:J.unknown()})}),$4=J.object({name:J.string().optional()}).passthrough(),W4=J.object({hints:J.optional(J.array($4)),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(),X4=J.object({role:J.enum(["user","assistant"]),content:J.union([X2,H2,Q2])}).passthrough(),H4=I.extend({method:J.literal("sampling/createMessage"),params:h.extend({messages:J.array(X4),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(W4)})}),S2=Z.extend({model:J.string(),stopReason:J.optional(J.enum(["endTurn","stopSequence","maxTokens"]).or(J.string())),role:J.enum(["user","assistant"]),content:J.discriminatedUnion("type",[X2,H2,Q2])}),Q4=J.object({type:J.literal("ref/resource"),uri:J.string()}).passthrough(),J4=J.object({type:J.literal("ref/prompt"),name:J.string()}).passthrough(),G2=I.extend({method:J.literal("completion/complete"),params:h.extend({ref:J.union([J4,Q4]),argument:J.object({name:J.string(),value:J.string()}).passthrough()})}),Y4=Z.extend({completion:J.object({values:J.array(J.string()).max(100),total:J.optional(J.number().int()),hasMore:J.optional(J.boolean())}).passthrough()}),G4=J.object({uri:J.string().startsWith("file://"),name:J.optional(J.string())}).passthrough(),w4=I.extend({method:J.literal("roots/list")}),E2=Z.extend({roots:J.array(G4)}),B4=p.extend({method:J.literal("notifications/roots/list_changed")}),H6=J.union([d$,p$,G2,sW,W2,$2,t$,s$,e$,ZW,lW,Y2,J2]),Q6=J.union([c$,o$,F2,B4]),J6=J.union([i$,S2,E2]),Y6=J.union([d$,H4,w4]),G6=J.union([c$,o$,eW,mW,hW,tW,dW]),w6=J.union([i$,IW,Y4,pW,iW,TW,yW,xW,N0,aW]);class S extends Error{constructor($,W,X){super(`MCP error ${$}: ${W}`);this.code=$,this.data=X,this.name="McpError"}}var D4=60000;class R2{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(c$,(W)=>{let X=this._requestHandlerAbortControllers.get(W.params.requestId);X===null||X===void 0||X.abort(W.params.reason)}),this.setNotificationHandler(o$,(W)=>{this._onprogress(W)}),this.setRequestHandler(d$,(W)=>({}))}_setupTimeout($,W,X,H,Q=!1){this._timeoutInfo.set($,{timeoutId:setTimeout(H,W),startTime:Date.now(),timeout:W,maxTotalTimeout:X,resetTimeoutOnProgress:Q,onTimeout:H})}_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 S(F.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(K2(W)||D0(W))this._onresponse(W);else if(J0(W))this._onrequest(W,X);else if(G0(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 S(F.ConnectionClosed,"Connection closed");for(let H of W.values())H(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((H)=>this._onerror(new Error(`Uncaught error in notification handler: ${H}`)))}_onrequest($,W){var X,H,Q,Y;let G=(X=this._requestHandlers.get($.method))!==null&&X!==void 0?X:this.fallbackRequestHandler;if(G===void 0){(H=this._transport)===null||H===void 0||H.send({jsonrpc:"2.0",id:$.id,error:{code:F.MethodNotFound,message:"Method not found"}}).catch((V)=>this._onerror(new Error(`Failed to send an error response: ${V}`)));return}let w=new AbortController;this._requestHandlerAbortControllers.set($.id,w);let B={signal:w.signal,sessionId:(Q=this._transport)===null||Q===void 0?void 0:Q.sessionId,_meta:(Y=$.params)===null||Y===void 0?void 0:Y._meta,sendNotification:(V)=>this.notification(V,{relatedRequestId:$.id}),sendRequest:(V,_,P)=>this.request(V,_,{...P,relatedRequestId:$.id}),authInfo:W===null||W===void 0?void 0:W.authInfo,requestId:$.id};Promise.resolve().then(()=>G($,B)).then((V)=>{var _;if(w.signal.aborted)return;return(_=this._transport)===null||_===void 0?void 0:_.send({result:V,jsonrpc:"2.0",id:$.id})},(V)=>{var _,P;if(w.signal.aborted)return;return(_=this._transport)===null||_===void 0?void 0:_.send({jsonrpc:"2.0",id:$.id,error:{code:Number.isSafeInteger(V.code)?V.code:F.InternalError,message:(P=V.message)!==null&&P!==void 0?P:"Internal error"}})}).catch((V)=>this._onerror(new Error(`Failed to send response: ${V}`))).finally(()=>{this._requestHandlerAbortControllers.delete($.id)})}_onprogress($){let{progressToken:W,...X}=$.params,H=Number(W),Q=this._progressHandlers.get(H);if(!Q){this._onerror(new Error(`Received a progress notification for an unknown token: ${JSON.stringify($)}`));return}let Y=this._responseHandlers.get(H),G=this._timeoutInfo.get(H);if(G&&Y&&G.resetTimeoutOnProgress)try{this._resetTimeout(H)}catch(w){Y(w);return}Q(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),K2($))X($);else{let H=new S($.error.code,$.error.message,$.error.data);X(H)}}get transport(){return this._transport}async close(){var $;await(($=this._transport)===null||$===void 0?void 0:$.close())}request($,W,X){let{relatedRequestId:H,resumptionToken:Q,onresumptiontoken:Y}=X!==null&&X!==void 0?X:{};return new Promise((G,w)=>{var B,V,_,P,W$,b2;if(!this._transport){w(new Error("Not connected"));return}if(((B=this._options)===null||B===void 0?void 0:B.enforceStrictCapabilities)===!0)this.assertCapabilityForMethod($.method);(V=X===null||X===void 0?void 0:X.signal)===null||V===void 0||V.throwIfAborted();let n=this._requestMessageId++,l2={...$,jsonrpc:"2.0",id:n};if(X===null||X===void 0?void 0:X.onprogress)this._progressHandlers.set(n,X.onprogress),l2.params={...$.params,_meta:{...((_=$.params)===null||_===void 0?void 0:_._meta)||{},progressToken:n}};let m2=(C)=>{var X$;this._responseHandlers.delete(n),this._progressHandlers.delete(n),this._cleanupTimeout(n),(X$=this._transport)===null||X$===void 0||X$.send({jsonrpc:"2.0",method:"notifications/cancelled",params:{requestId:n,reason:String(C)}},{relatedRequestId:H,resumptionToken:Q,onresumptiontoken:Y}).catch((F$)=>this._onerror(new Error(`Failed to send cancellation: ${F$}`))),w(C)};this._responseHandlers.set(n,(C)=>{var X$;if((X$=X===null||X===void 0?void 0:X.signal)===null||X$===void 0?void 0:X$.aborted)return;if(C instanceof Error)return w(C);try{let F$=W.parse(C.result);G(F$)}catch(F$){w(F$)}}),(P=X===null||X===void 0?void 0:X.signal)===null||P===void 0||P.addEventListener("abort",()=>{var C;m2((C=X===null||X===void 0?void 0:X.signal)===null||C===void 0?void 0:C.reason)});let n2=(W$=X===null||X===void 0?void 0:X.timeout)!==null&&W$!==void 0?W$:D4,j1=()=>m2(new S(F.RequestTimeout,"Request timed out",{timeout:n2}));this._setupTimeout(n,n2,X===null||X===void 0?void 0:X.maxTotalTimeout,j1,(b2=X===null||X===void 0?void 0:X.resetTimeoutOnProgress)!==null&&b2!==void 0?b2:!1),this._transport.send(l2,{relatedRequestId:H,resumptionToken:Q,onresumptiontoken:Y}).catch((C)=>{this._cleanupTimeout(n),w(C)})})}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,(H,Q)=>{return Promise.resolve(W($.parse(H),Q))})}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 _0($,W){return Object.entries(W).reduce((X,[H,Q])=>{if(Q&&typeof Q==="object")X[H]=X[H]?{...X[H],...Q}:Q;else X[H]=Q;return X},{...$})}class v2 extends R2{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(p$,(H)=>this._oninitialize(H)),this.setNotificationHandler(F2,()=>{var H;return(H=this.oninitialized)===null||H===void 0?void 0:H.call(this)})}registerCapabilities($){if(this.transport)throw new Error("Cannot register capabilities after connecting to transport");this._capabilities=_0(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:W0.includes(W)?W:L2,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"},i$)}async createMessage($,W){return this.request({method:"sampling/createMessage",params:$},S2,W)}async listRoots($,W){return this.request({method:"roots/list",params:$},E2,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 U0=Symbol("Let zodToJsonSchema decide on which parser to use");var q0={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"},L0=($)=>typeof $==="string"?{...q0,name:$}:{...q0,...$};var K0=($)=>{let W=L0($),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(([H,Q])=>[Q._def,{def:Q._def,path:[...W.basePath,W.definitionPath,H],jsonSchema:void 0}]))}};function f2($,W,X,H){if(!H?.errorMessages)return;if(X)$.errorMessage={...$.errorMessage,[W]:X}}function L($,W,X,H,Q){$[W]=X,f2($,W,H,Q)}function F0(){return{}}function S0($,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)L(X,"minItems",$.minLength.value,$.minLength.message,W);if($.maxLength)L(X,"maxItems",$.maxLength.value,$.maxLength.message,W);if($.exactLength)L(X,"minItems",$.exactLength.value,$.exactLength.message,W),L(X,"maxItems",$.exactLength.value,$.exactLength.message,W);return X}function E0($,W){let X={type:"integer",format:"int64"};if(!$.checks)return X;for(let H of $.checks)switch(H.kind){case"min":if(W.target==="jsonSchema7")if(H.inclusive)L(X,"minimum",H.value,H.message,W);else L(X,"exclusiveMinimum",H.value,H.message,W);else{if(!H.inclusive)X.exclusiveMinimum=!0;L(X,"minimum",H.value,H.message,W)}break;case"max":if(W.target==="jsonSchema7")if(H.inclusive)L(X,"maximum",H.value,H.message,W);else L(X,"exclusiveMaximum",H.value,H.message,W);else{if(!H.inclusive)X.exclusiveMaximum=!0;L(X,"maximum",H.value,H.message,W)}break;case"multipleOf":L(X,"multipleOf",H.value,H.message,W);break}return X}function R0(){return{type:"boolean"}}function w2($,W){return N($.type._def,W)}var v0=($,W)=>{return N($.innerType._def,W)};function k2($,W,X){let H=X??W.dateStrategy;if(Array.isArray(H))return{anyOf:H.map((Q,Y)=>k2($,W,Q))};switch(H){case"string":case"format:date-time":return{type:"string",format:"date-time"};case"format:date":return{type:"string",format:"date"};case"integer":return M4($,W)}}var M4=($,W)=>{let X={type:"integer",format:"unix-time"};if(W.target==="openApi3")return X;for(let H of $.checks)switch(H.kind){case"min":L(X,"minimum",H.value,H.message,W);break;case"max":L(X,"maximum",H.value,H.message,W);break}return X};function f0($,W){return{...N($.innerType._def,W),default:$.defaultValue()}}function k0($,W){return W.effectStrategy==="input"?N($.schema._def,W):{}}function I0($){return{type:"string",enum:Array.from($.values)}}var j4=($)=>{if("type"in $&&$.type==="string")return!1;return"allOf"in $};function P0($,W){let X=[N($.left._def,{...W,currentPath:[...W.currentPath,"allOf","0"]}),N($.right._def,{...W,currentPath:[...W.currentPath,"allOf","1"]})].filter((Y)=>!!Y),H=W.target==="jsonSchema2019-09"?{unevaluatedProperties:!1}:void 0,Q=[];return X.forEach((Y)=>{if(j4(Y)){if(Q.push(...Y.allOf),Y.unevaluatedProperties===void 0)H=void 0}else{let G=Y;if("additionalProperties"in Y&&Y.additionalProperties===!1){let{additionalProperties:w,...B}=Y;G=B}else H=void 0;Q.push(G)}}),Q.length?{allOf:Q,...H}:void 0}function C0($,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}}var I2=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(I2===void 0)I2=RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$","u");return I2},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 B2($,W){let X={type:"string"};if($.checks)for(let H of $.checks)switch(H.kind){case"min":L(X,"minLength",typeof X.minLength==="number"?Math.max(X.minLength,H.value):H.value,H.message,W);break;case"max":L(X,"maxLength",typeof X.maxLength==="number"?Math.min(X.maxLength,H.value):H.value,H.message,W);break;case"email":switch(W.emailStrategy){case"format:email":m(X,"email",H.message,W);break;case"format:idn-email":m(X,"idn-email",H.message,W);break;case"pattern:zod":v(X,l.email,H.message,W);break}break;case"url":m(X,"uri",H.message,W);break;case"uuid":m(X,"uuid",H.message,W);break;case"regex":v(X,H.regex,H.message,W);break;case"cuid":v(X,l.cuid,H.message,W);break;case"cuid2":v(X,l.cuid2,H.message,W);break;case"startsWith":v(X,RegExp(`^${P2(H.value,W)}`),H.message,W);break;case"endsWith":v(X,RegExp(`${P2(H.value,W)}$`),H.message,W);break;case"datetime":m(X,"date-time",H.message,W);break;case"date":m(X,"date",H.message,W);break;case"time":m(X,"time",H.message,W);break;case"duration":m(X,"duration",H.message,W);break;case"length":L(X,"minLength",typeof X.minLength==="number"?Math.max(X.minLength,H.value):H.value,H.message,W),L(X,"maxLength",typeof X.maxLength==="number"?Math.min(X.maxLength,H.value):H.value,H.message,W);break;case"includes":{v(X,RegExp(P2(H.value,W)),H.message,W);break}case"ip":{if(H.version!=="v6")m(X,"ipv4",H.message,W);if(H.version!=="v4")m(X,"ipv6",H.message,W);break}case"base64url":v(X,l.base64url,H.message,W);break;case"jwt":v(X,l.jwt,H.message,W);break;case"cidr":{if(H.version!=="v6")v(X,l.ipv4Cidr,H.message,W);if(H.version!=="v4")v(X,l.ipv6Cidr,H.message,W);break}case"emoji":v(X,l.emoji(),H.message,W);break;case"ulid":{v(X,l.ulid,H.message,W);break}case"base64":{switch(W.base64Strategy){case"format:binary":{m(X,"binary",H.message,W);break}case"contentEncoding:base64":{L(X,"contentEncoding","base64",H.message,W);break}case"pattern:zod":{v(X,l.base64,H.message,W);break}}break}case"nanoid":v(X,l.nanoid,H.message,W);case"toLowerCase":case"toUpperCase":case"trim":break;default:((Q)=>{})(H)}return X}function P2($,W){return W.patternStrategy==="escape"?V4($):$}var z4=new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");function V4($){let W="";for(let X=0;X<$.length;X++){if(!z4.has($[X]))W+="\\";W+=$[X]}return W}function m($,W,X,H){if($.format||$.anyOf?.some((Q)=>Q.format)){if(!$.anyOf)$.anyOf=[];if($.format){if($.anyOf.push({format:$.format,...$.errorMessage&&H.errorMessages&&{errorMessage:{format:$.errorMessage.format}}}),delete $.format,$.errorMessage){if(delete $.errorMessage.format,Object.keys($.errorMessage).length===0)delete $.errorMessage}}$.anyOf.push({format:W,...X&&H.errorMessages&&{errorMessage:{format:X}}})}else L($,"format",W,X,H)}function v($,W,X,H){if($.pattern||$.allOf?.some((Q)=>Q.pattern)){if(!$.allOf)$.allOf=[];if($.pattern){if($.allOf.push({pattern:$.pattern,...$.errorMessage&&H.errorMessages&&{errorMessage:{pattern:$.errorMessage.pattern}}}),delete $.pattern,$.errorMessage){if(delete $.errorMessage.pattern,Object.keys($.errorMessage).length===0)delete $.errorMessage}}$.allOf.push({pattern:g0(W,H),...X&&H.errorMessages&&{errorMessage:{pattern:X}}})}else L($,"pattern",g0(W,H),X,H)}function g0($,W){if(!W.applyRegexFlags||!$.flags)return $.source;let X={i:$.flags.includes("i"),m:$.flags.includes("m"),s:$.flags.includes("s")},H=X.i?$.source.toLowerCase():$.source,Q="",Y=!1,G=!1,w=!1;for(let B=0;B<H.length;B++){if(Y){Q+=H[B],Y=!1;continue}if(X.i){if(G){if(H[B].match(/[a-z]/)){if(w)Q+=H[B],Q+=`${H[B-2]}-${H[B]}`.toUpperCase(),w=!1;else if(H[B+1]==="-"&&H[B+2]?.match(/[a-z]/))Q+=H[B],w=!0;else Q+=`${H[B]}${H[B].toUpperCase()}`;continue}}else if(H[B].match(/[a-z]/)){Q+=`[${H[B]}${H[B].toUpperCase()}]`;continue}}if(X.m){if(H[B]==="^"){Q+=`(^|(?<=[\r
|
2
|
-
]))`;continue}else if(
|
3
|
-
]))`;continue}}if(X.s&&
|
4
|
-
`:`[${
|
5
|
-
]`;continue}if(Q+=H[B],H[B]==="\\")Y=!0;else if(G&&H[B]==="]")G=!1;else if(!G&&H[B]==="[")G=!0}try{new RegExp(Q)}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 Q}function D2($,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((H,Q)=>({...H,[Q]:N($.valueType._def,{...W,currentPath:[...W.currentPath,"properties",Q]})??{}}),{}),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:H,...Q}=B2($.keyType._def,W);return{...X,propertyNames:Q}}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:H,...Q}=w2($.keyType._def,W);return{...X,propertyNames:Q}}return X}function T0($,W){if(W.mapStrategy==="record")return D2($,W);let X=N($.keyType._def,{...W,currentPath:[...W.currentPath,"items","items","0"]})||{},H=N($.valueType._def,{...W,currentPath:[...W.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[X,H],minItems:2,maxItems:2}}}function y0($){let W=$.values,H=Object.keys($.values).filter((Y)=>{return typeof W[W[Y]]!=="number"}).map((Y)=>W[Y]),Q=Array.from(new Set(H.map((Y)=>typeof Y)));return{type:Q.length===1?Q[0]==="string"?"string":"number":["string","number"],enum:H}}function x0(){return{not:{}}}function h0($){return $.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var T$={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function l0($,W){if(W.target==="openApi3")return Z0($,W);let X=$.options instanceof Map?Array.from($.options.values()):$.options;if(X.every((H)=>(H._def.typeName in T$)&&(!H._def.checks||!H._def.checks.length))){let H=X.reduce((Q,Y)=>{let G=T$[Y._def.typeName];return G&&!Q.includes(G)?[...Q,G]:Q},[]);return{type:H.length>1?H:H[0]}}else if(X.every((H)=>H._def.typeName==="ZodLiteral"&&!H.description)){let H=X.reduce((Q,Y)=>{let G=typeof Y._def.value;switch(G){case"string":case"number":case"boolean":return[...Q,G];case"bigint":return[...Q,"integer"];case"object":if(Y._def.value===null)return[...Q,"null"];case"symbol":case"undefined":case"function":default:return Q}},[]);if(H.length===X.length){let Q=H.filter((Y,G,w)=>w.indexOf(Y)===G);return{type:Q.length>1?Q:Q[0],enum:X.reduce((Y,G)=>{return Y.includes(G._def.value)?Y:[...Y,G._def.value]},[])}}}else if(X.every((H)=>H._def.typeName==="ZodEnum"))return{type:"string",enum:X.reduce((H,Q)=>[...H,...Q._def.values.filter((Y)=>!H.includes(Y))],[])};return Z0($,W)}var Z0=($,W)=>{let X=($.options instanceof Map?Array.from($.options.values()):$.options).map((H,Q)=>N(H._def,{...W,currentPath:[...W.currentPath,"anyOf",`${Q}`]})).filter((H)=>!!H&&(!W.strictUnions||typeof H==="object"&&Object.keys(H).length>0));return X.length?{anyOf:X}:void 0};function m0($,W){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes($.innerType._def.typeName)&&(!$.innerType._def.checks||!$.innerType._def.checks.length)){if(W.target==="openApi3")return{type:T$[$.innerType._def.typeName],nullable:!0};return{type:[T$[$.innerType._def.typeName],"null"]}}if(W.target==="openApi3"){let H=N($.innerType._def,{...W,currentPath:[...W.currentPath]});if(H&&"$ref"in H)return{allOf:[H],nullable:!0};return H&&{...H,nullable:!0}}let X=N($.innerType._def,{...W,currentPath:[...W.currentPath,"anyOf","0"]});return X&&{anyOf:[X,{type:"null"}]}}function n0($,W){let X={type:"number"};if(!$.checks)return X;for(let H of $.checks)switch(H.kind){case"int":X.type="integer",f2(X,"type",H.message,W);break;case"min":if(W.target==="jsonSchema7")if(H.inclusive)L(X,"minimum",H.value,H.message,W);else L(X,"exclusiveMinimum",H.value,H.message,W);else{if(!H.inclusive)X.exclusiveMinimum=!0;L(X,"minimum",H.value,H.message,W)}break;case"max":if(W.target==="jsonSchema7")if(H.inclusive)L(X,"maximum",H.value,H.message,W);else L(X,"exclusiveMaximum",H.value,H.message,W);else{if(!H.inclusive)X.exclusiveMaximum=!0;L(X,"maximum",H.value,H.message,W)}break;case"multipleOf":L(X,"multipleOf",H.value,H.message,W);break}return X}function u0($,W){let X=W.target==="openAi",H={type:"object",properties:{}},Q=[],Y=$.shape();for(let w in Y){let B=Y[w];if(B===void 0||B._def===void 0)continue;let V=b4(B);if(V&&X){if(B instanceof k)B=B._def.innerType;if(!B.isNullable())B=B.nullable();V=!1}let _=N(B._def,{...W,currentPath:[...W.currentPath,"properties",w],propertyPath:[...W.currentPath,"properties",w]});if(_===void 0)continue;if(H.properties[w]=_,!V)Q.push(w)}if(Q.length)H.required=Q;let G=A4($,W);if(G!==void 0)H.additionalProperties=G;return H}function A4($,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 b4($){try{return $.isOptional()}catch{return!0}}var i0=($,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 c0=($,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"]}),H=N($.out._def,{...W,currentPath:[...W.currentPath,"allOf",X?"1":"0"]});return{allOf:[X,H].filter((Q)=>Q!==void 0)}};function p0($,W){return N($.type._def,W)}function d0($,W){let H={type:"array",uniqueItems:!0,items:N($.valueType._def,{...W,currentPath:[...W.currentPath,"items"]})};if($.minSize)L(H,"minItems",$.minSize.value,$.minSize.message,W);if($.maxSize)L(H,"maxItems",$.maxSize.value,$.maxSize.message,W);return H}function o0($,W){if($.rest)return{type:"array",minItems:$.items.length,items:$.items.map((X,H)=>N(X._def,{...W,currentPath:[...W.currentPath,"items",`${H}`]})).reduce((X,H)=>H===void 0?X:[...X,H],[]),additionalItems:N($.rest._def,{...W,currentPath:[...W.currentPath,"additionalItems"]})};else return{type:"array",minItems:$.items.length,maxItems:$.items.length,items:$.items.map((X,H)=>N(X._def,{...W,currentPath:[...W.currentPath,"items",`${H}`]})).reduce((X,H)=>H===void 0?X:[...X,H],[])}}function r0(){return{not:{}}}function a0(){return{}}var t0=($,W)=>{return N($.innerType._def,W)};var s0=($,W,X)=>{switch(W){case M.ZodString:return B2($,X);case M.ZodNumber:return n0($,X);case M.ZodObject:return u0($,X);case M.ZodBigInt:return E0($,X);case M.ZodBoolean:return R0();case M.ZodDate:return k2($,X);case M.ZodUndefined:return r0();case M.ZodNull:return h0(X);case M.ZodArray:return S0($,X);case M.ZodUnion:case M.ZodDiscriminatedUnion:return l0($,X);case M.ZodIntersection:return P0($,X);case M.ZodTuple:return o0($,X);case M.ZodRecord:return D2($,X);case M.ZodLiteral:return C0($,X);case M.ZodEnum:return I0($);case M.ZodNativeEnum:return y0($);case M.ZodNullable:return m0($,X);case M.ZodOptional:return i0($,X);case M.ZodMap:return T0($,X);case M.ZodSet:return d0($,X);case M.ZodLazy:return()=>$.getter()._def;case M.ZodPromise:return p0($,X);case M.ZodNaN:case M.ZodNever:return x0();case M.ZodEffects:return k0($,X);case M.ZodAny:return F0();case M.ZodUnknown:return a0();case M.ZodDefault:return f0($,X);case M.ZodBranded:return w2($,X);case M.ZodReadonly:return t0($,X);case M.ZodCatch:return v0($,X);case M.ZodPipeline:return c0($,X);case M.ZodFunction:case M.ZodVoid:case M.ZodSymbol:return;default:return((H)=>{return})(W)}};function N($,W,X=!1){let H=W.seen.get($);if(W.override){let w=W.override?.($,W,H,X);if(w!==U0)return w}if(H&&!X){let w=N4(H,W);if(w!==void 0)return w}let Q={def:$,path:W.currentPath,jsonSchema:void 0};W.seen.set($,Q);let Y=s0($,$.typeName,W),G=typeof Y==="function"?N(Y(),W):Y;if(G)_4($,W,G);if(W.postProcess){let w=W.postProcess(G,$,W);return Q.jsonSchema=G,w}return Q.jsonSchema=G,G}var N4=($,W)=>{switch(W.$refStrategy){case"root":return{$ref:$.path.join("/")};case"relative":return{$ref:O4(W.currentPath,$.path)};case"none":case"seen":{if($.path.length<W.currentPath.length&&$.path.every((X,H)=>W.currentPath[H]===X))return console.warn(`Recursive reference detected at ${W.currentPath.join("/")}! Defaulting to any`),{};return W.$refStrategy==="seen"?{}:void 0}}},O4=($,W)=>{let X=0;for(;X<$.length&&X<W.length;X++)if($[X]!==W[X])break;return[($.length-X).toString(),...W.slice(X)].join("/")},_4=($,W,X)=>{if($.description){if(X.description=$.description,W.markdownDescription)X.markdownDescription=$.description}return X};var M2=($,W)=>{let X=K0(W),H=typeof W==="object"&&W.definitions?Object.entries(W.definitions).reduce((B,[V,_])=>({...B,[V]:N(_._def,{...X,currentPath:[...X.basePath,X.definitionPath,V]},!0)??{}}),{}):void 0,Q=typeof W==="string"?W:W?.nameStrategy==="title"?void 0:W?.name,Y=N($._def,Q===void 0?X:{...X,currentPath:[...X.basePath,X.definitionPath,Q]},!1)??{},G=typeof W==="object"&&W.name!==void 0&&W.nameStrategy==="title"?W.name:void 0;if(G!==void 0)Y.title=G;let w=Q===void 0?H?{...Y,[X.definitionPath]:H}:Y:{$ref:[...X.$refStrategy==="relative"?[]:X.basePath,X.definitionPath,Q].join("/"),[X.definitionPath]:{...H,[Q]:Y}};if(X.target==="jsonSchema7")w.$schema="http://json-schema.org/draft-07/schema#";else if(X.target==="jsonSchema2019-09"||X.target==="openAi")w.$schema="https://json-schema.org/draft/2019-09/schema#";if(X.target==="openAi"&&(("anyOf"in w)||("oneOf"in w)||("allOf"in w)||("type"in w)&&Array.isArray(w.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return w};var C2;(function($){$.Completable="McpCompletable"})(C2||(C2={}));class y$ extends q{_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}}y$.create=($,W)=>{return new y$({type:$,typeName:C2.Completable,complete:W.complete,...q4(W)})};function q4($){if(!$)return{};let{errorMap:W,invalid_type_error:X,required_error:H,description:Q}=$;if(W&&(X||H))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(W)return{errorMap:W,description:Q};return{errorMap:(G,w)=>{var B,V;let{message:_}=$;if(G.code==="invalid_enum_value")return{message:_!==null&&_!==void 0?_:w.defaultError};if(typeof w.data==="undefined")return{message:(B=_!==null&&_!==void 0?_:H)!==null&&B!==void 0?B:w.defaultError};if(G.code!=="invalid_type")return{message:w.defaultError};return{message:(V=_!==null&&_!==void 0?_:X)!==null&&V!==void 0?V:w.defaultError}},description:Q}}class g2{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 v2($,W)}async connect($){return await this.server.connect($)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(J2.shape.method.value),this.server.assertCanSetRequestHandler(Y2.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(J2,()=>({tools:Object.entries(this._registeredTools).filter(([,$])=>$.enabled).map(([$,W])=>{let X={name:$,description:W.description,inputSchema:W.inputSchema?M2(W.inputSchema,{strictUnions:!0}):U4,annotations:W.annotations};if(W.outputSchema)X.outputSchema=M2(W.outputSchema,{strictUnions:!0});return X})})),this.server.setRequestHandler(Y2,async($,W)=>{let X=this._registeredTools[$.params.name];if(!X)throw new S(F.InvalidParams,`Tool ${$.params.name} not found`);if(!X.enabled)throw new S(F.InvalidParams,`Tool ${$.params.name} disabled`);let H;if(X.inputSchema){let Q=await X.inputSchema.safeParseAsync($.params.arguments);if(!Q.success)throw new S(F.InvalidParams,`Invalid arguments for tool ${$.params.name}: ${Q.error.message}`);let Y=Q.data,G=X.callback;try{H=await Promise.resolve(G(Y,W))}catch(w){H={content:[{type:"text",text:w instanceof Error?w.message:String(w)}],isError:!0}}}else{let Q=X.callback;try{H=await Promise.resolve(Q(W))}catch(Y){H={content:[{type:"text",text:Y instanceof Error?Y.message:String(Y)}],isError:!0}}}if(X.outputSchema){if(!H.structuredContent)throw new S(F.InvalidParams,`Tool ${$.params.name} has an output schema but no structured content was provided`);let Q=await X.outputSchema.safeParseAsync(H.structuredContent);if(!Q.success)throw new S(F.InvalidParams,`Invalid structured content for tool ${$.params.name}: ${Q.error.message}`)}return H}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(G2.shape.method.value),this.server.setRequestHandler(G2,async($)=>{switch($.params.ref.type){case"ref/prompt":return this.handlePromptCompletion($,$.params.ref);case"ref/resource":return this.handleResourceCompletion($,$.params.ref);default:throw new S(F.InvalidParams,`Invalid completion reference: ${$.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion($,W){let X=this._registeredPrompts[W.name];if(!X)throw new S(F.InvalidParams,`Prompt ${W.name} not found`);if(!X.enabled)throw new S(F.InvalidParams,`Prompt ${W.name} disabled`);if(!X.argsSchema)return j2;let H=X.argsSchema.shape[$.params.argument.name];if(!(H instanceof y$))return j2;let Y=await H._def.complete($.params.argument.value);return $1(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 j2;throw new S(F.InvalidParams,`Resource template ${$.params.ref.uri} not found`)}let H=X.resourceTemplate.completeCallback($.params.argument.name);if(!H)return j2;let Q=await H($.params.argument.value);return $1(Q)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(t$.shape.method.value),this.server.assertCanSetRequestHandler(s$.shape.method.value),this.server.assertCanSetRequestHandler(e$.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(t$,async($,W)=>{let X=Object.entries(this._registeredResources).filter(([Q,Y])=>Y.enabled).map(([Q,Y])=>({uri:Q,name:Y.name,...Y.metadata})),H=[];for(let Q of Object.values(this._registeredResourceTemplates)){if(!Q.resourceTemplate.listCallback)continue;let Y=await Q.resourceTemplate.listCallback(W);for(let G of Y.resources)H.push({...G,...Q.metadata})}return{resources:[...X,...H]}}),this.server.setRequestHandler(s$,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([W,X])=>({name:W,uriTemplate:X.resourceTemplate.uriTemplate.toString(),...X.metadata}))}}),this.server.setRequestHandler(e$,async($,W)=>{let X=new URL($.params.uri),H=this._registeredResources[X.toString()];if(H){if(!H.enabled)throw new S(F.InvalidParams,`Resource ${X} disabled`);return H.readCallback(X,W)}for(let Q of Object.values(this._registeredResourceTemplates)){let Y=Q.resourceTemplate.uriTemplate.match(X.toString());if(Y)return Q.readCallback(X,Y,W)}throw new S(F.InvalidParams,`Resource ${X} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler($2.shape.method.value),this.server.assertCanSetRequestHandler(W2.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler($2,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,$])=>$.enabled).map(([$,W])=>{return{name:$,description:W.description,arguments:W.argsSchema?K4(W.argsSchema):void 0}})})),this.server.setRequestHandler(W2,async($,W)=>{let X=this._registeredPrompts[$.params.name];if(!X)throw new S(F.InvalidParams,`Prompt ${$.params.name} not found`);if(!X.enabled)throw new S(F.InvalidParams,`Prompt ${$.params.name} disabled`);if(X.argsSchema){let H=await X.argsSchema.safeParseAsync($.params.arguments);if(!H.success)throw new S(F.InvalidParams,`Invalid arguments for prompt ${$.params.name}: ${H.error.message}`);let Q=H.data,Y=X.callback;return await Promise.resolve(Y(Q,W))}else{let H=X.callback;return await Promise.resolve(H(W))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource($,W,...X){let H;if(typeof X[0]==="object")H=X.shift();let Q=X[0];if(typeof W==="string"){if(this._registeredResources[W])throw new Error(`Resource ${W} is already registered`);let Y={name:$,metadata:H,readCallback:Q,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:H,readCallback:Q,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,H,Q,Y){let G={description:W,inputSchema:X===void 0?void 0:J.object(X),outputSchema:H===void 0?void 0:J.object(H),annotations:Q,callback:Y,enabled:!0,disable:()=>G.update({enabled:!1}),enable:()=>G.update({enabled:!0}),remove:()=>G.update({name:null}),update:(w)=>{if(typeof w.name!=="undefined"&&w.name!==$){if(delete this._registeredTools[$],w.name)this._registeredTools[w.name]=G}if(typeof w.description!=="undefined")G.description=w.description;if(typeof w.paramsSchema!=="undefined")G.inputSchema=J.object(w.paramsSchema);if(typeof w.callback!=="undefined")G.callback=w.callback;if(typeof w.annotations!=="undefined")G.annotations=w.annotations;if(typeof w.enabled!=="undefined")G.enabled=w.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,H,Q,Y;if(typeof W[0]==="string")X=W.shift();if(W.length>1){let w=W[0];if(e0(w)){if(H=W.shift(),W.length>1&&typeof W[0]==="object"&&W[0]!==null&&!e0(W[0]))Y=W.shift()}else if(typeof w==="object"&&w!==null)Y=W.shift()}let G=W[0];return this._createRegisteredTool($,X,H,Q,Y,G)}registerTool($,W,X){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let{description:H,inputSchema:Q,outputSchema:Y,annotations:G}=W;return this._createRegisteredTool($,H,Q,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 H;if(W.length>1)H=W.shift();let Q=W[0],Y={description:X,argsSchema:H===void 0?void 0:J.object(H),callback:Q,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 U4={type:"object"};function e0($){if(typeof $!=="object"||$===null)return!1;return Object.keys($).length===0||Object.values($).some(L4)}function L4($){return $!==null&&typeof $==="object"&&"parse"in $&&typeof $.parse==="function"&&"safeParse"in $&&typeof $.safeParse==="function"}function K4($){return Object.entries($.shape).map(([W,X])=>({name:W,description:X.description,required:!X.isOptional()}))}function $1($){return{completion:{values:$.slice(0,100),total:$.length,hasMore:$.length>100}}}var j2={completion:{values:[],hasMore:!1}};var W1=process.argv.find(($)=>$.startsWith("--figma-api-key=")),F4=W1?W1.split("=")[1]:"",z2=F4||process.env.personalToken||process.env.FIGMA_API_KEY||"",X1="F2C MCP",H1=process.env.FIGMA_VERSION||"0.0.1";class Q1{f2cHost="https://f2c-figma-api.yy.com/api";personalToken=z2;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 H=await fetch($,{method:"GET"});if(!H.ok)throw new Error(`HTTP error! status: ${H.status}`);return W==="text"?await H.text():await H.json()}catch(X){throw console.error("HTTP error",X),X}}opToUrl($,W={}){if(Object.keys(W).length===0)return $;let X=new URL($);for(let[H,Q]of Object.entries(W))if(typeof Q==="object"&&Q!==null)for(let[Y,G]of Object.entries(Q))X.searchParams.append(`${H}[${Y}]`,G);else X.searchParams.append(H,Q);return X.toString()}}var J1=new Q1;var V2=O2(require("fs")),K$=O2(require("path"));class Y1{imgFormat="png";setImgFormat($){this.imgFormat=$}async downloadImage($,W){try{if(!V2.default.existsSync(W.localPath))V2.default.mkdirSync(W.localPath,{recursive:!0});let X=`${W.fileName}.${this.imgFormat}`,H=K$.default.join(W.localPath,X),Q=await fetch($);if(!Q.ok)throw new Error(`下载失败: ${Q.status} ${Q.statusText}`);let Y=await Q.arrayBuffer();return V2.default.writeFileSync(H,new Uint8Array(Y)),K$.default.join(K$.default.basename(W.localPath),X).replace(/\\/g,"/")}catch(X){throw console.error("图片下载错误:",X),X}}async processContent($,W){W=K$.default.join(W,"images");try{let X=/https:\/\/figma-alpha-api\.s3\.us-west-2\.amazonaws\.com\/images\/[a-f0-9-]+/g,H=$.match(X);if(!H)return $;let Q=$;for(let Y of H){let G=K$.default.basename(Y),w=await this.downloadImage(Y,{localPath:W,fileName:G});Q=Q.replace(Y,w)}return Q}catch(X){throw console.error("内容处理错误:",X),X}}}var T2=new Y1;var G1=($)=>{$.tool("figma_to_code","Transform Figma designs into production-ready code. This tool converts selected Figma nodes into HTML, React with CSS Modules, or React with Tailwind CSS, enabling seamless design-to-code workflow.",{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".'),format:J.enum(["html","react-cssmodules","react-tailwind"]).default("html").describe('Specify the output format: "html" generates semantic HTML/CSS, "react-cssmodules" creates React components with scoped CSS modules, "react-tailwind" produces React components with utility-first Tailwind classes.'),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 image asset storage. Directory will be created if non-existent. Path must follow OS-specific format without special character escaping."),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,X)=>{console.log(X);try{let H=await J1.nodeToCode(W)||[];if(W.localPath)T2.setImgFormat(W.imgFormat),await Promise.all(H.map(async(Q)=>{Q.content=await T2.processContent(Q.content,W.localPath)}));return{content:[{type:"text",text:JSON.stringify(H)}]}}catch(H){return console.error("Tool execution error:",H),{content:[{type:"text",text:`Error: ${H.message}`}]}}})};class w1{figmaHost="https://api.figma.com/v1";personalToken=z2;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}},H=await fetch($,X);if(!H.ok)throw new Error(`HTTP error! status: ${H.status}`);return W==="text"?await H.text():await H.json()}catch(X){throw console.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 H=new URL($);for(let[Q,Y]of Object.entries(W))if(!X.includes(Q))H.searchParams.append(Q,Y);return H.toString()}}var y2=new w1;var B1=($)=>{$.tool("figma_get_file_data","Get detailed information about a Figma file",{fileKey:J.string().describe("Unique identifier of the Figma file"),ids:J.string().describe("List of node IDs to retrieve, comma separated"),personalToken:J.string().optional().describe("Your Figma personal access token, The parameters are not required when the tool is called."),version:J.string().optional().describe("Specify the version to return"),depth:J.number().optional().describe("Specify the depth of nodes to return"),geometry:J.enum(["paths"]).optional().describe("Specify whether to include geometry path data"),plugin_data:J.string().optional().describe("Specify plugin data to return"),branch_data:J.boolean().optional().describe("Specify whether to return branch data")},async(W)=>{try{let X=await y2.files(W);return{content:[{type:"text",text:JSON.stringify(X)}]}}catch(X){return{content:[{type:"text",text:`Error: ${X.message}`}]}}}),$.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(W)=>{try{let X=await y2.images(W);return{content:[{type:"text",text:JSON.stringify(X)}]}}catch(X){return{content:[{type:"text",text:`Error: ${X.message}`}]}}})};var A2=new g2({name:X1,version:H1},{capabilities:{logging:{}}});B1(A2);G1(A2);var h2=O2(require("node:process"));class x2{append($){this._buffer=this._buffer?Buffer.concat([this._buffer,$]):$}readMessage(){if(!this._buffer)return null;let $=this._buffer.indexOf(`
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
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
|
+
<html>
|
7
|
+
<head>
|
8
|
+
<meta charset="UTF-8">
|
9
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
10
|
+
<title>F2C Generated</title>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
${$}
|
14
|
+
</body>
|
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
|
+
|
18
|
+
## Save Location
|
19
|
+
${W.localPath}
|
20
|
+
|
21
|
+
## Generated Files
|
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(`
|
23
|
+
|
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);
|
27
|
+
|
28
|
+
//# debugId=CF04ECA407BC615164756E2164756E21
|
10
29
|
//# sourceMappingURL=stdio.js.map
|