@f2c/mcp 0.3.2 → 0.3.3

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 CHANGED
@@ -16,7 +16,7 @@ Content-Type: ${H.type||"application/octet-stream"}\r
16
16
  ]))`;continue}else if(J[D]==="$"){G+=`($|(?=[\r
17
17
  ]))`;continue}}if(Q.s&&J[D]==="."){G+=M?`${J[D]}\r
18
18
  `:`[${J[D]}\r
19
- ]`;continue}if(G+=J[D],J[D]==="\\")H=!0;else if(M&&J[D]==="]")M=!1;else if(!M&&J[D]==="[")M=!0}try{new RegExp(G)}catch{return console.warn(`Could not convert regex pattern at ${X.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),$.source}return G}function M1($,X){if(X.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(X.target==="openApi3"&&$.keyType?._def.typeName===N.ZodEnum)return{type:"object",required:$.keyType._def.values,properties:$.keyType._def.values.reduce((J,G)=>({...J,[G]:P($.valueType._def,{...X,currentPath:[...X.currentPath,"properties",G]})??{}}),{}),additionalProperties:X.rejectedAdditionalProperties};let Q={type:"object",additionalProperties:P($.valueType._def,{...X,currentPath:[...X.currentPath,"additionalProperties"]})??X.allowedAdditionalProperties};if(X.target==="openApi3")return Q;if($.keyType?._def.typeName===N.ZodString&&$.keyType._def.checks?.length){let{type:J,...G}=H1($.keyType._def,X);return{...Q,propertyNames:G}}else if($.keyType?._def.typeName===N.ZodEnum)return{...Q,propertyNames:{enum:$.keyType._def.values}};else if($.keyType?._def.typeName===N.ZodBranded&&$.keyType._def.type._def.typeName===N.ZodString&&$.keyType._def.type._def.checks?.length){let{type:J,...G}=Y1($.keyType._def,X);return{...Q,propertyNames:G}}return Q}function OQ($,X){if(X.mapStrategy==="record")return M1($,X);let Q=P($.keyType._def,{...X,currentPath:[...X.currentPath,"items","items","0"]})||{},J=P($.valueType._def,{...X,currentPath:[...X.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[Q,J],minItems:2,maxItems:2}}}function qQ($){let X=$.values,J=Object.keys($.values).filter((H)=>{return typeof X[X[H]]!=="number"}).map((H)=>X[H]),G=Array.from(new Set(J.map((H)=>typeof H)));return{type:G.length===1?G[0]==="string"?"string":"number":["string","number"],enum:J}}function _Q(){return{not:{}}}function AQ($){return $.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var l6={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function KQ($,X){if(X.target==="openApi3")return jQ($,X);let Q=$.options instanceof Map?Array.from($.options.values()):$.options;if(Q.every((J)=>(J._def.typeName in l6)&&(!J._def.checks||!J._def.checks.length))){let J=Q.reduce((G,H)=>{let M=l6[H._def.typeName];return M&&!G.includes(M)?[...G,M]:G},[]);return{type:J.length>1?J:J[0]}}else if(Q.every((J)=>J._def.typeName==="ZodLiteral"&&!J.description)){let J=Q.reduce((G,H)=>{let M=typeof H._def.value;switch(M){case"string":case"number":case"boolean":return[...G,M];case"bigint":return[...G,"integer"];case"object":if(H._def.value===null)return[...G,"null"];case"symbol":case"undefined":case"function":default:return G}},[]);if(J.length===Q.length){let G=J.filter((H,M,z)=>z.indexOf(H)===M);return{type:G.length>1?G:G[0],enum:Q.reduce((H,M)=>{return H.includes(M._def.value)?H:[...H,M._def.value]},[])}}}else if(Q.every((J)=>J._def.typeName==="ZodEnum"))return{type:"string",enum:Q.reduce((J,G)=>[...J,...G._def.values.filter((H)=>!J.includes(H))],[])};return jQ($,X)}var jQ=($,X)=>{let Q=($.options instanceof Map?Array.from($.options.values()):$.options).map((J,G)=>P(J._def,{...X,currentPath:[...X.currentPath,"anyOf",`${G}`]})).filter((J)=>!!J&&(!X.strictUnions||typeof J==="object"&&Object.keys(J).length>0));return Q.length?{anyOf:Q}:void 0};function UQ($,X){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes($.innerType._def.typeName)&&(!$.innerType._def.checks||!$.innerType._def.checks.length)){if(X.target==="openApi3")return{type:l6[$.innerType._def.typeName],nullable:!0};return{type:[l6[$.innerType._def.typeName],"null"]}}if(X.target==="openApi3"){let J=P($.innerType._def,{...X,currentPath:[...X.currentPath]});if(J&&"$ref"in J)return{allOf:[J],nullable:!0};return J&&{...J,nullable:!0}}let Q=P($.innerType._def,{...X,currentPath:[...X.currentPath,"anyOf","0"]});return Q&&{anyOf:[Q,{type:"null"}]}}function NQ($,X){let Q={type:"number"};if(!$.checks)return Q;for(let J of $.checks)switch(J.kind){case"int":Q.type="integer",P2(Q,"type",J.message,X);break;case"min":if(X.target==="jsonSchema7")if(J.inclusive)t(Q,"minimum",J.value,J.message,X);else t(Q,"exclusiveMinimum",J.value,J.message,X);else{if(!J.inclusive)Q.exclusiveMinimum=!0;t(Q,"minimum",J.value,J.message,X)}break;case"max":if(X.target==="jsonSchema7")if(J.inclusive)t(Q,"maximum",J.value,J.message,X);else t(Q,"exclusiveMaximum",J.value,J.message,X);else{if(!J.inclusive)Q.exclusiveMaximum=!0;t(Q,"maximum",J.value,J.message,X)}break;case"multipleOf":t(Q,"multipleOf",J.value,J.message,X);break}return Q}p0();function LQ($,X){let Q=X.target==="openAi",J={type:"object",properties:{}},G=[],H=$.shape();for(let z in H){let D=H[z];if(D===void 0||D._def===void 0)continue;let O=i9(D);if(O&&Q){if(D instanceof k$)D=D._def.innerType;if(!D.isNullable())D=D.nullable();O=!1}let _=P(D._def,{...X,currentPath:[...X.currentPath,"properties",z],propertyPath:[...X.currentPath,"properties",z]});if(_===void 0)continue;if(J.properties[z]=_,!O)G.push(z)}if(G.length)J.required=G;let M=n9($,X);if(M!==void 0)J.additionalProperties=M;return J}function n9($,X){if($.catchall._def.typeName!=="ZodNever")return P($.catchall._def,{...X,currentPath:[...X.currentPath,"additionalProperties"]});switch($.unknownKeys){case"passthrough":return X.allowedAdditionalProperties;case"strict":return X.rejectedAdditionalProperties;case"strip":return X.removeAdditionalStrategy==="strict"?X.allowedAdditionalProperties:X.rejectedAdditionalProperties}}function i9($){try{return $.isOptional()}catch{return!0}}var SQ=($,X)=>{if(X.currentPath.toString()===X.propertyPath?.toString())return P($.innerType._def,X);let Q=P($.innerType._def,{...X,currentPath:[...X.currentPath,"anyOf","1"]});return Q?{anyOf:[{not:{}},Q]}:{}};var FQ=($,X)=>{if(X.pipeStrategy==="input")return P($.in._def,X);else if(X.pipeStrategy==="output")return P($.out._def,X);let Q=P($.in._def,{...X,currentPath:[...X.currentPath,"allOf","0"]}),J=P($.out._def,{...X,currentPath:[...X.currentPath,"allOf",Q?"1":"0"]});return{allOf:[Q,J].filter((G)=>G!==void 0)}};function EQ($,X){return P($.type._def,X)}function RQ($,X){let J={type:"array",uniqueItems:!0,items:P($.valueType._def,{...X,currentPath:[...X.currentPath,"items"]})};if($.minSize)t(J,"minItems",$.minSize.value,$.minSize.message,X);if($.maxSize)t(J,"maxItems",$.maxSize.value,$.maxSize.message,X);return J}function vQ($,X){if($.rest)return{type:"array",minItems:$.items.length,items:$.items.map((Q,J)=>P(Q._def,{...X,currentPath:[...X.currentPath,"items",`${J}`]})).reduce((Q,J)=>J===void 0?Q:[...Q,J],[]),additionalItems:P($.rest._def,{...X,currentPath:[...X.currentPath,"additionalItems"]})};else return{type:"array",minItems:$.items.length,maxItems:$.items.length,items:$.items.map((Q,J)=>P(Q._def,{...X,currentPath:[...X.currentPath,"items",`${J}`]})).reduce((Q,J)=>J===void 0?Q:[...Q,J],[])}}function CQ(){return{not:{}}}function kQ(){return{}}var IQ=($,X)=>{return P($.innerType._def,X)};var bQ=($,X,Q)=>{switch(X){case N.ZodString:return H1($,Q);case N.ZodNumber:return NQ($,Q);case N.ZodObject:return LQ($,Q);case N.ZodBigInt:return GQ($,Q);case N.ZodBoolean:return YQ();case N.ZodDate:return f2($,Q);case N.ZodUndefined:return CQ();case N.ZodNull:return AQ(Q);case N.ZodArray:return JQ($,Q);case N.ZodUnion:case N.ZodDiscriminatedUnion:return KQ($,Q);case N.ZodIntersection:return BQ($,Q);case N.ZodTuple:return vQ($,Q);case N.ZodRecord:return M1($,Q);case N.ZodLiteral:return DQ($,Q);case N.ZodEnum:return zQ($);case N.ZodNativeEnum:return qQ($);case N.ZodNullable:return UQ($,Q);case N.ZodOptional:return SQ($,Q);case N.ZodMap:return OQ($,Q);case N.ZodSet:return RQ($,Q);case N.ZodLazy:return()=>$.getter()._def;case N.ZodPromise:return EQ($,Q);case N.ZodNaN:case N.ZodNever:return _Q();case N.ZodEffects:return wQ($,Q);case N.ZodAny:return WQ();case N.ZodUnknown:return kQ();case N.ZodDefault:return MQ($,Q);case N.ZodBranded:return Y1($,Q);case N.ZodReadonly:return IQ($,Q);case N.ZodCatch:return HQ($,Q);case N.ZodPipeline:return FQ($,Q);case N.ZodFunction:case N.ZodVoid:case N.ZodSymbol:return;default:return((J)=>{return})(X)}};function P($,X,Q=!1){let J=X.seen.get($);if(X.override){let z=X.override?.($,X,J,Q);if(z!==$Q)return z}if(J&&!Q){let z=d9(J,X);if(z!==void 0)return z}let G={def:$,path:X.currentPath,jsonSchema:void 0};X.seen.set($,G);let H=bQ($,$.typeName,X),M=typeof H==="function"?P(H(),X):H;if(M)r9($,X,M);if(X.postProcess){let z=X.postProcess(M,$,X);return G.jsonSchema=M,z}return G.jsonSchema=M,M}var d9=($,X)=>{switch(X.$refStrategy){case"root":return{$ref:$.path.join("/")};case"relative":return{$ref:o9(X.currentPath,$.path)};case"none":case"seen":{if($.path.length<X.currentPath.length&&$.path.every((Q,J)=>X.currentPath[J]===Q))return console.warn(`Recursive reference detected at ${X.currentPath.join("/")}! Defaulting to any`),{};return X.$refStrategy==="seen"?{}:void 0}}},o9=($,X)=>{let Q=0;for(;Q<$.length&&Q<X.length;Q++)if($[Q]!==X[Q])break;return[($.length-Q).toString(),...X.slice(Q)].join("/")},r9=($,X,Q)=>{if($.description){if(Q.description=$.description,X.markdownDescription)Q.markdownDescription=$.description}return Q};var w1=($,X)=>{let Q=QQ(X),J=typeof X==="object"&&X.definitions?Object.entries(X.definitions).reduce((D,[O,_])=>({...D,[O]:P(_._def,{...Q,currentPath:[...Q.basePath,Q.definitionPath,O]},!0)??{}}),{}):void 0,G=typeof X==="string"?X:X?.nameStrategy==="title"?void 0:X?.name,H=P($._def,G===void 0?Q:{...Q,currentPath:[...Q.basePath,Q.definitionPath,G]},!1)??{},M=typeof X==="object"&&X.name!==void 0&&X.nameStrategy==="title"?X.name:void 0;if(M!==void 0)H.title=M;let z=G===void 0?J?{...H,[Q.definitionPath]:J}:H:{$ref:[...Q.$refStrategy==="relative"?[]:Q.basePath,Q.definitionPath,G].join("/"),[Q.definitionPath]:{...J,[G]:H}};if(Q.target==="jsonSchema7")z.$schema="http://json-schema.org/draft-07/schema#";else if(Q.target==="jsonSchema2019-09"||Q.target==="openAi")z.$schema="https://json-schema.org/draft/2019-09/schema#";if(Q.target==="openAi"&&(("anyOf"in z)||("oneOf"in z)||("allOf"in z)||("type"in z)&&Array.isArray(z.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return z};p0();m6();p0();var x2;(function($){$.Completable="McpCompletable"})(x2||(x2={}));class c6 extends c{_parse($){let{ctx:X}=this._processInputParams($),Q=X.data;return this._def.type._parse({data:Q,path:X.path,parent:X})}unwrap(){return this._def.type}}c6.create=($,X)=>{return new c6({type:$,typeName:x2.Completable,complete:X.complete,...a9(X)})};function a9($){if(!$)return{};let{errorMap:X,invalid_type_error:Q,required_error:J,description:G}=$;if(X&&(Q||J))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(X)return{errorMap:X,description:G};return{errorMap:(M,z)=>{var D,O;let{message:_}=$;if(M.code==="invalid_enum_value")return{message:_!==null&&_!==void 0?_:z.defaultError};if(typeof z.data==="undefined")return{message:(D=_!==null&&_!==void 0?_:J)!==null&&D!==void 0?D:z.defaultError};if(M.code!=="invalid_type")return{message:z.defaultError};return{message:(O=_!==null&&_!==void 0?_:Q)!==null&&O!==void 0?O:z.defaultError}},description:G}}class h2{constructor($,X){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new b2($,X)}async connect($){return await this.server.connect($)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(W1.shape.method.value),this.server.assertCanSetRequestHandler(J1.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(W1,()=>({tools:Object.entries(this._registeredTools).filter(([,$])=>$.enabled).map(([$,X])=>{let Q={name:$,description:X.description,inputSchema:X.inputSchema?w1(X.inputSchema,{strictUnions:!0}):t9,annotations:X.annotations};if(X.outputSchema)Q.outputSchema=w1(X.outputSchema,{strictUnions:!0});return Q})})),this.server.setRequestHandler(J1,async($,X)=>{let Q=this._registeredTools[$.params.name];if(!Q)throw new w$(H$.InvalidParams,`Tool ${$.params.name} not found`);if(!Q.enabled)throw new w$(H$.InvalidParams,`Tool ${$.params.name} disabled`);let J;if(Q.inputSchema){let G=await Q.inputSchema.safeParseAsync($.params.arguments);if(!G.success)throw new w$(H$.InvalidParams,`Invalid arguments for tool ${$.params.name}: ${G.error.message}`);let H=G.data,M=Q.callback;try{J=await Promise.resolve(M(H,X))}catch(z){J={content:[{type:"text",text:z instanceof Error?z.message:String(z)}],isError:!0}}}else{let G=Q.callback;try{J=await Promise.resolve(G(X))}catch(H){J={content:[{type:"text",text:H instanceof Error?H.message:String(H)}],isError:!0}}}if(Q.outputSchema){if(!J.structuredContent)throw new w$(H$.InvalidParams,`Tool ${$.params.name} has an output schema but no structured content was provided`);let G=await Q.outputSchema.safeParseAsync(J.structuredContent);if(!G.success)throw new w$(H$.InvalidParams,`Invalid structured content for tool ${$.params.name}: ${G.error.message}`)}return J}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(G1.shape.method.value),this.server.setRequestHandler(G1,async($)=>{switch($.params.ref.type){case"ref/prompt":return this.handlePromptCompletion($,$.params.ref);case"ref/resource":return this.handleResourceCompletion($,$.params.ref);default:throw new w$(H$.InvalidParams,`Invalid completion reference: ${$.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion($,X){let Q=this._registeredPrompts[X.name];if(!Q)throw new w$(H$.InvalidParams,`Prompt ${X.name} not found`);if(!Q.enabled)throw new w$(H$.InvalidParams,`Prompt ${X.name} disabled`);if(!Q.argsSchema)return z1;let J=Q.argsSchema.shape[$.params.argument.name];if(!(J instanceof c6))return z1;let H=await J._def.complete($.params.argument.value);return fQ(H)}async handleResourceCompletion($,X){let Q=Object.values(this._registeredResourceTemplates).find((H)=>H.resourceTemplate.uriTemplate.toString()===X.uri);if(!Q){if(this._registeredResources[X.uri])return z1;throw new w$(H$.InvalidParams,`Resource template ${$.params.ref.uri} not found`)}let J=Q.resourceTemplate.completeCallback($.params.argument.name);if(!J)return z1;let G=await J($.params.argument.value);return fQ(G)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(rX.shape.method.value),this.server.assertCanSetRequestHandler(aX.shape.method.value),this.server.assertCanSetRequestHandler(tX.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(rX,async($,X)=>{let Q=Object.entries(this._registeredResources).filter(([G,H])=>H.enabled).map(([G,H])=>({uri:G,name:H.name,...H.metadata})),J=[];for(let G of Object.values(this._registeredResourceTemplates)){if(!G.resourceTemplate.listCallback)continue;let H=await G.resourceTemplate.listCallback(X);for(let M of H.resources)J.push({...M,...G.metadata})}return{resources:[...Q,...J]}}),this.server.setRequestHandler(aX,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([X,Q])=>({name:X,uriTemplate:Q.resourceTemplate.uriTemplate.toString(),...Q.metadata}))}}),this.server.setRequestHandler(tX,async($,X)=>{let Q=new URL($.params.uri),J=this._registeredResources[Q.toString()];if(J){if(!J.enabled)throw new w$(H$.InvalidParams,`Resource ${Q} disabled`);return J.readCallback(Q,X)}for(let G of Object.values(this._registeredResourceTemplates)){let H=G.resourceTemplate.uriTemplate.match(Q.toString());if(H)return G.readCallback(Q,H,X)}throw new w$(H$.InvalidParams,`Resource ${Q} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler(sX.shape.method.value),this.server.assertCanSetRequestHandler(eX.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(sX,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,$])=>$.enabled).map(([$,X])=>{return{name:$,description:X.description,arguments:X.argsSchema?e9(X.argsSchema):void 0}})})),this.server.setRequestHandler(eX,async($,X)=>{let Q=this._registeredPrompts[$.params.name];if(!Q)throw new w$(H$.InvalidParams,`Prompt ${$.params.name} not found`);if(!Q.enabled)throw new w$(H$.InvalidParams,`Prompt ${$.params.name} disabled`);if(Q.argsSchema){let J=await Q.argsSchema.safeParseAsync($.params.arguments);if(!J.success)throw new w$(H$.InvalidParams,`Invalid arguments for prompt ${$.params.name}: ${J.error.message}`);let G=J.data,H=Q.callback;return await Promise.resolve(H(G,X))}else{let J=Q.callback;return await Promise.resolve(J(X))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource($,X,...Q){let J;if(typeof Q[0]==="object")J=Q.shift();let G=Q[0];if(typeof X==="string"){if(this._registeredResources[X])throw new Error(`Resource ${X} is already registered`);let H={name:$,metadata:J,readCallback:G,enabled:!0,disable:()=>H.update({enabled:!1}),enable:()=>H.update({enabled:!0}),remove:()=>H.update({uri:null}),update:(M)=>{if(typeof M.uri!=="undefined"&&M.uri!==X){if(delete this._registeredResources[X],M.uri)this._registeredResources[M.uri]=H}if(typeof M.name!=="undefined")H.name=M.name;if(typeof M.metadata!=="undefined")H.metadata=M.metadata;if(typeof M.callback!=="undefined")H.readCallback=M.callback;if(typeof M.enabled!=="undefined")H.enabled=M.enabled;this.sendResourceListChanged()}};return this._registeredResources[X]=H,this.setResourceRequestHandlers(),this.sendResourceListChanged(),H}else{if(this._registeredResourceTemplates[$])throw new Error(`Resource template ${$} is already registered`);let H={resourceTemplate:X,metadata:J,readCallback:G,enabled:!0,disable:()=>H.update({enabled:!1}),enable:()=>H.update({enabled:!0}),remove:()=>H.update({name:null}),update:(M)=>{if(typeof M.name!=="undefined"&&M.name!==$){if(delete this._registeredResourceTemplates[$],M.name)this._registeredResourceTemplates[M.name]=H}if(typeof M.template!=="undefined")H.resourceTemplate=M.template;if(typeof M.metadata!=="undefined")H.metadata=M.metadata;if(typeof M.callback!=="undefined")H.readCallback=M.callback;if(typeof M.enabled!=="undefined")H.enabled=M.enabled;this.sendResourceListChanged()}};return this._registeredResourceTemplates[$]=H,this.setResourceRequestHandlers(),this.sendResourceListChanged(),H}}_createRegisteredTool($,X,Q,J,G,H){let M={description:X,inputSchema:Q===void 0?void 0:B.object(Q),outputSchema:J===void 0?void 0:B.object(J),annotations:G,callback:H,enabled:!0,disable:()=>M.update({enabled:!1}),enable:()=>M.update({enabled:!0}),remove:()=>M.update({name:null}),update:(z)=>{if(typeof z.name!=="undefined"&&z.name!==$){if(delete this._registeredTools[$],z.name)this._registeredTools[z.name]=M}if(typeof z.description!=="undefined")M.description=z.description;if(typeof z.paramsSchema!=="undefined")M.inputSchema=B.object(z.paramsSchema);if(typeof z.callback!=="undefined")M.callback=z.callback;if(typeof z.annotations!=="undefined")M.annotations=z.annotations;if(typeof z.enabled!=="undefined")M.enabled=z.enabled;this.sendToolListChanged()}};return this._registeredTools[$]=M,this.setToolRequestHandlers(),this.sendToolListChanged(),M}tool($,...X){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let Q,J,G,H;if(typeof X[0]==="string")Q=X.shift();if(X.length>1){let z=X[0];if(PQ(z)){if(J=X.shift(),X.length>1&&typeof X[0]==="object"&&X[0]!==null&&!PQ(X[0]))H=X.shift()}else if(typeof z==="object"&&z!==null)H=X.shift()}let M=X[0];return this._createRegisteredTool($,Q,J,G,H,M)}registerTool($,X,Q){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let{description:J,inputSchema:G,outputSchema:H,annotations:M}=X;return this._createRegisteredTool($,J,G,H,M,Q)}prompt($,...X){if(this._registeredPrompts[$])throw new Error(`Prompt ${$} is already registered`);let Q;if(typeof X[0]==="string")Q=X.shift();let J;if(X.length>1)J=X.shift();let G=X[0],H={description:Q,argsSchema:J===void 0?void 0:B.object(J),callback:G,enabled:!0,disable:()=>H.update({enabled:!1}),enable:()=>H.update({enabled:!0}),remove:()=>H.update({name:null}),update:(M)=>{if(typeof M.name!=="undefined"&&M.name!==$){if(delete this._registeredPrompts[$],M.name)this._registeredPrompts[M.name]=H}if(typeof M.description!=="undefined")H.description=M.description;if(typeof M.argsSchema!=="undefined")H.argsSchema=B.object(M.argsSchema);if(typeof M.callback!=="undefined")H.callback=M.callback;if(typeof M.enabled!=="undefined")H.enabled=M.enabled;this.sendPromptListChanged()}};return this._registeredPrompts[$]=H,this.setPromptRequestHandlers(),this.sendPromptListChanged(),H}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 t9={type:"object"};function PQ($){if(typeof $!=="object"||$===null)return!1;return Object.keys($).length===0||Object.values($).some(s9)}function s9($){return $!==null&&typeof $==="object"&&"parse"in $&&typeof $.parse==="function"&&"safeParse"in $&&typeof $.safeParse==="function"}function e9($){return Object.entries($.shape).map(([X,Q])=>({name:X,description:Q.description,required:!Q.isOptional()}))}function fQ($){return{completion:{values:$.slice(0,100),total:$.length,hasMore:$.length>100}}}var z1={completion:{values:[],hasMore:!1}};function gQ($,X){let Q=process.argv,J=`--${$}=`;for(let G of Q)if(G.startsWith(J))return G.substring(J.length);return X}q4();var QG=y$("FigmaConfig",1),u6=gQ("figma-api-key")||process.env.FIGMA_API_KEY||"",hQ="F2C MCP",yQ=process.env.FIGMA_VERSION||"0.0.1";QG.debug("DEFAULT_PERSONAL_TOKEN",u6);var ZQ=($)=>{};var mQ=($)=>{ZQ($)};var t2=null;async function EG(){if(typeof global!=="undefined"&&global.fetch)return global.fetch;if(typeof globalThis.fetch!=="undefined")return globalThis.fetch;if(!t2)try{t2=await Promise.resolve().then(() => (g7(),f7))}catch($){throw new Error("Neither native fetch nor node-fetch is available. Please install node-fetch or upgrade to Node.js 18+")}return t2.default}async function RG($,X){return(await EG())($,X)}var e4=RG;q4();var T7=y$("F2cApi",1);class x7{f2cHost="https://f2c-figma-api.yy.com/api";personalToken=u6;async nodeToCode($){let X={fileKey:$.fileKey,nodeIds:$.ids,personal_token:$.personalToken||this.personalToken,option:{cssFramework:"inlinecss",imgFormat:$.imgFormat||"png",scaleSize:$.scaleSize||2},format:"files"};if($.format==="react-cssmodules")X.option.cssFramework="cssmodules";else if($.format==="react-tailwind")X.option.cssFramework="tailwindcss";let Q=this.opToUrl(`${this.f2cHost}/nodes`,X);return this.fetch(Q,"json")}async fetch($,X="json"){try{let Q={method:"GET",headers:{"F2c-Api-Platform":"mcp"}};T7.debug("fetch",$);let J=await e4($,Q);if(!J.ok)throw new Error(`HTTP error! status: ${J.status}`);return X==="text"?await J.text():await J.json()}catch(Q){throw T7.error("HTTP error",Q),Q}}opToUrl($,X={}){if(Object.keys(X).length===0)return $;let Q=new URL($);for(let[J,G]of Object.entries(X))if(typeof G==="object"&&G!==null)for(let[H,M]of Object.entries(G))Q.searchParams.append(`${J}[${H}]`,M);else Q.searchParams.append(J,G);return Q.toString()}}var h7=new x7;q4();var vG=y$("FigmaRestApi");class y7{figmaHost="https://api.figma.com/v1";personalToken=u6;async files($){let X;if($.ids)X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/nodes`,$);else X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}`,$);return this.fetch(X)}async images($){let X=this.opToUrl(`${this.figmaHost}/images/${$.fileKey}`,$);return this.fetch(X)}async imageFills($){let X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/images`,$);return this.fetch(X)}async meta($){let X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/meta`,$);return this.fetch(X)}async fetch($,X="json"){try{let Q={method:"GET",headers:{"X-FIGMA-TOKEN":this.personalToken}},J=await e4($,Q);if(!J.ok)throw new Error(`HTTP error! status: ${J.status}`);return X==="text"?await J.text():await J.json()}catch(Q){throw vG.error("HTTP error",Q),Q}}opToUrl($,X={},Q=["fileKey","personalToken"]){if(Object.keys(X).length===0)return $;if(X.personalToken)this.personalToken=X.personalToken;let J=new URL($);for(let[G,H]of Object.entries(X))if(!Q.includes(G))J.searchParams.append(G,H);return J.toString()}}var Z7=new y7;q4();var V$={};K2(V$,{void:()=>BY,util:()=>o,unknown:()=>wY,union:()=>qY,undefined:()=>YY,tuple:()=>jY,transformer:()=>CY,symbol:()=>GY,string:()=>r7,strictObject:()=>OY,setErrorMap:()=>IG,set:()=>NY,record:()=>KY,quotelessJson:()=>CG,promise:()=>vY,preprocess:()=>bY,pipeline:()=>PY,ostring:()=>fY,optional:()=>kY,onumber:()=>gY,oboolean:()=>TY,objectUtil:()=>s2,object:()=>VY,number:()=>a7,nullable:()=>IY,null:()=>HY,never:()=>zY,nativeEnum:()=>RY,nan:()=>QY,map:()=>UY,makeIssue:()=>s6,literal:()=>FY,lazy:()=>SY,late:()=>$Y,isValid:()=>a0,isDirty:()=>E1,isAsync:()=>X6,isAborted:()=>F1,intersection:()=>AY,instanceof:()=>XY,getParsedType:()=>D0,getErrorMap:()=>$6,function:()=>LY,enum:()=>EY,effect:()=>CY,discriminatedUnion:()=>_Y,defaultErrorMap:()=>I0,datetimeRegex:()=>i7,date:()=>JY,custom:()=>o7,coerce:()=>xY,boolean:()=>t7,bigint:()=>WY,array:()=>DY,any:()=>MY,addIssueToContext:()=>S,ZodVoid:()=>QX,ZodUnknown:()=>t0,ZodUnion:()=>H6,ZodUndefined:()=>G6,ZodType:()=>i,ZodTuple:()=>O0,ZodTransformer:()=>X0,ZodSymbol:()=>XX,ZodString:()=>t$,ZodSet:()=>S4,ZodSchema:()=>i,ZodRecord:()=>WX,ZodReadonly:()=>O6,ZodPromise:()=>F4,ZodPipeline:()=>YX,ZodParsedType:()=>L,ZodOptional:()=>e$,ZodObject:()=>M$,ZodNumber:()=>s0,ZodNullable:()=>P0,ZodNull:()=>Y6,ZodNever:()=>V0,ZodNativeEnum:()=>B6,ZodNaN:()=>GX,ZodMap:()=>JX,ZodLiteral:()=>z6,ZodLazy:()=>w6,ZodIssueCode:()=>K,ZodIntersection:()=>M6,ZodFunction:()=>W6,ZodFirstPartyTypeKind:()=>g,ZodError:()=>R$,ZodEnum:()=>$4,ZodEffects:()=>X0,ZodDiscriminatedUnion:()=>v1,ZodDefault:()=>D6,ZodDate:()=>N4,ZodCatch:()=>V6,ZodBranded:()=>C1,ZodBoolean:()=>J6,ZodBigInt:()=>e0,ZodArray:()=>s$,ZodAny:()=>L4,Schema:()=>i,ParseStatus:()=>q$,OK:()=>j$,NEVER:()=>hY,INVALID:()=>f,EMPTY_PATH:()=>bG,DIRTY:()=>U4,BRAND:()=>eG});var o;(function($){$.assertEqual=(G)=>{};function X(G){}$.assertIs=X;function Q(G){throw new Error}$.assertNever=Q,$.arrayToEnum=(G)=>{let H={};for(let M of G)H[M]=M;return H},$.getValidEnumValues=(G)=>{let H=$.objectKeys(G).filter((z)=>typeof G[G[z]]!=="number"),M={};for(let z of H)M[z]=G[z];return $.objectValues(M)},$.objectValues=(G)=>{return $.objectKeys(G).map(function(H){return G[H]})},$.objectKeys=typeof Object.keys==="function"?(G)=>Object.keys(G):(G)=>{let H=[];for(let M in G)if(Object.prototype.hasOwnProperty.call(G,M))H.push(M);return H},$.find=(G,H)=>{for(let M of G)if(H(M))return M;return},$.isInteger=typeof Number.isInteger==="function"?(G)=>Number.isInteger(G):(G)=>typeof G==="number"&&Number.isFinite(G)&&Math.floor(G)===G;function J(G,H=" | "){return G.map((M)=>typeof M==="string"?`'${M}'`:M).join(H)}$.joinValues=J,$.jsonStringifyReplacer=(G,H)=>{if(typeof H==="bigint")return H.toString();return H}})(o||(o={}));var s2;(function($){$.mergeShapes=(X,Q)=>{return{...X,...Q}}})(s2||(s2={}));var L=o.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D0=($)=>{switch(typeof $){case"undefined":return L.undefined;case"string":return L.string;case"number":return Number.isNaN($)?L.nan:L.number;case"boolean":return L.boolean;case"function":return L.function;case"bigint":return L.bigint;case"symbol":return L.symbol;case"object":if(Array.isArray($))return L.array;if($===null)return L.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return L.promise;if(typeof Map!=="undefined"&&$ instanceof Map)return L.map;if(typeof Set!=="undefined"&&$ instanceof Set)return L.set;if(typeof Date!=="undefined"&&$ instanceof Date)return L.date;return L.object;default:return L.unknown}};var K=o.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"]),CG=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class R$ extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(Q)=>{this.issues=[...this.issues,Q]},this.addIssues=(Q=[])=>{this.issues=[...this.issues,...Q]};let X=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,X);else this.__proto__=X;this.name="ZodError",this.issues=$}format($){let X=$||function(G){return G.message},Q={_errors:[]},J=(G)=>{for(let H of G.issues)if(H.code==="invalid_union")H.unionErrors.map(J);else if(H.code==="invalid_return_type")J(H.returnTypeError);else if(H.code==="invalid_arguments")J(H.argumentsError);else if(H.path.length===0)Q._errors.push(X(H));else{let M=Q,z=0;while(z<H.path.length){let D=H.path[z];if(z!==H.path.length-1)M[D]=M[D]||{_errors:[]};else M[D]=M[D]||{_errors:[]},M[D]._errors.push(X(H));M=M[D],z++}}};return J(this),Q}static assert($){if(!($ instanceof R$))throw new Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,o.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(X)=>X.message){let X={},Q=[];for(let J of this.issues)if(J.path.length>0)X[J.path[0]]=X[J.path[0]]||[],X[J.path[0]].push($(J));else Q.push($(J));return{formErrors:Q,fieldErrors:X}}get formErrors(){return this.flatten()}}R$.create=($)=>{return new R$($)};var kG=($,X)=>{let Q;switch($.code){case K.invalid_type:if($.received===L.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case K.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,o.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:Q=`Unrecognized key(s) in object: ${o.joinValues($.keys,", ")}`;break;case K.invalid_union:Q="Invalid input";break;case K.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${o.joinValues($.options)}`;break;case K.invalid_enum_value:Q=`Invalid enum value. Expected ${o.joinValues($.options)}, received '${$.received}'`;break;case K.invalid_arguments:Q="Invalid function arguments";break;case K.invalid_return_type:Q="Invalid function return type";break;case K.invalid_date:Q="Invalid date";break;case K.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(Q=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")Q=`${Q} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)Q=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)Q=`Invalid input: must end with "${$.validation.endsWith}"`;else o.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case K.too_small:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else Q="Invalid input";break;case K.too_big:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")Q=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else Q="Invalid input";break;case K.custom:Q="Invalid input";break;case K.invalid_intersection_types:Q="Intersection results could not be merged";break;case K.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case K.not_finite:Q="Number must be finite";break;default:Q=X.defaultError,o.assertNever($)}return{message:Q}},I0=kG;var m7=I0;function IG($){m7=$}function $6(){return m7}var s6=($)=>{let{data:X,path:Q,errorMaps:J,issueData:G}=$,H=[...Q,...G.path||[]],M={...G,path:H};if(G.message!==void 0)return{...G,path:H,message:G.message};let z="",D=J.filter((O)=>!!O).slice().reverse();for(let O of D)z=O(M,{data:X,defaultError:z}).message;return{...G,path:H,message:z}},bG=[];function S($,X){let Q=$6(),J=s6({issueData:X,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===I0?void 0:I0].filter((G)=>!!G)});$.common.issues.push(J)}class q${constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,X){let Q=[];for(let J of X){if(J.status==="aborted")return f;if(J.status==="dirty")$.dirty();Q.push(J.value)}return{status:$.value,value:Q}}static async mergeObjectAsync($,X){let Q=[];for(let J of X){let G=await J.key,H=await J.value;Q.push({key:G,value:H})}return q$.mergeObjectSync($,Q)}static mergeObjectSync($,X){let Q={};for(let J of X){let{key:G,value:H}=J;if(G.status==="aborted")return f;if(H.status==="aborted")return f;if(G.status==="dirty")$.dirty();if(H.status==="dirty")$.dirty();if(G.value!=="__proto__"&&(typeof H.value!=="undefined"||J.alwaysSet))Q[G.value]=H.value}return{status:$.value,value:Q}}}var f=Object.freeze({status:"aborted"}),U4=($)=>({status:"dirty",value:$}),j$=($)=>({status:"valid",value:$}),F1=($)=>$.status==="aborted",E1=($)=>$.status==="dirty",a0=($)=>$.status==="valid",X6=($)=>typeof Promise!=="undefined"&&$ instanceof Promise;var v;(function($){$.errToObj=(X)=>typeof X==="string"?{message:X}:X||{},$.toString=(X)=>typeof X==="string"?X:X?.message})(v||(v={}));var R1=function($,X,Q,J){if(Q==="a"&&!J)throw new TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!J:!X.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return Q==="m"?J:Q==="a"?J.call($):J?J.value:X.get($)},u7=function($,X,Q,J,G){if(J==="m")throw new TypeError("Private method is not writable");if(J==="a"&&!G)throw new TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!G:!X.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return J==="a"?G.call($,Q):G?G.value=Q:X.set($,Q),Q},e6,$X;class $0{constructor($,X,Q,J){this._cachedPath=[],this.parent=$,this.data=X,this._path=Q,this._key=J}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 l7=($,X)=>{if(a0(X))return{success:!0,data:X.value};else{if(!$.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Q=new R$($.common.issues);return this._error=Q,this._error}}}};function p($){if(!$)return{};let{errorMap:X,invalid_type_error:Q,required_error:J,description:G}=$;if(X&&(Q||J))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(X)return{errorMap:X,description:G};return{errorMap:(M,z)=>{let{message:D}=$;if(M.code==="invalid_enum_value")return{message:D??z.defaultError};if(typeof z.data==="undefined")return{message:D??J??z.defaultError};if(M.code!=="invalid_type")return{message:z.defaultError};return{message:D??Q??z.defaultError}},description:G}}class i{get description(){return this._def.description}_getType($){return D0($.data)}_getOrReturnCtx($,X){return X||{common:$.parent.common,data:$.data,parsedType:D0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new q$,ctx:{common:$.parent.common,data:$.data,parsedType:D0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let X=this._parse($);if(X6(X))throw new Error("Synchronous parse encountered promise.");return X}_parseAsync($){let X=this._parse($);return Promise.resolve(X)}parse($,X){let Q=this.safeParse($,X);if(Q.success)return Q.data;throw Q.error}safeParse($,X){let Q={common:{issues:[],async:X?.async??!1,contextualErrorMap:X?.errorMap},path:X?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:D0($)},J=this._parseSync({data:$,path:Q.path,parent:Q});return l7(Q,J)}"~validate"($){let X={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:D0($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:X});return a0(Q)?{value:Q.value}:{issues:X.common.issues}}catch(Q){if(Q?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;X.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:X}).then((Q)=>a0(Q)?{value:Q.value}:{issues:X.common.issues})}async parseAsync($,X){let Q=await this.safeParseAsync($,X);if(Q.success)return Q.data;throw Q.error}async safeParseAsync($,X){let Q={common:{issues:[],contextualErrorMap:X?.errorMap,async:!0},path:X?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:D0($)},J=this._parse({data:$,path:Q.path,parent:Q}),G=await(X6(J)?J:Promise.resolve(J));return l7(Q,G)}refine($,X){let Q=(J)=>{if(typeof X==="string"||typeof X==="undefined")return{message:X};else if(typeof X==="function")return X(J);else return X};return this._refinement((J,G)=>{let H=$(J),M=()=>G.addIssue({code:K.custom,...Q(J)});if(typeof Promise!=="undefined"&&H instanceof Promise)return H.then((z)=>{if(!z)return M(),!1;else return!0});if(!H)return M(),!1;else return!0})}refinement($,X){return this._refinement((Q,J)=>{if(!$(Q))return J.addIssue(typeof X==="function"?X(Q,J):X),!1;else return!0})}_refinement($){return new X0({schema:this,typeName:g.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(X)=>this["~validate"](X)}}optional(){return e$.create(this,this._def)}nullable(){return P0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return s$.create(this)}promise(){return F4.create(this,this._def)}or($){return H6.create([this,$],this._def)}and($){return M6.create(this,$,this._def)}transform($){return new X0({...p(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:$}})}default($){let X=typeof $==="function"?$:()=>$;return new D6({...p(this._def),innerType:this,defaultValue:X,typeName:g.ZodDefault})}brand(){return new C1({typeName:g.ZodBranded,type:this,...p(this._def)})}catch($){let X=typeof $==="function"?$:()=>$;return new V6({...p(this._def),innerType:this,catchValue:X,typeName:g.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return YX.create(this,$)}readonly(){return O6.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var PG=/^c[^\s-]{8,}$/i,fG=/^[0-9a-z]+$/,gG=/^[0-9A-HJKMNP-TV-Z]{26}$/i,TG=/^[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,xG=/^[a-z0-9_-]{21}$/i,hG=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,yG=/^[-+]?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)?)??$/,ZG=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,mG="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",e2,lG=/^(?:(?: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])$/,cG=/^(?:(?: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])$/,uG=/^(([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]))$/,pG=/^(([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])$/,nG=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,iG=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,p7="((\\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])))",dG=new RegExp(`^${p7}$`);function n7($){let X="[0-5]\\d";if($.precision)X=`${X}\\.\\d{${$.precision}}`;else if($.precision==null)X=`${X}(\\.\\d+)?`;let Q=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${X})${Q}`}function oG($){return new RegExp(`^${n7($)}$`)}function i7($){let X=`${p7}T${n7($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return X=`${X}(${Q.join("|")})`,new RegExp(`^${X}$`)}function rG($,X){if((X==="v4"||!X)&&lG.test($))return!0;if((X==="v6"||!X)&&uG.test($))return!0;return!1}function aG($,X){if(!hG.test($))return!1;try{let[Q]=$.split("."),J=Q.replace(/-/g,"+").replace(/_/g,"/").padEnd(Q.length+(4-Q.length%4)%4,"="),G=JSON.parse(atob(J));if(typeof G!=="object"||G===null)return!1;if("typ"in G&&G?.typ!=="JWT")return!1;if(!G.alg)return!1;if(X&&G.alg!==X)return!1;return!0}catch{return!1}}function tG($,X){if((X==="v4"||!X)&&cG.test($))return!0;if((X==="v6"||!X)&&pG.test($))return!0;return!1}class t$ extends i{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==L.string){let G=this._getOrReturnCtx($);return S(G,{code:K.invalid_type,expected:L.string,received:G.parsedType}),f}let Q=new q$,J=void 0;for(let G of this._def.checks)if(G.kind==="min"){if($.data.length<G.value)J=this._getOrReturnCtx($,J),S(J,{code:K.too_small,minimum:G.value,type:"string",inclusive:!0,exact:!1,message:G.message}),Q.dirty()}else if(G.kind==="max"){if($.data.length>G.value)J=this._getOrReturnCtx($,J),S(J,{code:K.too_big,maximum:G.value,type:"string",inclusive:!0,exact:!1,message:G.message}),Q.dirty()}else if(G.kind==="length"){let H=$.data.length>G.value,M=$.data.length<G.value;if(H||M){if(J=this._getOrReturnCtx($,J),H)S(J,{code:K.too_big,maximum:G.value,type:"string",inclusive:!0,exact:!0,message:G.message});else if(M)S(J,{code:K.too_small,minimum:G.value,type:"string",inclusive:!0,exact:!0,message:G.message});Q.dirty()}}else if(G.kind==="email"){if(!ZG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"email",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="emoji"){if(!e2)e2=new RegExp(mG,"u");if(!e2.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"emoji",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="uuid"){if(!TG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"uuid",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="nanoid"){if(!xG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"nanoid",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="cuid"){if(!PG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"cuid",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="cuid2"){if(!fG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"cuid2",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="ulid"){if(!gG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"ulid",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="url")try{new URL($.data)}catch{J=this._getOrReturnCtx($,J),S(J,{validation:"url",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="regex"){if(G.regex.lastIndex=0,!G.regex.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"regex",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="trim")$.data=$.data.trim();else if(G.kind==="includes"){if(!$.data.includes(G.value,G.position))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:{includes:G.value,position:G.position},message:G.message}),Q.dirty()}else if(G.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(G.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(G.kind==="startsWith"){if(!$.data.startsWith(G.value))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:{startsWith:G.value},message:G.message}),Q.dirty()}else if(G.kind==="endsWith"){if(!$.data.endsWith(G.value))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:{endsWith:G.value},message:G.message}),Q.dirty()}else if(G.kind==="datetime"){if(!i7(G).test($.data))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:"datetime",message:G.message}),Q.dirty()}else if(G.kind==="date"){if(!dG.test($.data))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:"date",message:G.message}),Q.dirty()}else if(G.kind==="time"){if(!oG(G).test($.data))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:"time",message:G.message}),Q.dirty()}else if(G.kind==="duration"){if(!yG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"duration",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="ip"){if(!rG($.data,G.version))J=this._getOrReturnCtx($,J),S(J,{validation:"ip",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="jwt"){if(!aG($.data,G.alg))J=this._getOrReturnCtx($,J),S(J,{validation:"jwt",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="cidr"){if(!tG($.data,G.version))J=this._getOrReturnCtx($,J),S(J,{validation:"cidr",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="base64"){if(!nG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"base64",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="base64url"){if(!iG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"base64url",code:K.invalid_string,message:G.message}),Q.dirty()}else o.assertNever(G);return{status:Q.value,value:$.data}}_regex($,X,Q){return this.refinement((J)=>$.test(J),{validation:X,code:K.invalid_string,...v.errToObj(Q)})}_addCheck($){return new t$({...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($,X){return this._addCheck({kind:"regex",regex:$,...v.errToObj(X)})}includes($,X){return this._addCheck({kind:"includes",value:$,position:X?.position,...v.errToObj(X?.message)})}startsWith($,X){return this._addCheck({kind:"startsWith",value:$,...v.errToObj(X)})}endsWith($,X){return this._addCheck({kind:"endsWith",value:$,...v.errToObj(X)})}min($,X){return this._addCheck({kind:"min",value:$,...v.errToObj(X)})}max($,X){return this._addCheck({kind:"max",value:$,...v.errToObj(X)})}length($,X){return this._addCheck({kind:"length",value:$,...v.errToObj(X)})}nonempty($){return this.min(1,v.errToObj($))}trim(){return new t$({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t$({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t$({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxLength(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}}t$.create=($)=>{return new t$({checks:[],typeName:g.ZodString,coerce:$?.coerce??!1,...p($)})};function sG($,X){let Q=($.toString().split(".")[1]||"").length,J=(X.toString().split(".")[1]||"").length,G=Q>J?Q:J,H=Number.parseInt($.toFixed(G).replace(".","")),M=Number.parseInt(X.toFixed(G).replace(".",""));return H%M/10**G}class s0 extends i{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($)!==L.number){let G=this._getOrReturnCtx($);return S(G,{code:K.invalid_type,expected:L.number,received:G.parsedType}),f}let Q=void 0,J=new q$;for(let G of this._def.checks)if(G.kind==="int"){if(!o.isInteger($.data))Q=this._getOrReturnCtx($,Q),S(Q,{code:K.invalid_type,expected:"integer",received:"float",message:G.message}),J.dirty()}else if(G.kind==="min"){if(G.inclusive?$.data<G.value:$.data<=G.value)Q=this._getOrReturnCtx($,Q),S(Q,{code:K.too_small,minimum:G.value,type:"number",inclusive:G.inclusive,exact:!1,message:G.message}),J.dirty()}else if(G.kind==="max"){if(G.inclusive?$.data>G.value:$.data>=G.value)Q=this._getOrReturnCtx($,Q),S(Q,{code:K.too_big,maximum:G.value,type:"number",inclusive:G.inclusive,exact:!1,message:G.message}),J.dirty()}else if(G.kind==="multipleOf"){if(sG($.data,G.value)!==0)Q=this._getOrReturnCtx($,Q),S(Q,{code:K.not_multiple_of,multipleOf:G.value,message:G.message}),J.dirty()}else if(G.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),S(Q,{code:K.not_finite,message:G.message}),J.dirty()}else o.assertNever(G);return{status:J.value,value:$.data}}gte($,X){return this.setLimit("min",$,!0,v.toString(X))}gt($,X){return this.setLimit("min",$,!1,v.toString(X))}lte($,X){return this.setLimit("max",$,!0,v.toString(X))}lt($,X){return this.setLimit("max",$,!1,v.toString(X))}setLimit($,X,Q,J){return new s0({...this._def,checks:[...this._def.checks,{kind:$,value:X,inclusive:Q,message:v.toString(J)}]})}_addCheck($){return new s0({...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($,X){return this._addCheck({kind:"multipleOf",value:$,message:v.toString(X)})}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 X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxValue(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&o.isInteger($.value))}get isFinite(){let $=null,X=null;for(let Q of this._def.checks)if(Q.kind==="finite"||Q.kind==="int"||Q.kind==="multipleOf")return!0;else if(Q.kind==="min"){if(X===null||Q.value>X)X=Q.value}else if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return Number.isFinite(X)&&Number.isFinite($)}}s0.create=($)=>{return new s0({checks:[],typeName:g.ZodNumber,coerce:$?.coerce||!1,...p($)})};class e0 extends i{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($)!==L.bigint)return this._getInvalidInput($);let Q=void 0,J=new q$;for(let G of this._def.checks)if(G.kind==="min"){if(G.inclusive?$.data<G.value:$.data<=G.value)Q=this._getOrReturnCtx($,Q),S(Q,{code:K.too_small,type:"bigint",minimum:G.value,inclusive:G.inclusive,message:G.message}),J.dirty()}else if(G.kind==="max"){if(G.inclusive?$.data>G.value:$.data>=G.value)Q=this._getOrReturnCtx($,Q),S(Q,{code:K.too_big,type:"bigint",maximum:G.value,inclusive:G.inclusive,message:G.message}),J.dirty()}else if(G.kind==="multipleOf"){if($.data%G.value!==BigInt(0))Q=this._getOrReturnCtx($,Q),S(Q,{code:K.not_multiple_of,multipleOf:G.value,message:G.message}),J.dirty()}else o.assertNever(G);return{status:J.value,value:$.data}}_getInvalidInput($){let X=this._getOrReturnCtx($);return S(X,{code:K.invalid_type,expected:L.bigint,received:X.parsedType}),f}gte($,X){return this.setLimit("min",$,!0,v.toString(X))}gt($,X){return this.setLimit("min",$,!1,v.toString(X))}lte($,X){return this.setLimit("max",$,!0,v.toString(X))}lt($,X){return this.setLimit("max",$,!1,v.toString(X))}setLimit($,X,Q,J){return new e0({...this._def,checks:[...this._def.checks,{kind:$,value:X,inclusive:Q,message:v.toString(J)}]})}_addCheck($){return new e0({...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($,X){return this._addCheck({kind:"multipleOf",value:$,message:v.toString(X)})}get minValue(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxValue(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}}e0.create=($)=>{return new e0({checks:[],typeName:g.ZodBigInt,coerce:$?.coerce??!1,...p($)})};class J6 extends i{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==L.boolean){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.boolean,received:Q.parsedType}),f}return j$($.data)}}J6.create=($)=>{return new J6({typeName:g.ZodBoolean,coerce:$?.coerce||!1,...p($)})};class N4 extends i{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==L.date){let G=this._getOrReturnCtx($);return S(G,{code:K.invalid_type,expected:L.date,received:G.parsedType}),f}if(Number.isNaN($.data.getTime())){let G=this._getOrReturnCtx($);return S(G,{code:K.invalid_date}),f}let Q=new q$,J=void 0;for(let G of this._def.checks)if(G.kind==="min"){if($.data.getTime()<G.value)J=this._getOrReturnCtx($,J),S(J,{code:K.too_small,message:G.message,inclusive:!0,exact:!1,minimum:G.value,type:"date"}),Q.dirty()}else if(G.kind==="max"){if($.data.getTime()>G.value)J=this._getOrReturnCtx($,J),S(J,{code:K.too_big,message:G.message,inclusive:!0,exact:!1,maximum:G.value,type:"date"}),Q.dirty()}else o.assertNever(G);return{status:Q.value,value:new Date($.data.getTime())}}_addCheck($){return new N4({...this._def,checks:[...this._def.checks,$]})}min($,X){return this._addCheck({kind:"min",value:$.getTime(),message:v.toString(X)})}max($,X){return this._addCheck({kind:"max",value:$.getTime(),message:v.toString(X)})}get minDate(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $!=null?new Date($):null}}N4.create=($)=>{return new N4({checks:[],coerce:$?.coerce||!1,typeName:g.ZodDate,...p($)})};class XX extends i{_parse($){if(this._getType($)!==L.symbol){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.symbol,received:Q.parsedType}),f}return j$($.data)}}XX.create=($)=>{return new XX({typeName:g.ZodSymbol,...p($)})};class G6 extends i{_parse($){if(this._getType($)!==L.undefined){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.undefined,received:Q.parsedType}),f}return j$($.data)}}G6.create=($)=>{return new G6({typeName:g.ZodUndefined,...p($)})};class Y6 extends i{_parse($){if(this._getType($)!==L.null){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.null,received:Q.parsedType}),f}return j$($.data)}}Y6.create=($)=>{return new Y6({typeName:g.ZodNull,...p($)})};class L4 extends i{constructor(){super(...arguments);this._any=!0}_parse($){return j$($.data)}}L4.create=($)=>{return new L4({typeName:g.ZodAny,...p($)})};class t0 extends i{constructor(){super(...arguments);this._unknown=!0}_parse($){return j$($.data)}}t0.create=($)=>{return new t0({typeName:g.ZodUnknown,...p($)})};class V0 extends i{_parse($){let X=this._getOrReturnCtx($);return S(X,{code:K.invalid_type,expected:L.never,received:X.parsedType}),f}}V0.create=($)=>{return new V0({typeName:g.ZodNever,...p($)})};class QX extends i{_parse($){if(this._getType($)!==L.undefined){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.void,received:Q.parsedType}),f}return j$($.data)}}QX.create=($)=>{return new QX({typeName:g.ZodVoid,...p($)})};class s$ extends i{_parse($){let{ctx:X,status:Q}=this._processInputParams($),J=this._def;if(X.parsedType!==L.array)return S(X,{code:K.invalid_type,expected:L.array,received:X.parsedType}),f;if(J.exactLength!==null){let H=X.data.length>J.exactLength.value,M=X.data.length<J.exactLength.value;if(H||M)S(X,{code:H?K.too_big:K.too_small,minimum:M?J.exactLength.value:void 0,maximum:H?J.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:J.exactLength.message}),Q.dirty()}if(J.minLength!==null){if(X.data.length<J.minLength.value)S(X,{code:K.too_small,minimum:J.minLength.value,type:"array",inclusive:!0,exact:!1,message:J.minLength.message}),Q.dirty()}if(J.maxLength!==null){if(X.data.length>J.maxLength.value)S(X,{code:K.too_big,maximum:J.maxLength.value,type:"array",inclusive:!0,exact:!1,message:J.maxLength.message}),Q.dirty()}if(X.common.async)return Promise.all([...X.data].map((H,M)=>{return J.type._parseAsync(new $0(X,H,X.path,M))})).then((H)=>{return q$.mergeArray(Q,H)});let G=[...X.data].map((H,M)=>{return J.type._parseSync(new $0(X,H,X.path,M))});return q$.mergeArray(Q,G)}get element(){return this._def.type}min($,X){return new s$({...this._def,minLength:{value:$,message:v.toString(X)}})}max($,X){return new s$({...this._def,maxLength:{value:$,message:v.toString(X)}})}length($,X){return new s$({...this._def,exactLength:{value:$,message:v.toString(X)}})}nonempty($){return this.min(1,$)}}s$.create=($,X)=>{return new s$({type:$,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,...p(X)})};function Q6($){if($ instanceof M$){let X={};for(let Q in $.shape){let J=$.shape[Q];X[Q]=e$.create(Q6(J))}return new M$({...$._def,shape:()=>X})}else if($ instanceof s$)return new s$({...$._def,type:Q6($.element)});else if($ instanceof e$)return e$.create(Q6($.unwrap()));else if($ instanceof P0)return P0.create(Q6($.unwrap()));else if($ instanceof O0)return O0.create($.items.map((X)=>Q6(X)));else return $}class M$ extends i{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),X=o.objectKeys($);return this._cached={shape:$,keys:X},this._cached}_parse($){if(this._getType($)!==L.object){let D=this._getOrReturnCtx($);return S(D,{code:K.invalid_type,expected:L.object,received:D.parsedType}),f}let{status:Q,ctx:J}=this._processInputParams($),{shape:G,keys:H}=this._getCached(),M=[];if(!(this._def.catchall instanceof V0&&this._def.unknownKeys==="strip")){for(let D in J.data)if(!H.includes(D))M.push(D)}let z=[];for(let D of H){let O=G[D],_=J.data[D];z.push({key:{status:"valid",value:D},value:O._parse(new $0(J,_,J.path,D)),alwaysSet:D in J.data})}if(this._def.catchall instanceof V0){let D=this._def.unknownKeys;if(D==="passthrough")for(let O of M)z.push({key:{status:"valid",value:O},value:{status:"valid",value:J.data[O]}});else if(D==="strict"){if(M.length>0)S(J,{code:K.unrecognized_keys,keys:M}),Q.dirty()}else if(D==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let D=this._def.catchall;for(let O of M){let _=J.data[O];z.push({key:{status:"valid",value:O},value:D._parse(new $0(J,_,J.path,O)),alwaysSet:O in J.data})}}if(J.common.async)return Promise.resolve().then(async()=>{let D=[];for(let O of z){let _=await O.key,m=await O.value;D.push({key:_,value:m,alwaysSet:O.alwaysSet})}return D}).then((D)=>{return q$.mergeObjectSync(Q,D)});else return q$.mergeObjectSync(Q,z)}get shape(){return this._def.shape()}strict($){return v.errToObj,new M$({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(X,Q)=>{let J=this._def.errorMap?.(X,Q).message??Q.defaultError;if(X.code==="unrecognized_keys")return{message:v.errToObj($).message??J};return{message:J}}}:{}})}strip(){return new M$({...this._def,unknownKeys:"strip"})}passthrough(){return new M$({...this._def,unknownKeys:"passthrough"})}extend($){return new M$({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new M$({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:g.ZodObject})}setKey($,X){return this.augment({[$]:X})}catchall($){return new M$({...this._def,catchall:$})}pick($){let X={};for(let Q of o.objectKeys($))if($[Q]&&this.shape[Q])X[Q]=this.shape[Q];return new M$({...this._def,shape:()=>X})}omit($){let X={};for(let Q of o.objectKeys(this.shape))if(!$[Q])X[Q]=this.shape[Q];return new M$({...this._def,shape:()=>X})}deepPartial(){return Q6(this)}partial($){let X={};for(let Q of o.objectKeys(this.shape)){let J=this.shape[Q];if($&&!$[Q])X[Q]=J;else X[Q]=J.optional()}return new M$({...this._def,shape:()=>X})}required($){let X={};for(let Q of o.objectKeys(this.shape))if($&&!$[Q])X[Q]=this.shape[Q];else{let G=this.shape[Q];while(G instanceof e$)G=G._def.innerType;X[Q]=G}return new M$({...this._def,shape:()=>X})}keyof(){return d7(o.objectKeys(this.shape))}}M$.create=($,X)=>{return new M$({shape:()=>$,unknownKeys:"strip",catchall:V0.create(),typeName:g.ZodObject,...p(X)})};M$.strictCreate=($,X)=>{return new M$({shape:()=>$,unknownKeys:"strict",catchall:V0.create(),typeName:g.ZodObject,...p(X)})};M$.lazycreate=($,X)=>{return new M$({shape:$,unknownKeys:"strip",catchall:V0.create(),typeName:g.ZodObject,...p(X)})};class H6 extends i{_parse($){let{ctx:X}=this._processInputParams($),Q=this._def.options;function J(G){for(let M of G)if(M.result.status==="valid")return M.result;for(let M of G)if(M.result.status==="dirty")return X.common.issues.push(...M.ctx.common.issues),M.result;let H=G.map((M)=>new R$(M.ctx.common.issues));return S(X,{code:K.invalid_union,unionErrors:H}),f}if(X.common.async)return Promise.all(Q.map(async(G)=>{let H={...X,common:{...X.common,issues:[]},parent:null};return{result:await G._parseAsync({data:X.data,path:X.path,parent:H}),ctx:H}})).then(J);else{let G=void 0,H=[];for(let z of Q){let D={...X,common:{...X.common,issues:[]},parent:null},O=z._parseSync({data:X.data,path:X.path,parent:D});if(O.status==="valid")return O;else if(O.status==="dirty"&&!G)G={result:O,ctx:D};if(D.common.issues.length)H.push(D.common.issues)}if(G)return X.common.issues.push(...G.ctx.common.issues),G.result;let M=H.map((z)=>new R$(z));return S(X,{code:K.invalid_union,unionErrors:M}),f}}get options(){return this._def.options}}H6.create=($,X)=>{return new H6({options:$,typeName:g.ZodUnion,...p(X)})};var b0=($)=>{if($ instanceof w6)return b0($.schema);else if($ instanceof X0)return b0($.innerType());else if($ instanceof z6)return[$.value];else if($ instanceof $4)return $.options;else if($ instanceof B6)return o.objectValues($.enum);else if($ instanceof D6)return b0($._def.innerType);else if($ instanceof G6)return[void 0];else if($ instanceof Y6)return[null];else if($ instanceof e$)return[void 0,...b0($.unwrap())];else if($ instanceof P0)return[null,...b0($.unwrap())];else if($ instanceof C1)return b0($.unwrap());else if($ instanceof O6)return b0($.unwrap());else if($ instanceof V6)return b0($._def.innerType);else return[]};class v1 extends i{_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==L.object)return S(X,{code:K.invalid_type,expected:L.object,received:X.parsedType}),f;let Q=this.discriminator,J=X.data[Q],G=this.optionsMap.get(J);if(!G)return S(X,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),f;if(X.common.async)return G._parseAsync({data:X.data,path:X.path,parent:X});else return G._parseSync({data:X.data,path:X.path,parent:X})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,X,Q){let J=new Map;for(let G of X){let H=b0(G.shape[$]);if(!H.length)throw new Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let M of H){if(J.has(M))throw new Error(`Discriminator property ${String($)} has duplicate value ${String(M)}`);J.set(M,G)}}return new v1({typeName:g.ZodDiscriminatedUnion,discriminator:$,options:X,optionsMap:J,...p(Q)})}}function $8($,X){let Q=D0($),J=D0(X);if($===X)return{valid:!0,data:$};else if(Q===L.object&&J===L.object){let G=o.objectKeys(X),H=o.objectKeys($).filter((z)=>G.indexOf(z)!==-1),M={...$,...X};for(let z of H){let D=$8($[z],X[z]);if(!D.valid)return{valid:!1};M[z]=D.data}return{valid:!0,data:M}}else if(Q===L.array&&J===L.array){if($.length!==X.length)return{valid:!1};let G=[];for(let H=0;H<$.length;H++){let M=$[H],z=X[H],D=$8(M,z);if(!D.valid)return{valid:!1};G.push(D.data)}return{valid:!0,data:G}}else if(Q===L.date&&J===L.date&&+$===+X)return{valid:!0,data:$};else return{valid:!1}}class M6 extends i{_parse($){let{status:X,ctx:Q}=this._processInputParams($),J=(G,H)=>{if(F1(G)||F1(H))return f;let M=$8(G.value,H.value);if(!M.valid)return S(Q,{code:K.invalid_intersection_types}),f;if(E1(G)||E1(H))X.dirty();return{status:X.value,value:M.data}};if(Q.common.async)return Promise.all([this._def.left._parseAsync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseAsync({data:Q.data,path:Q.path,parent:Q})]).then(([G,H])=>J(G,H));else return J(this._def.left._parseSync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseSync({data:Q.data,path:Q.path,parent:Q}))}}M6.create=($,X,Q)=>{return new M6({left:$,right:X,typeName:g.ZodIntersection,...p(Q)})};class O0 extends i{_parse($){let{status:X,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.array)return S(Q,{code:K.invalid_type,expected:L.array,received:Q.parsedType}),f;if(Q.data.length<this._def.items.length)return S(Q,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;if(!this._def.rest&&Q.data.length>this._def.items.length)S(Q,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),X.dirty();let G=[...Q.data].map((H,M)=>{let z=this._def.items[M]||this._def.rest;if(!z)return null;return z._parse(new $0(Q,H,Q.path,M))}).filter((H)=>!!H);if(Q.common.async)return Promise.all(G).then((H)=>{return q$.mergeArray(X,H)});else return q$.mergeArray(X,G)}get items(){return this._def.items}rest($){return new O0({...this._def,rest:$})}}O0.create=($,X)=>{if(!Array.isArray($))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new O0({items:$,typeName:g.ZodTuple,rest:null,...p(X)})};class WX extends i{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:X,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.object)return S(Q,{code:K.invalid_type,expected:L.object,received:Q.parsedType}),f;let J=[],G=this._def.keyType,H=this._def.valueType;for(let M in Q.data)J.push({key:G._parse(new $0(Q,M,Q.path,M)),value:H._parse(new $0(Q,Q.data[M],Q.path,M)),alwaysSet:M in Q.data});if(Q.common.async)return q$.mergeObjectAsync(X,J);else return q$.mergeObjectSync(X,J)}get element(){return this._def.valueType}static create($,X,Q){if(X instanceof i)return new WX({keyType:$,valueType:X,typeName:g.ZodRecord,...p(Q)});return new WX({keyType:t$.create(),valueType:$,typeName:g.ZodRecord,...p(X)})}}class JX extends i{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:X,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.map)return S(Q,{code:K.invalid_type,expected:L.map,received:Q.parsedType}),f;let J=this._def.keyType,G=this._def.valueType,H=[...Q.data.entries()].map(([M,z],D)=>{return{key:J._parse(new $0(Q,M,Q.path,[D,"key"])),value:G._parse(new $0(Q,z,Q.path,[D,"value"]))}});if(Q.common.async){let M=new Map;return Promise.resolve().then(async()=>{for(let z of H){let D=await z.key,O=await z.value;if(D.status==="aborted"||O.status==="aborted")return f;if(D.status==="dirty"||O.status==="dirty")X.dirty();M.set(D.value,O.value)}return{status:X.value,value:M}})}else{let M=new Map;for(let z of H){let{key:D,value:O}=z;if(D.status==="aborted"||O.status==="aborted")return f;if(D.status==="dirty"||O.status==="dirty")X.dirty();M.set(D.value,O.value)}return{status:X.value,value:M}}}}JX.create=($,X,Q)=>{return new JX({valueType:X,keyType:$,typeName:g.ZodMap,...p(Q)})};class S4 extends i{_parse($){let{status:X,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.set)return S(Q,{code:K.invalid_type,expected:L.set,received:Q.parsedType}),f;let J=this._def;if(J.minSize!==null){if(Q.data.size<J.minSize.value)S(Q,{code:K.too_small,minimum:J.minSize.value,type:"set",inclusive:!0,exact:!1,message:J.minSize.message}),X.dirty()}if(J.maxSize!==null){if(Q.data.size>J.maxSize.value)S(Q,{code:K.too_big,maximum:J.maxSize.value,type:"set",inclusive:!0,exact:!1,message:J.maxSize.message}),X.dirty()}let G=this._def.valueType;function H(z){let D=new Set;for(let O of z){if(O.status==="aborted")return f;if(O.status==="dirty")X.dirty();D.add(O.value)}return{status:X.value,value:D}}let M=[...Q.data.values()].map((z,D)=>G._parse(new $0(Q,z,Q.path,D)));if(Q.common.async)return Promise.all(M).then((z)=>H(z));else return H(M)}min($,X){return new S4({...this._def,minSize:{value:$,message:v.toString(X)}})}max($,X){return new S4({...this._def,maxSize:{value:$,message:v.toString(X)}})}size($,X){return this.min($,X).max($,X)}nonempty($){return this.min(1,$)}}S4.create=($,X)=>{return new S4({valueType:$,minSize:null,maxSize:null,typeName:g.ZodSet,...p(X)})};class W6 extends i{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==L.function)return S(X,{code:K.invalid_type,expected:L.function,received:X.parsedType}),f;function Q(M,z){return s6({data:M,path:X.path,errorMaps:[X.common.contextualErrorMap,X.schemaErrorMap,$6(),I0].filter((D)=>!!D),issueData:{code:K.invalid_arguments,argumentsError:z}})}function J(M,z){return s6({data:M,path:X.path,errorMaps:[X.common.contextualErrorMap,X.schemaErrorMap,$6(),I0].filter((D)=>!!D),issueData:{code:K.invalid_return_type,returnTypeError:z}})}let G={errorMap:X.common.contextualErrorMap},H=X.data;if(this._def.returns instanceof F4){let M=this;return j$(async function(...z){let D=new R$([]),O=await M._def.args.parseAsync(z,G).catch((x)=>{throw D.addIssue(Q(z,x)),D}),_=await Reflect.apply(H,this,O);return await M._def.returns._def.type.parseAsync(_,G).catch((x)=>{throw D.addIssue(J(_,x)),D})})}else{let M=this;return j$(function(...z){let D=M._def.args.safeParse(z,G);if(!D.success)throw new R$([Q(z,D.error)]);let O=Reflect.apply(H,this,D.data),_=M._def.returns.safeParse(O,G);if(!_.success)throw new R$([J(O,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new W6({...this._def,args:O0.create($).rest(t0.create())})}returns($){return new W6({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,X,Q){return new W6({args:$?$:O0.create([]).rest(t0.create()),returns:X||t0.create(),typeName:g.ZodFunction,...p(Q)})}}class w6 extends i{get schema(){return this._def.getter()}_parse($){let{ctx:X}=this._processInputParams($);return this._def.getter()._parse({data:X.data,path:X.path,parent:X})}}w6.create=($,X)=>{return new w6({getter:$,typeName:g.ZodLazy,...p(X)})};class z6 extends i{_parse($){if($.data!==this._def.value){let X=this._getOrReturnCtx($);return S(X,{received:X.data,code:K.invalid_literal,expected:this._def.value}),f}return{status:"valid",value:$.data}}get value(){return this._def.value}}z6.create=($,X)=>{return new z6({value:$,typeName:g.ZodLiteral,...p(X)})};function d7($,X){return new $4({values:$,typeName:g.ZodEnum,...p(X)})}class $4 extends i{constructor(){super(...arguments);e6.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let X=this._getOrReturnCtx($),Q=this._def.values;return S(X,{expected:o.joinValues(Q),received:X.parsedType,code:K.invalid_type}),f}if(!R1(this,e6,"f"))u7(this,e6,new Set(this._def.values),"f");if(!R1(this,e6,"f").has($.data)){let X=this._getOrReturnCtx($),Q=this._def.values;return S(X,{received:X.data,code:K.invalid_enum_value,options:Q}),f}return j$($.data)}get options(){return this._def.values}get enum(){let $={};for(let X of this._def.values)$[X]=X;return $}get Values(){let $={};for(let X of this._def.values)$[X]=X;return $}get Enum(){let $={};for(let X of this._def.values)$[X]=X;return $}extract($,X=this._def){return $4.create($,{...this._def,...X})}exclude($,X=this._def){return $4.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...X})}}e6=new WeakMap;$4.create=d7;class B6 extends i{constructor(){super(...arguments);$X.set(this,void 0)}_parse($){let X=o.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==L.string&&Q.parsedType!==L.number){let J=o.objectValues(X);return S(Q,{expected:o.joinValues(J),received:Q.parsedType,code:K.invalid_type}),f}if(!R1(this,$X,"f"))u7(this,$X,new Set(o.getValidEnumValues(this._def.values)),"f");if(!R1(this,$X,"f").has($.data)){let J=o.objectValues(X);return S(Q,{received:Q.data,code:K.invalid_enum_value,options:J}),f}return j$($.data)}get enum(){return this._def.values}}$X=new WeakMap;B6.create=($,X)=>{return new B6({values:$,typeName:g.ZodNativeEnum,...p(X)})};class F4 extends i{unwrap(){return this._def.type}_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==L.promise&&X.common.async===!1)return S(X,{code:K.invalid_type,expected:L.promise,received:X.parsedType}),f;let Q=X.parsedType===L.promise?X.data:Promise.resolve(X.data);return j$(Q.then((J)=>{return this._def.type.parseAsync(J,{path:X.path,errorMap:X.common.contextualErrorMap})}))}}F4.create=($,X)=>{return new F4({type:$,typeName:g.ZodPromise,...p(X)})};class X0 extends i{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:X,ctx:Q}=this._processInputParams($),J=this._def.effect||null,G={addIssue:(H)=>{if(S(Q,H),H.fatal)X.abort();else X.dirty()},get path(){return Q.path}};if(G.addIssue=G.addIssue.bind(G),J.type==="preprocess"){let H=J.transform(Q.data,G);if(Q.common.async)return Promise.resolve(H).then(async(M)=>{if(X.value==="aborted")return f;let z=await this._def.schema._parseAsync({data:M,path:Q.path,parent:Q});if(z.status==="aborted")return f;if(z.status==="dirty")return U4(z.value);if(X.value==="dirty")return U4(z.value);return z});else{if(X.value==="aborted")return f;let M=this._def.schema._parseSync({data:H,path:Q.path,parent:Q});if(M.status==="aborted")return f;if(M.status==="dirty")return U4(M.value);if(X.value==="dirty")return U4(M.value);return M}}if(J.type==="refinement"){let H=(M)=>{let z=J.refinement(M,G);if(Q.common.async)return Promise.resolve(z);if(z instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return M};if(Q.common.async===!1){let M=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(M.status==="aborted")return f;if(M.status==="dirty")X.dirty();return H(M.value),{status:X.value,value:M.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((M)=>{if(M.status==="aborted")return f;if(M.status==="dirty")X.dirty();return H(M.value).then(()=>{return{status:X.value,value:M.value}})})}if(J.type==="transform")if(Q.common.async===!1){let H=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!a0(H))return H;let M=J.transform(H.value,G);if(M instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:X.value,value:M}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((H)=>{if(!a0(H))return H;return Promise.resolve(J.transform(H.value,G)).then((M)=>({status:X.value,value:M}))});o.assertNever(J)}}X0.create=($,X,Q)=>{return new X0({schema:$,typeName:g.ZodEffects,effect:X,...p(Q)})};X0.createWithPreprocess=($,X,Q)=>{return new X0({schema:X,effect:{type:"preprocess",transform:$},typeName:g.ZodEffects,...p(Q)})};class e$ extends i{_parse($){if(this._getType($)===L.undefined)return j$(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}e$.create=($,X)=>{return new e$({innerType:$,typeName:g.ZodOptional,...p(X)})};class P0 extends i{_parse($){if(this._getType($)===L.null)return j$(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}P0.create=($,X)=>{return new P0({innerType:$,typeName:g.ZodNullable,...p(X)})};class D6 extends i{_parse($){let{ctx:X}=this._processInputParams($),Q=X.data;if(X.parsedType===L.undefined)Q=this._def.defaultValue();return this._def.innerType._parse({data:Q,path:X.path,parent:X})}removeDefault(){return this._def.innerType}}D6.create=($,X)=>{return new D6({innerType:$,typeName:g.ZodDefault,defaultValue:typeof X.default==="function"?X.default:()=>X.default,...p(X)})};class V6 extends i{_parse($){let{ctx:X}=this._processInputParams($),Q={...X,common:{...X.common,issues:[]}},J=this._def.innerType._parse({data:Q.data,path:Q.path,parent:{...Q}});if(X6(J))return J.then((G)=>{return{status:"valid",value:G.status==="valid"?G.value:this._def.catchValue({get error(){return new R$(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:J.status==="valid"?J.value:this._def.catchValue({get error(){return new R$(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}V6.create=($,X)=>{return new V6({innerType:$,typeName:g.ZodCatch,catchValue:typeof X.catch==="function"?X.catch:()=>X.catch,...p(X)})};class GX extends i{_parse($){if(this._getType($)!==L.nan){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.nan,received:Q.parsedType}),f}return{status:"valid",value:$.data}}}GX.create=($)=>{return new GX({typeName:g.ZodNaN,...p($)})};var eG=Symbol("zod_brand");class C1 extends i{_parse($){let{ctx:X}=this._processInputParams($),Q=X.data;return this._def.type._parse({data:Q,path:X.path,parent:X})}unwrap(){return this._def.type}}class YX extends i{_parse($){let{status:X,ctx:Q}=this._processInputParams($);if(Q.common.async)return(async()=>{let G=await this._def.in._parseAsync({data:Q.data,path:Q.path,parent:Q});if(G.status==="aborted")return f;if(G.status==="dirty")return X.dirty(),U4(G.value);else return this._def.out._parseAsync({data:G.value,path:Q.path,parent:Q})})();else{let J=this._def.in._parseSync({data:Q.data,path:Q.path,parent:Q});if(J.status==="aborted")return f;if(J.status==="dirty")return X.dirty(),{status:"dirty",value:J.value};else return this._def.out._parseSync({data:J.value,path:Q.path,parent:Q})}}static create($,X){return new YX({in:$,out:X,typeName:g.ZodPipeline})}}class O6 extends i{_parse($){let X=this._def.innerType._parse($),Q=(J)=>{if(a0(J))J.value=Object.freeze(J.value);return J};return X6(X)?X.then((J)=>Q(J)):Q(X)}unwrap(){return this._def.innerType}}O6.create=($,X)=>{return new O6({innerType:$,typeName:g.ZodReadonly,...p(X)})};function c7($,X){let Q=typeof $==="function"?$(X):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function o7($,X={},Q){if($)return L4.create().superRefine((J,G)=>{let H=$(J);if(H instanceof Promise)return H.then((M)=>{if(!M){let z=c7(X,J),D=z.fatal??Q??!0;G.addIssue({code:"custom",...z,fatal:D})}});if(!H){let M=c7(X,J),z=M.fatal??Q??!0;G.addIssue({code:"custom",...M,fatal:z})}return});return L4.create()}var $Y={object:M$.lazycreate},g;(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"})(g||(g={}));var XY=($,X={message:`Input not instance of ${$.name}`})=>o7((Q)=>Q instanceof $,X),r7=t$.create,a7=s0.create,QY=GX.create,WY=e0.create,t7=J6.create,JY=N4.create,GY=XX.create,YY=G6.create,HY=Y6.create,MY=L4.create,wY=t0.create,zY=V0.create,BY=QX.create,DY=s$.create,VY=M$.create,OY=M$.strictCreate,qY=H6.create,_Y=v1.create,AY=M6.create,jY=O0.create,KY=WX.create,UY=JX.create,NY=S4.create,LY=W6.create,SY=w6.create,FY=z6.create,EY=$4.create,RY=B6.create,vY=F4.create,CY=X0.create,kY=e$.create,IY=P0.create,bY=X0.createWithPreprocess,PY=YX.create,fY=()=>r7().optional(),gY=()=>a7().optional(),TY=()=>t7().optional(),xY={string:($)=>t$.create({...$,coerce:!0}),number:($)=>s0.create({...$,coerce:!0}),boolean:($)=>J6.create({...$,coerce:!0}),bigint:($)=>e0.create({...$,coerce:!0}),date:($)=>N4.create({...$,coerce:!0})};var hY=f;var HX=x$(require("fs")),X4=x$(require("path")),X8=x$(require("fs/promises"));q4();var Q0=y$("Downloader");class s7{op;assetsPath="";savePath="";setup($){if(this.op=$,this.op.localPath)this.assetsPath=X4.default.join(this.op.localPath,"assets"),this.savePath=this.op.localPath}async downloadImage($,X){let{imgFormat:Q}=this.op,J=this.assetsPath;try{if(!HX.default.existsSync(J))HX.default.mkdirSync(J,{recursive:!0});let G=`${X}.${Q}`,H=X4.default.join(J,G),M=await e4($);if(!M.ok)throw new Error(`下载失败: ${M.status} ${M.statusText}`);let z=await M.arrayBuffer();return HX.default.writeFileSync(H,new Uint8Array(z)),X4.default.join(X4.default.basename(J),G).replace(/\\/g,"/")}catch(G){throw Q0.error("图片下载错误:",G),G}}async downLoadImageAndReplaceContent($){try{let X=/https:\/\/figma-alpha-api\.s3\.us-west-2\.amazonaws\.com\/images\/[a-f0-9-]+/g,Q=$.match(X);if(!Q)return $;let J=[...new Set(Q)],G=new Map;await Promise.all(J.map(async(M)=>{let z=X4.default.basename(M),D=await this.downloadImage(M,z);G.set(M,D)}));let H=$;for(let[M,z]of G.entries()){let D=new RegExp(M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");H=H.replace(D,z)}return H}catch(X){throw Q0.error("内容处理错误:",X),X}}async checkLocalAndDownload($){if(!this.op.localPath)return;await Promise.all($.map(async(X)=>{X.content=await this.downLoadImageAndReplaceContent(X.content)}));for(let X of $)try{let Q=await this.saveContentToFile(X.content,X.path);Q0.debug(`Successfully saved: ${Q}`)}catch(Q){Q0.error(`Failed to save file ${X.path}:`,Q)}}async ensureDirectoryExists($){if(!HX.default.existsSync($))Q0.debug(`Creating directory: ${$}`),await X8.default.mkdir($,{recursive:!0})}async saveContentToFile($,X){try{let Q=X4.default.join(this.savePath,X),J=X4.default.dirname(Q);if(Q0.debug(`Full path: ${Q}, directory: ${J}`),await this.ensureDirectoryExists(J),X.endsWith(".html"))Q0.debug("Wrapping content with HTML template"),$=this.wrapHtmlContent($);return Q0.debug(`Writing ${$.length} bytes to file`),await X8.default.writeFile(Q,$),Q0.info(`File saved: ${Q}`),Q}catch(Q){throw Q0.error("File save error:",X,Q),Q}}wrapHtmlContent($){return Q0.debug("Wrapping content with HTML template"),`<!DOCTYPE html>
19
+ ]`;continue}if(G+=J[D],J[D]==="\\")H=!0;else if(M&&J[D]==="]")M=!1;else if(!M&&J[D]==="[")M=!0}try{new RegExp(G)}catch{return console.warn(`Could not convert regex pattern at ${X.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`),$.source}return G}function M1($,X){if(X.target==="openAi")console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");if(X.target==="openApi3"&&$.keyType?._def.typeName===N.ZodEnum)return{type:"object",required:$.keyType._def.values,properties:$.keyType._def.values.reduce((J,G)=>({...J,[G]:P($.valueType._def,{...X,currentPath:[...X.currentPath,"properties",G]})??{}}),{}),additionalProperties:X.rejectedAdditionalProperties};let Q={type:"object",additionalProperties:P($.valueType._def,{...X,currentPath:[...X.currentPath,"additionalProperties"]})??X.allowedAdditionalProperties};if(X.target==="openApi3")return Q;if($.keyType?._def.typeName===N.ZodString&&$.keyType._def.checks?.length){let{type:J,...G}=H1($.keyType._def,X);return{...Q,propertyNames:G}}else if($.keyType?._def.typeName===N.ZodEnum)return{...Q,propertyNames:{enum:$.keyType._def.values}};else if($.keyType?._def.typeName===N.ZodBranded&&$.keyType._def.type._def.typeName===N.ZodString&&$.keyType._def.type._def.checks?.length){let{type:J,...G}=Y1($.keyType._def,X);return{...Q,propertyNames:G}}return Q}function OQ($,X){if(X.mapStrategy==="record")return M1($,X);let Q=P($.keyType._def,{...X,currentPath:[...X.currentPath,"items","items","0"]})||{},J=P($.valueType._def,{...X,currentPath:[...X.currentPath,"items","items","1"]})||{};return{type:"array",maxItems:125,items:{type:"array",items:[Q,J],minItems:2,maxItems:2}}}function qQ($){let X=$.values,J=Object.keys($.values).filter((H)=>{return typeof X[X[H]]!=="number"}).map((H)=>X[H]),G=Array.from(new Set(J.map((H)=>typeof H)));return{type:G.length===1?G[0]==="string"?"string":"number":["string","number"],enum:J}}function _Q(){return{not:{}}}function AQ($){return $.target==="openApi3"?{enum:["null"],nullable:!0}:{type:"null"}}var l6={ZodString:"string",ZodNumber:"number",ZodBigInt:"integer",ZodBoolean:"boolean",ZodNull:"null"};function KQ($,X){if(X.target==="openApi3")return jQ($,X);let Q=$.options instanceof Map?Array.from($.options.values()):$.options;if(Q.every((J)=>(J._def.typeName in l6)&&(!J._def.checks||!J._def.checks.length))){let J=Q.reduce((G,H)=>{let M=l6[H._def.typeName];return M&&!G.includes(M)?[...G,M]:G},[]);return{type:J.length>1?J:J[0]}}else if(Q.every((J)=>J._def.typeName==="ZodLiteral"&&!J.description)){let J=Q.reduce((G,H)=>{let M=typeof H._def.value;switch(M){case"string":case"number":case"boolean":return[...G,M];case"bigint":return[...G,"integer"];case"object":if(H._def.value===null)return[...G,"null"];case"symbol":case"undefined":case"function":default:return G}},[]);if(J.length===Q.length){let G=J.filter((H,M,z)=>z.indexOf(H)===M);return{type:G.length>1?G:G[0],enum:Q.reduce((H,M)=>{return H.includes(M._def.value)?H:[...H,M._def.value]},[])}}}else if(Q.every((J)=>J._def.typeName==="ZodEnum"))return{type:"string",enum:Q.reduce((J,G)=>[...J,...G._def.values.filter((H)=>!J.includes(H))],[])};return jQ($,X)}var jQ=($,X)=>{let Q=($.options instanceof Map?Array.from($.options.values()):$.options).map((J,G)=>P(J._def,{...X,currentPath:[...X.currentPath,"anyOf",`${G}`]})).filter((J)=>!!J&&(!X.strictUnions||typeof J==="object"&&Object.keys(J).length>0));return Q.length?{anyOf:Q}:void 0};function UQ($,X){if(["ZodString","ZodNumber","ZodBigInt","ZodBoolean","ZodNull"].includes($.innerType._def.typeName)&&(!$.innerType._def.checks||!$.innerType._def.checks.length)){if(X.target==="openApi3")return{type:l6[$.innerType._def.typeName],nullable:!0};return{type:[l6[$.innerType._def.typeName],"null"]}}if(X.target==="openApi3"){let J=P($.innerType._def,{...X,currentPath:[...X.currentPath]});if(J&&"$ref"in J)return{allOf:[J],nullable:!0};return J&&{...J,nullable:!0}}let Q=P($.innerType._def,{...X,currentPath:[...X.currentPath,"anyOf","0"]});return Q&&{anyOf:[Q,{type:"null"}]}}function NQ($,X){let Q={type:"number"};if(!$.checks)return Q;for(let J of $.checks)switch(J.kind){case"int":Q.type="integer",P2(Q,"type",J.message,X);break;case"min":if(X.target==="jsonSchema7")if(J.inclusive)t(Q,"minimum",J.value,J.message,X);else t(Q,"exclusiveMinimum",J.value,J.message,X);else{if(!J.inclusive)Q.exclusiveMinimum=!0;t(Q,"minimum",J.value,J.message,X)}break;case"max":if(X.target==="jsonSchema7")if(J.inclusive)t(Q,"maximum",J.value,J.message,X);else t(Q,"exclusiveMaximum",J.value,J.message,X);else{if(!J.inclusive)Q.exclusiveMaximum=!0;t(Q,"maximum",J.value,J.message,X)}break;case"multipleOf":t(Q,"multipleOf",J.value,J.message,X);break}return Q}p0();function LQ($,X){let Q=X.target==="openAi",J={type:"object",properties:{}},G=[],H=$.shape();for(let z in H){let D=H[z];if(D===void 0||D._def===void 0)continue;let O=i9(D);if(O&&Q){if(D instanceof k$)D=D._def.innerType;if(!D.isNullable())D=D.nullable();O=!1}let _=P(D._def,{...X,currentPath:[...X.currentPath,"properties",z],propertyPath:[...X.currentPath,"properties",z]});if(_===void 0)continue;if(J.properties[z]=_,!O)G.push(z)}if(G.length)J.required=G;let M=n9($,X);if(M!==void 0)J.additionalProperties=M;return J}function n9($,X){if($.catchall._def.typeName!=="ZodNever")return P($.catchall._def,{...X,currentPath:[...X.currentPath,"additionalProperties"]});switch($.unknownKeys){case"passthrough":return X.allowedAdditionalProperties;case"strict":return X.rejectedAdditionalProperties;case"strip":return X.removeAdditionalStrategy==="strict"?X.allowedAdditionalProperties:X.rejectedAdditionalProperties}}function i9($){try{return $.isOptional()}catch{return!0}}var SQ=($,X)=>{if(X.currentPath.toString()===X.propertyPath?.toString())return P($.innerType._def,X);let Q=P($.innerType._def,{...X,currentPath:[...X.currentPath,"anyOf","1"]});return Q?{anyOf:[{not:{}},Q]}:{}};var FQ=($,X)=>{if(X.pipeStrategy==="input")return P($.in._def,X);else if(X.pipeStrategy==="output")return P($.out._def,X);let Q=P($.in._def,{...X,currentPath:[...X.currentPath,"allOf","0"]}),J=P($.out._def,{...X,currentPath:[...X.currentPath,"allOf",Q?"1":"0"]});return{allOf:[Q,J].filter((G)=>G!==void 0)}};function EQ($,X){return P($.type._def,X)}function RQ($,X){let J={type:"array",uniqueItems:!0,items:P($.valueType._def,{...X,currentPath:[...X.currentPath,"items"]})};if($.minSize)t(J,"minItems",$.minSize.value,$.minSize.message,X);if($.maxSize)t(J,"maxItems",$.maxSize.value,$.maxSize.message,X);return J}function vQ($,X){if($.rest)return{type:"array",minItems:$.items.length,items:$.items.map((Q,J)=>P(Q._def,{...X,currentPath:[...X.currentPath,"items",`${J}`]})).reduce((Q,J)=>J===void 0?Q:[...Q,J],[]),additionalItems:P($.rest._def,{...X,currentPath:[...X.currentPath,"additionalItems"]})};else return{type:"array",minItems:$.items.length,maxItems:$.items.length,items:$.items.map((Q,J)=>P(Q._def,{...X,currentPath:[...X.currentPath,"items",`${J}`]})).reduce((Q,J)=>J===void 0?Q:[...Q,J],[])}}function CQ(){return{not:{}}}function kQ(){return{}}var IQ=($,X)=>{return P($.innerType._def,X)};var bQ=($,X,Q)=>{switch(X){case N.ZodString:return H1($,Q);case N.ZodNumber:return NQ($,Q);case N.ZodObject:return LQ($,Q);case N.ZodBigInt:return GQ($,Q);case N.ZodBoolean:return YQ();case N.ZodDate:return f2($,Q);case N.ZodUndefined:return CQ();case N.ZodNull:return AQ(Q);case N.ZodArray:return JQ($,Q);case N.ZodUnion:case N.ZodDiscriminatedUnion:return KQ($,Q);case N.ZodIntersection:return BQ($,Q);case N.ZodTuple:return vQ($,Q);case N.ZodRecord:return M1($,Q);case N.ZodLiteral:return DQ($,Q);case N.ZodEnum:return zQ($);case N.ZodNativeEnum:return qQ($);case N.ZodNullable:return UQ($,Q);case N.ZodOptional:return SQ($,Q);case N.ZodMap:return OQ($,Q);case N.ZodSet:return RQ($,Q);case N.ZodLazy:return()=>$.getter()._def;case N.ZodPromise:return EQ($,Q);case N.ZodNaN:case N.ZodNever:return _Q();case N.ZodEffects:return wQ($,Q);case N.ZodAny:return WQ();case N.ZodUnknown:return kQ();case N.ZodDefault:return MQ($,Q);case N.ZodBranded:return Y1($,Q);case N.ZodReadonly:return IQ($,Q);case N.ZodCatch:return HQ($,Q);case N.ZodPipeline:return FQ($,Q);case N.ZodFunction:case N.ZodVoid:case N.ZodSymbol:return;default:return((J)=>{return})(X)}};function P($,X,Q=!1){let J=X.seen.get($);if(X.override){let z=X.override?.($,X,J,Q);if(z!==$Q)return z}if(J&&!Q){let z=d9(J,X);if(z!==void 0)return z}let G={def:$,path:X.currentPath,jsonSchema:void 0};X.seen.set($,G);let H=bQ($,$.typeName,X),M=typeof H==="function"?P(H(),X):H;if(M)r9($,X,M);if(X.postProcess){let z=X.postProcess(M,$,X);return G.jsonSchema=M,z}return G.jsonSchema=M,M}var d9=($,X)=>{switch(X.$refStrategy){case"root":return{$ref:$.path.join("/")};case"relative":return{$ref:o9(X.currentPath,$.path)};case"none":case"seen":{if($.path.length<X.currentPath.length&&$.path.every((Q,J)=>X.currentPath[J]===Q))return console.warn(`Recursive reference detected at ${X.currentPath.join("/")}! Defaulting to any`),{};return X.$refStrategy==="seen"?{}:void 0}}},o9=($,X)=>{let Q=0;for(;Q<$.length&&Q<X.length;Q++)if($[Q]!==X[Q])break;return[($.length-Q).toString(),...X.slice(Q)].join("/")},r9=($,X,Q)=>{if($.description){if(Q.description=$.description,X.markdownDescription)Q.markdownDescription=$.description}return Q};var w1=($,X)=>{let Q=QQ(X),J=typeof X==="object"&&X.definitions?Object.entries(X.definitions).reduce((D,[O,_])=>({...D,[O]:P(_._def,{...Q,currentPath:[...Q.basePath,Q.definitionPath,O]},!0)??{}}),{}):void 0,G=typeof X==="string"?X:X?.nameStrategy==="title"?void 0:X?.name,H=P($._def,G===void 0?Q:{...Q,currentPath:[...Q.basePath,Q.definitionPath,G]},!1)??{},M=typeof X==="object"&&X.name!==void 0&&X.nameStrategy==="title"?X.name:void 0;if(M!==void 0)H.title=M;let z=G===void 0?J?{...H,[Q.definitionPath]:J}:H:{$ref:[...Q.$refStrategy==="relative"?[]:Q.basePath,Q.definitionPath,G].join("/"),[Q.definitionPath]:{...J,[G]:H}};if(Q.target==="jsonSchema7")z.$schema="http://json-schema.org/draft-07/schema#";else if(Q.target==="jsonSchema2019-09"||Q.target==="openAi")z.$schema="https://json-schema.org/draft/2019-09/schema#";if(Q.target==="openAi"&&(("anyOf"in z)||("oneOf"in z)||("allOf"in z)||("type"in z)&&Array.isArray(z.type)))console.warn("Warning: OpenAI may not support schemas with unions as roots! Try wrapping it in an object property.");return z};p0();m6();p0();var x2;(function($){$.Completable="McpCompletable"})(x2||(x2={}));class c6 extends c{_parse($){let{ctx:X}=this._processInputParams($),Q=X.data;return this._def.type._parse({data:Q,path:X.path,parent:X})}unwrap(){return this._def.type}}c6.create=($,X)=>{return new c6({type:$,typeName:x2.Completable,complete:X.complete,...a9(X)})};function a9($){if(!$)return{};let{errorMap:X,invalid_type_error:Q,required_error:J,description:G}=$;if(X&&(Q||J))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(X)return{errorMap:X,description:G};return{errorMap:(M,z)=>{var D,O;let{message:_}=$;if(M.code==="invalid_enum_value")return{message:_!==null&&_!==void 0?_:z.defaultError};if(typeof z.data==="undefined")return{message:(D=_!==null&&_!==void 0?_:J)!==null&&D!==void 0?D:z.defaultError};if(M.code!=="invalid_type")return{message:z.defaultError};return{message:(O=_!==null&&_!==void 0?_:Q)!==null&&O!==void 0?O:z.defaultError}},description:G}}class h2{constructor($,X){this._registeredResources={},this._registeredResourceTemplates={},this._registeredTools={},this._registeredPrompts={},this._toolHandlersInitialized=!1,this._completionHandlerInitialized=!1,this._resourceHandlersInitialized=!1,this._promptHandlersInitialized=!1,this.server=new b2($,X)}async connect($){return await this.server.connect($)}async close(){await this.server.close()}setToolRequestHandlers(){if(this._toolHandlersInitialized)return;this.server.assertCanSetRequestHandler(W1.shape.method.value),this.server.assertCanSetRequestHandler(J1.shape.method.value),this.server.registerCapabilities({tools:{listChanged:!0}}),this.server.setRequestHandler(W1,()=>({tools:Object.entries(this._registeredTools).filter(([,$])=>$.enabled).map(([$,X])=>{let Q={name:$,description:X.description,inputSchema:X.inputSchema?w1(X.inputSchema,{strictUnions:!0}):t9,annotations:X.annotations};if(X.outputSchema)Q.outputSchema=w1(X.outputSchema,{strictUnions:!0});return Q})})),this.server.setRequestHandler(J1,async($,X)=>{let Q=this._registeredTools[$.params.name];if(!Q)throw new w$(H$.InvalidParams,`Tool ${$.params.name} not found`);if(!Q.enabled)throw new w$(H$.InvalidParams,`Tool ${$.params.name} disabled`);let J;if(Q.inputSchema){let G=await Q.inputSchema.safeParseAsync($.params.arguments);if(!G.success)throw new w$(H$.InvalidParams,`Invalid arguments for tool ${$.params.name}: ${G.error.message}`);let H=G.data,M=Q.callback;try{J=await Promise.resolve(M(H,X))}catch(z){J={content:[{type:"text",text:z instanceof Error?z.message:String(z)}],isError:!0}}}else{let G=Q.callback;try{J=await Promise.resolve(G(X))}catch(H){J={content:[{type:"text",text:H instanceof Error?H.message:String(H)}],isError:!0}}}if(Q.outputSchema){if(!J.structuredContent)throw new w$(H$.InvalidParams,`Tool ${$.params.name} has an output schema but no structured content was provided`);let G=await Q.outputSchema.safeParseAsync(J.structuredContent);if(!G.success)throw new w$(H$.InvalidParams,`Invalid structured content for tool ${$.params.name}: ${G.error.message}`)}return J}),this._toolHandlersInitialized=!0}setCompletionRequestHandler(){if(this._completionHandlerInitialized)return;this.server.assertCanSetRequestHandler(G1.shape.method.value),this.server.setRequestHandler(G1,async($)=>{switch($.params.ref.type){case"ref/prompt":return this.handlePromptCompletion($,$.params.ref);case"ref/resource":return this.handleResourceCompletion($,$.params.ref);default:throw new w$(H$.InvalidParams,`Invalid completion reference: ${$.params.ref}`)}}),this._completionHandlerInitialized=!0}async handlePromptCompletion($,X){let Q=this._registeredPrompts[X.name];if(!Q)throw new w$(H$.InvalidParams,`Prompt ${X.name} not found`);if(!Q.enabled)throw new w$(H$.InvalidParams,`Prompt ${X.name} disabled`);if(!Q.argsSchema)return z1;let J=Q.argsSchema.shape[$.params.argument.name];if(!(J instanceof c6))return z1;let H=await J._def.complete($.params.argument.value);return fQ(H)}async handleResourceCompletion($,X){let Q=Object.values(this._registeredResourceTemplates).find((H)=>H.resourceTemplate.uriTemplate.toString()===X.uri);if(!Q){if(this._registeredResources[X.uri])return z1;throw new w$(H$.InvalidParams,`Resource template ${$.params.ref.uri} not found`)}let J=Q.resourceTemplate.completeCallback($.params.argument.name);if(!J)return z1;let G=await J($.params.argument.value);return fQ(G)}setResourceRequestHandlers(){if(this._resourceHandlersInitialized)return;this.server.assertCanSetRequestHandler(rX.shape.method.value),this.server.assertCanSetRequestHandler(aX.shape.method.value),this.server.assertCanSetRequestHandler(tX.shape.method.value),this.server.registerCapabilities({resources:{listChanged:!0}}),this.server.setRequestHandler(rX,async($,X)=>{let Q=Object.entries(this._registeredResources).filter(([G,H])=>H.enabled).map(([G,H])=>({uri:G,name:H.name,...H.metadata})),J=[];for(let G of Object.values(this._registeredResourceTemplates)){if(!G.resourceTemplate.listCallback)continue;let H=await G.resourceTemplate.listCallback(X);for(let M of H.resources)J.push({...M,...G.metadata})}return{resources:[...Q,...J]}}),this.server.setRequestHandler(aX,async()=>{return{resourceTemplates:Object.entries(this._registeredResourceTemplates).map(([X,Q])=>({name:X,uriTemplate:Q.resourceTemplate.uriTemplate.toString(),...Q.metadata}))}}),this.server.setRequestHandler(tX,async($,X)=>{let Q=new URL($.params.uri),J=this._registeredResources[Q.toString()];if(J){if(!J.enabled)throw new w$(H$.InvalidParams,`Resource ${Q} disabled`);return J.readCallback(Q,X)}for(let G of Object.values(this._registeredResourceTemplates)){let H=G.resourceTemplate.uriTemplate.match(Q.toString());if(H)return G.readCallback(Q,H,X)}throw new w$(H$.InvalidParams,`Resource ${Q} not found`)}),this.setCompletionRequestHandler(),this._resourceHandlersInitialized=!0}setPromptRequestHandlers(){if(this._promptHandlersInitialized)return;this.server.assertCanSetRequestHandler(sX.shape.method.value),this.server.assertCanSetRequestHandler(eX.shape.method.value),this.server.registerCapabilities({prompts:{listChanged:!0}}),this.server.setRequestHandler(sX,()=>({prompts:Object.entries(this._registeredPrompts).filter(([,$])=>$.enabled).map(([$,X])=>{return{name:$,description:X.description,arguments:X.argsSchema?e9(X.argsSchema):void 0}})})),this.server.setRequestHandler(eX,async($,X)=>{let Q=this._registeredPrompts[$.params.name];if(!Q)throw new w$(H$.InvalidParams,`Prompt ${$.params.name} not found`);if(!Q.enabled)throw new w$(H$.InvalidParams,`Prompt ${$.params.name} disabled`);if(Q.argsSchema){let J=await Q.argsSchema.safeParseAsync($.params.arguments);if(!J.success)throw new w$(H$.InvalidParams,`Invalid arguments for prompt ${$.params.name}: ${J.error.message}`);let G=J.data,H=Q.callback;return await Promise.resolve(H(G,X))}else{let J=Q.callback;return await Promise.resolve(J(X))}}),this.setCompletionRequestHandler(),this._promptHandlersInitialized=!0}resource($,X,...Q){let J;if(typeof Q[0]==="object")J=Q.shift();let G=Q[0];if(typeof X==="string"){if(this._registeredResources[X])throw new Error(`Resource ${X} is already registered`);let H={name:$,metadata:J,readCallback:G,enabled:!0,disable:()=>H.update({enabled:!1}),enable:()=>H.update({enabled:!0}),remove:()=>H.update({uri:null}),update:(M)=>{if(typeof M.uri!=="undefined"&&M.uri!==X){if(delete this._registeredResources[X],M.uri)this._registeredResources[M.uri]=H}if(typeof M.name!=="undefined")H.name=M.name;if(typeof M.metadata!=="undefined")H.metadata=M.metadata;if(typeof M.callback!=="undefined")H.readCallback=M.callback;if(typeof M.enabled!=="undefined")H.enabled=M.enabled;this.sendResourceListChanged()}};return this._registeredResources[X]=H,this.setResourceRequestHandlers(),this.sendResourceListChanged(),H}else{if(this._registeredResourceTemplates[$])throw new Error(`Resource template ${$} is already registered`);let H={resourceTemplate:X,metadata:J,readCallback:G,enabled:!0,disable:()=>H.update({enabled:!1}),enable:()=>H.update({enabled:!0}),remove:()=>H.update({name:null}),update:(M)=>{if(typeof M.name!=="undefined"&&M.name!==$){if(delete this._registeredResourceTemplates[$],M.name)this._registeredResourceTemplates[M.name]=H}if(typeof M.template!=="undefined")H.resourceTemplate=M.template;if(typeof M.metadata!=="undefined")H.metadata=M.metadata;if(typeof M.callback!=="undefined")H.readCallback=M.callback;if(typeof M.enabled!=="undefined")H.enabled=M.enabled;this.sendResourceListChanged()}};return this._registeredResourceTemplates[$]=H,this.setResourceRequestHandlers(),this.sendResourceListChanged(),H}}_createRegisteredTool($,X,Q,J,G,H){let M={description:X,inputSchema:Q===void 0?void 0:B.object(Q),outputSchema:J===void 0?void 0:B.object(J),annotations:G,callback:H,enabled:!0,disable:()=>M.update({enabled:!1}),enable:()=>M.update({enabled:!0}),remove:()=>M.update({name:null}),update:(z)=>{if(typeof z.name!=="undefined"&&z.name!==$){if(delete this._registeredTools[$],z.name)this._registeredTools[z.name]=M}if(typeof z.description!=="undefined")M.description=z.description;if(typeof z.paramsSchema!=="undefined")M.inputSchema=B.object(z.paramsSchema);if(typeof z.callback!=="undefined")M.callback=z.callback;if(typeof z.annotations!=="undefined")M.annotations=z.annotations;if(typeof z.enabled!=="undefined")M.enabled=z.enabled;this.sendToolListChanged()}};return this._registeredTools[$]=M,this.setToolRequestHandlers(),this.sendToolListChanged(),M}tool($,...X){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let Q,J,G,H;if(typeof X[0]==="string")Q=X.shift();if(X.length>1){let z=X[0];if(PQ(z)){if(J=X.shift(),X.length>1&&typeof X[0]==="object"&&X[0]!==null&&!PQ(X[0]))H=X.shift()}else if(typeof z==="object"&&z!==null)H=X.shift()}let M=X[0];return this._createRegisteredTool($,Q,J,G,H,M)}registerTool($,X,Q){if(this._registeredTools[$])throw new Error(`Tool ${$} is already registered`);let{description:J,inputSchema:G,outputSchema:H,annotations:M}=X;return this._createRegisteredTool($,J,G,H,M,Q)}prompt($,...X){if(this._registeredPrompts[$])throw new Error(`Prompt ${$} is already registered`);let Q;if(typeof X[0]==="string")Q=X.shift();let J;if(X.length>1)J=X.shift();let G=X[0],H={description:Q,argsSchema:J===void 0?void 0:B.object(J),callback:G,enabled:!0,disable:()=>H.update({enabled:!1}),enable:()=>H.update({enabled:!0}),remove:()=>H.update({name:null}),update:(M)=>{if(typeof M.name!=="undefined"&&M.name!==$){if(delete this._registeredPrompts[$],M.name)this._registeredPrompts[M.name]=H}if(typeof M.description!=="undefined")H.description=M.description;if(typeof M.argsSchema!=="undefined")H.argsSchema=B.object(M.argsSchema);if(typeof M.callback!=="undefined")H.callback=M.callback;if(typeof M.enabled!=="undefined")H.enabled=M.enabled;this.sendPromptListChanged()}};return this._registeredPrompts[$]=H,this.setPromptRequestHandlers(),this.sendPromptListChanged(),H}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 t9={type:"object"};function PQ($){if(typeof $!=="object"||$===null)return!1;return Object.keys($).length===0||Object.values($).some(s9)}function s9($){return $!==null&&typeof $==="object"&&"parse"in $&&typeof $.parse==="function"&&"safeParse"in $&&typeof $.safeParse==="function"}function e9($){return Object.entries($.shape).map(([X,Q])=>({name:X,description:Q.description,required:!Q.isOptional()}))}function fQ($){return{completion:{values:$.slice(0,100),total:$.length,hasMore:$.length>100}}}var z1={completion:{values:[],hasMore:!1}};function gQ($,X){let Q=process.argv,J=`--${$}=`;for(let G of Q)if(G.startsWith(J))return G.substring(J.length);return X}q4();var QG=y$("FigmaConfig",1),u6=gQ("figma-api-key")||process.env.FIGMA_API_KEY||process.env.personalToken||"",hQ="F2C MCP",yQ=process.env.FIGMA_VERSION||"0.0.1";QG.debug("DEFAULT_PERSONAL_TOKEN",u6);var ZQ=($)=>{};var mQ=($)=>{ZQ($)};var t2=null;async function EG(){if(typeof global!=="undefined"&&global.fetch)return global.fetch;if(typeof globalThis.fetch!=="undefined")return globalThis.fetch;if(!t2)try{t2=await Promise.resolve().then(() => (g7(),f7))}catch($){throw new Error("Neither native fetch nor node-fetch is available. Please install node-fetch or upgrade to Node.js 18+")}return t2.default}async function RG($,X){return(await EG())($,X)}var e4=RG;q4();var T7=y$("F2cApi",1);class x7{f2cHost="https://f2c-figma-api.yy.com/api";personalToken=u6;async nodeToCode($){let X={fileKey:$.fileKey,nodeIds:$.ids,personal_token:$.personalToken||this.personalToken,option:{cssFramework:"inlinecss",imgFormat:$.imgFormat||"png",scaleSize:$.scaleSize||2},format:"files"};if($.format==="react-cssmodules")X.option.cssFramework="cssmodules";else if($.format==="react-tailwind")X.option.cssFramework="tailwindcss";let Q=this.opToUrl(`${this.f2cHost}/nodes`,X);return this.fetch(Q,"json")}async fetch($,X="json"){try{let Q={method:"GET",headers:{"F2c-Api-Platform":"mcp"}};T7.debug("fetch",$);let J=await e4($,Q);if(!J.ok)throw new Error(`HTTP error! status: ${J.status}`);return X==="text"?await J.text():await J.json()}catch(Q){throw T7.error("HTTP error",Q),Q}}opToUrl($,X={}){if(Object.keys(X).length===0)return $;let Q=new URL($);for(let[J,G]of Object.entries(X))if(typeof G==="object"&&G!==null)for(let[H,M]of Object.entries(G))Q.searchParams.append(`${J}[${H}]`,M);else Q.searchParams.append(J,G);return Q.toString()}}var h7=new x7;q4();var vG=y$("FigmaRestApi");class y7{figmaHost="https://api.figma.com/v1";personalToken=u6;async files($){let X;if($.ids)X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/nodes`,$);else X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}`,$);return this.fetch(X)}async images($){let X=this.opToUrl(`${this.figmaHost}/images/${$.fileKey}`,$);return this.fetch(X)}async imageFills($){let X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/images`,$);return this.fetch(X)}async meta($){let X=this.opToUrl(`${this.figmaHost}/files/${$.fileKey}/meta`,$);return this.fetch(X)}async fetch($,X="json"){try{let Q={method:"GET",headers:{"X-FIGMA-TOKEN":this.personalToken}},J=await e4($,Q);if(!J.ok)throw new Error(`HTTP error! status: ${J.status}`);return X==="text"?await J.text():await J.json()}catch(Q){throw vG.error("HTTP error",Q),Q}}opToUrl($,X={},Q=["fileKey","personalToken"]){if(Object.keys(X).length===0)return $;if(X.personalToken)this.personalToken=X.personalToken;let J=new URL($);for(let[G,H]of Object.entries(X))if(!Q.includes(G))J.searchParams.append(G,H);return J.toString()}}var Z7=new y7;q4();var V$={};K2(V$,{void:()=>BY,util:()=>o,unknown:()=>wY,union:()=>qY,undefined:()=>YY,tuple:()=>jY,transformer:()=>CY,symbol:()=>GY,string:()=>r7,strictObject:()=>OY,setErrorMap:()=>IG,set:()=>NY,record:()=>KY,quotelessJson:()=>CG,promise:()=>vY,preprocess:()=>bY,pipeline:()=>PY,ostring:()=>fY,optional:()=>kY,onumber:()=>gY,oboolean:()=>TY,objectUtil:()=>s2,object:()=>VY,number:()=>a7,nullable:()=>IY,null:()=>HY,never:()=>zY,nativeEnum:()=>RY,nan:()=>QY,map:()=>UY,makeIssue:()=>s6,literal:()=>FY,lazy:()=>SY,late:()=>$Y,isValid:()=>a0,isDirty:()=>E1,isAsync:()=>X6,isAborted:()=>F1,intersection:()=>AY,instanceof:()=>XY,getParsedType:()=>D0,getErrorMap:()=>$6,function:()=>LY,enum:()=>EY,effect:()=>CY,discriminatedUnion:()=>_Y,defaultErrorMap:()=>I0,datetimeRegex:()=>i7,date:()=>JY,custom:()=>o7,coerce:()=>xY,boolean:()=>t7,bigint:()=>WY,array:()=>DY,any:()=>MY,addIssueToContext:()=>S,ZodVoid:()=>QX,ZodUnknown:()=>t0,ZodUnion:()=>H6,ZodUndefined:()=>G6,ZodType:()=>i,ZodTuple:()=>O0,ZodTransformer:()=>X0,ZodSymbol:()=>XX,ZodString:()=>t$,ZodSet:()=>S4,ZodSchema:()=>i,ZodRecord:()=>WX,ZodReadonly:()=>O6,ZodPromise:()=>F4,ZodPipeline:()=>YX,ZodParsedType:()=>L,ZodOptional:()=>e$,ZodObject:()=>M$,ZodNumber:()=>s0,ZodNullable:()=>P0,ZodNull:()=>Y6,ZodNever:()=>V0,ZodNativeEnum:()=>B6,ZodNaN:()=>GX,ZodMap:()=>JX,ZodLiteral:()=>z6,ZodLazy:()=>w6,ZodIssueCode:()=>K,ZodIntersection:()=>M6,ZodFunction:()=>W6,ZodFirstPartyTypeKind:()=>g,ZodError:()=>R$,ZodEnum:()=>$4,ZodEffects:()=>X0,ZodDiscriminatedUnion:()=>v1,ZodDefault:()=>D6,ZodDate:()=>N4,ZodCatch:()=>V6,ZodBranded:()=>C1,ZodBoolean:()=>J6,ZodBigInt:()=>e0,ZodArray:()=>s$,ZodAny:()=>L4,Schema:()=>i,ParseStatus:()=>q$,OK:()=>j$,NEVER:()=>hY,INVALID:()=>f,EMPTY_PATH:()=>bG,DIRTY:()=>U4,BRAND:()=>eG});var o;(function($){$.assertEqual=(G)=>{};function X(G){}$.assertIs=X;function Q(G){throw new Error}$.assertNever=Q,$.arrayToEnum=(G)=>{let H={};for(let M of G)H[M]=M;return H},$.getValidEnumValues=(G)=>{let H=$.objectKeys(G).filter((z)=>typeof G[G[z]]!=="number"),M={};for(let z of H)M[z]=G[z];return $.objectValues(M)},$.objectValues=(G)=>{return $.objectKeys(G).map(function(H){return G[H]})},$.objectKeys=typeof Object.keys==="function"?(G)=>Object.keys(G):(G)=>{let H=[];for(let M in G)if(Object.prototype.hasOwnProperty.call(G,M))H.push(M);return H},$.find=(G,H)=>{for(let M of G)if(H(M))return M;return},$.isInteger=typeof Number.isInteger==="function"?(G)=>Number.isInteger(G):(G)=>typeof G==="number"&&Number.isFinite(G)&&Math.floor(G)===G;function J(G,H=" | "){return G.map((M)=>typeof M==="string"?`'${M}'`:M).join(H)}$.joinValues=J,$.jsonStringifyReplacer=(G,H)=>{if(typeof H==="bigint")return H.toString();return H}})(o||(o={}));var s2;(function($){$.mergeShapes=(X,Q)=>{return{...X,...Q}}})(s2||(s2={}));var L=o.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),D0=($)=>{switch(typeof $){case"undefined":return L.undefined;case"string":return L.string;case"number":return Number.isNaN($)?L.nan:L.number;case"boolean":return L.boolean;case"function":return L.function;case"bigint":return L.bigint;case"symbol":return L.symbol;case"object":if(Array.isArray($))return L.array;if($===null)return L.null;if($.then&&typeof $.then==="function"&&$.catch&&typeof $.catch==="function")return L.promise;if(typeof Map!=="undefined"&&$ instanceof Map)return L.map;if(typeof Set!=="undefined"&&$ instanceof Set)return L.set;if(typeof Date!=="undefined"&&$ instanceof Date)return L.date;return L.object;default:return L.unknown}};var K=o.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"]),CG=($)=>{return JSON.stringify($,null,2).replace(/"([^"]+)":/g,"$1:")};class R$ extends Error{get errors(){return this.issues}constructor($){super();this.issues=[],this.addIssue=(Q)=>{this.issues=[...this.issues,Q]},this.addIssues=(Q=[])=>{this.issues=[...this.issues,...Q]};let X=new.target.prototype;if(Object.setPrototypeOf)Object.setPrototypeOf(this,X);else this.__proto__=X;this.name="ZodError",this.issues=$}format($){let X=$||function(G){return G.message},Q={_errors:[]},J=(G)=>{for(let H of G.issues)if(H.code==="invalid_union")H.unionErrors.map(J);else if(H.code==="invalid_return_type")J(H.returnTypeError);else if(H.code==="invalid_arguments")J(H.argumentsError);else if(H.path.length===0)Q._errors.push(X(H));else{let M=Q,z=0;while(z<H.path.length){let D=H.path[z];if(z!==H.path.length-1)M[D]=M[D]||{_errors:[]};else M[D]=M[D]||{_errors:[]},M[D]._errors.push(X(H));M=M[D],z++}}};return J(this),Q}static assert($){if(!($ instanceof R$))throw new Error(`Not a ZodError: ${$}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,o.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten($=(X)=>X.message){let X={},Q=[];for(let J of this.issues)if(J.path.length>0)X[J.path[0]]=X[J.path[0]]||[],X[J.path[0]].push($(J));else Q.push($(J));return{formErrors:Q,fieldErrors:X}}get formErrors(){return this.flatten()}}R$.create=($)=>{return new R$($)};var kG=($,X)=>{let Q;switch($.code){case K.invalid_type:if($.received===L.undefined)Q="Required";else Q=`Expected ${$.expected}, received ${$.received}`;break;case K.invalid_literal:Q=`Invalid literal value, expected ${JSON.stringify($.expected,o.jsonStringifyReplacer)}`;break;case K.unrecognized_keys:Q=`Unrecognized key(s) in object: ${o.joinValues($.keys,", ")}`;break;case K.invalid_union:Q="Invalid input";break;case K.invalid_union_discriminator:Q=`Invalid discriminator value. Expected ${o.joinValues($.options)}`;break;case K.invalid_enum_value:Q=`Invalid enum value. Expected ${o.joinValues($.options)}, received '${$.received}'`;break;case K.invalid_arguments:Q="Invalid function arguments";break;case K.invalid_return_type:Q="Invalid function return type";break;case K.invalid_date:Q="Invalid date";break;case K.invalid_string:if(typeof $.validation==="object")if("includes"in $.validation){if(Q=`Invalid input: must include "${$.validation.includes}"`,typeof $.validation.position==="number")Q=`${Q} at one or more positions greater than or equal to ${$.validation.position}`}else if("startsWith"in $.validation)Q=`Invalid input: must start with "${$.validation.startsWith}"`;else if("endsWith"in $.validation)Q=`Invalid input: must end with "${$.validation.endsWith}"`;else o.assertNever($.validation);else if($.validation!=="regex")Q=`Invalid ${$.validation}`;else Q="Invalid";break;case K.too_small:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at least":"more than"} ${$.minimum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at least":"over"} ${$.minimum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${$.minimum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly equal to ":$.inclusive?"greater than or equal to ":"greater than "}${new Date(Number($.minimum))}`;else Q="Invalid input";break;case K.too_big:if($.type==="array")Q=`Array must contain ${$.exact?"exactly":$.inclusive?"at most":"less than"} ${$.maximum} element(s)`;else if($.type==="string")Q=`String must contain ${$.exact?"exactly":$.inclusive?"at most":"under"} ${$.maximum} character(s)`;else if($.type==="number")Q=`Number must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="bigint")Q=`BigInt must be ${$.exact?"exactly":$.inclusive?"less than or equal to":"less than"} ${$.maximum}`;else if($.type==="date")Q=`Date must be ${$.exact?"exactly":$.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number($.maximum))}`;else Q="Invalid input";break;case K.custom:Q="Invalid input";break;case K.invalid_intersection_types:Q="Intersection results could not be merged";break;case K.not_multiple_of:Q=`Number must be a multiple of ${$.multipleOf}`;break;case K.not_finite:Q="Number must be finite";break;default:Q=X.defaultError,o.assertNever($)}return{message:Q}},I0=kG;var m7=I0;function IG($){m7=$}function $6(){return m7}var s6=($)=>{let{data:X,path:Q,errorMaps:J,issueData:G}=$,H=[...Q,...G.path||[]],M={...G,path:H};if(G.message!==void 0)return{...G,path:H,message:G.message};let z="",D=J.filter((O)=>!!O).slice().reverse();for(let O of D)z=O(M,{data:X,defaultError:z}).message;return{...G,path:H,message:z}},bG=[];function S($,X){let Q=$6(),J=s6({issueData:X,data:$.data,path:$.path,errorMaps:[$.common.contextualErrorMap,$.schemaErrorMap,Q,Q===I0?void 0:I0].filter((G)=>!!G)});$.common.issues.push(J)}class q${constructor(){this.value="valid"}dirty(){if(this.value==="valid")this.value="dirty"}abort(){if(this.value!=="aborted")this.value="aborted"}static mergeArray($,X){let Q=[];for(let J of X){if(J.status==="aborted")return f;if(J.status==="dirty")$.dirty();Q.push(J.value)}return{status:$.value,value:Q}}static async mergeObjectAsync($,X){let Q=[];for(let J of X){let G=await J.key,H=await J.value;Q.push({key:G,value:H})}return q$.mergeObjectSync($,Q)}static mergeObjectSync($,X){let Q={};for(let J of X){let{key:G,value:H}=J;if(G.status==="aborted")return f;if(H.status==="aborted")return f;if(G.status==="dirty")$.dirty();if(H.status==="dirty")$.dirty();if(G.value!=="__proto__"&&(typeof H.value!=="undefined"||J.alwaysSet))Q[G.value]=H.value}return{status:$.value,value:Q}}}var f=Object.freeze({status:"aborted"}),U4=($)=>({status:"dirty",value:$}),j$=($)=>({status:"valid",value:$}),F1=($)=>$.status==="aborted",E1=($)=>$.status==="dirty",a0=($)=>$.status==="valid",X6=($)=>typeof Promise!=="undefined"&&$ instanceof Promise;var v;(function($){$.errToObj=(X)=>typeof X==="string"?{message:X}:X||{},$.toString=(X)=>typeof X==="string"?X:X?.message})(v||(v={}));var R1=function($,X,Q,J){if(Q==="a"&&!J)throw new TypeError("Private accessor was defined without a getter");if(typeof X==="function"?$!==X||!J:!X.has($))throw new TypeError("Cannot read private member from an object whose class did not declare it");return Q==="m"?J:Q==="a"?J.call($):J?J.value:X.get($)},u7=function($,X,Q,J,G){if(J==="m")throw new TypeError("Private method is not writable");if(J==="a"&&!G)throw new TypeError("Private accessor was defined without a setter");if(typeof X==="function"?$!==X||!G:!X.has($))throw new TypeError("Cannot write private member to an object whose class did not declare it");return J==="a"?G.call($,Q):G?G.value=Q:X.set($,Q),Q},e6,$X;class $0{constructor($,X,Q,J){this._cachedPath=[],this.parent=$,this.data=X,this._path=Q,this._key=J}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 l7=($,X)=>{if(a0(X))return{success:!0,data:X.value};else{if(!$.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let Q=new R$($.common.issues);return this._error=Q,this._error}}}};function p($){if(!$)return{};let{errorMap:X,invalid_type_error:Q,required_error:J,description:G}=$;if(X&&(Q||J))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);if(X)return{errorMap:X,description:G};return{errorMap:(M,z)=>{let{message:D}=$;if(M.code==="invalid_enum_value")return{message:D??z.defaultError};if(typeof z.data==="undefined")return{message:D??J??z.defaultError};if(M.code!=="invalid_type")return{message:z.defaultError};return{message:D??Q??z.defaultError}},description:G}}class i{get description(){return this._def.description}_getType($){return D0($.data)}_getOrReturnCtx($,X){return X||{common:$.parent.common,data:$.data,parsedType:D0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}_processInputParams($){return{status:new q$,ctx:{common:$.parent.common,data:$.data,parsedType:D0($.data),schemaErrorMap:this._def.errorMap,path:$.path,parent:$.parent}}}_parseSync($){let X=this._parse($);if(X6(X))throw new Error("Synchronous parse encountered promise.");return X}_parseAsync($){let X=this._parse($);return Promise.resolve(X)}parse($,X){let Q=this.safeParse($,X);if(Q.success)return Q.data;throw Q.error}safeParse($,X){let Q={common:{issues:[],async:X?.async??!1,contextualErrorMap:X?.errorMap},path:X?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:D0($)},J=this._parseSync({data:$,path:Q.path,parent:Q});return l7(Q,J)}"~validate"($){let X={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:D0($)};if(!this["~standard"].async)try{let Q=this._parseSync({data:$,path:[],parent:X});return a0(Q)?{value:Q.value}:{issues:X.common.issues}}catch(Q){if(Q?.message?.toLowerCase()?.includes("encountered"))this["~standard"].async=!0;X.common={issues:[],async:!0}}return this._parseAsync({data:$,path:[],parent:X}).then((Q)=>a0(Q)?{value:Q.value}:{issues:X.common.issues})}async parseAsync($,X){let Q=await this.safeParseAsync($,X);if(Q.success)return Q.data;throw Q.error}async safeParseAsync($,X){let Q={common:{issues:[],contextualErrorMap:X?.errorMap,async:!0},path:X?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:$,parsedType:D0($)},J=this._parse({data:$,path:Q.path,parent:Q}),G=await(X6(J)?J:Promise.resolve(J));return l7(Q,G)}refine($,X){let Q=(J)=>{if(typeof X==="string"||typeof X==="undefined")return{message:X};else if(typeof X==="function")return X(J);else return X};return this._refinement((J,G)=>{let H=$(J),M=()=>G.addIssue({code:K.custom,...Q(J)});if(typeof Promise!=="undefined"&&H instanceof Promise)return H.then((z)=>{if(!z)return M(),!1;else return!0});if(!H)return M(),!1;else return!0})}refinement($,X){return this._refinement((Q,J)=>{if(!$(Q))return J.addIssue(typeof X==="function"?X(Q,J):X),!1;else return!0})}_refinement($){return new X0({schema:this,typeName:g.ZodEffects,effect:{type:"refinement",refinement:$}})}superRefine($){return this._refinement($)}constructor($){this.spa=this.safeParseAsync,this._def=$,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:(X)=>this["~validate"](X)}}optional(){return e$.create(this,this._def)}nullable(){return P0.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return s$.create(this)}promise(){return F4.create(this,this._def)}or($){return H6.create([this,$],this._def)}and($){return M6.create(this,$,this._def)}transform($){return new X0({...p(this._def),schema:this,typeName:g.ZodEffects,effect:{type:"transform",transform:$}})}default($){let X=typeof $==="function"?$:()=>$;return new D6({...p(this._def),innerType:this,defaultValue:X,typeName:g.ZodDefault})}brand(){return new C1({typeName:g.ZodBranded,type:this,...p(this._def)})}catch($){let X=typeof $==="function"?$:()=>$;return new V6({...p(this._def),innerType:this,catchValue:X,typeName:g.ZodCatch})}describe($){return new this.constructor({...this._def,description:$})}pipe($){return YX.create(this,$)}readonly(){return O6.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}var PG=/^c[^\s-]{8,}$/i,fG=/^[0-9a-z]+$/,gG=/^[0-9A-HJKMNP-TV-Z]{26}$/i,TG=/^[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,xG=/^[a-z0-9_-]{21}$/i,hG=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,yG=/^[-+]?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)?)??$/,ZG=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,mG="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",e2,lG=/^(?:(?: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])$/,cG=/^(?:(?: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])$/,uG=/^(([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]))$/,pG=/^(([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])$/,nG=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,iG=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,p7="((\\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])))",dG=new RegExp(`^${p7}$`);function n7($){let X="[0-5]\\d";if($.precision)X=`${X}\\.\\d{${$.precision}}`;else if($.precision==null)X=`${X}(\\.\\d+)?`;let Q=$.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${X})${Q}`}function oG($){return new RegExp(`^${n7($)}$`)}function i7($){let X=`${p7}T${n7($)}`,Q=[];if(Q.push($.local?"Z?":"Z"),$.offset)Q.push("([+-]\\d{2}:?\\d{2})");return X=`${X}(${Q.join("|")})`,new RegExp(`^${X}$`)}function rG($,X){if((X==="v4"||!X)&&lG.test($))return!0;if((X==="v6"||!X)&&uG.test($))return!0;return!1}function aG($,X){if(!hG.test($))return!1;try{let[Q]=$.split("."),J=Q.replace(/-/g,"+").replace(/_/g,"/").padEnd(Q.length+(4-Q.length%4)%4,"="),G=JSON.parse(atob(J));if(typeof G!=="object"||G===null)return!1;if("typ"in G&&G?.typ!=="JWT")return!1;if(!G.alg)return!1;if(X&&G.alg!==X)return!1;return!0}catch{return!1}}function tG($,X){if((X==="v4"||!X)&&cG.test($))return!0;if((X==="v6"||!X)&&pG.test($))return!0;return!1}class t$ extends i{_parse($){if(this._def.coerce)$.data=String($.data);if(this._getType($)!==L.string){let G=this._getOrReturnCtx($);return S(G,{code:K.invalid_type,expected:L.string,received:G.parsedType}),f}let Q=new q$,J=void 0;for(let G of this._def.checks)if(G.kind==="min"){if($.data.length<G.value)J=this._getOrReturnCtx($,J),S(J,{code:K.too_small,minimum:G.value,type:"string",inclusive:!0,exact:!1,message:G.message}),Q.dirty()}else if(G.kind==="max"){if($.data.length>G.value)J=this._getOrReturnCtx($,J),S(J,{code:K.too_big,maximum:G.value,type:"string",inclusive:!0,exact:!1,message:G.message}),Q.dirty()}else if(G.kind==="length"){let H=$.data.length>G.value,M=$.data.length<G.value;if(H||M){if(J=this._getOrReturnCtx($,J),H)S(J,{code:K.too_big,maximum:G.value,type:"string",inclusive:!0,exact:!0,message:G.message});else if(M)S(J,{code:K.too_small,minimum:G.value,type:"string",inclusive:!0,exact:!0,message:G.message});Q.dirty()}}else if(G.kind==="email"){if(!ZG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"email",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="emoji"){if(!e2)e2=new RegExp(mG,"u");if(!e2.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"emoji",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="uuid"){if(!TG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"uuid",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="nanoid"){if(!xG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"nanoid",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="cuid"){if(!PG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"cuid",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="cuid2"){if(!fG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"cuid2",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="ulid"){if(!gG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"ulid",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="url")try{new URL($.data)}catch{J=this._getOrReturnCtx($,J),S(J,{validation:"url",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="regex"){if(G.regex.lastIndex=0,!G.regex.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"regex",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="trim")$.data=$.data.trim();else if(G.kind==="includes"){if(!$.data.includes(G.value,G.position))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:{includes:G.value,position:G.position},message:G.message}),Q.dirty()}else if(G.kind==="toLowerCase")$.data=$.data.toLowerCase();else if(G.kind==="toUpperCase")$.data=$.data.toUpperCase();else if(G.kind==="startsWith"){if(!$.data.startsWith(G.value))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:{startsWith:G.value},message:G.message}),Q.dirty()}else if(G.kind==="endsWith"){if(!$.data.endsWith(G.value))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:{endsWith:G.value},message:G.message}),Q.dirty()}else if(G.kind==="datetime"){if(!i7(G).test($.data))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:"datetime",message:G.message}),Q.dirty()}else if(G.kind==="date"){if(!dG.test($.data))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:"date",message:G.message}),Q.dirty()}else if(G.kind==="time"){if(!oG(G).test($.data))J=this._getOrReturnCtx($,J),S(J,{code:K.invalid_string,validation:"time",message:G.message}),Q.dirty()}else if(G.kind==="duration"){if(!yG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"duration",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="ip"){if(!rG($.data,G.version))J=this._getOrReturnCtx($,J),S(J,{validation:"ip",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="jwt"){if(!aG($.data,G.alg))J=this._getOrReturnCtx($,J),S(J,{validation:"jwt",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="cidr"){if(!tG($.data,G.version))J=this._getOrReturnCtx($,J),S(J,{validation:"cidr",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="base64"){if(!nG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"base64",code:K.invalid_string,message:G.message}),Q.dirty()}else if(G.kind==="base64url"){if(!iG.test($.data))J=this._getOrReturnCtx($,J),S(J,{validation:"base64url",code:K.invalid_string,message:G.message}),Q.dirty()}else o.assertNever(G);return{status:Q.value,value:$.data}}_regex($,X,Q){return this.refinement((J)=>$.test(J),{validation:X,code:K.invalid_string,...v.errToObj(Q)})}_addCheck($){return new t$({...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($,X){return this._addCheck({kind:"regex",regex:$,...v.errToObj(X)})}includes($,X){return this._addCheck({kind:"includes",value:$,position:X?.position,...v.errToObj(X?.message)})}startsWith($,X){return this._addCheck({kind:"startsWith",value:$,...v.errToObj(X)})}endsWith($,X){return this._addCheck({kind:"endsWith",value:$,...v.errToObj(X)})}min($,X){return this._addCheck({kind:"min",value:$,...v.errToObj(X)})}max($,X){return this._addCheck({kind:"max",value:$,...v.errToObj(X)})}length($,X){return this._addCheck({kind:"length",value:$,...v.errToObj(X)})}nonempty($){return this.min(1,v.errToObj($))}trim(){return new t$({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new t$({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new t$({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(($)=>$.kind==="datetime")}get isDate(){return!!this._def.checks.find(($)=>$.kind==="date")}get isTime(){return!!this._def.checks.find(($)=>$.kind==="time")}get isDuration(){return!!this._def.checks.find(($)=>$.kind==="duration")}get isEmail(){return!!this._def.checks.find(($)=>$.kind==="email")}get isURL(){return!!this._def.checks.find(($)=>$.kind==="url")}get isEmoji(){return!!this._def.checks.find(($)=>$.kind==="emoji")}get isUUID(){return!!this._def.checks.find(($)=>$.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(($)=>$.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(($)=>$.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(($)=>$.kind==="cuid2")}get isULID(){return!!this._def.checks.find(($)=>$.kind==="ulid")}get isIP(){return!!this._def.checks.find(($)=>$.kind==="ip")}get isCIDR(){return!!this._def.checks.find(($)=>$.kind==="cidr")}get isBase64(){return!!this._def.checks.find(($)=>$.kind==="base64")}get isBase64url(){return!!this._def.checks.find(($)=>$.kind==="base64url")}get minLength(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxLength(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}}t$.create=($)=>{return new t$({checks:[],typeName:g.ZodString,coerce:$?.coerce??!1,...p($)})};function sG($,X){let Q=($.toString().split(".")[1]||"").length,J=(X.toString().split(".")[1]||"").length,G=Q>J?Q:J,H=Number.parseInt($.toFixed(G).replace(".","")),M=Number.parseInt(X.toFixed(G).replace(".",""));return H%M/10**G}class s0 extends i{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($)!==L.number){let G=this._getOrReturnCtx($);return S(G,{code:K.invalid_type,expected:L.number,received:G.parsedType}),f}let Q=void 0,J=new q$;for(let G of this._def.checks)if(G.kind==="int"){if(!o.isInteger($.data))Q=this._getOrReturnCtx($,Q),S(Q,{code:K.invalid_type,expected:"integer",received:"float",message:G.message}),J.dirty()}else if(G.kind==="min"){if(G.inclusive?$.data<G.value:$.data<=G.value)Q=this._getOrReturnCtx($,Q),S(Q,{code:K.too_small,minimum:G.value,type:"number",inclusive:G.inclusive,exact:!1,message:G.message}),J.dirty()}else if(G.kind==="max"){if(G.inclusive?$.data>G.value:$.data>=G.value)Q=this._getOrReturnCtx($,Q),S(Q,{code:K.too_big,maximum:G.value,type:"number",inclusive:G.inclusive,exact:!1,message:G.message}),J.dirty()}else if(G.kind==="multipleOf"){if(sG($.data,G.value)!==0)Q=this._getOrReturnCtx($,Q),S(Q,{code:K.not_multiple_of,multipleOf:G.value,message:G.message}),J.dirty()}else if(G.kind==="finite"){if(!Number.isFinite($.data))Q=this._getOrReturnCtx($,Q),S(Q,{code:K.not_finite,message:G.message}),J.dirty()}else o.assertNever(G);return{status:J.value,value:$.data}}gte($,X){return this.setLimit("min",$,!0,v.toString(X))}gt($,X){return this.setLimit("min",$,!1,v.toString(X))}lte($,X){return this.setLimit("max",$,!0,v.toString(X))}lt($,X){return this.setLimit("max",$,!1,v.toString(X))}setLimit($,X,Q,J){return new s0({...this._def,checks:[...this._def.checks,{kind:$,value:X,inclusive:Q,message:v.toString(J)}]})}_addCheck($){return new s0({...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($,X){return this._addCheck({kind:"multipleOf",value:$,message:v.toString(X)})}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 X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxValue(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}get isInt(){return!!this._def.checks.find(($)=>$.kind==="int"||$.kind==="multipleOf"&&o.isInteger($.value))}get isFinite(){let $=null,X=null;for(let Q of this._def.checks)if(Q.kind==="finite"||Q.kind==="int"||Q.kind==="multipleOf")return!0;else if(Q.kind==="min"){if(X===null||Q.value>X)X=Q.value}else if(Q.kind==="max"){if($===null||Q.value<$)$=Q.value}return Number.isFinite(X)&&Number.isFinite($)}}s0.create=($)=>{return new s0({checks:[],typeName:g.ZodNumber,coerce:$?.coerce||!1,...p($)})};class e0 extends i{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($)!==L.bigint)return this._getInvalidInput($);let Q=void 0,J=new q$;for(let G of this._def.checks)if(G.kind==="min"){if(G.inclusive?$.data<G.value:$.data<=G.value)Q=this._getOrReturnCtx($,Q),S(Q,{code:K.too_small,type:"bigint",minimum:G.value,inclusive:G.inclusive,message:G.message}),J.dirty()}else if(G.kind==="max"){if(G.inclusive?$.data>G.value:$.data>=G.value)Q=this._getOrReturnCtx($,Q),S(Q,{code:K.too_big,type:"bigint",maximum:G.value,inclusive:G.inclusive,message:G.message}),J.dirty()}else if(G.kind==="multipleOf"){if($.data%G.value!==BigInt(0))Q=this._getOrReturnCtx($,Q),S(Q,{code:K.not_multiple_of,multipleOf:G.value,message:G.message}),J.dirty()}else o.assertNever(G);return{status:J.value,value:$.data}}_getInvalidInput($){let X=this._getOrReturnCtx($);return S(X,{code:K.invalid_type,expected:L.bigint,received:X.parsedType}),f}gte($,X){return this.setLimit("min",$,!0,v.toString(X))}gt($,X){return this.setLimit("min",$,!1,v.toString(X))}lte($,X){return this.setLimit("max",$,!0,v.toString(X))}lt($,X){return this.setLimit("max",$,!1,v.toString(X))}setLimit($,X,Q,J){return new e0({...this._def,checks:[...this._def.checks,{kind:$,value:X,inclusive:Q,message:v.toString(J)}]})}_addCheck($){return new e0({...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($,X){return this._addCheck({kind:"multipleOf",value:$,message:v.toString(X)})}get minValue(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $}get maxValue(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $}}e0.create=($)=>{return new e0({checks:[],typeName:g.ZodBigInt,coerce:$?.coerce??!1,...p($)})};class J6 extends i{_parse($){if(this._def.coerce)$.data=Boolean($.data);if(this._getType($)!==L.boolean){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.boolean,received:Q.parsedType}),f}return j$($.data)}}J6.create=($)=>{return new J6({typeName:g.ZodBoolean,coerce:$?.coerce||!1,...p($)})};class N4 extends i{_parse($){if(this._def.coerce)$.data=new Date($.data);if(this._getType($)!==L.date){let G=this._getOrReturnCtx($);return S(G,{code:K.invalid_type,expected:L.date,received:G.parsedType}),f}if(Number.isNaN($.data.getTime())){let G=this._getOrReturnCtx($);return S(G,{code:K.invalid_date}),f}let Q=new q$,J=void 0;for(let G of this._def.checks)if(G.kind==="min"){if($.data.getTime()<G.value)J=this._getOrReturnCtx($,J),S(J,{code:K.too_small,message:G.message,inclusive:!0,exact:!1,minimum:G.value,type:"date"}),Q.dirty()}else if(G.kind==="max"){if($.data.getTime()>G.value)J=this._getOrReturnCtx($,J),S(J,{code:K.too_big,message:G.message,inclusive:!0,exact:!1,maximum:G.value,type:"date"}),Q.dirty()}else o.assertNever(G);return{status:Q.value,value:new Date($.data.getTime())}}_addCheck($){return new N4({...this._def,checks:[...this._def.checks,$]})}min($,X){return this._addCheck({kind:"min",value:$.getTime(),message:v.toString(X)})}max($,X){return this._addCheck({kind:"max",value:$.getTime(),message:v.toString(X)})}get minDate(){let $=null;for(let X of this._def.checks)if(X.kind==="min"){if($===null||X.value>$)$=X.value}return $!=null?new Date($):null}get maxDate(){let $=null;for(let X of this._def.checks)if(X.kind==="max"){if($===null||X.value<$)$=X.value}return $!=null?new Date($):null}}N4.create=($)=>{return new N4({checks:[],coerce:$?.coerce||!1,typeName:g.ZodDate,...p($)})};class XX extends i{_parse($){if(this._getType($)!==L.symbol){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.symbol,received:Q.parsedType}),f}return j$($.data)}}XX.create=($)=>{return new XX({typeName:g.ZodSymbol,...p($)})};class G6 extends i{_parse($){if(this._getType($)!==L.undefined){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.undefined,received:Q.parsedType}),f}return j$($.data)}}G6.create=($)=>{return new G6({typeName:g.ZodUndefined,...p($)})};class Y6 extends i{_parse($){if(this._getType($)!==L.null){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.null,received:Q.parsedType}),f}return j$($.data)}}Y6.create=($)=>{return new Y6({typeName:g.ZodNull,...p($)})};class L4 extends i{constructor(){super(...arguments);this._any=!0}_parse($){return j$($.data)}}L4.create=($)=>{return new L4({typeName:g.ZodAny,...p($)})};class t0 extends i{constructor(){super(...arguments);this._unknown=!0}_parse($){return j$($.data)}}t0.create=($)=>{return new t0({typeName:g.ZodUnknown,...p($)})};class V0 extends i{_parse($){let X=this._getOrReturnCtx($);return S(X,{code:K.invalid_type,expected:L.never,received:X.parsedType}),f}}V0.create=($)=>{return new V0({typeName:g.ZodNever,...p($)})};class QX extends i{_parse($){if(this._getType($)!==L.undefined){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.void,received:Q.parsedType}),f}return j$($.data)}}QX.create=($)=>{return new QX({typeName:g.ZodVoid,...p($)})};class s$ extends i{_parse($){let{ctx:X,status:Q}=this._processInputParams($),J=this._def;if(X.parsedType!==L.array)return S(X,{code:K.invalid_type,expected:L.array,received:X.parsedType}),f;if(J.exactLength!==null){let H=X.data.length>J.exactLength.value,M=X.data.length<J.exactLength.value;if(H||M)S(X,{code:H?K.too_big:K.too_small,minimum:M?J.exactLength.value:void 0,maximum:H?J.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:J.exactLength.message}),Q.dirty()}if(J.minLength!==null){if(X.data.length<J.minLength.value)S(X,{code:K.too_small,minimum:J.minLength.value,type:"array",inclusive:!0,exact:!1,message:J.minLength.message}),Q.dirty()}if(J.maxLength!==null){if(X.data.length>J.maxLength.value)S(X,{code:K.too_big,maximum:J.maxLength.value,type:"array",inclusive:!0,exact:!1,message:J.maxLength.message}),Q.dirty()}if(X.common.async)return Promise.all([...X.data].map((H,M)=>{return J.type._parseAsync(new $0(X,H,X.path,M))})).then((H)=>{return q$.mergeArray(Q,H)});let G=[...X.data].map((H,M)=>{return J.type._parseSync(new $0(X,H,X.path,M))});return q$.mergeArray(Q,G)}get element(){return this._def.type}min($,X){return new s$({...this._def,minLength:{value:$,message:v.toString(X)}})}max($,X){return new s$({...this._def,maxLength:{value:$,message:v.toString(X)}})}length($,X){return new s$({...this._def,exactLength:{value:$,message:v.toString(X)}})}nonempty($){return this.min(1,$)}}s$.create=($,X)=>{return new s$({type:$,minLength:null,maxLength:null,exactLength:null,typeName:g.ZodArray,...p(X)})};function Q6($){if($ instanceof M$){let X={};for(let Q in $.shape){let J=$.shape[Q];X[Q]=e$.create(Q6(J))}return new M$({...$._def,shape:()=>X})}else if($ instanceof s$)return new s$({...$._def,type:Q6($.element)});else if($ instanceof e$)return e$.create(Q6($.unwrap()));else if($ instanceof P0)return P0.create(Q6($.unwrap()));else if($ instanceof O0)return O0.create($.items.map((X)=>Q6(X)));else return $}class M$ extends i{constructor(){super(...arguments);this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let $=this._def.shape(),X=o.objectKeys($);return this._cached={shape:$,keys:X},this._cached}_parse($){if(this._getType($)!==L.object){let D=this._getOrReturnCtx($);return S(D,{code:K.invalid_type,expected:L.object,received:D.parsedType}),f}let{status:Q,ctx:J}=this._processInputParams($),{shape:G,keys:H}=this._getCached(),M=[];if(!(this._def.catchall instanceof V0&&this._def.unknownKeys==="strip")){for(let D in J.data)if(!H.includes(D))M.push(D)}let z=[];for(let D of H){let O=G[D],_=J.data[D];z.push({key:{status:"valid",value:D},value:O._parse(new $0(J,_,J.path,D)),alwaysSet:D in J.data})}if(this._def.catchall instanceof V0){let D=this._def.unknownKeys;if(D==="passthrough")for(let O of M)z.push({key:{status:"valid",value:O},value:{status:"valid",value:J.data[O]}});else if(D==="strict"){if(M.length>0)S(J,{code:K.unrecognized_keys,keys:M}),Q.dirty()}else if(D==="strip");else throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let D=this._def.catchall;for(let O of M){let _=J.data[O];z.push({key:{status:"valid",value:O},value:D._parse(new $0(J,_,J.path,O)),alwaysSet:O in J.data})}}if(J.common.async)return Promise.resolve().then(async()=>{let D=[];for(let O of z){let _=await O.key,m=await O.value;D.push({key:_,value:m,alwaysSet:O.alwaysSet})}return D}).then((D)=>{return q$.mergeObjectSync(Q,D)});else return q$.mergeObjectSync(Q,z)}get shape(){return this._def.shape()}strict($){return v.errToObj,new M$({...this._def,unknownKeys:"strict",...$!==void 0?{errorMap:(X,Q)=>{let J=this._def.errorMap?.(X,Q).message??Q.defaultError;if(X.code==="unrecognized_keys")return{message:v.errToObj($).message??J};return{message:J}}}:{}})}strip(){return new M$({...this._def,unknownKeys:"strip"})}passthrough(){return new M$({...this._def,unknownKeys:"passthrough"})}extend($){return new M$({...this._def,shape:()=>({...this._def.shape(),...$})})}merge($){return new M$({unknownKeys:$._def.unknownKeys,catchall:$._def.catchall,shape:()=>({...this._def.shape(),...$._def.shape()}),typeName:g.ZodObject})}setKey($,X){return this.augment({[$]:X})}catchall($){return new M$({...this._def,catchall:$})}pick($){let X={};for(let Q of o.objectKeys($))if($[Q]&&this.shape[Q])X[Q]=this.shape[Q];return new M$({...this._def,shape:()=>X})}omit($){let X={};for(let Q of o.objectKeys(this.shape))if(!$[Q])X[Q]=this.shape[Q];return new M$({...this._def,shape:()=>X})}deepPartial(){return Q6(this)}partial($){let X={};for(let Q of o.objectKeys(this.shape)){let J=this.shape[Q];if($&&!$[Q])X[Q]=J;else X[Q]=J.optional()}return new M$({...this._def,shape:()=>X})}required($){let X={};for(let Q of o.objectKeys(this.shape))if($&&!$[Q])X[Q]=this.shape[Q];else{let G=this.shape[Q];while(G instanceof e$)G=G._def.innerType;X[Q]=G}return new M$({...this._def,shape:()=>X})}keyof(){return d7(o.objectKeys(this.shape))}}M$.create=($,X)=>{return new M$({shape:()=>$,unknownKeys:"strip",catchall:V0.create(),typeName:g.ZodObject,...p(X)})};M$.strictCreate=($,X)=>{return new M$({shape:()=>$,unknownKeys:"strict",catchall:V0.create(),typeName:g.ZodObject,...p(X)})};M$.lazycreate=($,X)=>{return new M$({shape:$,unknownKeys:"strip",catchall:V0.create(),typeName:g.ZodObject,...p(X)})};class H6 extends i{_parse($){let{ctx:X}=this._processInputParams($),Q=this._def.options;function J(G){for(let M of G)if(M.result.status==="valid")return M.result;for(let M of G)if(M.result.status==="dirty")return X.common.issues.push(...M.ctx.common.issues),M.result;let H=G.map((M)=>new R$(M.ctx.common.issues));return S(X,{code:K.invalid_union,unionErrors:H}),f}if(X.common.async)return Promise.all(Q.map(async(G)=>{let H={...X,common:{...X.common,issues:[]},parent:null};return{result:await G._parseAsync({data:X.data,path:X.path,parent:H}),ctx:H}})).then(J);else{let G=void 0,H=[];for(let z of Q){let D={...X,common:{...X.common,issues:[]},parent:null},O=z._parseSync({data:X.data,path:X.path,parent:D});if(O.status==="valid")return O;else if(O.status==="dirty"&&!G)G={result:O,ctx:D};if(D.common.issues.length)H.push(D.common.issues)}if(G)return X.common.issues.push(...G.ctx.common.issues),G.result;let M=H.map((z)=>new R$(z));return S(X,{code:K.invalid_union,unionErrors:M}),f}}get options(){return this._def.options}}H6.create=($,X)=>{return new H6({options:$,typeName:g.ZodUnion,...p(X)})};var b0=($)=>{if($ instanceof w6)return b0($.schema);else if($ instanceof X0)return b0($.innerType());else if($ instanceof z6)return[$.value];else if($ instanceof $4)return $.options;else if($ instanceof B6)return o.objectValues($.enum);else if($ instanceof D6)return b0($._def.innerType);else if($ instanceof G6)return[void 0];else if($ instanceof Y6)return[null];else if($ instanceof e$)return[void 0,...b0($.unwrap())];else if($ instanceof P0)return[null,...b0($.unwrap())];else if($ instanceof C1)return b0($.unwrap());else if($ instanceof O6)return b0($.unwrap());else if($ instanceof V6)return b0($._def.innerType);else return[]};class v1 extends i{_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==L.object)return S(X,{code:K.invalid_type,expected:L.object,received:X.parsedType}),f;let Q=this.discriminator,J=X.data[Q],G=this.optionsMap.get(J);if(!G)return S(X,{code:K.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[Q]}),f;if(X.common.async)return G._parseAsync({data:X.data,path:X.path,parent:X});else return G._parseSync({data:X.data,path:X.path,parent:X})}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create($,X,Q){let J=new Map;for(let G of X){let H=b0(G.shape[$]);if(!H.length)throw new Error(`A discriminator value for key \`${$}\` could not be extracted from all schema options`);for(let M of H){if(J.has(M))throw new Error(`Discriminator property ${String($)} has duplicate value ${String(M)}`);J.set(M,G)}}return new v1({typeName:g.ZodDiscriminatedUnion,discriminator:$,options:X,optionsMap:J,...p(Q)})}}function $8($,X){let Q=D0($),J=D0(X);if($===X)return{valid:!0,data:$};else if(Q===L.object&&J===L.object){let G=o.objectKeys(X),H=o.objectKeys($).filter((z)=>G.indexOf(z)!==-1),M={...$,...X};for(let z of H){let D=$8($[z],X[z]);if(!D.valid)return{valid:!1};M[z]=D.data}return{valid:!0,data:M}}else if(Q===L.array&&J===L.array){if($.length!==X.length)return{valid:!1};let G=[];for(let H=0;H<$.length;H++){let M=$[H],z=X[H],D=$8(M,z);if(!D.valid)return{valid:!1};G.push(D.data)}return{valid:!0,data:G}}else if(Q===L.date&&J===L.date&&+$===+X)return{valid:!0,data:$};else return{valid:!1}}class M6 extends i{_parse($){let{status:X,ctx:Q}=this._processInputParams($),J=(G,H)=>{if(F1(G)||F1(H))return f;let M=$8(G.value,H.value);if(!M.valid)return S(Q,{code:K.invalid_intersection_types}),f;if(E1(G)||E1(H))X.dirty();return{status:X.value,value:M.data}};if(Q.common.async)return Promise.all([this._def.left._parseAsync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseAsync({data:Q.data,path:Q.path,parent:Q})]).then(([G,H])=>J(G,H));else return J(this._def.left._parseSync({data:Q.data,path:Q.path,parent:Q}),this._def.right._parseSync({data:Q.data,path:Q.path,parent:Q}))}}M6.create=($,X,Q)=>{return new M6({left:$,right:X,typeName:g.ZodIntersection,...p(Q)})};class O0 extends i{_parse($){let{status:X,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.array)return S(Q,{code:K.invalid_type,expected:L.array,received:Q.parsedType}),f;if(Q.data.length<this._def.items.length)return S(Q,{code:K.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),f;if(!this._def.rest&&Q.data.length>this._def.items.length)S(Q,{code:K.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),X.dirty();let G=[...Q.data].map((H,M)=>{let z=this._def.items[M]||this._def.rest;if(!z)return null;return z._parse(new $0(Q,H,Q.path,M))}).filter((H)=>!!H);if(Q.common.async)return Promise.all(G).then((H)=>{return q$.mergeArray(X,H)});else return q$.mergeArray(X,G)}get items(){return this._def.items}rest($){return new O0({...this._def,rest:$})}}O0.create=($,X)=>{if(!Array.isArray($))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new O0({items:$,typeName:g.ZodTuple,rest:null,...p(X)})};class WX extends i{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:X,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.object)return S(Q,{code:K.invalid_type,expected:L.object,received:Q.parsedType}),f;let J=[],G=this._def.keyType,H=this._def.valueType;for(let M in Q.data)J.push({key:G._parse(new $0(Q,M,Q.path,M)),value:H._parse(new $0(Q,Q.data[M],Q.path,M)),alwaysSet:M in Q.data});if(Q.common.async)return q$.mergeObjectAsync(X,J);else return q$.mergeObjectSync(X,J)}get element(){return this._def.valueType}static create($,X,Q){if(X instanceof i)return new WX({keyType:$,valueType:X,typeName:g.ZodRecord,...p(Q)});return new WX({keyType:t$.create(),valueType:$,typeName:g.ZodRecord,...p(X)})}}class JX extends i{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse($){let{status:X,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.map)return S(Q,{code:K.invalid_type,expected:L.map,received:Q.parsedType}),f;let J=this._def.keyType,G=this._def.valueType,H=[...Q.data.entries()].map(([M,z],D)=>{return{key:J._parse(new $0(Q,M,Q.path,[D,"key"])),value:G._parse(new $0(Q,z,Q.path,[D,"value"]))}});if(Q.common.async){let M=new Map;return Promise.resolve().then(async()=>{for(let z of H){let D=await z.key,O=await z.value;if(D.status==="aborted"||O.status==="aborted")return f;if(D.status==="dirty"||O.status==="dirty")X.dirty();M.set(D.value,O.value)}return{status:X.value,value:M}})}else{let M=new Map;for(let z of H){let{key:D,value:O}=z;if(D.status==="aborted"||O.status==="aborted")return f;if(D.status==="dirty"||O.status==="dirty")X.dirty();M.set(D.value,O.value)}return{status:X.value,value:M}}}}JX.create=($,X,Q)=>{return new JX({valueType:X,keyType:$,typeName:g.ZodMap,...p(Q)})};class S4 extends i{_parse($){let{status:X,ctx:Q}=this._processInputParams($);if(Q.parsedType!==L.set)return S(Q,{code:K.invalid_type,expected:L.set,received:Q.parsedType}),f;let J=this._def;if(J.minSize!==null){if(Q.data.size<J.minSize.value)S(Q,{code:K.too_small,minimum:J.minSize.value,type:"set",inclusive:!0,exact:!1,message:J.minSize.message}),X.dirty()}if(J.maxSize!==null){if(Q.data.size>J.maxSize.value)S(Q,{code:K.too_big,maximum:J.maxSize.value,type:"set",inclusive:!0,exact:!1,message:J.maxSize.message}),X.dirty()}let G=this._def.valueType;function H(z){let D=new Set;for(let O of z){if(O.status==="aborted")return f;if(O.status==="dirty")X.dirty();D.add(O.value)}return{status:X.value,value:D}}let M=[...Q.data.values()].map((z,D)=>G._parse(new $0(Q,z,Q.path,D)));if(Q.common.async)return Promise.all(M).then((z)=>H(z));else return H(M)}min($,X){return new S4({...this._def,minSize:{value:$,message:v.toString(X)}})}max($,X){return new S4({...this._def,maxSize:{value:$,message:v.toString(X)}})}size($,X){return this.min($,X).max($,X)}nonempty($){return this.min(1,$)}}S4.create=($,X)=>{return new S4({valueType:$,minSize:null,maxSize:null,typeName:g.ZodSet,...p(X)})};class W6 extends i{constructor(){super(...arguments);this.validate=this.implement}_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==L.function)return S(X,{code:K.invalid_type,expected:L.function,received:X.parsedType}),f;function Q(M,z){return s6({data:M,path:X.path,errorMaps:[X.common.contextualErrorMap,X.schemaErrorMap,$6(),I0].filter((D)=>!!D),issueData:{code:K.invalid_arguments,argumentsError:z}})}function J(M,z){return s6({data:M,path:X.path,errorMaps:[X.common.contextualErrorMap,X.schemaErrorMap,$6(),I0].filter((D)=>!!D),issueData:{code:K.invalid_return_type,returnTypeError:z}})}let G={errorMap:X.common.contextualErrorMap},H=X.data;if(this._def.returns instanceof F4){let M=this;return j$(async function(...z){let D=new R$([]),O=await M._def.args.parseAsync(z,G).catch((x)=>{throw D.addIssue(Q(z,x)),D}),_=await Reflect.apply(H,this,O);return await M._def.returns._def.type.parseAsync(_,G).catch((x)=>{throw D.addIssue(J(_,x)),D})})}else{let M=this;return j$(function(...z){let D=M._def.args.safeParse(z,G);if(!D.success)throw new R$([Q(z,D.error)]);let O=Reflect.apply(H,this,D.data),_=M._def.returns.safeParse(O,G);if(!_.success)throw new R$([J(O,_.error)]);return _.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...$){return new W6({...this._def,args:O0.create($).rest(t0.create())})}returns($){return new W6({...this._def,returns:$})}implement($){return this.parse($)}strictImplement($){return this.parse($)}static create($,X,Q){return new W6({args:$?$:O0.create([]).rest(t0.create()),returns:X||t0.create(),typeName:g.ZodFunction,...p(Q)})}}class w6 extends i{get schema(){return this._def.getter()}_parse($){let{ctx:X}=this._processInputParams($);return this._def.getter()._parse({data:X.data,path:X.path,parent:X})}}w6.create=($,X)=>{return new w6({getter:$,typeName:g.ZodLazy,...p(X)})};class z6 extends i{_parse($){if($.data!==this._def.value){let X=this._getOrReturnCtx($);return S(X,{received:X.data,code:K.invalid_literal,expected:this._def.value}),f}return{status:"valid",value:$.data}}get value(){return this._def.value}}z6.create=($,X)=>{return new z6({value:$,typeName:g.ZodLiteral,...p(X)})};function d7($,X){return new $4({values:$,typeName:g.ZodEnum,...p(X)})}class $4 extends i{constructor(){super(...arguments);e6.set(this,void 0)}_parse($){if(typeof $.data!=="string"){let X=this._getOrReturnCtx($),Q=this._def.values;return S(X,{expected:o.joinValues(Q),received:X.parsedType,code:K.invalid_type}),f}if(!R1(this,e6,"f"))u7(this,e6,new Set(this._def.values),"f");if(!R1(this,e6,"f").has($.data)){let X=this._getOrReturnCtx($),Q=this._def.values;return S(X,{received:X.data,code:K.invalid_enum_value,options:Q}),f}return j$($.data)}get options(){return this._def.values}get enum(){let $={};for(let X of this._def.values)$[X]=X;return $}get Values(){let $={};for(let X of this._def.values)$[X]=X;return $}get Enum(){let $={};for(let X of this._def.values)$[X]=X;return $}extract($,X=this._def){return $4.create($,{...this._def,...X})}exclude($,X=this._def){return $4.create(this.options.filter((Q)=>!$.includes(Q)),{...this._def,...X})}}e6=new WeakMap;$4.create=d7;class B6 extends i{constructor(){super(...arguments);$X.set(this,void 0)}_parse($){let X=o.getValidEnumValues(this._def.values),Q=this._getOrReturnCtx($);if(Q.parsedType!==L.string&&Q.parsedType!==L.number){let J=o.objectValues(X);return S(Q,{expected:o.joinValues(J),received:Q.parsedType,code:K.invalid_type}),f}if(!R1(this,$X,"f"))u7(this,$X,new Set(o.getValidEnumValues(this._def.values)),"f");if(!R1(this,$X,"f").has($.data)){let J=o.objectValues(X);return S(Q,{received:Q.data,code:K.invalid_enum_value,options:J}),f}return j$($.data)}get enum(){return this._def.values}}$X=new WeakMap;B6.create=($,X)=>{return new B6({values:$,typeName:g.ZodNativeEnum,...p(X)})};class F4 extends i{unwrap(){return this._def.type}_parse($){let{ctx:X}=this._processInputParams($);if(X.parsedType!==L.promise&&X.common.async===!1)return S(X,{code:K.invalid_type,expected:L.promise,received:X.parsedType}),f;let Q=X.parsedType===L.promise?X.data:Promise.resolve(X.data);return j$(Q.then((J)=>{return this._def.type.parseAsync(J,{path:X.path,errorMap:X.common.contextualErrorMap})}))}}F4.create=($,X)=>{return new F4({type:$,typeName:g.ZodPromise,...p(X)})};class X0 extends i{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===g.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse($){let{status:X,ctx:Q}=this._processInputParams($),J=this._def.effect||null,G={addIssue:(H)=>{if(S(Q,H),H.fatal)X.abort();else X.dirty()},get path(){return Q.path}};if(G.addIssue=G.addIssue.bind(G),J.type==="preprocess"){let H=J.transform(Q.data,G);if(Q.common.async)return Promise.resolve(H).then(async(M)=>{if(X.value==="aborted")return f;let z=await this._def.schema._parseAsync({data:M,path:Q.path,parent:Q});if(z.status==="aborted")return f;if(z.status==="dirty")return U4(z.value);if(X.value==="dirty")return U4(z.value);return z});else{if(X.value==="aborted")return f;let M=this._def.schema._parseSync({data:H,path:Q.path,parent:Q});if(M.status==="aborted")return f;if(M.status==="dirty")return U4(M.value);if(X.value==="dirty")return U4(M.value);return M}}if(J.type==="refinement"){let H=(M)=>{let z=J.refinement(M,G);if(Q.common.async)return Promise.resolve(z);if(z instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return M};if(Q.common.async===!1){let M=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(M.status==="aborted")return f;if(M.status==="dirty")X.dirty();return H(M.value),{status:X.value,value:M.value}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((M)=>{if(M.status==="aborted")return f;if(M.status==="dirty")X.dirty();return H(M.value).then(()=>{return{status:X.value,value:M.value}})})}if(J.type==="transform")if(Q.common.async===!1){let H=this._def.schema._parseSync({data:Q.data,path:Q.path,parent:Q});if(!a0(H))return H;let M=J.transform(H.value,G);if(M instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:X.value,value:M}}else return this._def.schema._parseAsync({data:Q.data,path:Q.path,parent:Q}).then((H)=>{if(!a0(H))return H;return Promise.resolve(J.transform(H.value,G)).then((M)=>({status:X.value,value:M}))});o.assertNever(J)}}X0.create=($,X,Q)=>{return new X0({schema:$,typeName:g.ZodEffects,effect:X,...p(Q)})};X0.createWithPreprocess=($,X,Q)=>{return new X0({schema:X,effect:{type:"preprocess",transform:$},typeName:g.ZodEffects,...p(Q)})};class e$ extends i{_parse($){if(this._getType($)===L.undefined)return j$(void 0);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}e$.create=($,X)=>{return new e$({innerType:$,typeName:g.ZodOptional,...p(X)})};class P0 extends i{_parse($){if(this._getType($)===L.null)return j$(null);return this._def.innerType._parse($)}unwrap(){return this._def.innerType}}P0.create=($,X)=>{return new P0({innerType:$,typeName:g.ZodNullable,...p(X)})};class D6 extends i{_parse($){let{ctx:X}=this._processInputParams($),Q=X.data;if(X.parsedType===L.undefined)Q=this._def.defaultValue();return this._def.innerType._parse({data:Q,path:X.path,parent:X})}removeDefault(){return this._def.innerType}}D6.create=($,X)=>{return new D6({innerType:$,typeName:g.ZodDefault,defaultValue:typeof X.default==="function"?X.default:()=>X.default,...p(X)})};class V6 extends i{_parse($){let{ctx:X}=this._processInputParams($),Q={...X,common:{...X.common,issues:[]}},J=this._def.innerType._parse({data:Q.data,path:Q.path,parent:{...Q}});if(X6(J))return J.then((G)=>{return{status:"valid",value:G.status==="valid"?G.value:this._def.catchValue({get error(){return new R$(Q.common.issues)},input:Q.data})}});else return{status:"valid",value:J.status==="valid"?J.value:this._def.catchValue({get error(){return new R$(Q.common.issues)},input:Q.data})}}removeCatch(){return this._def.innerType}}V6.create=($,X)=>{return new V6({innerType:$,typeName:g.ZodCatch,catchValue:typeof X.catch==="function"?X.catch:()=>X.catch,...p(X)})};class GX extends i{_parse($){if(this._getType($)!==L.nan){let Q=this._getOrReturnCtx($);return S(Q,{code:K.invalid_type,expected:L.nan,received:Q.parsedType}),f}return{status:"valid",value:$.data}}}GX.create=($)=>{return new GX({typeName:g.ZodNaN,...p($)})};var eG=Symbol("zod_brand");class C1 extends i{_parse($){let{ctx:X}=this._processInputParams($),Q=X.data;return this._def.type._parse({data:Q,path:X.path,parent:X})}unwrap(){return this._def.type}}class YX extends i{_parse($){let{status:X,ctx:Q}=this._processInputParams($);if(Q.common.async)return(async()=>{let G=await this._def.in._parseAsync({data:Q.data,path:Q.path,parent:Q});if(G.status==="aborted")return f;if(G.status==="dirty")return X.dirty(),U4(G.value);else return this._def.out._parseAsync({data:G.value,path:Q.path,parent:Q})})();else{let J=this._def.in._parseSync({data:Q.data,path:Q.path,parent:Q});if(J.status==="aborted")return f;if(J.status==="dirty")return X.dirty(),{status:"dirty",value:J.value};else return this._def.out._parseSync({data:J.value,path:Q.path,parent:Q})}}static create($,X){return new YX({in:$,out:X,typeName:g.ZodPipeline})}}class O6 extends i{_parse($){let X=this._def.innerType._parse($),Q=(J)=>{if(a0(J))J.value=Object.freeze(J.value);return J};return X6(X)?X.then((J)=>Q(J)):Q(X)}unwrap(){return this._def.innerType}}O6.create=($,X)=>{return new O6({innerType:$,typeName:g.ZodReadonly,...p(X)})};function c7($,X){let Q=typeof $==="function"?$(X):typeof $==="string"?{message:$}:$;return typeof Q==="string"?{message:Q}:Q}function o7($,X={},Q){if($)return L4.create().superRefine((J,G)=>{let H=$(J);if(H instanceof Promise)return H.then((M)=>{if(!M){let z=c7(X,J),D=z.fatal??Q??!0;G.addIssue({code:"custom",...z,fatal:D})}});if(!H){let M=c7(X,J),z=M.fatal??Q??!0;G.addIssue({code:"custom",...M,fatal:z})}return});return L4.create()}var $Y={object:M$.lazycreate},g;(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"})(g||(g={}));var XY=($,X={message:`Input not instance of ${$.name}`})=>o7((Q)=>Q instanceof $,X),r7=t$.create,a7=s0.create,QY=GX.create,WY=e0.create,t7=J6.create,JY=N4.create,GY=XX.create,YY=G6.create,HY=Y6.create,MY=L4.create,wY=t0.create,zY=V0.create,BY=QX.create,DY=s$.create,VY=M$.create,OY=M$.strictCreate,qY=H6.create,_Y=v1.create,AY=M6.create,jY=O0.create,KY=WX.create,UY=JX.create,NY=S4.create,LY=W6.create,SY=w6.create,FY=z6.create,EY=$4.create,RY=B6.create,vY=F4.create,CY=X0.create,kY=e$.create,IY=P0.create,bY=X0.createWithPreprocess,PY=YX.create,fY=()=>r7().optional(),gY=()=>a7().optional(),TY=()=>t7().optional(),xY={string:($)=>t$.create({...$,coerce:!0}),number:($)=>s0.create({...$,coerce:!0}),boolean:($)=>J6.create({...$,coerce:!0}),bigint:($)=>e0.create({...$,coerce:!0}),date:($)=>N4.create({...$,coerce:!0})};var hY=f;var HX=x$(require("fs")),X4=x$(require("path")),X8=x$(require("fs/promises"));q4();var Q0=y$("Downloader");class s7{op;assetsPath="";savePath="";setup($){if(this.op=$,this.op.localPath)this.assetsPath=X4.default.join(this.op.localPath,"assets"),this.savePath=this.op.localPath}async downloadImage($,X){let{imgFormat:Q}=this.op,J=this.assetsPath;try{if(!HX.default.existsSync(J))HX.default.mkdirSync(J,{recursive:!0});let G=`${X}.${Q}`,H=X4.default.join(J,G),M=await e4($);if(!M.ok)throw new Error(`下载失败: ${M.status} ${M.statusText}`);let z=await M.arrayBuffer();return HX.default.writeFileSync(H,new Uint8Array(z)),X4.default.join(X4.default.basename(J),G).replace(/\\/g,"/")}catch(G){throw Q0.error("图片下载错误:",G),G}}async downLoadImageAndReplaceContent($){try{let X=/https:\/\/figma-alpha-api\.s3\.us-west-2\.amazonaws\.com\/images\/[a-f0-9-]+/g,Q=$.match(X);if(!Q)return $;let J=[...new Set(Q)],G=new Map;await Promise.all(J.map(async(M)=>{let z=X4.default.basename(M),D=await this.downloadImage(M,z);G.set(M,D)}));let H=$;for(let[M,z]of G.entries()){let D=new RegExp(M.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),"g");H=H.replace(D,z)}return H}catch(X){throw Q0.error("内容处理错误:",X),X}}async checkLocalAndDownload($){if(!this.op.localPath)return;await Promise.all($.map(async(X)=>{X.content=await this.downLoadImageAndReplaceContent(X.content)}));for(let X of $)try{let Q=await this.saveContentToFile(X.content,X.path);Q0.debug(`Successfully saved: ${Q}`)}catch(Q){Q0.error(`Failed to save file ${X.path}:`,Q)}}async ensureDirectoryExists($){if(!HX.default.existsSync($))Q0.debug(`Creating directory: ${$}`),await X8.default.mkdir($,{recursive:!0})}async saveContentToFile($,X){try{let Q=X4.default.join(this.savePath,X),J=X4.default.dirname(Q);if(Q0.debug(`Full path: ${Q}, directory: ${J}`),await this.ensureDirectoryExists(J),X.endsWith(".html"))Q0.debug("Wrapping content with HTML template"),$=this.wrapHtmlContent($);return Q0.debug(`Writing ${$.length} bytes to file`),await X8.default.writeFile(Q,$),Q0.info(`File saved: ${Q}`),Q}catch(Q){throw Q0.error("File save error:",X,Q),Q}}wrapHtmlContent($){return Q0.debug("Wrapping content with HTML template"),`<!DOCTYPE html>
20
20
  <html>
21
21
  <head>
22
22
  <meta charset="UTF-8">
@@ -39,5 +39,5 @@ ${G}. Convert the Tailwind to vanilla CSS if not already used in the codebase. D
39
39
  `);if($===-1)return null;let X=this._buffer.toString("utf8",0,$).replace(/\r$/,"");return this._buffer=this._buffer.subarray($+1),ZY(X)}clear(){this._buffer=void 0}}function ZY($){return p3.parse(JSON.parse($))}function $W($){return JSON.stringify($)+`
40
40
  `}class G8{constructor($=J8.default.stdin,X=J8.default.stdout){this._stdin=$,this._stdout=X,this._readBuffer=new W8,this._started=!1,this._ondata=(Q)=>{this._readBuffer.append(Q),this.processReadBuffer()},this._onerror=(Q)=>{var J;(J=this.onerror)===null||J===void 0||J.call(this,Q)}}async start(){if(this._started)throw new Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){var $,X;while(!0)try{let Q=this._readBuffer.readMessage();if(Q===null)break;($=this.onmessage)===null||$===void 0||$.call(this,Q)}catch(Q){(X=this.onerror)===null||X===void 0||X.call(this,Q)}}async close(){var $;if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),($=this.onclose)===null||$===void 0||$.call(this)}send($){return new Promise((X)=>{let Q=$W($);if(this._stdout.write(Q))X();else this._stdout.once("drain",X)})}}q4();var mY=y$("StdioTransport");async function XW($){try{let X=new G8;await $.connect(X)}catch(X){mY.info(JSON.stringify({jsonrpc:"2.0",id:null,error:{code:-32000,message:`Server startup failed: ${X.message}`}})),process.exit(1)}}XW(k1);
41
41
 
42
- //# debugId=A644BBB9B2A1590564756E2164756E21
42
+ //# debugId=AB64C629C532F8A864756E2164756E21
43
43
  //# sourceMappingURL=cli.js.map