@hey-api/openapi-ts 0.80.11 → 0.80.12

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/internal.cjs CHANGED
@@ -9,6 +9,6 @@ ${JSON.stringify(s,null,2)}`);}return r};var ba=({operation:e,plugin:t})=>{if(!t
9
9
  `}),S):g.nodes.push(S),g.methods.add(x),r.set(f,g);});});let i=a=>{if(s.has(a.className))return;if(a.classes.size)for(let c of a.classes){let m=r.get(c);i(m),a.nodes.push(n.propertyDeclaration({initializer:n.newExpression({argumentsArray:[],expression:n.identifier({text:N({config:{case:"preserve",name:t.config.httpResources.classNameBuilder},name:m.className})})}),name:E({case:"camelCase",value:m.className})}));}let p=n.classDeclaration({decorator:a.root?{args:[{providedIn:"root"}],name:"Injectable"}:void 0,exportClass:a.root,name:N({config:{case:"preserve",name:t.config.httpResources.classNameBuilder},name:a.className}),nodes:a.nodes});e.add(p),s.add(a.className);};for(let a of r.values())i(a);},Lf=({file:e,plugin:t})=>{t.forEach("operation",({operation:r})=>{let s=le({context:t.context,operation:r}),o=Vf({file:e,functionName:t.config.httpResources.methodNameBuilder(r),isRequiredOptions:s,operation:r,plugin:t});e.add(o);});},Aa=({file:e,isRequiredOptions:t,operation:r,plugin:s,responseTypeName:o})=>{let i=s.getPlugin("@hey-api/sdk"),a=s.config.httpRequests.asClass,p,c=t?n.callExpression({functionName:"options",parameters:[]}):n.conditionalExpression({condition:n.identifier({text:"options"}),whenFalse:n.identifier({text:"undefined"}),whenTrue:n.callExpression({functionName:"options",parameters:[]})});if(a){let m=pt({context:s.context,operation:r,plugin:i}),f=Array.from(m.values())[0];if(f){let l=f.path[0],d=N({config:{case:"preserve",name:s.config.httpRequests.classNameBuilder},name:l}),y=n.callExpression({functionName:"inject",parameters:[n.identifier({text:d})]});for(let x=1;x<f.path.length;x++){let S=f.path[x];S&&(y=n.propertyAccessExpression({expression:y,name:E({case:"camelCase",value:S})}));}let g=s.config.httpRequests.methodNameBuilder(r);y=n.propertyAccessExpression({expression:y,name:g}),p=n.callExpression({functionName:y,parameters:[c]});}}else {let m=s.config.httpRequests.methodNameBuilder(r),f=e.import({module:e.relativePathToFile({context:s.context,id:`${s.name}${Dr}`}),name:m});p=n.callExpression({functionName:f.name,parameters:[c]});}return n.callExpression({functionName:"httpResource",parameters:[n.arrowFunction({parameters:[],statements:[n.returnStatement({expression:p})]})],types:[n.typeNode(o)]})},Df=({file:e,isRequiredOptions:t,methodName:r,operation:s,plugin:o})=>{let i=o.getPlugin("@hey-api/typescript"),a=o.context.file({id:T}),p=e.import({asType:true,module:e.relativePathToFile({context:o.context,id:T}),name:a.getName(i.api.getId({operation:s,type:"data"}))}),c=e.import({asType:true,module:e.relativePathToFile({context:o.context,id:T}),name:a.getName(i.api.getId({operation:s,type:"response"}))});return n.methodDeclaration({accessLevel:"public",comment:ie({operation:s}),name:r,parameters:[{isRequired:t,name:"options",type:`() => Options<${p.name||"unknown"}, ThrowOnError>`}],returnType:void 0,statements:[n.returnStatement({expression:Aa({file:e,isRequiredOptions:t,operation:s,plugin:o,responseTypeName:c.name||"unknown"})})],types:[{default:false,extends:"boolean",name:"ThrowOnError"}]})},Vf=({file:e,functionName:t,isRequiredOptions:r,operation:s,plugin:o})=>{let i=o.getPlugin("@hey-api/typescript"),a=o.context.file({id:T}),p=e.import({asType:true,module:e.relativePathToFile({context:o.context,id:T}),name:a.getName(i.api.getId({operation:s,type:"data"}))}),c=e.import({asType:true,module:e.relativePathToFile({context:o.context,id:T}),name:a.getName(i.api.getId({operation:s,type:"response"}))});return n.constVariable({comment:ie({operation:s}),exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:r,name:"options",type:`() => Options<${p.name||"unknown"}, ThrowOnError>`}],statements:[n.returnStatement({expression:Aa({file:e,isRequiredOptions:r,operation:s,plugin:o,responseTypeName:c.name||"unknown"})})],types:[{default:false,extends:"boolean",name:"ThrowOnError"}]}),name:t})},Ia=({plugin:e})=>{let t=e.createFile({id:`${e.name}${Bs}`,path:`${e.output}${Bs}`});e.config.httpResources.asClass&&t.import({module:"@angular/core",name:"Injectable"}),e.config.httpRequests.asClass&&t.import({module:"@angular/core",name:"inject"}),t.import({module:"@angular/common/http",name:"httpResource"}),t.import({module:t.relativePathToFile({context:e.context,id:J}),name:"Options"}),e.config.httpResources.asClass?Ff({file:t,plugin:e}):Lf({file:t,plugin:e});};var Pa=({plugin:e})=>{e.config.httpRequests.enabled&&Ra({plugin:e}),e.config.httpResources.enabled&&Ia({plugin:e});};var Rn={config:{exportFromIndex:false},dependencies:["@hey-api/client-angular","@hey-api/sdk"],handler:Pa,name:"@angular/common",output:"@angular/common",resolveConfig:(e,t)=>{if(e.config.httpRequests=t.valueToObject({defaultValue:{asClass:false,classNameBuilder:"{{name}}Requests",enabled:true},mappers:{boolean:r=>({enabled:r})},value:e.config.httpRequests}),!e.config.httpRequests.methodNameBuilder){let{asClass:r}=e.config.httpRequests;e.config.httpRequests.methodNameBuilder=s=>r?String(s.id):`${String(s.id)}Request`;}if(e.config.httpResources=t.valueToObject({defaultValue:{asClass:false,classNameBuilder:"{{name}}Resources",enabled:true},mappers:{boolean:r=>({enabled:r})},value:e.config.httpResources}),!e.config.httpResources.methodNameBuilder){let{asClass:r}=e.config.httpResources;e.config.httpResources.methodNameBuilder=s=>r?String(s.id):`${String(s.id)}Resource`;}}};var Ze={baseUrl:true,bundle:true,exportFromIndex:false},Ue={dependencies:["@hey-api/typescript"],output:"client",tags:["client"]};var Bf=({plugin:e})=>{let{baseUrl:t}=e.config;if(t===false)return;if(typeof t=="string")return t;let{servers:r}=e.context.ir;if(r)return r[typeof t=="number"?t:0]?.url},Ea=({plugin:e})=>{let t=e.context.file({id:de}),r=Q({config:e.context.config,sourceOutput:t.nameWithoutExtension()}),s=t.import({module:r,name:"createClient"}),o=t.import({module:r,name:"createConfig"}),i=e.getPlugin("@hey-api/typescript"),a=e.context.file({id:T}),p=t.import({asType:true,module:t.relativePathToFile({context:e.context,id:T}),name:a.getName(i.api.getId({type:"ClientOptions"}))}),c=e.config.runtimeConfigPath?t.import({module:t.relativePathToFile({context:e.context,id:e.config.runtimeConfigPath}),name:"createClientConfig"}):void 0,m=[],f=Bf({plugin:e});if(f){let y=_e(f);if(y.protocol&&y.host&&!f.includes("{"))m.push({key:Ie(e.context.config),value:f});else if(f!=="/"&&f.startsWith("/")){let g=f.endsWith("/")?f.slice(0,-1):f;m.push({key:Ie(e.context.config),value:g});}}"throwOnError"in e.config&&e.config.throwOnError&&m.push({key:"throwOnError",value:true});let l=[n.callExpression({functionName:o.name,parameters:m.length?[n.objectExpression({obj:m})]:void 0,types:p.name?[n.typeReferenceNode({typeName:p.name})]:void 0})],d=n.constVariable({exportConst:true,expression:n.callExpression({functionName:s.name,parameters:c?[n.callExpression({functionName:c.name,parameters:l})]:l}),name:"client"});t.add(d);};var Na=({plugin:e})=>{let t=e.context.file({id:de}),r=Q({config:e.context.config,sourceOutput:t.nameWithoutExtension()}),s=e.getPlugin("@hey-api/typescript"),o=e.context.file({id:T}),i=t.import({asType:true,module:t.relativePathToFile({context:e.context,id:T}),name:o.getName(s.api.getId({type:"ClientOptions"}))}),a=t.import({asType:true,module:r,name:"Config"}),p=t.import({alias:"DefaultClientOptions",asType:true,module:r,name:"ClientOptions"}),c=n.typeReferenceNode({typeName:p.name}),m=n.typeReferenceNode({typeName:"T"}),f=n.typeAliasDeclaration({comment:["The `createClientConfig()` function will be called on client initialization","and the returned object will become the client's initial configuration.","","You may want to initialize your client this way instead of calling","`setConfig()`. This is useful for example if you're using Next.js","to ensure your client always has the correct values."],exportType:true,name:"CreateClientConfig",type:n.functionTypeNode({parameters:[n.parameterDeclaration({name:"override",required:false,type:n.typeReferenceNode({typeArguments:[n.typeIntersectionNode({types:[c,m]})],typeName:a.name})})],returnType:n.typeReferenceNode({typeArguments:[n.typeIntersectionNode({types:[n.typeReferenceNode({typeArguments:[c],typeName:"Required"}),m]})],typeName:a.name})}),typeParameters:[{default:i.name?n.typeReferenceNode({typeName:i.name}):void 0,extends:c,name:"T"}]});t.add(f);};var Qe=({plugin:e})=>{e.createFile({id:de,path:e.output}),Na({plugin:e}),Ea({plugin:e});};var An={...Ue,config:{...Ze,throwOnError:false},handler:Qe,name:"@hey-api/client-angular"};var In={...Ue,config:{...Ze,throwOnError:false},handler:Qe,name:"@hey-api/client-axios"};var Pn={...Ue,config:{...Ze,throwOnError:false},handler:Qe,name:"@hey-api/client-fetch"};var En={...Ue,config:{...Ze,throwOnError:false},handler:Qe,name:"@hey-api/client-next"};var Nn={...Ue,config:Ze,handler:Qe,name:"@hey-api/client-nuxt"};var jn={config:{},handler:()=>{},name:"legacy/angular",output:"client",tags:["client"]};var Cn={config:{},handler:()=>{},name:"legacy/axios",output:"client",tags:["client"]};var kn={config:{},handler:()=>{},name:"legacy/fetch",output:"client",tags:["client"]};var vn={config:{},handler:()=>{},name:"legacy/node",output:"client",tags:["client"]};var wn={config:{},handler:()=>{},name:"legacy/xhr",output:"client",tags:["client"]};var qn="schemas",zs=({plugin:e,schema:t})=>{e.config.type==="form"&&(t.description&&delete t.description,t["x-enum-descriptions"]&&delete t["x-enum-descriptions"],t["x-enum-varnames"]&&delete t["x-enum-varnames"],t["x-enumNames"]&&delete t["x-enumNames"],t.title&&delete t.title);},yr=({context:e,plugin:t,schema:r})=>{if(Array.isArray(r))return r.map(o=>yr({context:e,plugin:t,schema:o}));let s=structuredClone(r);if(s.$ref)return s.$ref=decodeURI(s.$ref),s;if(zs({plugin:t,schema:s}),s.additionalProperties&&typeof s.additionalProperties!="boolean"&&(s.additionalProperties=yr({context:e,plugin:t,schema:s.additionalProperties})),s.allOf&&(s.allOf=s.allOf.map(o=>yr({context:e,plugin:t,schema:o}))),s.items&&(s.items=yr({context:e,plugin:t,schema:s.items})),s.properties)for(let o in s.properties){let i=s.properties[o];typeof i!="boolean"&&(s.properties[o]=yr({context:e,plugin:t,schema:i}));}return s},At=({context:e,plugin:t,schema:r})=>{if(Array.isArray(r))return r.map(o=>At({context:e,plugin:t,schema:o}));let s=structuredClone(r);if("$ref"in s)return s.$ref=decodeURI(s.$ref),s;if(zs({plugin:t,schema:s}),s.additionalProperties&&typeof s.additionalProperties!="boolean"&&(s.additionalProperties=At({context:e,plugin:t,schema:s.additionalProperties})),s.allOf&&(s.allOf=s.allOf.map(o=>At({context:e,plugin:t,schema:o}))),s.anyOf&&(s.anyOf=s.anyOf.map(o=>At({context:e,plugin:t,schema:o}))),s.items&&(s.items=At({context:e,plugin:t,schema:s.items})),s.oneOf&&(s.oneOf=s.oneOf.map(o=>At({context:e,plugin:t,schema:o}))),s.properties)for(let o in s.properties){let i=s.properties[o];typeof i!="boolean"&&(s.properties[o]=At({context:e,plugin:t,schema:i}));}return s},ct=({context:e,plugin:t,schema:r})=>{if(Array.isArray(r))return r.map(o=>ct({context:e,plugin:t,schema:o}));let s=structuredClone(r);if(zs({plugin:t,schema:s}),s.$ref&&(s.$ref=decodeURI(s.$ref)),s.additionalProperties&&typeof s.additionalProperties!="boolean"&&(s.additionalProperties=ct({context:e,plugin:t,schema:s.additionalProperties})),s.allOf&&(s.allOf=s.allOf.map(o=>ct({context:e,plugin:t,schema:o}))),s.anyOf&&(s.anyOf=s.anyOf.map(o=>ct({context:e,plugin:t,schema:o}))),s.items&&(s.items=ct({context:e,plugin:t,schema:s.items})),s.oneOf&&(s.oneOf=s.oneOf.map(o=>ct({context:e,plugin:t,schema:o}))),s.prefixItems&&(s.prefixItems=s.prefixItems.map(o=>ct({context:e,plugin:t,schema:o}))),s.properties)for(let o in s.properties){let i=s.properties[o];typeof i!="boolean"&&(s.properties[o]=ct({context:e,plugin:t,schema:i}));}return s},Ks=({name:e,plugin:t,schema:r})=>{let s="";return t.config.nameBuilder&&(typeof t.config.nameBuilder=="function"?s=t.config.nameBuilder(e,r):s=t.config.nameBuilder.replace("{{name}}",e)),s||(s=`${e}Schema`),xe(s)},Yf=({context:e,plugin:t})=>{if(e.spec.definitions)for(let r in e.spec.definitions){let s=e.spec.definitions[r],o=yr({context:e,plugin:t,schema:s}),i=n.constVariable({assertion:"const",exportConst:true,expression:n.objectExpression({obj:o}),name:Ks({name:r,plugin:t,schema:s})});e.file({id:qn}).add(i);}},el=({context:e,plugin:t})=>{if(e.spec.components)for(let r in e.spec.components.schemas){let s=e.spec.components.schemas[r],o=At({context:e,plugin:t,schema:s}),i=n.constVariable({assertion:"const",exportConst:true,expression:n.objectExpression({obj:o}),name:Ks({name:r,plugin:t,schema:s})});e.file({id:qn}).add(i);}},tl=({context:e,plugin:t})=>{if(e.spec.components)for(let r in e.spec.components.schemas){let s=e.spec.components.schemas[r],o=ct({context:e,plugin:t,schema:s}),i=n.constVariable({assertion:"const",exportConst:true,expression:n.objectExpression({obj:o}),name:Ks({name:r,plugin:t,schema:s})});e.file({id:qn}).add(i);}},ja=({plugin:e})=>{if(e.createFile({id:qn,path:e.output}),"swagger"in e.context.spec){Yf({context:e.context,plugin:e});return}switch(e.context.spec.openapi){case "3.0.0":case "3.0.1":case "3.0.2":case "3.0.3":case "3.0.4":el({context:e.context,plugin:e});break;case "3.1.0":case "3.1.1":tl({context:e.context,plugin:e});break;default:throw new Error("Unsupported OpenAPI specification")}};var Ws=(e,t)=>{let r=I();if(Array.isArray(e))return e.map(o=>Ws(o));if(typeof e!="object"||e===null)return e;let s={...e};return Object.entries(s).forEach(([o,i])=>{if(r.plugins["@hey-api/schemas"]?.config.type==="form"&&["description","x-enum-descriptions","x-enum-varnames","x-enumNames","title"].includes(o)&&t!=="properties"){delete s[o];return}o==="$ref"&&typeof i=="string"&&(s[o]=decodeURIComponent(i)),i&&typeof i=="object"&&(s[o]=Ws(i,o));}),s},rl=(e,t)=>{let r=I(),s=Ft(e),o=r.plugins["@hey-api/schemas"];return o?.config.nameBuilder?typeof o.config.nameBuilder=="function"?o.config.nameBuilder(s,t):o.config.nameBuilder.replace("{{name}}",s):`${s}Schema`},Ca=({files:e,openApi:t,plugin:r})=>{let s=I();e.schemas=new Me({dir:s.output.path,exportFromIndex:r.config.exportFromIndex,id:"schemas",name:"schemas.ts"});let o=(i,a)=>{let p=Ws(a),c=n.objectExpression({obj:p}),m=n.constVariable({assertion:"const",exportConst:true,expression:c,name:rl(i,a)});e.schemas.add(m);};"swagger"in t&&Object.entries(t.definitions??{}).forEach(([i,a])=>{o(i,a);}),"openapi"in t&&Object.entries(t.components?.schemas??{}).forEach(([i,a])=>{o(i,a);});};var $n={config:{exportFromIndex:false,nameBuilder:e=>`${e}Schema`,type:"json"},handler:ja,handlerLegacy:Ca,name:"@hey-api/schemas",output:"schemas"};var Wt=({meta:e,onImport:t,...r})=>{if(!e)return {created:false,name:""};let{created:s,name:o}=Te({meta:e,...r});return o&&t(o),{created:s,name:o}},$a=e=>`${e}ModelResponseTransformer`,Ht=e=>`${E({case:"PascalCase",value:e})}Data`,gr=e=>`${E({case:"PascalCase",value:e})}Error`,Hs=e=>`${e}Transformer`,Xe=e=>`${E({case:"PascalCase",value:e})}Response`,Zs=({importedType:e,throwOnError:t})=>{let r=z.OptionsLegacyParser.name;return t?`${r}<${e||"unknown"}, ${t}>`:e?`${r}<${e}>`:r},ka=(e,t)=>{let r=I(),{name:s}=Te({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Ht}),o=He(t.parameters);if(!X(r))return [{isRequired:o,name:"options",type:Zs({importedType:s,throwOnError:"ThrowOnError"})}];if(!t.parameters.length)return [];let i=a=>{if(a.default!==void 0)return JSON.stringify(a.default,null,4)};return r.useOptions?[{default:o?void 0:{},name:"data",type:s}]:t.parameters.map(a=>{let p=`${s}['${a.name}']`;return {default:a?.default,isRequired:(!a.isRequired&&!i(a)?"?":"")=="",name:a.name,type:p}})},va=(e,t)=>{let r=I(),s=n.typeNode("void");if(t.responses.filter(a=>a.responseTypes.includes("success")).length){let{name:a}=Te({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Xe});s=n.typeUnionNode({types:[a]});}return r.useOptions&&r.plugins["@hey-api/sdk"]?.config.response==="response"&&(s=n.typeNode("ApiResult",[s])),j(r).name==="legacy/angular"?s=n.typeNode("Observable",[s]):s=n.typeNode("CancelablePromise",[s]),s},wa=e=>{let t=I();if(!X(t))return [e.deprecated&&"@deprecated",e.summary&&B(e.summary),e.description&&B(e.description)];let r=[];e.parameters.length&&(t.useOptions?r=["@param data The data for the request.",...e.parameters.map(i=>`@param data.${i.name} ${i.description?B(i.description):""}`)]:r=e.parameters.map(i=>`@param ${i.name} ${i.description?B(i.description):""}`));let s=e.responses.filter(i=>i.responseTypes.includes("success"));return [e.deprecated&&"@deprecated",e.summary&&B(e.summary),e.description&&B(e.description),...r,...s.map(i=>`@returns ${i.type} ${i.description?B(i.description):""}`),"@throws ApiError"]},sl=({client:e,onClientImport:t,onImport:r,operation:s})=>{let o=I(),i=Xe(s.name),{name:a}=Te({client:e,meta:{$ref:`transformers/${i}`,name:i},nameTransformer:Hs});if(a&&r(a),!X(o)){let f=[{spread:"options"}],d=s.parameters.filter(y=>y.in==="body"||y.in==="formData").map(y=>y.mediaType||(y.in==="formData"?"multipart/form-data":void 0)).filter(Boolean).filter(Tt);return d.length===1&&(d[0]==="multipart/form-data"&&(f=[...f,{spread:"formDataBodySerializer"},{key:"headers",value:[{key:"Content-Type",value:null},{spread:"options?.headers"}]}],t?.("formDataBodySerializer")),d[0]==="application/x-www-form-urlencoded"&&(f=[...f,{spread:"urlSearchParamsBodySerializer"},{key:"headers",value:[{key:"Content-Type",value:d[0]},{spread:"options?.headers"}]}],t?.("urlSearchParamsBodySerializer"))),f=[...f,{key:"url",value:s.path}],a&&(f=[...f,{key:"responseTransformer",value:a}]),n.objectExpression({identifiers:["responseTransformer"],obj:f})}let p=f=>f.reduce((l,d)=>{let y=d.prop,g=o.useOptions?`data.${d.name}`:d.name;return y===g?l[y]=y:et(y)===y?l[y]=g:l[`'${y}'`]=g,l},{}),c={method:s.method,url:s.path};s.parametersPath.length&&(c.path=p(s.parametersPath)),s.parametersCookie.length&&(c.cookies=p(s.parametersCookie)),s.parametersHeader.length&&(c.headers=p(s.parametersHeader)),s.parametersQuery.length&&(c.query=p(s.parametersQuery)),s.parametersForm.length&&(c.formData=p(s.parametersForm)),s.parametersBody&&(s.parametersBody.in==="formData"&&(o.useOptions?c.formData=`data.${s.parametersBody.name}`:c.formData=s.parametersBody.name),s.parametersBody.in==="body"&&(o.useOptions?c.body=`data.${s.parametersBody.name}`:c.body=s.parametersBody.name)),s.parametersBody?.mediaType&&(c.mediaType=s.parametersBody?.mediaType),s.responseHeader&&(c.responseHeader=s.responseHeader),a&&(c.responseTransformer=a);let m=s.responses.filter(f=>f.responseTypes.includes("error"));if(m.length>0){let f={};m.forEach(l=>{f[l.code]=l.description??"";}),c.errors=f;}return n.objectExpression({identifiers:["body","cookies","formData","headers","path","query","responseTransformer"],obj:c,shorthand:true})},Re=({config:e,handleIllegal:t,id:r,operation:s})=>e.plugins["@hey-api/sdk"]?.config.methodNameBuilder?e.plugins["@hey-api/sdk"].config.methodNameBuilder(s):t&&r.match(ye)?`${r}_`:r,qa=({client:e,onClientImport:t,onImport:r,operation:s})=>{let o=I(),i=sl({client:e,onClientImport:t,onImport:r,operation:s});if(!X(o)){let p=Te({client:e,meta:{$ref:s.name,name:s.name},nameTransformer:gr}).name,m=s.responses.filter(f=>f.responseTypes.includes("success")).length?Te({client:e,meta:{$ref:s.name,name:s.name},nameTransformer:Xe}).name:"void";return [n.returnFunctionCall({args:[i],name:`(options?.client ?? client).${s.method.toLocaleLowerCase()}`,types:p&&m?[m,p,"ThrowOnError"]:p?["unknown",p,"ThrowOnError"]:m?[m,"unknown","ThrowOnError"]:[]})]}return Ct(o)?[n.returnFunctionCall({args:[i],name:"this.httpRequest.request"})]:j(o).name==="legacy/angular"?[n.returnFunctionCall({args:["OpenAPI","this.http",i],name:"__request"})]:[n.returnFunctionCall({args:["OpenAPI",i],name:"__request"})]},ol=({client:e,onClientImport:t,onImport:r,onNode:s,service:o})=>{let i=I(),a=j(i),p=X(i);for(let d of o.operations)d.parameters.length&&Wt({client:e,meta:{$ref:d.name,name:d.name},nameTransformer:Ht,onImport:r}),p||Wt({client:e,meta:{$ref:d.name,name:d.name},nameTransformer:gr,onImport:r}),d.responses.filter(g=>g.responseTypes.includes("success")).length&&Wt({client:e,meta:{$ref:d.name,name:d.name},nameTransformer:Xe,onImport:r});let c={default:("throwOnError"in a.config?a.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"};if(!i.plugins["@hey-api/sdk"]?.config.asClass&&!Ct(i)){for(let d of o.operations){let y={parameters:ka(e,d),returnType:p?va(e,d):void 0,statements:qa({client:e,onClientImport:t,onImport:r,operation:d}),types:p?void 0:[c]},g=a.name==="legacy/angular"?n.anonymousFunction(y):n.arrowFunction(y),x=n.constVariable({comment:wa(d),exportConst:true,expression:g,name:Re({config:i,handleIllegal:true,id:d.name,operation:d})});s(x);}return}let m=o.operations.map(d=>n.methodDeclaration({accessLevel:"public",comment:wa(d),isStatic:Ct(i)===void 0&&a.name!=="legacy/angular",name:Re({config:i,id:d.name,operation:d}),parameters:ka(e,d),returnType:p?va(e,d):void 0,statements:qa({client:e,onClientImport:t,onImport:r,operation:d}),types:p?void 0:[c]}));if(!m.length)return;Ct(i)?m=[n.constructorDeclaration({multiLine:false,parameters:[{accessLevel:"public",isReadOnly:true,name:"httpRequest",type:"BaseHttpRequest"}]}),...m]:a.name==="legacy/angular"&&(m=[n.constructorDeclaration({multiLine:false,parameters:[{accessLevel:"public",isReadOnly:true,name:"http",type:"HttpClient"}]}),...m]);let f=[];m.forEach((d,y)=>{y&&f.push(n.identifier({text:`
10
10
  `})),f.push(d);});let l=n.classDeclaration({decorator:a.name==="legacy/angular"?{args:[{providedIn:"root"}],name:"Injectable"}:void 0,exportClass:true,name:dr({config:i,name:o.name}),nodes:f});s(l);},Ma=({client:e,files:t,plugin:r})=>{let s=I(),o=X(s),i="sdk";if(t.sdk=new Me({dir:s.output.path,exportFromIndex:r.config.exportFromIndex,id:"sdk",name:`${i}.ts`}),!o)t.sdk.import({module:Q({config:s,sourceOutput:i}),name:"createClient"}),t.sdk.import({module:Q({config:s,sourceOutput:i}),name:"createConfig"}),t.sdk.import({...z.OptionsLegacyParser,module:Q({config:s,sourceOutput:i})});else if(j(s).name==="legacy/angular"?(t.sdk.import({module:"@angular/core",name:"Injectable"}),Ct(s)||t.sdk.import({module:"@angular/common/http",name:"HttpClient"}),t.sdk.import({asType:true,module:"rxjs",name:"Observable"})):t.sdk.import({asType:true,module:"./core/CancelablePromise",name:"CancelablePromise"}),s.plugins["@hey-api/sdk"]?.config.response==="response"&&t.sdk.import({asType:true,module:"./core/ApiResult",name:"ApiResult"}),Ct(s)){let p=j(s);t.sdk.import({asType:p.name!=="legacy/angular",module:"./core/BaseHttpRequest",name:"BaseHttpRequest"});}else t.sdk.import({module:"./core/OpenAPI",name:"OpenAPI"}),t.sdk.import({alias:"__request",module:"./core/request",name:"request"});if(!o){let a=j(s),p=n.constVariable({exportConst:true,expression:n.callExpression({functionName:"createClient",parameters:[n.callExpression({functionName:"createConfig",parameters:["throwOnError"in a&&a.throwOnError?n.objectExpression({obj:[{key:"throwOnError",value:true}]}):void 0]})]}),name:"client"});t.sdk.add(p);}for(let a of e.services)ol({client:e,onClientImport:p=>{t.sdk.import({module:Q({config:s,sourceOutput:i}),name:p});},onImport:p=>{t.sdk.import({asType:!p.endsWith("Transformer"),module:`./${t.types.nameWithoutExtension()}`,name:p});},onNode:p=>{t.sdk.add(p);},service:a});};var Fa=({clientOptions:e,plugin:t})=>{let r=t.context.file({id:J}),o=j(t.context.config).name==="@hey-api/client-nuxt",i=Q({config:t.context.config,sourceOutput:r.nameWithoutExtension()}),a=r.import({asType:true,module:i,name:"TDataShape"}),p=r.import({asType:true,module:i,name:"Client"}),c=n.typeAliasDeclaration({exportType:true,name:"Options",type:n.typeIntersectionNode({types:[n.typeReferenceNode({typeArguments:o?[n.typeReferenceNode({typeName:"TComposable"}),n.typeReferenceNode({typeName:"TData"}),n.typeReferenceNode({typeName:bs}),n.typeReferenceNode({typeName:$e})]:[n.typeReferenceNode({typeName:"TData"}),n.typeReferenceNode({typeName:"ThrowOnError"})],typeName:e.name}),n.typeInterfaceNode({properties:[{comment:["You can provide a client instance returned by `createClient()` instead of","individual options. This might be also useful if you want to implement a","custom client."],isRequired:!t.config.client,name:"client",type:n.typeReferenceNode({typeName:p.name})},{comment:["You can pass arbitrary values through the `meta` object. This can be","used to access values that aren't defined as part of the SDK function."],isRequired:false,name:"meta",type:n.typeReferenceNode({typeArguments:[n.keywordTypeNode({keyword:"string"}),n.keywordTypeNode({keyword:"unknown"})],typeName:"Record"})}],useLegacyResolution:false})]}),typeParameters:o?[n.typeParameterDeclaration({constraint:n.typeReferenceNode({typeName:"Composable"}),name:"TComposable"}),n.typeParameterDeclaration({constraint:n.typeReferenceNode({typeName:a.name}),defaultType:n.typeReferenceNode({typeName:a.name}),name:"TData"}),n.typeParameterDeclaration({defaultType:n.keywordTypeNode({keyword:"unknown"}),name:bs}),n.typeParameterDeclaration({defaultType:n.keywordTypeNode({keyword:"undefined"}),name:$e})]:[n.typeParameterDeclaration({constraint:n.typeReferenceNode({typeName:a.name}),defaultType:n.typeReferenceNode({typeName:a.name}),name:"TData"}),n.typeParameterDeclaration({constraint:n.keywordTypeNode({keyword:"boolean"}),defaultType:n.keywordTypeNode({keyword:"boolean"}),name:"ThrowOnError"})]});r.add(c);};var al=({plugin:e})=>{let t=n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:n.this(),name:"_client"}),operator:"=",right:n.propertyAccessExpression({expression:n.identifier({text:"args"}),name:"client"})})});return [n.propertyDeclaration({initializer:e.config.client?n.identifier({text:"_heyApiClient"}):void 0,modifier:"protected",name:"_client",type:b__default.default.factory.createTypeReferenceNode("Client")}),n.identifier({text:`
11
11
  `}),n.constructorDeclaration({multiLine:true,parameters:[{isRequired:!e.config.client,name:"args",type:n.typeInterfaceNode({properties:[{isRequired:!e.config.client,name:"client",type:"Client"}],useLegacyResolution:false})}],statements:[e.config.client?n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"args"}),isOptional:true,name:"client"}),thenStatement:n.block({statements:[t]})}):t]})]},pl=({plugin:e})=>{let t=j(e.context.config),r=t.name==="@hey-api/client-angular",s=t.name==="@hey-api/client-nuxt",o=e.context.file({id:J}),i=new Map,a=new Set,p=e.config.instance?al({plugin:e}):[];e.forEach("operation",({operation:m})=>{let f=le({context:e.context,operation:m}),l=e.getPlugin("@hey-api/typescript"),d=e.context.file({id:T}),y=o.import({asType:true,module:o.relativePathToFile({context:e.context,id:T}),name:s?d.getName(l.api.getId({operation:m,type:"response"})):void 0}),g=pt({context:e.context,operation:m,plugin:e});for(let x of g.values())x.path.forEach((S,O)=>{i.has(S)||i.set(S,{className:S,classes:new Set,methods:new Set,nodes:[],root:!O});let v=x.path[O-1];if(v&&v!==S){let C=i.get(v);C.classes.add(S),i.set(v,C);}if(!(x.path.length===O+1))return;let $=i.get(S);if($.methods.has(x.methodName))return;let F=Vs({file:o,isRequiredOptions:f,operation:m,plugin:e}),W=_s({isRequiredOptions:f,opParameters:F,operation:m,plugin:e}),L=n.methodDeclaration({accessLevel:"public",comment:ie({operation:m}),isStatic:r?false:!e.config.instance,name:x.methodName,parameters:F.parameters,returnType:void 0,statements:W,types:s?[{extends:n.typeNode("Composable"),name:rr},{default:y.name?n.typeReferenceNode({typeName:y.name}):n.typeNode("undefined"),extends:y.name?n.typeReferenceNode({typeName:y.name}):void 0,name:$e}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]});$.nodes.length?$.nodes.push(n.identifier({text:`
12
- `}),L):$.nodes.push(L),$.methods.add(x.methodName),i.set(S,$);});});let c=m=>{if(a.has(m.className))return;if(m.classes.size)for(let l of m.classes){let d=i.get(l);c(d),m.nodes.push(n.propertyDeclaration({initializer:e.config.instance?n.newExpression({argumentsArray:e.config.instance?[n.objectExpression({multiLine:false,obj:[{key:"client",value:n.propertyAccessExpression({expression:n.this(),name:"_client"})}]})]:[],expression:n.identifier({text:d.className})}):n.identifier({text:d.className}),modifier:e.config.instance?void 0:"static",name:E({case:"camelCase",value:d.className})}));}let f=n.classDeclaration({decorator:m.root&&r?{args:[{providedIn:"root"}],name:"Injectable"}:void 0,exportClass:m.root,extendedClasses:e.config.instance?["_HeyApiClient"]:void 0,name:m.className,nodes:m.nodes});o.add(f),a.add(m.className);};if(p.length){let m=n.classDeclaration({exportClass:false,name:"_HeyApiClient",nodes:p});o.add(m);}for(let m of i.values())c(m);},cl=({plugin:e})=>{let t=j(e.context.config),r=t.name==="@hey-api/client-nuxt",s=e.context.file({id:J});e.forEach("operation",({operation:o})=>{let i=le({context:e.context,operation:o}),a=e.getPlugin("@hey-api/typescript"),p=e.context.file({id:T}),c=s.import({asType:true,module:s.relativePathToFile({context:e.context,id:T}),name:r?p.getName(a.api.getId({operation:o,type:"response"})):void 0}),m=Vs({file:s,isRequiredOptions:i,operation:o,plugin:e}),f=_s({isRequiredOptions:i,opParameters:m,operation:o,plugin:e}),l=n.constVariable({comment:ie({operation:o}),exportConst:true,expression:n.arrowFunction({parameters:m.parameters,returnType:void 0,statements:f,types:r?[{extends:n.typeNode("Composable"),name:rr},{default:c.name?n.typeReferenceNode({typeName:c.name}):n.typeNode("undefined"),extends:c.name?n.typeReferenceNode({typeName:c.name}):void 0,name:$e}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]}),name:Re({config:e.context.config,handleIllegal:true,id:o.id,operation:o})});s.add(l);});},La=({plugin:e})=>{let t=e.createFile({id:J,path:e.output}),r=Q({config:e.context.config,sourceOutput:t.nameWithoutExtension()}),s=t.import({...z.Options,alias:"ClientOptions",module:r}),o=j(e.context.config),i=o.name==="@hey-api/client-angular";o.name==="@hey-api/client-nuxt"&&t.import({asType:true,module:r,name:"Composable"}),i&&e.config.asClass&&t.import({module:"@angular/core",name:"Injectable"}),Fa({clientOptions:s,plugin:e}),e.config.asClass?pl({plugin:e}):cl({plugin:e});};var Mn={config:{asClass:false,auth:true,classNameBuilder:"{{name}}",classStructure:"auto",client:true,exportFromIndex:true,instance:false,operationId:true,params_EXPERIMENTAL:"default",response:"body",responseStyle:"fields",transformer:false,validator:false},dependencies:["@hey-api/typescript"],handler:La,handlerLegacy:Ma,name:"@hey-api/sdk",output:"sdk",resolveConfig:(e,t)=>{e.config.client?(typeof e.config.client=="boolean"&&(e.config.client=t.pluginByTag("client",{defaultPlugin:"@hey-api/client-fetch"})),e.dependencies.add(e.config.client)):e.config.client=false,e.config.transformer?(typeof e.config.transformer=="boolean"&&(e.config.transformer=t.pluginByTag("transformer")),e.dependencies.add(e.config.transformer)):e.config.transformer=false,typeof e.config.validator!="object"&&(e.config.validator={request:e.config.validator,response:e.config.validator}),e.config.validator.request?(typeof e.config.validator.request=="boolean"&&(e.config.validator.request=t.pluginByTag("validator")),e.dependencies.add(e.config.validator.request)):e.config.validator.request=false,e.config.validator.response?(typeof e.config.validator.response=="boolean"&&(e.config.validator.response=t.pluginByTag("validator")),e.dependencies.add(e.config.validator.response)):e.config.validator.response=false,e.config.instance?(typeof e.config.instance!="string"&&(e.config.instance="Sdk"),e.config.asClass=true):e.config.instance=false,e.config.classNameBuilder==="{{name}}"&&e.config.client==="@hey-api/client-angular"&&(e.config.classNameBuilder="{{name}}Service");}};var fl="$OpenApiTs",oe={$refs:[],base:"",description:null,enum:[],enums:[],export:"interface",imports:[],in:"",isDefinition:false,isNullable:false,isReadOnly:false,isRequired:false,link:null,name:"",properties:[],template:null,type:""},ll=({comments:e,leadingComment:t,meta:r,obj:s,onNode:o,...i})=>{if(!r)return;let{created:a,name:p}=Te({create:true,meta:r,...i});if(a){let c=n.enumDeclaration({comments:e,leadingComment:t,name:p,obj:s});o(c);}},mt=({comment:e,meta:t,onCreated:r,onNode:s,type:o,...i})=>{if(!t)return {created:false,name:""};let a=Te({create:true,meta:t,...i}),{created:p,name:c}=a;if(p){let m=n.typeAliasDeclaration({comment:e,exportType:true,name:c,type:o});s(m),r?.(c);}return a},ul=e=>{let t=[];Da(e),e.model.enums.forEach(r=>yl({...e,model:r,onNode:s=>{t.push(s);}})),t.length&&e.onNode(n.namespaceDeclaration({name:e.model.name,statements:t}));},dl=({client:e,model:t,onNode:r})=>{let s=I(),o={},i={};t.enum.forEach(c=>{let{key:m,value:f}=qs(c);o[m]=f;let l=c.customDescription||c.description;l&&(i[m]=[B(l)]);});let a=[t.description&&B(t.description),t.deprecated&&"@deprecated"],p=s.plugins["@hey-api/typescript"];if(p?.config&&typeof p.config.enums=="object"&&p.config.enums.enabled&&p.config.enums.mode==="typescript"){ll({client:e,comments:i,leadingComment:a,meta:t.meta,obj:o,onNode:r});return}mt({client:e,comment:a,meta:t.meta,onCreated:c=>{let m=s.plugins["@hey-api/typescript"];if(m?.config&&typeof m.config.enums=="object"&&m.config.enums.enabled&&m.config.enums.mode==="javascript"){let f=n.objectExpression({multiLine:true,obj:Object.entries(o).map(([d,y])=>({comments:i[d],key:d,value:y})),unescape:true}),l=n.constVariable({assertion:"const",comment:a,exportConst:true,expression:f,name:c});r(l);}},onNode:r,type:ia(t.enum)});},yl=({model:e,onNode:t})=>{let r={},s={};e.enum.forEach(o=>{let{key:i,value:a}=qs(o);r[i]=a;let p=o.customDescription||o.description;p&&(s[i]=[B(p)]);}),t(n.enumDeclaration({comments:s,leadingComment:[e.description&&B(e.description),e.deprecated&&"@deprecated"],name:e.meta?.name||e.name,obj:r}));},Da=({client:e,model:t,onNode:r})=>{mt({client:e,comment:[t.description&&B(t.description),t.deprecated&&"@deprecated"],meta:t.meta,onNode:r,type:Se(t)});},gl=e=>{switch(e.model.export){case "all-of":case "any-of":case "one-of":case "interface":return ul(e);case "enum":return dl(e);default:return Da(e)}},hl=({client:e,onNode:t})=>{let r={},s=I();if(!s.plugins["@hey-api/sdk"]&&!s.plugins["@hey-api/typescript"]?.config.tree)return;let o=X(s);for(let a of e.services)for(let p of a.operations){if(!p.parameters.length&&!p.responses.length)continue;r[p.path]||(r[p.path]={});let c=r[p.path];c[p.method]||(c[p.method]={});let m=c[p.method];if(m.$ref=p.name,p.responses.length>0){if(m.res||(m.res={}),Array.isArray(m.res))continue;p.responses.forEach(l=>{m.res[l.code]=l;});}if(p.parameters.length>0){let l={mediaType:null,...oe,in:"body",name:"body",prop:"body"},d=p.parameters.filter(O=>O.in==="body");d.length||(d=p.parameters.filter(O=>O.in==="formData")),d.length===1?l={...oe,...d[0],in:"body",isRequired:d[0].isRequired,name:"body",prop:"body"}:d.length>1&&(l={...oe,in:"body",isRequired:d.some(O=>O.isRequired),mediaType:"multipart/form-data",name:"body",prop:"body",properties:d});let y={...oe,in:"header",isRequired:He(p.parameters.filter(O=>O.in==="header")),mediaType:null,name:o?"header":"headers",prop:o?"header":"headers",properties:p.parameters.filter(O=>O.in==="header").sort(qr)},g={...oe,in:"path",isRequired:He(p.parameters.filter(O=>O.in==="path")),mediaType:null,name:"path",prop:"path",properties:p.parameters.filter(O=>O.in==="path").sort(qr)},x={...oe,in:"query",isRequired:He(p.parameters.filter(O=>O.in==="query")),mediaType:null,name:"query",prop:"query",properties:p.parameters.filter(O=>O.in==="query").sort(qr)},S=o?oa([...p.parameters]):[l,y,g,x].filter(O=>O.properties.length||O.$refs.length||O.mediaType);m.req=S,mt({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:Ht,onNode:t,type:Se({...oe,properties:S})});}let f=p.responses.filter(l=>l.responseTypes.includes("success"));if(f.length>0){mt({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:Xe,onNode:t,type:Se({...oe,export:"any-of",properties:f})});let l=p.responses.filter(d=>d.responseTypes.includes("error"));o||mt({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:gr,onNode:t,type:Se(l.length?{...oe,export:"one-of",properties:l}:{...oe,base:"unknown"})});}}let i=Object.entries(r).map(([a,p])=>{let c=Object.entries(p).map(([f,l])=>{let d=f,y=[];if(l.req){let x=l.$ref,{name:S}=Te({client:e,meta:{$ref:x,name:x},nameTransformer:Ht}),O={...oe,base:S,export:"reference",isRequired:true,name:"req",properties:[],type:S};y=[...y,O];}if(l.res){let x=Object.entries(l.res).map(([O,v])=>({...oe,...v,isRequired:true,name:String(O)})),S={...oe,isRequired:true,name:"res",properties:x};y=[...y,S];}return {...oe,isRequired:true,name:d.toLocaleLowerCase(),properties:y}}).filter(Boolean);return {...oe,isRequired:true,name:`'${a}'`,properties:c}});s.plugins["@hey-api/typescript"]?.config.tree&&mt({client:e,meta:{$ref:"@hey-api/openapi-ts",name:fl},onNode:t,type:Se({...oe,properties:i})});},Va=({client:e,files:t,plugin:r})=>{let s=I();t.types=new Me({dir:s.output.path,exportFromIndex:r.config.exportFromIndex,id:"types",name:"types.ts"});let o=i=>{t.types?.add(i);};for(let i of e.models)gl({client:e,model:i,onNode:o});hl({client:e,onNode:o});};var It="data",xl=e=>e.base==="unknown"&&e.export==="generic"&&e.type==="unknown",_a=({client:e,model:t})=>t.$refs.map(s=>{let o=e.models.find(i=>i.meta?.$ref===s);if(!o)throw new Error(`Ref ${s} could not be found. Transformers cannot be generated without having access to all refs.`);return o}),Ba=e=>{let t=e.model.meta.name,{name:r}=mt({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:$a,onCreated:o=>{let i=Fn({...e,meta:{$ref:`transformers/${t}`,name:o},path:[It]});za({...e,async:false,name:o,statements:i});},type:`(${It}: any) => ${t}`});return {created:!!e.client.types[r],name:r}},bl=e=>{let{model:t}=e,r=_a(e);if(r.length===1){let{created:s,name:o}=Ba({...e,model:r[0]});return s?[n.transformArrayMutation({path:e.path,transformerName:o})]:[]}return $r(t)||t.link&&!Array.isArray(t.link)&&t.link.export==="any-of"&&t.link.properties.find(s=>$r(s))?[n.transformArrayMap({path:e.path,transformExpression:n.conditionalExpression({condition:n.identifier({text:"item"}),whenFalse:n.identifier({text:"item"}),whenTrue:n.transformNewDate({parameterName:"item"})})})]:[]},Ol=e=>{let{model:t}=e,r=[...e.path,t.name];return t.type==="string"&&t.export!=="array"&&$r(t)?[n.transformDateMutation({path:r})]:Fn({...e,model:t,path:r})},Fn=e=>{let{model:t}=e;switch(t.export){case "array":return bl(e);case "interface":return t.properties.flatMap(r=>Ol({...e,model:r}));case "reference":{if(t.$refs.length!==1)return [];let r=_a(e),{created:s,name:o}=Ba({...e,model:r[0]});return s?t.in==="response"?[n.expressionToStatement({expression:n.callExpression({functionName:o,parameters:[It]})})]:n.transformFunctionMutation({path:e.path,transformerName:o}):[]}default:return []}},za=({async:e,client:t,name:r,onNode:s,onRemoveNode:o,statements:i})=>{let a={created:false,name:r};if(!i.length)return pa({client:t,name:r}),o?.(),a;let p=n.arrowFunction({async:e,multiLine:true,parameters:[{name:It}],statements:[...i,n.returnVariable({expression:It})]}),c=n.constVariable({exportConst:true,expression:p,name:r,typeName:r});return s(c),{created:true,name:r}},Ka=({client:e,files:t})=>{let r=I(),s=i=>{t.types?.add(i);},o=()=>{t.types?.removeNode_LEGACY();};for(let i of e.services)for(let a of i.operations){let p=a.responses.filter(f=>f.responseTypes.includes("success"));if(!p.length)continue;let c=p.filter(f=>!xl(f));if(!c.length)continue;if(c.length>1){r.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${q(a)} has ${c.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);continue}let m=Xe(a.name);mt({client:e,meta:{$ref:`transformers/${m}`,name:m},nameTransformer:Hs,onCreated:f=>{let l=p.length>1?p.flatMap(d=>{let y=Fn({client:e,meta:{$ref:`transformers/${m}`,name:m},model:d,onNode:s,onRemoveNode:o,path:[It]});return y.length?[n.ifStatement({expression:n.safeAccessExpression(["data"]),thenStatement:n.block({statements:y})})]:[]}):Fn({client:e,meta:{$ref:`transformers/${m}`,name:m},model:p[0],onNode:s,onRemoveNode:o,path:[It]});za({async:true,client:e,name:f,onNode:s,onRemoveNode:o,statements:l});},onNode:s,type:`(${It}: any) => Promise<${m}>`});}};var Ln={config:{bigInt:true,dates:true,exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:ha,handlerLegacy:Ka,name:"@hey-api/transformers",output:"transformers",tags:["transformer"]};var Ha=({context:e,name:t})=>(G.lastIndex=0,G.test(t)?t.startsWith("-")?b__default.default.factory.createStringLiteral(t):b__default.default.factory.createNumericLiteral(t):E({case:e.config.output.case,value:t}));var Ne=({schema:e})=>{let t=[];return e.title&&t.push(B(e.title)),e.description&&t.push(B(e.description)),e.deprecated&&t.push("@deprecated"),t.length?t:void 0};var Dn=n.keywordTypeNode({keyword:"string"}),Rl=({server:e})=>{let t=_e(e.url);return t.protocol&&t.host?n.literalTypeNode({literal:n.stringLiteral({text:e.url})}):n.templateLiteralType({value:[t.protocol||Dn,"://",t.host||Dn,t.port?`:${t.port}`:"",t.path||""]})},Za=({nodeInfo:e,plugin:t,servers:r})=>{let s=t.context.file({id:T}),o=j(t.context.config),i=r.map(c=>Rl({server:c}));r.length?"strictBaseUrl"in o.config&&o.config.strictBaseUrl||i.push(n.typeIntersectionNode({types:[Dn,b__default.default.factory.createTypeLiteralNode([])]})):i.push(Dn);let a=n.typeInterfaceNode({properties:[{name:Ie(t.context.config),type:n.typeUnionNode({types:i})}],useLegacyResolution:false}),p=n.typeAliasDeclaration({exportType:e.exported,name:e.node,type:a});s.add(p);};var Us=({parameters:e})=>{let t={type:"object"};if(e){let r={},s=[];for(let o in e){let i=e[o];r[i.name]=H({detectFormat:false,schema:i.schema}),i.required&&s.push(i.name);}t.properties=r,s.length&&(t.required=s);}return t},Al=({operation:e,plugin:t,state:r})=>{let s=t.context.file({id:T}),o={type:"object"},i=[];o.properties||(o.properties={}),e.body?(o.properties.body=e.body.schema,e.body.required&&i.push("body")):o.properties.body={type:"never"},e.parameters?.header&&(o.properties.headers=Us({parameters:e.parameters.header}),o.properties.headers.required&&i.push("headers")),e.parameters?.path?(o.properties.path=Us({parameters:e.parameters.path}),o.properties.path.required&&i.push("path")):o.properties.path={type:"never"},e.parameters?.query?(o.properties.query=Us({parameters:e.parameters.query}),o.properties.query.required&&i.push("query")):o.properties.query={type:"never"},o.properties.url={const:e.path,type:"string"},i.push("url"),o.required=i;let a=N({config:t.config.requests,name:e.id}),p=s.updateNode(t.api.getId({operation:e,type:"data"}),{exported:true,name:a}),c=ae({onRef:void 0,plugin:t,schema:o,state:r}),m=n.typeAliasDeclaration({exportType:p.exported,name:p.node,type:c});s.add(m);},Ua=({operation:e,plugin:t,state:r})=>{Al({operation:e,plugin:t,state:r});let s=t.context.file({id:T}),{error:o,errors:i,response:a,responses:p}=Fe(e);if(i){let c=N({config:t.config.errors,name:e.id}),m=s.updateNode(t.api.getId({operation:e,type:"errors"}),{exported:true,name:c}),f=ae({onRef:void 0,plugin:t,schema:i,state:r}),l=n.typeAliasDeclaration({exportType:m.exported,name:m.node,type:f});if(s.add(l),o){let d=N({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),y=s.updateNode(t.api.getId({operation:e,type:"error"}),{exported:true,name:d}),g=n.indexedAccessTypeNode({indexType:b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m.node),objectType:m.node}),x=n.typeAliasDeclaration({exportType:y.exported,name:y.node,type:g});s.add(x);}}if(p){let c=N({config:t.config.responses,name:e.id}),m=s.updateNode(t.api.getId({operation:e,type:"responses"}),{exported:true,name:c}),f=ae({onRef:void 0,plugin:t,schema:p,state:r}),l=n.typeAliasDeclaration({exportType:m.exported,name:m.node,type:f});if(s.add(l),a){let d=N({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),y=s.updateNode(t.api.getId({operation:e,type:"response"}),{exported:true,name:d}),g=n.indexedAccessTypeNode({indexType:b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m.node),objectType:m.node}),x=n.typeAliasDeclaration({exportType:y.exported,name:y.node,type:g});s.add(x);}}};var Il=({plugin:e,schema:t})=>{let r=[];return {obj:(t.items??[]).map((o,i)=>{let a=typeof o.const;r.includes(a)||r.push(a);let p;return o.title?p=o.title:a==="number"||a==="string"?p=`${o.const}`:a==="boolean"?p=o.const?"true":"false":o.const===null?p="null":p=`${i}`,p&&(p=E({case:e.config.enums.case,stripLeadingSeparators:false,value:p}),G.lastIndex=0,G.test(p)&&e.config.enums.enabled&&e.config.enums.mode==="typescript"&&(p=`_${p}`)),{comments:Ne({schema:o}),key:p,value:o.const}}),typeofItems:r}},Pl=({onRef:e,plugin:t,schema:r,state:s})=>{if(!r.items)return n.typeArrayNode(n.keywordTypeNode({keyword:"unknown"}));r=H({detectFormat:false,schema:r});let o=[];for(let i of r.items){let a=ae({onRef:e,plugin:t,schema:i,state:s});o.push(a);}return o.length===1?n.typeArrayNode(o[0]):r.logicalOperator==="and"?n.typeArrayNode(n.typeIntersectionNode({types:o})):n.typeArrayNode(n.typeUnionNode({types:o}))},El=({schema:e})=>e.const!==void 0?n.literalTypeNode({literal:n.ots.boolean(e.const)}):n.keywordTypeNode({keyword:"boolean"}),Nl=({onRef:e,plugin:t,schema:r,state:s})=>ae({onRef:e,plugin:t,schema:{...r,type:void 0},state:s}),jl=({plugin:e,schema:t})=>t.const!==void 0?n.literalTypeNode({literal:n.ots.number(t.const)}):t.type==="integer"&&t.format==="int64"&&e.getPlugin("@hey-api/transformers")?.config.bigInt?n.typeReferenceNode({typeName:"bigint"}):n.keywordTypeNode({keyword:"number"}),Cl=({onRef:e,plugin:t,schema:r,state:s})=>{let o,i,a=[],p=[],c=r.required??[],m=false;for(let f in r.properties){let l=r.properties[f],d=ae({onRef:e,plugin:t,schema:l,state:s}),y=c.includes(f);a.push({comment:Ne({schema:l}),isReadOnly:l.accessScope==="read",isRequired:y,name:Ha({context:t.context,name:f}),type:d}),p.push(l),y||(m=true);}return r.additionalProperties&&(r.additionalProperties.type!=="never"||!p.length)&&(r.additionalProperties.type==="never"?p=[r.additionalProperties]:p.unshift(r.additionalProperties),m&&p.push({type:"undefined"}),i={isRequired:!r.propertyNames,name:"key",type:ae({onRef:e,plugin:t,schema:p.length===1?p[0]:{items:p,logicalOperator:"or"},state:s})},r.propertyNames?.$ref&&(o=ae({onRef:e,plugin:t,schema:{$ref:r.propertyNames.$ref},state:s}))),n.typeInterfaceNode({indexKey:o,indexProperty:i,properties:a,useLegacyResolution:false})},kl=({plugin:e,schema:t,state:r})=>{if(t.const!==void 0)return n.literalTypeNode({literal:n.stringLiteral({text:t.const})});if(t.format){if(t.format==="binary")return n.typeUnionNode({types:[n.typeReferenceNode({typeName:"Blob"}),n.typeReferenceNode({typeName:"File"})]});if((t.format==="date-time"||t.format==="date")&&e.getPlugin("@hey-api/transformers")?.config.dates)return n.typeReferenceNode({typeName:"Date"});if(t.format==="typeid"&&typeof t.example=="string"){let s=String(t.example).split("_");s.pop();let o=s.join("_");r.usedTypeIDs.add(o);let i=xe(E({case:e.config.case,value:o+"_id"}));return n.typeReferenceNode({typeName:i})}}return n.keywordTypeNode({keyword:"string"})},vl=({onRef:e,plugin:t,schema:r,state:s})=>{let o=[];if(r.const&&Array.isArray(r.const))o=r.const.map(i=>n.valueToExpression({value:i})??n.identifier({text:"unknown"}));else if(r.items)for(let i of r.items){let a=ae({onRef:e,plugin:t,schema:i,state:s});o.push(a);}return n.typeTupleNode({types:o})},Xa=({onRef:e,plugin:t,schema:r,state:s})=>{let o=t.getPlugin("@hey-api/transformers");if(o?.config.typeTransformers)for(let i of o.config.typeTransformers){let a=t.context.file({id:T}),p=i({file:a,schema:r});if(p)return p}switch(r.type){case "array":return Pl({onRef:e,plugin:t,schema:r,state:s});case "boolean":return El({schema:r});case "enum":return Nl({onRef:e,plugin:t,schema:r,state:s});case "integer":case "number":return jl({plugin:t,schema:r});case "never":return n.keywordTypeNode({keyword:"never"});case "null":return n.literalTypeNode({literal:n.null()});case "object":return Cl({onRef:e,plugin:t,schema:r,state:s});case "string":return kl({plugin:t,schema:r,state:s});case "tuple":return vl({onRef:e,plugin:t,schema:r,state:s});case "undefined":return n.keywordTypeNode({keyword:"undefined"});case "unknown":return n.keywordTypeNode({keyword:"unknown"});case "void":return n.keywordTypeNode({keyword:"void"})}},ae=({onRef:e,plugin:t,schema:r,state:s})=>{let o=t.context.file({id:T});if(r.$ref)return e&&e(t.api.getId({type:"ref",value:r.$ref})),o.getNode(t.api.getId({type:"ref",value:r.$ref})).node;if(r.type)return Xa({onRef:e,plugin:t,schema:r,state:s});if(r.items){if(r=H({detectFormat:false,schema:r}),r.items){let i=[];for(let a of r.items){let p=ae({onRef:e,plugin:t,schema:a,state:s});i.push(p);}return r.logicalOperator==="and"?n.typeIntersectionNode({types:i}):n.typeUnionNode({types:i})}return ae({onRef:e,plugin:t,schema:r,state:s})}return Xa({onRef:e,plugin:t,schema:{type:"unknown"},state:s})},wl=({id:e,plugin:t,schema:r,type:s})=>{let o=t.context.file({id:T}),i=o.getNode(t.api.getId({type:"ref",value:e}));if(r.type==="enum"&&t.config.enums.enabled){let p=Il({plugin:t,schema:r});if(t.config.enums.mode==="javascript"){t.config.enums.constantsIgnoreNull&&p.typeofItems.includes("object")&&(p.obj=p.obj.filter(d=>d.value!==null));let c=n.constVariable({assertion:"const",comment:Ne({schema:r}),exportConst:i.exported,expression:n.objectExpression({multiLine:true,obj:p.obj}),name:i.node});o.add(c);let m=n.typeOfExpression({text:i.node.typeName}),f=b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m),l=n.typeAliasDeclaration({comment:Ne({schema:r}),exportType:i.exported,name:i.node,type:n.indexedAccessTypeNode({indexType:f,objectType:m})});o.add(l);return}else if(t.config.enums.mode==="typescript"&&!p.typeofItems.some(m=>m!=="number"&&m!=="string")){let m=n.enumDeclaration({leadingComment:Ne({schema:r}),name:i.node,obj:p.obj});o.add(m);return}}let a=n.typeAliasDeclaration({comment:Ne({schema:r}),exportType:i.exported,name:i.node,type:s});o.add(a);},Qs=({id:e,plugin:t,schema:r,state:s})=>{let o=t.context.file({id:T}),i=ae({onRef:void 0,plugin:t,schema:r,state:s}),a=N({config:t.config.definitions,name:D(e)});o.updateNode(t.api.getId({type:"ref",value:e}),{exported:true,name:a}),wl({id:e,plugin:t,schema:r,type:i});},Ga=({plugin:e})=>{let t={usedTypeIDs:new Set},r=e.createFile({case:e.config.case,id:T,path:e.output}),s=N({config:{case:e.config.case},name:"ClientOptions"}),o=r.updateNode(e.api.getId({type:"ClientOptions"}),{exported:true,name:s}),i=[];if(e.forEach("operation","parameter","requestBody","schema","server",a=>{a.type==="operation"?Ua({operation:a.operation,plugin:e,state:t}):a.type==="parameter"?Qs({id:a.$ref,plugin:e,schema:a.parameter.schema,state:t}):a.type==="requestBody"?Qs({id:a.$ref,plugin:e,schema:a.requestBody.schema,state:t}):a.type==="schema"?Qs({id:a.$ref,plugin:e,schema:a.schema,state:t}):a.type==="server"&&i.push(a.server);}),t.usedTypeIDs.size){let a=n.typeParameterDeclaration({constraint:n.keywordTypeNode({keyword:"string"}),name:"T"}),p=n.typeAliasDeclaration({exportType:true,name:"TypeID",type:n.templateLiteralType({value:[n.typeReferenceNode({typeName:"T"}),"_",n.keywordTypeNode({keyword:"string"})]}),typeParameters:[a]});r.add(p);for(let c of t.usedTypeIDs.values()){let m=xe(E({case:e.config.case,value:c+"_id"})),f=n.typeAliasDeclaration({exportType:true,name:m,type:n.typeReferenceNode({typeArguments:[n.literalTypeNode({literal:n.stringLiteral({text:c})})],typeName:"TypeID"})});r.add(f);}}Za({nodeInfo:o,plugin:e,servers:i});};var ql=e=>{switch(e.type){case "data":case "error":case "errors":case "response":case "responses":return `${e.operation.id}-${e.type}`;case "ref":return e.value;default:return e.type}},Ja={getId:ql,schemaToType:e=>ae({onRef:void 0,...e})};var _n={api:Ja,config:{case:"PascalCase",exportFromIndex:true,style:"preserve",tree:false},handler:Ga,handlerLegacy:Va,name:"@hey-api/typescript",output:"types",resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.definitions}),e.config.enums=t.valueToObject({defaultValue:{case:"SCREAMING_SNAKE_CASE",constantsIgnoreNull:false,enabled:!!e.config.enums,mode:"javascript"},mappers:{boolean:r=>({enabled:r}),string:r=>({mode:r})},value:e.config.enums}),e.config.errors=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",error:"{{name}}Error",name:"{{name}}Errors"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.errors}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}Data"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}Responses",response:"{{name}}Response"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.responses});}};var hr=(e,t,r)=>{let s=e.config[r].meta;if(typeof s!="function")return;let o=s(t);return n.valueToExpression({value:o})};var Pt=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),s=t.getPlugin("@hey-api/sdk");return Ds({file:r,operation:e,plugin:s})},Bn=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),s=t.getPlugin("@hey-api/typescript"),o=t.context.file({id:T}),a={asType:true,name:r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:o.getName(s.api.getId({operation:e,type:"error"}))}).name||""};if(a.name||(a=r.import({asType:true,module:t.name,name:"DefaultError"})),j(t.context.config).name==="@hey-api/client-axios"){let c=r.import({asType:true,module:"axios",name:"AxiosError"});a={...c,name:`${c.name}<${a.name}>`};}return a},zn=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),s=t.getPlugin("@hey-api/typescript"),o=t.context.file({id:T});return r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:o.getName(s.api.getId({operation:e,type:"response"}))}).name||"unknown"};var ep="createQueryKey",Wn="QueryKey",Vr="TOptions",Ya=n.identifier({text:"infinite"}),Kn=n.identifier({text:"options"}),Hn=({plugin:e})=>{let t=e.context.file({id:e.name}),r=t.identifier({$ref:`#/tanstack-query-create-query-key/${ep}`,case:e.config.case,create:true,namespace:"value"});if(r.name){let s=n.indexedAccessTypeNode({indexType:n.literalTypeNode({literal:n.ots.number(0)}),objectType:n.typeReferenceNode({typeArguments:[n.typeReferenceNode({typeName:Vr})],typeName:Wn})}),o=Ie(e.context.config),i=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"id",type:n.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:n.typeReferenceNode({typeName:Vr})},{isRequired:false,name:"infinite",type:n.typeReferenceNode({typeName:"boolean"})},{isRequired:false,name:"tags",type:n.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],returnType:n.typeTupleNode({types:[s]}),statements:[n.constVariable({assertion:s,expression:n.objectExpression({multiLine:false,obj:[{key:"_id",value:n.identifier({text:"id"})},{key:o,value:n.identifier({text:`options?.${o} || (options?.client ?? _heyApiClient).getConfig().${o}`})}]}),name:"params",typeName:s}),n.ifStatement({expression:Ya,thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"_infinite"}),right:Ya})})]})}),n.ifStatement({expression:n.identifier({text:"tags"}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"tags"}),right:n.identifier({text:"tags"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:Kn,isOptional:true,name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.propertyAccessExpression({expression:"options",name:"body"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:Kn,isOptional:true,name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:Kn,isOptional:true,name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.propertyAccessExpression({expression:"options",name:"path"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:Kn,isOptional:true,name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.propertyAccessExpression({expression:"options",name:"query"})})})]})}),n.returnStatement({expression:n.arrayLiteralExpression({elements:[n.identifier({text:"params"})]})})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:z.Options.name})}),name:Vr}]}),name:r.name});t.add(i);}},Ml=({id:e,isInfinite:t,operation:r,plugin:s})=>{let i=s.context.file({id:s.name}).identifier({$ref:`#/tanstack-query-create-query-key/${ep}`,case:s.config.case,namespace:"value"}),a=t?s.config.infiniteQueryKeys:s.config.queryKeys,p;return a.tags&&r.tags&&r.tags.length>0&&(p=n.arrayLiteralExpression({elements:r.tags.map(m=>n.stringLiteral({text:m}))})),n.callExpression({functionName:i.name||"",parameters:[n.ots.string(e),"options",t||p?n.ots.boolean(!!t):void 0,p||void 0]})},Zn=({plugin:e})=>{let t=e.context.file({id:e.name}),r=[{name:"_id",type:n.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:n.keywordTypeNode({keyword:"boolean"})},{isRequired:false,name:"tags",type:n.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],s=n.typeAliasDeclaration({exportType:true,name:Wn,type:n.typeTupleNode({types:[n.typeIntersectionNode({types:[n.typeReferenceNode({typeName:`Pick<${Vr}, '${Ie(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),n.typeInterfaceNode({properties:r,useLegacyResolution:true})]})]}),typeParameters:[{extends:n.typeReferenceNode({typeName:n.identifier({text:z.Options.name})}),name:Vr}]});t.add(s);},Un=({isInfinite:e,operation:t,plugin:r,typeQueryKey:s})=>{let o=r.context.file({id:r.name}),i=Pt({operation:t,plugin:r}),a=e?o.identifier({$ref:`#/tanstack-query-infinite-query-key/${t.id}`,case:r.config.infiniteQueryKeys.case,create:true,nameTransformer:r.config.infiniteQueryKeys.name,namespace:"value"}):o.identifier({$ref:`#/tanstack-query-query-key/${t.id}`,case:r.config.queryKeys.case,create:true,nameTransformer:r.config.queryKeys.name,namespace:"value"});return n.constVariable({exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:pn(t),name:"options",type:i}],returnType:e?s:void 0,statements:Ml({id:t.id,isInfinite:e,operation:t,plugin:r})}),name:a.name||""})};var rp="createInfiniteParams",tp="infiniteQueryOptions",Ll=({plugin:e})=>{let t=e.context.file({id:e.name}),r=t.identifier({$ref:`#/tanstack-query-create-infinite-params/${rp}`,case:e.config.case,create:true,namespace:"value"}),s=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:n.typeReferenceNode({typeName:`QueryKey<${z.Options.name}>`})},{name:"page",type:n.typeReferenceNode({typeName:"K"})}],statements:[n.constVariable({expression:n.objectExpression({obj:[{spread:n.propertyAccessExpression({expression:"queryKey",name:0})}]}),name:"params"}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].path"},{assertion:"any",spread:"page.path"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].query"},{assertion:"any",spread:"page.query"}]})})})]})}),n.returnVariable({expression:n.asExpression({expression:n.asExpression({expression:n.identifier({text:"params"}),type:n.keywordTypeNode({keyword:"unknown"})}),type:b__default.default.factory.createTypeQueryNode(n.identifier({text:"page"}))})})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:`Pick<QueryKey<${z.Options.name}>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:"K"}]}),name:r.name||""});t.add(s);},np=({operation:e,plugin:t,queryFn:r,state:s})=>{if(!t.config.infiniteQueryOptions||!["get","post"].includes(e.method))return s;let o=di({context:t.context,operation:e});if(!o)return s;let i=t.context.file({id:t.name}),a=le({context:t.context,operation:e});s.hasInfiniteQueries||(s.hasInfiniteQueries=true,s.hasCreateQueryKeyParamsFunction||(Zn({plugin:t}),Hn({plugin:t}),s.hasCreateQueryKeyParamsFunction=true),s.hasCreateInfiniteParamsFunction||(Ll({plugin:t}),s.hasCreateInfiniteParamsFunction=true),i.import({module:t.name,name:tp}),s.typeInfiniteData=i.import({asType:true,module:t.name,name:"InfiniteData"})),s.hasUsedQueryFn=true;let p=Pt({operation:e,plugin:t}),c=Bn({operation:e,plugin:t}),m=zn({operation:e,plugin:t}),f=`${Wn}<${p}>`,l=`Pick<${f}[0], 'body' | 'headers' | 'path' | 'query'>`,d=t.getPlugin("@hey-api/typescript"),y={usedTypeIDs:new Set},g=d.api.schemaToType({plugin:d,schema:o.schema,state:y}),x=`${ke({node:g,unescape:true})} | ${l}`,S=Un({isInfinite:true,operation:e,plugin:t,typeQueryKey:f});i.add(S);let O=i.identifier({$ref:`#/tanstack-query-infinite-query-key/${e.id}`,case:t.config.infiniteQueryKeys.case,nameTransformer:t.config.infiniteQueryKeys.name,namespace:"value"}),v=n.awaitExpression({expression:n.callExpression({functionName:r,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),_=i.identifier({$ref:`#/tanstack-query-create-infinite-params/${rp}`,case:t.config.case,namespace:"value"}),$=[n.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:n.conditionalExpression({condition:n.binaryExpression({left:n.typeOfExpression({text:"pageParam"}),operator:"===",right:n.ots.string("object")}),whenFalse:n.objectExpression({multiLine:true,obj:[{key:o.in,value:n.objectExpression({multiLine:true,obj:[{key:o.name,value:n.identifier({text:"pageParam"})}]})}]}),whenTrue:n.identifier({text:"pageParam"})}),name:"page",typeName:l}),n.constVariable({expression:n.callExpression({functionName:_.name||"",parameters:["queryKey","page"]}),name:"params"})];t.getPlugin("@hey-api/sdk")?.config.responseStyle==="data"?$.push(n.returnVariable({expression:v})):$.push(n.constVariable({destructure:true,expression:v,name:"data"}),n.returnVariable({expression:"data"}));let F=i.identifier({$ref:`#/tanstack-query-infinite-query-options/${e.id}`,case:t.config.infiniteQueryOptions.case,create:true,nameTransformer:t.config.infiniteQueryOptions.name,namespace:"value"}),W=[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:$})},{key:"queryKey",value:n.callExpression({functionName:O.name||"",parameters:["options"]})}],L=hr(t,e,"infiniteQueryOptions");L&&W.push({key:"meta",value:L});let C=n.constVariable({comment:t.config.comments?ie({operation:e}):void 0,exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:a,name:"options",type:p}],statements:[n.returnFunctionCall({args:[n.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:W})],name:tp,types:[m,c.name||"unknown",`${typeof s.typeInfiniteData=="string"?s.typeInfiniteData:s.typeInfiniteData.name}<${m}>`,f,x]})]}),name:F.name||""});i.add(C);};var sp="mutationOptions",op=({operation:e,plugin:t,queryFn:r,state:s})=>{if(!t.config.mutationOptions.enabled||!["delete","patch","post","put"].includes(e.method))return s;let o=t.name==="@tanstack/angular-query-experimental"||t.name==="@tanstack/svelte-query"||t.name==="@tanstack/solid-query"?"MutationOptions":"UseMutationOptions",i=t.context.file({id:t.name});s.hasMutations||(s.hasMutations=true,i.import({asType:true,module:t.name,name:o})),s.hasUsedQueryFn=true;let a=Pt({operation:e,plugin:t}),p=Bn({operation:e,plugin:t}),c=zn({operation:e,plugin:t}),m=`${o}<${c}, ${p.name}, ${a}>`,f=n.awaitExpression({expression:n.callExpression({functionName:r,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"localOptions"},{key:"throwOnError",value:true}]})]})}),l=[];t.getPlugin("@hey-api/sdk")?.config.responseStyle==="data"?l.push(n.returnVariable({expression:f})):l.push(n.constVariable({destructure:true,expression:f,name:"data"}),n.returnVariable({expression:"data"}));let d=i.identifier({$ref:`#/tanstack-query-mutation-options/${e.id}`,case:t.config.mutationOptions.case,create:true,nameTransformer:t.config.mutationOptions.name,namespace:"value"}),y=[{key:"mutationFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{name:"localOptions"}],statements:l})}],g=hr(t,e,"mutationOptions");g&&y.push({key:"meta",value:g});let x=n.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${a}>`}],returnType:m,statements:[n.constVariable({expression:n.objectExpression({obj:y}),name:sp,typeName:m}),n.returnVariable({expression:sp})]}),S=n.constVariable({comment:t.config.comments?ie({operation:e}):void 0,exportConst:true,expression:x,name:d.name||""});return i.add(S),s};var ip="queryOptions",ap=({operation:e,plugin:t,queryFn:r,state:s})=>{if(!t.config.queryOptions||!["get","post"].includes(e.method))return s;let o=t.context.file({id:t.name}),i=le({context:t.context,operation:e});s.hasQueries||(s.hasQueries=true,s.hasCreateQueryKeyParamsFunction||(Zn({plugin:t}),Hn({plugin:t}),s.hasCreateQueryKeyParamsFunction=true),o.import({module:t.name,name:ip})),s.hasUsedQueryFn=true;let a=Un({isInfinite:false,operation:e,plugin:t});o.add(a);let p=Pt({operation:e,plugin:t}),c=o.identifier({$ref:`#/tanstack-query-query-key/${e.id}`,case:t.config.queryKeys.case,nameTransformer:t.config.queryKeys.name,namespace:"value"}),m=n.awaitExpression({expression:n.callExpression({functionName:r,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),f=[];t.getPlugin("@hey-api/sdk")?.config.responseStyle==="data"?f.push(n.returnVariable({expression:m})):f.push(n.constVariable({destructure:true,expression:m,name:"data"}),n.returnVariable({expression:"data"}));let l=o.identifier({$ref:`#/tanstack-query-query-options/${e.id}`,case:t.config.queryOptions.case,create:true,nameTransformer:t.config.queryOptions.name,namespace:"value"}),d=[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:f})},{key:"queryKey",value:n.callExpression({functionName:c.name||"",parameters:["options"]})}],y=hr(t,e,"queryOptions");y&&d.push({key:"meta",value:y});let g=n.constVariable({comment:t.config.comments?ie({operation:e}):void 0,exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:i,name:"options",type:p}],statements:[n.returnFunctionCall({args:[n.objectExpression({obj:d})],name:ip})]}),name:l.name||""});return o.add(g),s};var Ge=({plugin:e})=>{let t=e.createFile({case:e.config.case,id:e.name,path:e.output}),r={hasCreateInfiniteParamsFunction:false,hasCreateQueryKeyParamsFunction:false,hasInfiniteQueries:false,hasMutations:false,hasQueries:false,hasUsedQueryFn:false,typeInfiniteData:void 0};t.import({...z.Options,module:t.relativePathToFile({context:e.context,id:J})}),e.forEach("operation",({operation:s})=>{r.hasUsedQueryFn=false;let o=e.getPlugin("@hey-api/sdk"),i=o?.config.asClass?pt({context:e.context,operation:s,plugin:o}):void 0,a=i?i.values().next().value:void 0,p=(a?[a.path[0],...a.path.slice(1).map(c=>E({case:"camelCase",value:c})),a.methodName].filter(Boolean):[Re({config:e.context.config,handleIllegal:true,id:s.id,operation:s})]).join(".");ap({operation:s,plugin:e,queryFn:p,state:r}),np({operation:s,plugin:e,queryFn:p,state:r}),op({operation:s,plugin:e,queryFn:p,state:r}),r.hasUsedQueryFn&&t.import({module:t.relativePathToFile({context:e.context,id:J}),name:p.split(".")[0]});}),(r.hasQueries||r.hasInfiniteQueries)&&t.import({alias:"_heyApiClient",module:t.relativePathToFile({context:e.context,id:de}),name:"client"});};var Dl=e=>`${Re({config:I(),id:e.name,operation:e})}InfiniteOptions`,Vl=e=>`${Re({config:I(),id:e.name,operation:e})}Mutation`,_l=({config:e,id:t,operation:r})=>`${Re({config:e,id:t,operation:r})}Options`,Qn=({config:e,id:t,isInfinite:r,operation:s})=>`${Re({config:e,id:t,operation:s})}${r?"Infinite":""}QueryKey`,Bl=e=>{switch(e.in){case "formData":return "body";case "header":return "headers";default:return e.in}},zl="createInfiniteParams",gp="createQueryKey",pp="infiniteQueryOptions",cp="mutationOptions",Gs="QueryKey",mp="queryOptions",Br="TOptions",Kl=({file:e})=>{let t=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:n.typeNode(`QueryKey<${z.OptionsLegacyParser.name}>`)},{name:"page",type:n.typeNode("K")}],statements:[n.constVariable({expression:n.identifier({text:"queryKey[0]"}),name:"params"}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].path"},{spread:"page.path"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].query"},{spread:"page.query"}]})})})]})}),n.returnVariable({expression:b__default.default.factory.createAsExpression(b__default.default.factory.createAsExpression(n.identifier({text:"params"}),b__default.default.factory.createKeywordTypeNode(b__default.default.SyntaxKind.UnknownKeyword)),b__default.default.factory.createTypeQueryNode(n.identifier({text:"page"})))})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:`Pick<QueryKey<${z.OptionsLegacyParser.name}>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:"K"}]}),name:zl});e.add(t);},fp=({file:e})=>{let t=n.indexedAccessTypeNode({indexType:n.typeNode(0),objectType:n.typeNode(Gs,[n.typeNode(Br)])}),r=n.identifier({text:"infinite"}),s=Ie(I()),o=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"id",type:n.typeNode("string")},{isRequired:false,name:"options",type:n.typeNode(Br)},{isRequired:false,name:"infinite",type:n.typeNode("boolean")}],returnType:t,statements:[n.constVariable({assertion:t,expression:n.objectExpression({multiLine:false,obj:[{key:"_id",value:n.identifier({text:"id"})},{key:s,value:n.identifier({text:`options?.${s} || (options?.client ?? _heyApiClient).getConfig().${s}`})}]}),name:"params",typeName:t}),n.ifStatement({expression:r,thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"_infinite"}),right:r})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.propertyAccessExpression({expression:"options",name:"body"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.propertyAccessExpression({expression:"options",name:"path"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.propertyAccessExpression({expression:"options",name:"query"})})})]})}),n.returnVariable({expression:"params"})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:z.OptionsLegacyParser.name})}),name:Br}]}),name:gp});e.add(o);},lp=({file:e})=>{let t=[{name:"_id",type:n.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:n.keywordTypeNode({keyword:"boolean"})}],r=n.typeAliasDeclaration({name:Gs,type:n.typeTupleNode({types:[n.typeIntersectionNode({types:[n.typeReferenceNode({typeName:`Pick<${Br}, '${Ie(I())}' | 'body' | 'headers' | 'path' | 'query'>`}),n.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:n.typeReferenceNode({typeName:n.identifier({text:z.OptionsLegacyParser.name})}),name:Br}]});e.add(r);},Xs=({client:e,file:t,operation:r,typesModulePath:s})=>{let{name:o}=Wt({client:e,meta:r.parameters.length?{$ref:r.name,name:r.name}:void 0,nameTransformer:Ht,onImport:a=>{t.import({asType:true,module:s,name:a});}});return {typeData:Zs({importedType:o})}},up=({client:e,file:t,operation:r,pluginName:s,typesModulePath:o})=>{let i=I(),{name:a}=Wt({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:gr,onImport:m=>{t.import({asType:true,module:o,name:m});}}),p={asType:true,name:a};if(p.name||(p=t.import({asType:true,module:s,name:"DefaultError"})),j(i).name==="@hey-api/client-axios"){let m=t.import({asType:true,module:"axios",name:"AxiosError"});p={...m,name:`${m.name}<${p.name}>`};}return {typeError:p}},dp=({client:e,file:t,operation:r,typesModulePath:s})=>{let{name:o}=Wt({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Xe,onImport:a=>{t.import({asType:true,module:s,name:a});}});return {typeResponse:o||"void"}},yp=({id:e,isInfinite:t})=>n.arrayLiteralExpression({elements:[n.callExpression({functionName:gp,parameters:[n.ots.string(e),"options",t?n.ots.boolean(true):void 0]})],multiLine:false}),Je=({client:e,files:t,plugin:r})=>{let s=I();if(X(s))throw new Error("TanStack Query plugin does not support legacy clients");let o=t[r.name];o.import({...z.OptionsLegacyParser,module:Q({config:s,sourceOutput:r.output})});let i=Ut({moduleOutput:t.types.nameWithoutExtension(),sourceOutput:r.output}),a=r.name==="@tanstack/angular-query-experimental"||r.name==="@tanstack/svelte-query"||r.name==="@tanstack/solid-query"?"MutationOptions":"UseMutationOptions",p,c=false,m=false,f=false,l=false,d=false,y=new Map;for(let g of e.services)for(let x of g.operations){let S=q(x);if(y.has(S))continue;y.set(S,true);let O=[s.plugins["@hey-api/sdk"]?.config.asClass&&dr({config:s,name:g.name}),Re({config:s,handleIllegal:!s.plugins["@hey-api/sdk"]?.config.asClass,id:x.name,operation:x})].filter(Boolean).join("."),v=false;if(r.config.queryOptions&&["GET","POST"].includes(x.method)){d||(d=true,m||(lp({file:o}),fp({file:o}),m=true),o.import({module:r.name,name:mp})),v=true;let{typeData:_}=Xs({client:e,file:o,operation:x,typesModulePath:i}),$=He(x.parameters),F=n.constVariable({exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:$,name:"options",type:_}],statements:yp({id:x.name})}),name:Qn({config:s,id:x.name,operation:x})});o.add(F);let W=n.constVariable({comment:[],exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:$,name:"options",type:_}],statements:[n.returnFunctionCall({args:[n.objectExpression({obj:[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:[n.constVariable({destructure:true,expression:n.awaitExpression({expression:n.callExpression({functionName:O,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),n.returnVariable({expression:"data"})]})},{key:"queryKey",value:n.callExpression({functionName:Qn({config:s,id:x.name,operation:x}),parameters:["options"]})}]})],name:mp})]}),name:_l({config:s,id:x.name,operation:x})});o.add(W);}if(r.config.infiniteQueryOptions&&["GET","POST"].includes(x.method)){let _,$=x.parameters.find(F=>{if(fe(s.parser.pagination).test(F.name))return _=F,true;if(F.in==="body"){if(F.export==="reference"){let L=F.$refs[0];return e.models.find(Z=>Z.meta?.$ref===L)?.properties.find(Z=>{if(fe(s.parser.pagination).test(Z.name))return _=Z,true})}return F.properties.find(L=>{if(fe(s.parser.pagination).test(L.name))return _=L,true})}});if($&&_){f||(f=true,m||(lp({file:o}),fp({file:o}),m=true),c||(Kl({file:o}),c=true),o.import({module:r.name,name:pp}),p=o.import({asType:true,module:r.name,name:"InfiniteData"})),v=true;let{typeData:F}=Xs({client:e,file:o,operation:x,typesModulePath:i}),{typeError:W}=up({client:e,file:o,operation:x,pluginName:r.name,typesModulePath:i}),{typeResponse:L}=dp({client:e,file:o,operation:x,typesModulePath:i}),C=He(x.parameters),Z=`${Gs}<${F}>`,Ae=`Pick<${Z}[0], 'body' | 'headers' | 'path' | 'query'>`,Ce=`${_.base} | ${Ae}`,Zt=n.constVariable({exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:C,name:"options",type:F}],returnType:Z,statements:yp({id:x.name,isInfinite:true})}),name:Qn({config:s,id:x.name,isInfinite:true,operation:x})});o.add(Zt);let Fp=n.constVariable({comment:[],exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:C,name:"options",type:F}],statements:[n.returnFunctionCall({args:[n.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:[n.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:n.conditionalExpression({condition:n.binaryExpression({left:n.typeOfExpression({text:"pageParam"}),operator:"===",right:n.ots.string("object")}),whenFalse:n.objectExpression({multiLine:true,obj:[{key:Bl($),value:n.objectExpression({multiLine:true,obj:[{key:_.name,value:n.identifier({text:"pageParam"})}]})}]}),whenTrue:n.identifier({text:"pageParam"})}),name:"page",typeName:Ae}),n.constVariable({expression:n.callExpression({functionName:"createInfiniteParams",parameters:["queryKey","page"]}),name:"params"}),n.constVariable({destructure:true,expression:n.awaitExpression({expression:n.callExpression({functionName:O,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),n.returnVariable({expression:"data"})]})},{key:"queryKey",value:n.callExpression({functionName:Qn({config:s,id:x.name,isInfinite:true,operation:x}),parameters:["options"]})}]})],name:pp,types:[L,W.name,`${typeof p=="string"?p:p.name}<${L}>`,Z,Ce]})]}),name:Dl(x)});o.add(Fp);}}if(r.config.mutationOptions&&["DELETE","PATCH","POST","PUT"].includes(x.method)){l||(l=true,o.import({asType:true,module:r.name,name:a})),v=true;let{typeData:_}=Xs({client:e,file:o,operation:x,typesModulePath:i}),{typeError:$}=up({client:e,file:o,operation:x,pluginName:r.name,typesModulePath:i}),{typeResponse:F}=dp({client:e,file:o,operation:x,typesModulePath:i}),W=n.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${_}>`}],statements:[n.constVariable({expression:n.objectExpression({obj:[{key:"mutationFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{name:"localOptions"}],statements:[n.constVariable({destructure:true,expression:n.awaitExpression({expression:n.callExpression({functionName:O,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"localOptions"},{key:"throwOnError",value:true}]})]})}),name:"data"}),n.returnVariable({expression:"data"})]})}]}),name:cp,typeName:`${a}<${F}, ${$.name}, ${_}>`}),n.returnVariable({expression:cp})]}),L=n.constVariable({comment:[],exportConst:true,expression:W,name:Vl(x)});o.add(L);}(d||f)&&o.import({alias:"_heyApiClient",module:Ut({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:r.output}),name:"client"}),v&&o.import({module:Ut({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:r.output}),name:O.split(".")[0]});}};var Xn={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ge,handlerLegacy:Je,name:"@tanstack/angular-query-experimental",output:"@tanstack/angular-query-experimental",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Gn={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ge,handlerLegacy:Je,name:"@tanstack/react-query",output:"@tanstack/react-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Jn={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ge,handlerLegacy:Je,name:"@tanstack/solid-query",output:"@tanstack/solid-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Yn={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ge,handlerLegacy:Je,name:"@tanstack/svelte-query",output:"@tanstack/svelte-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var es={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ge,handlerLegacy:Je,name:"@tanstack/vue-query",output:"@tanstack/vue-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var hp="fastify",Xl=({operation:e,plugin:t})=>{let r=t.context.file({id:hp}),s=[],o=t.getPlugin("@hey-api/typescript"),i=t.context.file({id:T}),a=i.getName(o.api.getId({operation:e,type:"data"}));a&&(e.body&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:a}),s.push({isRequired:e.body.required,name:"Body",type:`${a}['body']`})),e.parameters&&(e.parameters.header&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:a}),s.push({isRequired:yt(e.parameters.header),name:"Headers",type:`${a}['headers']`})),e.parameters.path&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:a}),s.push({isRequired:yt(e.parameters.path),name:"Params",type:`${a}['path']`})),e.parameters.query&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:a}),s.push({isRequired:yt(e.parameters.query),name:"Querystring",type:`${a}['query']`}))));let{errors:p,responses:c}=Fe(e),m,f=i.getName(o.api.getId({operation:e,type:"errors"}));if(f&&p&&p.properties){let x=Object.keys(p.properties);if(x.length){if(!x.includes("default"))r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:f}),m=n.typeReferenceNode({typeName:f});else if(x.length>1){r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:f});let O=n.typeReferenceNode({typeName:f}),v=n.literalTypeNode({literal:n.stringLiteral({text:"default"})});m=n.typeReferenceNode({typeArguments:[O,v],typeName:"Omit"});}}}let l,d=i.getName(o.api.getId({operation:e,type:"responses"}));if(d&&c&&c.properties){let x=Object.keys(c.properties);if(x.length){if(!x.includes("default"))r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:d}),l=n.typeReferenceNode({typeName:d});else if(x.length>1){r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:d});let O=n.typeReferenceNode({typeName:d}),v=n.literalTypeNode({literal:n.stringLiteral({text:"default"})});l=n.typeReferenceNode({typeArguments:[O,v],typeName:"Omit"});}}}let y=[m,l].filter(Boolean);return y.length&&s.push({name:"Reply",type:n.typeIntersectionNode({types:y})}),s.length?{name:e.id,type:n.typeNode("RouteHandler",[n.typeInterfaceNode({properties:s,useLegacyResolution:false})])}:void 0},xp=({plugin:e})=>{let t=e.createFile({id:hp,path:e.output}),r=[];e.forEach("operation",({operation:o})=>{let i=Xl({operation:o,plugin:e});i&&r.push(i);});let s=t.identifier({$ref:"RouteHandlers",create:true,namespace:"type"});s.name&&(r.length&&t.import({asType:true,module:"fastify",name:"RouteHandler"}),t.add(n.typeAliasDeclaration({exportType:true,name:s.name,type:n.typeInterfaceNode({properties:r,useLegacyResolution:false})})));};var ts={config:{exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:xp,name:"fastify",output:"fastify"};var h={actions:{args:n.identifier({text:"args"}),base64:n.identifier({text:"base64"}),bic:n.identifier({text:"bic"}),brand:n.identifier({text:"brand"}),bytes:n.identifier({text:"bytes"}),check:n.identifier({text:"check"}),checkItems:n.identifier({text:"checkItems"}),creditCard:n.identifier({text:"creditCard"}),cuid2:n.identifier({text:"cuid2"}),decimal:n.identifier({text:"decimal"}),description:n.identifier({text:"description"}),digits:n.identifier({text:"digits"}),email:n.identifier({text:"email"}),emoji:n.identifier({text:"emoji"}),empty:n.identifier({text:"empty"}),endsWith:n.identifier({text:"endsWith"}),entries:n.identifier({text:"entries"}),everyItem:n.identifier({text:"everyItem"}),excludes:n.identifier({text:"excludes"}),filterItems:n.identifier({text:"filterItems"}),findItem:n.identifier({text:"findItem"}),finite:n.identifier({text:"finite"}),flavor:n.identifier({text:"flavor"}),graphemes:n.identifier({text:"graphemes"}),gtValue:n.identifier({text:"gtValue"}),hash:n.identifier({text:"hash"}),hexColor:n.identifier({text:"hexColor"}),hexadecimal:n.identifier({text:"hexadecimal"}),imei:n.identifier({text:"imei"}),includes:n.identifier({text:"includes"}),integer:n.identifier({text:"integer"}),ip:n.identifier({text:"ip"}),ipv4:n.identifier({text:"ipv4"}),ipv6:n.identifier({text:"ipv6"}),isoDate:n.identifier({text:"isoDate"}),isoDateTime:n.identifier({text:"isoDateTime"}),isoTime:n.identifier({text:"isoTime"}),isoTimeSecond:n.identifier({text:"isoTimeSecond"}),isoTimestamp:n.identifier({text:"isoTimestamp"}),isoWeek:n.identifier({text:"isoWeek"}),length:n.identifier({text:"length"}),ltValue:n.identifier({text:"ltValue"}),mac:n.identifier({text:"mac"}),mac48:n.identifier({text:"mac48"}),mac64:n.identifier({text:"mac64"}),mapItems:n.identifier({text:"mapItems"}),maxBytes:n.identifier({text:"maxBytes"}),maxEntries:n.identifier({text:"maxEntries"}),maxGraphemes:n.identifier({text:"maxGraphemes"}),maxLength:n.identifier({text:"maxLength"}),maxSize:n.identifier({text:"maxSize"}),maxValue:n.identifier({text:"maxValue"}),maxWords:n.identifier({text:"maxWords"}),metadata:n.identifier({text:"metadata"}),mimeType:n.identifier({text:"mimeType"}),minBytes:n.identifier({text:"minBytes"}),minEntries:n.identifier({text:"minEntries"}),minGraphemes:n.identifier({text:"minGraphemes"}),minLength:n.identifier({text:"minLength"}),minSize:n.identifier({text:"minSize"}),minValue:n.identifier({text:"minValue"}),minWords:n.identifier({text:"minWords"}),multipleOf:n.identifier({text:"multipleOf"}),nanoid:n.identifier({text:"nanoid"}),nonEmpty:n.identifier({text:"nonEmpty"}),normalize:n.identifier({text:"normalize"}),notBytes:n.identifier({text:"notBytes"}),notEntries:n.identifier({text:"notEntries"}),notGraphemes:n.identifier({text:"notGraphemes"}),notLength:n.identifier({text:"notLength"}),notSize:n.identifier({text:"notSize"}),notValue:n.identifier({text:"notValue"}),notValues:n.identifier({text:"notValues"}),notWords:n.identifier({text:"notWords"}),octal:n.identifier({text:"octal"}),parseJson:n.identifier({text:"parseJson"}),partialCheck:n.identifier({text:"partialCheck"}),rawCheck:n.identifier({text:"rawCheck"}),rawTransform:n.identifier({text:"rawTransform"}),readonly:n.identifier({text:"readonly"}),reduceItems:n.identifier({text:"reduceItems"}),regex:n.identifier({text:"regex"}),returns:n.identifier({text:"returns"}),rfcEmail:n.identifier({text:"rfcEmail"}),safeInteger:n.identifier({text:"safeInteger"}),size:n.identifier({text:"size"}),slug:n.identifier({text:"slug"}),someItem:n.identifier({text:"someItem"}),sortItems:n.identifier({text:"sortItems"}),startsWith:n.identifier({text:"startsWith"}),stringifyJson:n.identifier({text:"stringifyJson"}),title:n.identifier({text:"title"}),toLowerCase:n.identifier({text:"toLowerCase"}),toMaxValue:n.identifier({text:"toMaxValue"}),toMinValue:n.identifier({text:"toMinValue"}),toUpperCase:n.identifier({text:"toUpperCase"}),transform:n.identifier({text:"transform"}),trim:n.identifier({text:"trim"}),trimEnd:n.identifier({text:"trimEnd"}),trimStart:n.identifier({text:"trimStart"}),ulid:n.identifier({text:"ulid"}),url:n.identifier({text:"url"}),uuid:n.identifier({text:"uuid"}),value:n.identifier({text:"value"}),values:n.identifier({text:"values"}),words:n.identifier({text:"words"})},async:{argsAsync:n.identifier({text:"argsAsync"}),arrayAsync:n.identifier({text:"arrayAsync"}),awaitAsync:n.identifier({text:"awaitAsync"}),checkAsync:n.identifier({text:"checkAsync"}),checkItemsAsync:n.identifier({text:"checkItemsAsync"}),customAsync:n.identifier({text:"customAsync"}),exactOptionalAsync:n.identifier({text:"exactOptionalAsync"}),fallbackAsync:n.identifier({text:"fallbackAsync"}),forwardAsync:n.identifier({text:"forwardAsync"}),getDefaultsAsync:n.identifier({text:"getDefaultsAsync"}),getFallbacksAsync:n.identifier({text:"getFallbacksAsync"}),intersectAsync:n.identifier({text:"intersectAsync"}),lazyAsync:n.identifier({text:"lazyAsync"}),looseObjectAsync:n.identifier({text:"looseObjectAsync"}),looseTupleAsync:n.identifier({text:"looseTupleAsync"}),mapAsync:n.identifier({text:"mapAsync"}),nonNullableAsync:n.identifier({text:"nonNullableAsync"}),nonNullishAsync:n.identifier({text:"nonNullishAsync"}),nonOptionalAsync:n.identifier({text:"nonOptionalAsync"}),nullableAsync:n.identifier({text:"nullableAsync"}),nullishAsync:n.identifier({text:"nullishAsync"}),objectAsync:n.identifier({text:"objectAsync"}),objectWithRestAsync:n.identifier({text:"objectWithRestAsync"}),optionalAsync:n.identifier({text:"optionalAsync"}),parseAsync:n.identifier({text:"parseAsync"}),parserAsync:n.identifier({text:"parserAsync"}),partialAsync:n.identifier({text:"partialAsync"}),partialCheckAsync:n.identifier({text:"partialCheckAsync"}),pipeAsync:n.identifier({text:"pipeAsync"}),rawCheckAsync:n.identifier({text:"rawCheckAsync"}),rawTransformAsync:n.identifier({text:"rawTransformAsync"}),recordAsync:n.identifier({text:"recordAsync"}),requiredAsync:n.identifier({text:"requiredAsync"}),returnsAsync:n.identifier({text:"returnsAsync"}),safeParseAsync:n.identifier({text:"safeParseAsync"}),safeParserAsync:n.identifier({text:"safeParserAsync"}),setAsync:n.identifier({text:"setAsync"}),strictObjectAsync:n.identifier({text:"strictObjectAsync"}),strictTupleAsync:n.identifier({text:"strictTupleAsync"}),transformAsync:n.identifier({text:"transformAsync"}),tupleAsync:n.identifier({text:"tupleAsync"}),tupleWithRestAsync:n.identifier({text:"tupleWithRestAsync"}),undefinedableAsync:n.identifier({text:"undefinedableAsync"}),unionAsync:n.identifier({text:"unionAsync"}),variantAsync:n.identifier({text:"variantAsync"})},methods:{assert:n.identifier({text:"assert"}),config:n.identifier({text:"config"}),fallback:n.identifier({text:"fallback"}),flatten:n.identifier({text:"flatten"}),forward:n.identifier({text:"forward"}),getDefault:n.identifier({text:"getDefault"}),getDefaults:n.identifier({text:"getDefaults"}),getDescription:n.identifier({text:"getDescription"}),getFallback:n.identifier({text:"getFallback"}),getFallbacks:n.identifier({text:"getFallbacks"}),getMetadata:n.identifier({text:"getMetadata"}),getTitle:n.identifier({text:"getTitle"}),is:n.identifier({text:"is"}),keyof:n.identifier({text:"keyof"}),message:n.identifier({text:"message"}),omit:n.identifier({text:"omit"}),parse:n.identifier({text:"parse"}),parser:n.identifier({text:"parser"}),partial:n.identifier({text:"partial"}),pick:n.identifier({text:"pick"}),pipe:n.identifier({text:"pipe"}),required:n.identifier({text:"required"}),safeParse:n.identifier({text:"safeParse"}),safeParser:n.identifier({text:"safeParser"}),summarize:n.identifier({text:"summarize"}),unwrap:n.identifier({text:"unwrap"})},schemas:{any:n.identifier({text:"any"}),array:n.identifier({text:"array"}),bigInt:n.identifier({text:"bigint"}),blob:n.identifier({text:"blob"}),boolean:n.identifier({text:"boolean"}),custom:n.identifier({text:"custom"}),date:n.identifier({text:"date"}),enum:n.identifier({text:"enum"}),exactOptional:n.identifier({text:"exactOptional"}),file:n.identifier({text:"file"}),function:n.identifier({text:"function"}),instance:n.identifier({text:"instance"}),intersect:n.identifier({text:"intersect"}),lazy:n.identifier({text:"lazy"}),literal:n.identifier({text:"literal"}),looseObject:n.identifier({text:"looseObject"}),looseTuple:n.identifier({text:"looseTuple"}),map:n.identifier({text:"map"}),nan:n.identifier({text:"nan"}),never:n.identifier({text:"never"}),nonNullable:n.identifier({text:"nonNullable"}),nonNullish:n.identifier({text:"nonNullish"}),nonOptional:n.identifier({text:"nonOptional"}),null:n.identifier({text:"null"}),nullable:n.identifier({text:"nullable"}),nullish:n.identifier({text:"nullish"}),number:n.identifier({text:"number"}),object:n.identifier({text:"object"}),objectWithRest:n.identifier({text:"objectWithRest"}),optional:n.identifier({text:"optional"}),picklist:n.identifier({text:"picklist"}),promise:n.identifier({text:"promise"}),record:n.identifier({text:"record"}),set:n.identifier({text:"set"}),strictObject:n.identifier({text:"strictObject"}),strictTuple:n.identifier({text:"strictTuple"}),string:n.identifier({text:"string"}),symbol:n.identifier({text:"symbol"}),tuple:n.identifier({text:"tuple"}),tupleWithRest:n.identifier({text:"tupleWithRest"}),undefined:n.identifier({text:"undefined"}),undefinedable:n.identifier({text:"undefinedable"}),union:n.identifier({text:"union"}),unknown:n.identifier({text:"unknown"}),variant:n.identifier({text:"variant"}),void:n.identifier({text:"void"})},types:{GenericSchema:n.identifier({text:"GenericSchema"})},v:n.identifier({text:"v"})},Ye="valibot";var Jl=({file:e,operation:t,plugin:r})=>{let{requests:s}=r.config,o=r.context.file({id:Ye}).identifier({$ref:`#/valibot-response/${t.id}`,nameTransformer:typeof s=="object"?s.name:void 0,namespace:"value"});if(!o.name)return;e.import({module:e.relativePathToFile({context:r.context,id:Ye}),name:o.name}),e.import({alias:h.v.text,module:"valibot",name:"*"});let i="data";return n.arrowFunction({async:true,parameters:[{name:i}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.async.parseAsync}),parameters:[n.identifier({text:o.name}),n.identifier({text:i})]})})})]})},Yl=({file:e,operation:t,plugin:r})=>{let{responses:s}=r.config,o=r.context.file({id:Ye}).identifier({$ref:`#/valibot-response/${t.id}`,nameTransformer:typeof s=="object"?s.name:void 0,namespace:"value"});if(!o.name)return;e.import({module:e.relativePathToFile({context:r.context,id:Ye}),name:o.name}),e.import({alias:h.v.text,module:"valibot",name:"*"});let i="data";return n.arrowFunction({async:true,parameters:[{name:i}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.async.parseAsync}),parameters:[n.identifier({text:o.name}),n.identifier({text:i})]})})})]})},bp={createRequestValidator:Jl,createResponseValidator:Yl};var rs={int16:{max:32767,maxError:"Invalid value: Expected int16 to be <= 2^15-1",min:-32768,minError:"Invalid value: Expected int16 to be >= -2^15",needsBigInt:false},int32:{max:2147483647,maxError:"Invalid value: Expected int32 to be <= 2^31-1",min:-2147483648,minError:"Invalid value: Expected int32 to be >= -2^31",needsBigInt:false},int64:{max:"9223372036854775807",maxError:"Invalid value: Expected int64 to be <= 2^63-1",min:"-9223372036854775808",minError:"Invalid value: Expected int64 to be >= -2^63",needsBigInt:true},int8:{max:127,maxError:"Invalid value: Expected int8 to be <= 2^7-1",min:-128,minError:"Invalid value: Expected int8 to be >= -2^7",needsBigInt:false},uint16:{max:65535,maxError:"Invalid value: Expected uint16 to be <= 2^16-1",min:0,minError:"Invalid value: Expected uint16 to be >= 0",needsBigInt:false},uint32:{max:4294967295,maxError:"Invalid value: Expected uint32 to be <= 2^32-1",min:0,minError:"Invalid value: Expected uint32 to be >= 0",needsBigInt:false},uint64:{max:"18446744073709551615",maxError:"Invalid value: Expected uint64 to be <= 2^64-1",min:"0",minError:"Invalid value: Expected uint64 to be >= 0",needsBigInt:true},uint8:{max:255,maxError:"Invalid value: Expected uint8 to be <= 2^8-1",min:0,minError:"Invalid value: Expected uint8 to be >= 0",needsBigInt:false}},Js=e=>e!==void 0&&e in rs,Op=e=>Js(e)&&rs[e].needsBigInt,xr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r};var Sp=({operation:e,plugin:t,state:r})=>{let s=t.context.file({id:Ye});if(t.config.requests.enabled){let o=new Set,i={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let p={},c=[];for(let m in e.parameters.header){let f=e.parameters.header[m];p[f.name]=f.schema,f.required&&(c.push(f.name),o.add("headers"));}Object.keys(p).length&&(i.properties.headers={properties:p,required:c,type:"object"});}if(e.parameters.path){let p={},c=[];for(let m in e.parameters.path){let f=e.parameters.path[m];p[f.name]=f.schema,f.required&&(c.push(f.name),o.add("path"));}Object.keys(p).length&&(i.properties.path={properties:p,required:c,type:"object"});}if(e.parameters.query){let p={},c=[];for(let m in e.parameters.query){let f=e.parameters.query[m];p[f.name]=f.schema,f.required&&(c.push(f.name),o.add("query"));}Object.keys(p).length&&(i.properties.query={properties:p,required:c,type:"object"});}}e.body&&(i.properties.body=e.body.schema,e.body.required&&o.add("body")),i.required=[...o];let a=s.identifier({$ref:`#/valibot-data/${e.id}`,case:t.config.requests.case,create:true,nameTransformer:t.config.requests.name,namespace:"value"});ue({$ref:`#/valibot-data/${e.id}`,identifier:a,plugin:t,schema:i,state:r});}if(t.config.responses.enabled&&e.responses){let{response:o}=Fe(e);if(o){let i=s.identifier({$ref:`#/valibot-response/${e.id}`,case:t.config.responses.case,create:true,nameTransformer:t.config.responses.name,namespace:"value"});ue({$ref:`#/valibot-response/${e.id}`,identifier:i,plugin:t,schema:o,state:r});}}};var je=e=>e.length===1?e[0]:n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.methods.pipe}),parameters:e}),eu=({plugin:e,schema:t,state:r})=>{let s=n.propertyAccessExpression({expression:h.v,name:h.schemas.array}),o=[];if(t.items){t=H({schema:t});let i=t.items.map(a=>{let p=ue({plugin:e,schema:a,state:r});return je(p)});if(i.length===1){let a=n.callExpression({functionName:s,parameters:i});o.push(a);}else {t.logicalOperator;let a=n.callExpression({functionName:s,parameters:[zr()]});o.push(a);}}else {let i=n.callExpression({functionName:s,parameters:[zr()]});o.push(i);}if(t.minItems===t.maxItems&&t.minItems!==void 0){let i=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.length}),parameters:[n.valueToExpression({value:t.minItems})]});o.push(i);}else {if(t.minItems!==void 0){let i=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.minLength}),parameters:[n.valueToExpression({value:t.minItems})]});o.push(i);}if(t.maxItems!==void 0){let i=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.maxLength}),parameters:[n.valueToExpression({value:t.maxItems})]});o.push(i);}}return je(o)},tu=({schema:e})=>typeof e.const=="boolean"?n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[n.ots.boolean(e.const)]}):n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.boolean})}),ru=({schema:e})=>{let t=[],r=false;for(let o of e.items??[])o.type==="string"&&typeof o.const=="string"?t.push(n.stringLiteral({text:o.const})):(o.type==="null"||o.const===null)&&(r=true);if(!t.length)return zr();let s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.picklist}),parameters:[n.arrayLiteralExpression({elements:t,multiLine:false})]});return r&&(s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.nullable}),parameters:[s]})),s},nu=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.never})}),su=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.null})}),Tp=({schema:e})=>{let t=e.format,r=e.type==="integer",s=Op(t),o=Js(t)?rs[t]:null;if(e.const!==void 0&&e.const!==null){let a=e.const,p;if(typeof a=="number"&&!t)p=n.ots.number(a);else if(typeof a=="number"&&t)s?p=n.callExpression({functionName:"BigInt",parameters:[n.ots.string(a.toString())]}):p=n.ots.number(a);else if(typeof a=="string"&&s){let c=a.endsWith("n")?a.slice(0,-1):a;p=n.callExpression({functionName:"BigInt",parameters:[n.ots.string(c)]});}else if(typeof a=="bigint"){let c=a.toString(),m=c.endsWith("n")?c.slice(0,-1):c;p=n.callExpression({functionName:"BigInt",parameters:[n.ots.string(m)]});}else p=n.valueToExpression({value:a});return n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[p]})}let i=[];if(s){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.union}),parameters:[n.arrayLiteralExpression({elements:[n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.number})}),n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.string})}),n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.bigInt})})],multiLine:false})]});i.push(a);let p=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.transform}),parameters:[n.arrowFunction({parameters:[{name:"x"}],statements:n.callExpression({functionName:"BigInt",parameters:[n.identifier({text:"x"})]})})]});i.push(p);}else {let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.number})});i.push(a);}if(!s&&r){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.integer})});i.push(a);}if(o){let a=o.min,p=o.max,c=o.minError,m=o.maxError,f=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.minValue}),parameters:[s?n.callExpression({functionName:"BigInt",parameters:[n.ots.string(a.toString())]}):n.ots.number(a),n.ots.string(c)]});i.push(f);let l=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.maxValue}),parameters:[s?n.callExpression({functionName:"BigInt",parameters:[n.ots.string(p.toString())]}):n.ots.number(p),n.ots.string(m)]});i.push(l);}if(e.exclusiveMinimum!==void 0){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.gtValue}),parameters:[xr({isBigInt:s,value:e.exclusiveMinimum})]});i.push(a);}else if(e.minimum!==void 0){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.minValue}),parameters:[xr({isBigInt:s,value:e.minimum})]});i.push(a);}if(e.exclusiveMaximum!==void 0){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.ltValue}),parameters:[xr({isBigInt:s,value:e.exclusiveMaximum})]});i.push(a);}else if(e.maximum!==void 0){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.maxValue}),parameters:[xr({isBigInt:s,value:e.maximum})]});i.push(a);}return je(i)},ou=({plugin:e,schema:t,state:r})=>{let s=[],o=t.required??[];for(let a in t.properties){let p=t.properties[a],c=o.includes(a),m=ue({optional:!c,plugin:e,schema:p,state:r});G.lastIndex=0;let f;G.test(a)?f=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):f=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(f=`'${a}'`),s.push(n.propertyAssignment({initializer:je(m),name:f}));}if(t.additionalProperties&&t.additionalProperties.type==="object"&&!Object.keys(s).length){let a=ue({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.record}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.string}),parameters:[]}),je(a)]})}}let i=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(s,true)]});return {anyType:h.types.GenericSchema.text,expression:i}},iu=({schema:e})=>{if(typeof e.const=="string")return n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[n.ots.string(e.const)]});let t=[],r=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.string})});if(t.push(r),e.format)switch(e.format){case "date":t.push(n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.isoDate})}));break;case "date-time":t.push(n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.isoTimestamp})}));break;case "ipv4":case "ipv6":t.push(n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.ip})}));break;case "uri":t.push(n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.url})}));break;case "email":case "time":case "uuid":t.push(n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:n.identifier({text:e.format})})}));break}if(e.minLength===e.maxLength&&e.minLength!==void 0){let s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.length}),parameters:[n.valueToExpression({value:e.minLength})]});t.push(s);}else {if(e.minLength!==void 0){let s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.minLength}),parameters:[n.valueToExpression({value:e.minLength})]});t.push(s);}if(e.maxLength!==void 0){let s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.maxLength}),parameters:[n.valueToExpression({value:e.maxLength})]});t.push(s);}}if(e.pattern){let s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.regex}),parameters:[n.regularExpressionLiteral({text:e.pattern})]});t.push(s);}return je(t)},au=({plugin:e,schema:t,state:r})=>{if(t.const&&Array.isArray(t.const)){let s=t.const.map(i=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[n.valueToExpression({value:i})]}));return n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.tuple}),parameters:[n.arrayLiteralExpression({elements:s})]})}if(t.items){let s=t.items.map(i=>{let a=ue({plugin:e,schema:i,state:r});return je(a)});return n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.tuple}),parameters:[n.arrayLiteralExpression({elements:s})]})}return zr()},pu=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.undefined})}),zr=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.unknown})}),cu=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.void})}),Rp=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:eu({plugin:e,schema:t,state:r})};case "boolean":return {expression:tu({schema:t})};case "enum":return {expression:ru({schema:t})};case "integer":case "number":return {expression:Tp({schema:t})};case "never":return {expression:nu()};case "null":return {expression:su()};case "object":return ou({plugin:e,schema:t,state:r});case "string":return t.format==="int64"||t.format==="uint64"?{expression:Tp({schema:t})}:{expression:iu({schema:t})};case "tuple":return {expression:au({plugin:e,schema:t,state:r})};case "undefined":return {expression:pu()};case "unknown":return {expression:zr()};case "void":return {expression:cu()}}},ue=({$ref:e,identifier:t,optional:r,plugin:s,schema:o,state:i})=>{let a=s.context.file({id:Ye}),p,c=t,m=[];if(e&&(i.circularReferenceTracker.add(e),c||(c=a.identifier({$ref:e,case:i.nameCase,create:true,nameTransformer:i.nameTransformer,namespace:"value"}))),o.$ref){let f=i.circularReferenceTracker.has(o.$ref),l=a.identifier({$ref:o.$ref,case:i.nameCase,nameTransformer:i.nameTransformer,namespace:"value"});if(!l.name){let d=s.context.resolveIrRef(o.$ref),y=ue({$ref:o.$ref,plugin:s,schema:d,state:i});m.push(...y),l=a.identifier({$ref:o.$ref,case:i.nameCase,nameTransformer:i.nameTransformer,namespace:"value"});}if(l.name){let d=n.identifier({text:l.name});if(f){let y=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.lazy}),parameters:[n.arrowFunction({statements:[n.returnStatement({expression:d})]})]});m.push(y),i.hasCircularReference=true;}else m.push(d);}}else if(o.type){let f=Rp({plugin:s,schema:o,state:i});if(p=f.anyType,m.push(f.expression),s.config.metadata&&o.description){let l=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.metadata}),parameters:[n.objectExpression({obj:[{key:"description",value:n.stringLiteral({text:o.description})}]})]});m.push(l);}}else if(o.items)if(o=H({schema:o}),o.items){let f=o.items.map(l=>{let d=ue({plugin:s,schema:l,state:i});return je(d)});if(o.logicalOperator==="and"){let l=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.intersect}),parameters:[n.arrayLiteralExpression({elements:f})]});m.push(l);}else {let l=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.union}),parameters:[n.arrayLiteralExpression({elements:f})]});m.push(l);}}else {let f=ue({plugin:s,schema:o,state:i});m.push(...f);}else {let f=Rp({plugin:s,schema:{type:"unknown"},state:i});p=f.anyType,m.push(f.expression);}if(e&&i.circularReferenceTracker.delete(e),m.length&&o.accessScope==="read"){let f=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.readonly})});m.push(f);}if(m.length){let f;if(o.default!==void 0){let l=o.type==="integer"&&o.format==="int64";f=xr({isBigInt:l,value:o.default}),f&&(m=[n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.optional}),parameters:[je(m),f]})]);}r&&!f&&(m=[n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.optional}),parameters:[je(m)]})]);}if(c&&c.name&&c.created){let f=n.constVariable({comment:s.config.comments?Ne({schema:o}):void 0,exportConst:true,expression:je(m),name:c.name,typeName:i.hasCircularReference?n.propertyAccessExpression({expression:h.v,name:p||h.types.GenericSchema.text}):void 0});return a.add(f),[]}return m},Ap=({plugin:e})=>{e.createFile({case:e.config.case,id:Ye,path:e.output}).import({alias:h.v.text,module:"valibot",name:"*"}),e.forEach("operation","parameter","requestBody","schema",r=>{let s={circularReferenceTracker:new Set,hasCircularReference:false,nameCase:e.config.definitions.case,nameTransformer:e.config.definitions.name};r.type==="operation"?Sp({operation:r.operation,plugin:e,state:s}):r.type==="parameter"?ue({$ref:r.$ref,plugin:e,schema:r.parameter.schema,state:s}):r.type==="requestBody"?ue({$ref:r.$ref,plugin:e,schema:r.requestBody.schema,state:s}):r.type==="schema"&&ue({$ref:r.$ref,plugin:e,schema:r.schema,state:s});});};var ns={api:bp,config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:Ap,name:"valibot",output:"valibot",resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}Data"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}Response"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.responses});},tags:["validator"]};var u={ZodMiniOptional:n.identifier({text:"ZodMiniOptional"}),ZodOptional:n.identifier({text:"ZodOptional"}),_default:n.identifier({text:"_default"}),and:n.identifier({text:"and"}),array:n.identifier({text:"array"}),bigint:n.identifier({text:"bigint"}),boolean:n.identifier({text:"boolean"}),check:n.identifier({text:"check"}),coerce:n.identifier({text:"coerce"}),date:n.identifier({text:"date"}),datetime:n.identifier({text:"datetime"}),default:n.identifier({text:"default"}),describe:n.identifier({text:"describe"}),email:n.identifier({text:"email"}),enum:n.identifier({text:"enum"}),globalRegistry:n.identifier({text:"globalRegistry"}),gt:n.identifier({text:"gt"}),gte:n.identifier({text:"gte"}),infer:n.identifier({text:"infer"}),int:n.identifier({text:"int"}),intersection:n.identifier({text:"intersection"}),ip:n.identifier({text:"ip"}),ipv4:n.identifier({text:"ipv4"}),ipv6:n.identifier({text:"ipv6"}),iso:n.identifier({text:"iso"}),lazy:n.identifier({text:"lazy"}),length:n.identifier({text:"length"}),literal:n.identifier({text:"literal"}),lt:n.identifier({text:"lt"}),lte:n.identifier({text:"lte"}),max:n.identifier({text:"max"}),maxLength:n.identifier({text:"maxLength"}),min:n.identifier({text:"min"}),minLength:n.identifier({text:"minLength"}),never:n.identifier({text:"never"}),null:n.identifier({text:"null"}),nullable:n.identifier({text:"nullable"}),number:n.identifier({text:"number"}),object:n.identifier({text:"object"}),optional:n.identifier({text:"optional"}),parseAsync:n.identifier({text:"parseAsync"}),readonly:n.identifier({text:"readonly"}),record:n.identifier({text:"record"}),regex:n.identifier({text:"regex"}),register:n.identifier({text:"register"}),string:n.identifier({text:"string"}),time:n.identifier({text:"time"}),tuple:n.identifier({text:"tuple"}),undefined:n.identifier({text:"undefined"}),union:n.identifier({text:"union"}),unknown:n.identifier({text:"unknown"}),url:n.identifier({text:"url"}),uuid:n.identifier({text:"uuid"}),void:n.identifier({text:"void"}),z:n.identifier({text:"z"})},K="zod";var fu=({file:e,operation:t,plugin:r})=>{let o=r.context.file({id:K}).getName(r.api.getId({operation:t,type:"data"}));if(!o)return;e.import({module:e.relativePathToFile({context:r.context,id:K}),name:o});let i="data";return n.arrowFunction({async:true,parameters:[{name:i}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:n.identifier({text:o}),name:u.parseAsync}),parameters:[n.identifier({text:i})]})})})]})},lu=({file:e,operation:t,plugin:r})=>{let o=r.context.file({id:K}).getName(r.api.getId({operation:t,type:"responses"}));if(!o)return;e.import({module:e.relativePathToFile({context:r.context,id:K}),name:o});let i="data";return n.arrowFunction({async:true,parameters:[{name:i}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:n.identifier({text:o}),name:u.parseAsync}),parameters:[n.identifier({text:i})]})})})]})},uu=e=>{switch(e.type){case "data":case "responses":case "type-infer-data":case "type-infer-responses":return `${e.operation.id}-${e.type}`;case "ref":case "type-infer-ref":default:return `${e.type}-${e.value}`}},Ip={createRequestValidator:fu,createResponseValidator:lu,getId:uu};var ft=({plugin:e,schema:t,schemaId:r,typeInferId:s,zodSchema:o})=>{let i=e.context.file({id:K}),a=i.addNodeReference(r,{factory:c=>n.typeReferenceNode({typeName:c})}),p=n.constVariable({comment:e.config.comments?Ne({schema:t}):void 0,exportConst:true,expression:o.expression,name:a,typeName:o.typeName?n.propertyAccessExpression({expression:u.z,name:o.typeName}):void 0});if(i.add(p),s){let c=i.addNodeReference(s,{factory:l=>n.typeReferenceNode({typeName:l})}),m=i.addNodeReference(r,{factory:l=>n.identifier({text:l})}),f=n.typeAliasDeclaration({exportType:true,name:c,type:n.typeReferenceNode({typeArguments:[n.typeOfExpression({text:m})],typeName:n.propertyAccessExpression({expression:u.z,name:u.infer})})});i.add(f);}};var br=({plugin:e})=>{let t=e.package.getVersion("zod");if(t&&e.package.satisfies(t,"<4.0.0"))switch(e.config.compatibilityVersion){case 3:default:return "zod";case 4:return "zod/v4";case "mini":return "zod/v4-mini"}switch(e.config.compatibilityVersion){case 3:return "zod/v3";case 4:default:return "zod";case "mini":return "zod/mini"}};var Or=({getZodSchema:e,operation:t,plugin:r})=>{let s=r.context.file({id:K});if(r.config.requests.enabled){let o=new Set,i={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(t.parameters){if(t.parameters.header){let m={},f=[];for(let l in t.parameters.header){let d=t.parameters.header[l];m[d.name]=d.schema,d.required&&(f.push(d.name),o.add("headers"));}Object.keys(m).length&&(i.properties.headers={properties:m,required:f,type:"object"});}if(t.parameters.path){let m={},f=[];for(let l in t.parameters.path){let d=t.parameters.path[l];m[d.name]=d.schema,d.required&&(f.push(d.name),o.add("path"));}Object.keys(m).length&&(i.properties.path={properties:m,required:f,type:"object"});}if(t.parameters.query){let m={},f=[];for(let l in t.parameters.query){let d=t.parameters.query[l];m[d.name]=d.schema,d.required&&(f.push(d.name),o.add("query"));}Object.keys(m).length&&(i.properties.query={properties:m,required:f,type:"object"});}}t.body&&(i.properties.body=t.body.schema,t.body.required&&o.add("body")),i.required=[...o];let a=e(i),p=r.api.getId({operation:t,type:"data"}),c=r.config.requests.types.infer.enabled?r.api.getId({operation:t,type:"type-infer-data"}):void 0;ft({plugin:r,schema:i,schemaId:p,typeInferId:c,zodSchema:a}),s.updateNodeReferences(p,N({config:r.config.requests,name:t.id})),c&&s.updateNodeReferences(c,N({config:r.config.requests.types.infer,name:t.id}));}if(r.config.responses.enabled&&t.responses){let{response:o}=Fe(t);if(o){let i=e(o),a=r.api.getId({operation:t,type:"responses"}),p=r.config.responses.types.infer.enabled?r.api.getId({operation:t,type:"type-infer-responses"}):void 0;ft({plugin:r,schema:o,schemaId:a,typeInferId:p,zodSchema:i}),s.updateNodeReferences(a,N({config:r.config.responses,name:t.id})),p&&s.updateNodeReferences(p,N({config:r.config.responses.types.infer,name:t.id}));}}};var du=({plugin:e,schema:t,state:r})=>{let s={},o=n.propertyAccessExpression({expression:u.z,name:u.array});if(!t.items)s.expression=n.callExpression({functionName:o,parameters:[to().expression]});else {t=H({schema:t});let a=t.items.map(p=>{let c=Et({plugin:e,schema:p,state:r});return c.hasCircularReference&&(s.hasCircularReference=true),c.expression});a.length===1?s.expression=n.callExpression({functionName:o,parameters:a}):(t.logicalOperator,s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.array}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:a})]})]}));}let i=[];return t.minItems===t.maxItems&&t.minItems!==void 0?i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.length}),parameters:[n.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.minLength}),parameters:[n.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.maxLength}),parameters:[n.valueToExpression({value:t.maxItems})]}))),i.length&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.check}),parameters:i})),s},yu=({schema:e})=>{let t={};return typeof e.const=="boolean"?(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.boolean(e.const)]}),t):(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.boolean})}),t)},gu=({schema:e})=>{let t={},r=[],s=false;for(let o of e.items??[])o.type==="string"&&typeof o.const=="string"?r.push(n.stringLiteral({text:o.const})):(o.type==="null"||o.const===null)&&(s=true);return r.length?(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.enum}),parameters:[n.arrayLiteralExpression({elements:r,multiLine:false})]}),s&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.nullable}),parameters:[t.expression]})),t):to()},hu=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.never})}),t},xu=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.null})}),t},Kr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r},bu=({schema:e})=>{let t={},r=e.type==="integer"&&e.format==="int64";if(typeof e.const=="number")return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.number(e.const)]}),t;t.expression=n.callExpression({functionName:r?n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.coerce}),name:u.bigint}):n.propertyAccessExpression({expression:u.z,name:u.number})}),!r&&e.type==="integer"&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.int})}));let s=[];return e.exclusiveMinimum!==void 0?s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.gt}),parameters:[Kr({isBigInt:r,value:e.exclusiveMinimum})]})):e.minimum!==void 0&&s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.gte}),parameters:[Kr({isBigInt:r,value:e.minimum})]})),e.exclusiveMaximum!==void 0?s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.lt}),parameters:[Kr({isBigInt:r,value:e.exclusiveMaximum})]})):e.maximum!==void 0&&s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.lte}),parameters:[Kr({isBigInt:r,value:e.maximum})]})),s.length&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.expression,name:u.check}),parameters:s})),t},Ou=({plugin:e,schema:t,state:r})=>{let s={},o=[],i=t.required??[];for(let a in t.properties){let p=t.properties[a],c=i.includes(a),m=Et({optional:!c,plugin:e,schema:p,state:r});m.hasCircularReference&&(s.hasCircularReference=true),G.lastIndex=0;let f;G.test(a)?f=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):f=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(f=`'${a}'`),m.hasCircularReference?o.push(n.getAccessorDeclaration({name:f,returnType:m.typeName?n.propertyAccessExpression({expression:u.z,name:m.typeName}):void 0,statements:[n.returnStatement({expression:m.expression})]})):o.push(n.propertyAssignment({initializer:m.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Et({plugin:e,schema:t.additionalProperties,state:r});return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.record}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.string}),parameters:[]}),a.expression]}),a.hasCircularReference&&(s.hasCircularReference=true),s}return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(o,true)]}),s},Su=({plugin:e,schema:t})=>{let r={};if(typeof t.const=="string")return r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.string(t.const)]}),r;if(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.string})}),t.format)switch(t.format){case "date":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.date})});break;case "date-time":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.datetime}),parameters:e.config.dates.offset?[n.objectExpression({obj:[{key:"offset",value:true}]})]:[]});break;case "email":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.email})});break;case "ipv4":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.ipv4})});break;case "ipv6":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.ipv6})});break;case "time":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.time})});break;case "uri":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.url})});break;case "uuid":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.uuid})});break}let s=[];return t.minLength===t.maxLength&&t.minLength!==void 0?s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.length}),parameters:[n.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.minLength}),parameters:[n.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.maxLength}),parameters:[n.valueToExpression({value:t.maxLength})]}))),t.pattern&&s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.regex}),parameters:[n.regularExpressionLiteral({text:t.pattern})]})),s.length&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.check}),parameters:s})),r},Tu=({plugin:e,schema:t,state:r})=>{let s={};if(t.const&&Array.isArray(t.const)){let i=t.const.map(a=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.valueToExpression({value:a})]}));return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:i})]}),s}let o=[];for(let i of t.items??[]){let a=Et({plugin:e,schema:i,state:r});o.push(a.expression),a.hasCircularReference&&(s.hasCircularReference=true);}return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:o})]}),s},Ru=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.undefined})}),t},to=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.unknown})}),t},Au=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.void})}),t},Pp=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return du({plugin:e,schema:t,state:r});case "boolean":return yu({schema:t});case "enum":return gu({schema:t});case "integer":case "number":return bu({schema:t});case "never":return hu();case "null":return xu();case "object":return Ou({plugin:e,schema:t,state:r});case "string":return Su({plugin:e,schema:t});case "tuple":return Tu({plugin:e,schema:t,state:r});case "undefined":return Ru();case "unknown":return to();case "void":return Au()}},Et=({optional:e,plugin:t,schema:r,state:s})=>{let o=t.context.file({id:K}),i={};if(r.$ref){let a=s.circularReferenceTracker.includes(r.$ref),p=s.currentReferenceTracker.includes(r.$ref);s.circularReferenceTracker.push(r.$ref),s.currentReferenceTracker.push(r.$ref);let c=t.api.getId({type:"ref",value:r.$ref});if(a){let m=o.addNodeReference(c,{factory:f=>n.identifier({text:f})});p?i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.lazy}),parameters:[n.arrowFunction({returnType:n.keywordTypeNode({keyword:"any"}),statements:[n.returnStatement({expression:m})]})]}):i.expression=m,i.hasCircularReference=true;}else if(!o.getName(c)){let m=t.context.resolveIrRef(r.$ref);ss({id:r.$ref,plugin:t,schema:m,state:s});}if(!a){let m=o.addNodeReference(c,{factory:f=>n.identifier({text:f})});i.expression=m;}s.circularReferenceTracker.pop(),s.currentReferenceTracker.pop();}else if(r.type){let a=Pp({plugin:t,schema:r,state:s});i.expression=a.expression,i.hasCircularReference=a.hasCircularReference,t.config.metadata&&r.description&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.register}),parameters:[n.propertyAccessExpression({expression:u.z,name:u.globalRegistry}),n.objectExpression({obj:[{key:"description",value:n.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=H({schema:r}),r.items){let a=r.items.map(p=>Et({plugin:t,schema:p,state:s}).expression);if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.intersection}),parameters:a}):(i.expression=a[0],a.slice(1).forEach(c=>{i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.intersection}),parameters:[i.expression,c]});}));}else i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:a})]});}else i=Et({plugin:t,schema:r,state:s});else {let a=Pp({plugin:t,schema:{type:"unknown"},state:s});i.expression=a.expression;}if(i.expression&&(r.accessScope==="read"&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.readonly}),parameters:[i.expression]})),e&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.optional}),parameters:[i.expression]}),i.typeName=u.ZodMiniOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=Kr({isBigInt:a,value:r.default});p&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u._default}),parameters:[i.expression,p]}));}return i},ss=({id:e,plugin:t,schema:r,state:s})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...s,currentReferenceTracker:[e]},i=t.context.file({id:K}),a=t.api.getId({type:"ref",value:e});if(i.getName(a))return;let p=Et({plugin:t,schema:r,state:o}),c=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;ft({plugin:t,schema:r,schemaId:a,typeInferId:c,zodSchema:p});let m=D(e);i.updateNodeReferences(a,N({config:t.config.definitions,name:m})),c&&i.updateNodeReferences(c,N({config:t.config.definitions.types.infer,name:m}));},Ep=({plugin:e})=>{e.createFile({case:e.config.case,id:K,path:e.output}).import({alias:u.z.text,module:br({plugin:e}),name:"*"}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Or({getZodSchema:s=>Et({plugin:e,schema:s,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?ss({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?ss({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&ss({id:r.$ref,plugin:e,schema:r.schema});});};var Iu=({plugin:e,schema:t,state:r})=>{let s=n.propertyAccessExpression({expression:u.z,name:u.array}),o;if(!t.items)o=n.callExpression({functionName:s,parameters:[no()]});else {t=H({schema:t});let i=t.items.map(a=>Nt({plugin:e,schema:a,state:r}).expression);i.length===1?o=n.callExpression({functionName:s,parameters:i}):(t.logicalOperator,o=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.array}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:i})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?o=n.callExpression({functionName:n.propertyAccessExpression({expression:o,name:u.length}),parameters:[n.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(o=n.callExpression({functionName:n.propertyAccessExpression({expression:o,name:u.min}),parameters:[n.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(o=n.callExpression({functionName:n.propertyAccessExpression({expression:o,name:u.max}),parameters:[n.valueToExpression({value:t.maxItems})]}))),o},Pu=({schema:e})=>typeof e.const=="boolean"?n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.boolean(e.const)]}):n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.boolean})}),Eu=({schema:e})=>{let t=[],r=false;for(let o of e.items??[])o.type==="string"&&typeof o.const=="string"?t.push(n.stringLiteral({text:o.const})):(o.type==="null"||o.const===null)&&(r=true);if(!t.length)return no();let s=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.enum}),parameters:[n.arrayLiteralExpression({elements:t,multiLine:false})]});return r&&(s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.nullable})})),s},Nu=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.never})}),ju=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.null})}),Wr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r},Cu=({schema:e})=>{let t=e.type==="integer"&&e.format==="int64";if(typeof e.const=="number")return n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.number(e.const)]});let r=n.callExpression({functionName:t?n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.coerce}),name:u.bigint}):n.propertyAccessExpression({expression:u.z,name:u.number})});return !t&&e.type==="integer"&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.int})})),e.exclusiveMinimum!==void 0?r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.gt}),parameters:[Wr({isBigInt:t,value:e.exclusiveMinimum})]}):e.minimum!==void 0&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.gte}),parameters:[Wr({isBigInt:t,value:e.minimum})]})),e.exclusiveMaximum!==void 0?r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.lt}),parameters:[Wr({isBigInt:t,value:e.exclusiveMaximum})]}):e.maximum!==void 0&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.lte}),parameters:[Wr({isBigInt:t,value:e.maximum})]})),r},ku=({plugin:e,schema:t,state:r})=>{let s=[],o=t.required??[];for(let a in t.properties){let p=t.properties[a],c=o.includes(a),m=Nt({optional:!c,plugin:e,schema:p,state:r}).expression;G.lastIndex=0;let f;G.test(a)?f=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):f=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(f=`'${a}'`),s.push(n.propertyAssignment({initializer:m,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Nt({plugin:e,schema:t.additionalProperties,state:r}).expression;return {anyType:"AnyZodObject",expression:n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.record}),parameters:[a]})}}return {anyType:"AnyZodObject",expression:n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(s,true)]})}},vu=({plugin:e,schema:t})=>{if(typeof t.const=="string")return n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.string(t.const)]});let r=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.string})});if(t.format)switch(t.format){case "date":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.date})});break;case "date-time":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.datetime}),parameters:e.config.dates.offset?[n.objectExpression({obj:[{key:"offset",value:true}]})]:[]});break;case "email":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.email})});break;case "ipv4":case "ipv6":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.ip})});break;case "time":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.time})});break;case "uri":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.url})});break;case "uuid":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.length}),parameters:[n.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.min}),parameters:[n.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.max}),parameters:[n.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.regex}),parameters:[n.regularExpressionLiteral({text:t.pattern})]})),r},wu=({plugin:e,schema:t,state:r})=>{if(t.const&&Array.isArray(t.const)){let i=t.const.map(p=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.valueToExpression({value:p})]}));return n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:i})]})}let s=[];for(let i of t.items??[])s.push(Nt({plugin:e,schema:i,state:r}).expression);return n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:s})]})},qu=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.undefined})}),no=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.unknown})}),$u=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.void})}),Np=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:Iu({plugin:e,schema:t,state:r})};case "boolean":return {expression:Pu({schema:t})};case "enum":return {expression:Eu({schema:t})};case "integer":case "number":return {expression:Cu({schema:t})};case "never":return {expression:Nu()};case "null":return {expression:ju()};case "object":return ku({plugin:e,schema:t,state:r});case "string":return {expression:vu({plugin:e,schema:t})};case "tuple":return {expression:wu({plugin:e,schema:t,state:r})};case "undefined":return {expression:qu()};case "unknown":return {expression:no()};case "void":return {expression:$u()}}},Nt=({optional:e,plugin:t,schema:r,state:s})=>{let o=t.context.file({id:K}),i={};if(r.$ref){let a=s.circularReferenceTracker.includes(r.$ref);s.circularReferenceTracker.push(r.$ref),s.currentReferenceTracker.push(r.$ref);let p=t.api.getId({type:"ref",value:r.$ref});if(a){let c=o.addNodeReference(p,{factory:m=>n.identifier({text:m})});i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.lazy}),parameters:[n.arrowFunction({statements:[n.returnStatement({expression:c})]})]}),s.hasCircularReference=true;}else if(!o.getName(p)){let c=t.context.resolveIrRef(r.$ref);os({id:r.$ref,plugin:t,schema:c,state:s});}if(!a){let c=o.addNodeReference(p,{factory:m=>n.identifier({text:m})});i.expression=c;}s.circularReferenceTracker.pop(),s.currentReferenceTracker.pop();}else if(r.type){let a=Np({plugin:t,schema:r,state:s});i.expression=a.expression,i.typeName=a.anyType,t.config.metadata&&r.description&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.describe}),parameters:[n.stringLiteral({text:r.description})]}));}else if(r.items)if(r=H({schema:r}),r.items){let a=r.items.map(p=>Nt({plugin:t,schema:p,state:s}).expression);if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.intersection}),parameters:a}):(i.expression=a[0],a.slice(1).forEach(c=>{i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.and}),parameters:[c]});}));}else i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:a})]});}else i=Nt({plugin:t,schema:r,state:s});else {let a=Np({plugin:t,schema:{type:"unknown"},state:s});i.expression=a.expression,i.typeName=a.anyType;}if(i.expression&&(r.accessScope==="read"&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.readonly})})),e&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.optional})})),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=Wr({isBigInt:a,value:r.default});p&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.default}),parameters:[p]}));}return s.hasCircularReference?i.typeName||(i.typeName="ZodTypeAny"):i.typeName=void 0,i},os=({id:e,plugin:t,schema:r,state:s})=>{s||(s={circularReferenceTracker:[e],currentReferenceTracker:[e],hasCircularReference:false});let o=t.context.file({id:K}),i=t.api.getId({type:"ref",value:e});if(o.getName(i))return;let a=Nt({plugin:t,schema:r,state:s}),p=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;ft({plugin:t,schema:r,schemaId:i,typeInferId:p,zodSchema:a});let c=D(e);o.updateNodeReferences(i,N({config:t.config.definitions,name:c})),p&&o.updateNodeReferences(p,N({config:t.config.definitions.types.infer,name:c}));},jp=({plugin:e})=>{e.createFile({case:e.config.case,id:K,path:e.output}).import({module:br({plugin:e}),name:u.z.text}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Or({getZodSchema:s=>Nt({plugin:e,schema:s,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?os({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?os({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&os({id:r.$ref,plugin:e,schema:r.schema});});};var Mu=({plugin:e,schema:t,state:r})=>{let s={},o=n.propertyAccessExpression({expression:u.z,name:u.array});if(!t.items)s.expression=n.callExpression({functionName:o,parameters:[oo().expression]});else {t=H({schema:t});let i=t.items.map(a=>{let p=jt({plugin:e,schema:a,state:r});return p.hasCircularReference&&(s.hasCircularReference=true),p.expression});i.length===1?s.expression=n.callExpression({functionName:o,parameters:i}):(t.logicalOperator,s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.array}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:i})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.length}),parameters:[n.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.min}),parameters:[n.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.max}),parameters:[n.valueToExpression({value:t.maxItems})]}))),s},Fu=({schema:e})=>{let t={};return typeof e.const=="boolean"?(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.boolean(e.const)]}),t):(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.boolean})}),t)},Lu=({schema:e})=>{let t={},r=[],s=false;for(let o of e.items??[])o.type==="string"&&typeof o.const=="string"?r.push(n.stringLiteral({text:o.const})):(o.type==="null"||o.const===null)&&(s=true);return r.length?(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.enum}),parameters:[n.arrayLiteralExpression({elements:r,multiLine:false})]}),s&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.nullable}),parameters:[t.expression]})),t):oo()},Du=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.never})}),t},Vu=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.null})}),t},Hr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r},_u=({schema:e})=>{let t={},r=e.type==="integer"&&e.format==="int64";return typeof e.const=="number"?(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.number(e.const)]}),t):(t.expression=n.callExpression({functionName:r?n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.coerce}),name:u.bigint}):n.propertyAccessExpression({expression:u.z,name:u.number})}),!r&&e.type==="integer"&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.int})})),e.exclusiveMinimum!==void 0?t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.expression,name:u.gt}),parameters:[Hr({isBigInt:r,value:e.exclusiveMinimum})]}):e.minimum!==void 0&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.expression,name:u.gte}),parameters:[Hr({isBigInt:r,value:e.minimum})]})),e.exclusiveMaximum!==void 0?t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.expression,name:u.lt}),parameters:[Hr({isBigInt:r,value:e.exclusiveMaximum})]}):e.maximum!==void 0&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.expression,name:u.lte}),parameters:[Hr({isBigInt:r,value:e.maximum})]})),t)},Bu=({plugin:e,schema:t,state:r})=>{let s={},o=[],i=t.required??[];for(let a in t.properties){let p=t.properties[a],c=i.includes(a),m=jt({optional:!c,plugin:e,schema:p,state:r});m.hasCircularReference&&(s.hasCircularReference=true),G.lastIndex=0;let f;G.test(a)?f=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):f=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(f=`'${a}'`),m.hasCircularReference?o.push(n.getAccessorDeclaration({name:f,returnType:m.typeName?n.propertyAccessExpression({expression:u.z,name:m.typeName}):void 0,statements:[n.returnStatement({expression:m.expression})]})):o.push(n.propertyAssignment({initializer:m.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=jt({plugin:e,schema:t.additionalProperties,state:r});return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.record}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.string}),parameters:[]}),a.expression]}),a.hasCircularReference&&(s.hasCircularReference=true),s.hasCircularReference?{...s,typeName:"ZodType"}:s}return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(o,true)]}),s.hasCircularReference?{...s,typeName:"ZodType"}:s},zu=({plugin:e,schema:t})=>{let r={};if(typeof t.const=="string")return r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.string(t.const)]}),r;if(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.string})}),t.format)switch(t.format){case "date":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.date})});break;case "date-time":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.datetime}),parameters:e.config.dates.offset?[n.objectExpression({obj:[{key:"offset",value:true}]})]:[]});break;case "email":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.email})});break;case "ipv4":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.ipv4})});break;case "ipv6":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.ipv6})});break;case "time":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.time})});break;case "uri":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.url})});break;case "uuid":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.length}),parameters:[n.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.min}),parameters:[n.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.max}),parameters:[n.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.regex}),parameters:[n.regularExpressionLiteral({text:t.pattern})]})),r},Ku=({plugin:e,schema:t,state:r})=>{let s={};if(t.const&&Array.isArray(t.const)){let i=t.const.map(a=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.valueToExpression({value:a})]}));return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:i})]}),s}let o=[];for(let i of t.items??[]){let a=jt({plugin:e,schema:i,state:r});o.push(a.expression),a.hasCircularReference&&(s.hasCircularReference=true);}return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:o})]}),s},Wu=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.undefined})}),t},oo=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.unknown})}),t},Hu=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.void})}),t},Cp=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return Mu({plugin:e,schema:t,state:r});case "boolean":return Fu({schema:t});case "enum":return Lu({schema:t});case "integer":case "number":return _u({schema:t});case "never":return Du();case "null":return Vu();case "object":return Bu({plugin:e,schema:t,state:r});case "string":return zu({plugin:e,schema:t});case "tuple":return Ku({plugin:e,schema:t,state:r});case "undefined":return Wu();case "unknown":return oo();case "void":return Hu()}},jt=({optional:e,plugin:t,schema:r,state:s})=>{let o=t.context.file({id:K}),i={};if(r.$ref){let a=s.circularReferenceTracker.includes(r.$ref),p=s.currentReferenceTracker.includes(r.$ref);s.circularReferenceTracker.push(r.$ref),s.currentReferenceTracker.push(r.$ref);let c=t.api.getId({type:"ref",value:r.$ref});if(a){let m=o.addNodeReference(c,{factory:f=>n.identifier({text:f})});p?i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.lazy}),parameters:[n.arrowFunction({returnType:n.keywordTypeNode({keyword:"any"}),statements:[n.returnStatement({expression:m})]})]}):i.expression=m,i.hasCircularReference=true;}else if(!o.getName(c)){let m=t.context.resolveIrRef(r.$ref);is({id:r.$ref,plugin:t,schema:m,state:s});}if(!a){let m=o.addNodeReference(c,{factory:f=>n.identifier({text:f})});i.expression=m;}s.circularReferenceTracker.pop(),s.currentReferenceTracker.pop();}else if(r.type){let a=Cp({plugin:t,schema:r,state:s});i.expression=a.expression,i.hasCircularReference=a.hasCircularReference,t.config.metadata&&r.description&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.register}),parameters:[n.propertyAccessExpression({expression:u.z,name:u.globalRegistry}),n.objectExpression({obj:[{key:"description",value:n.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=H({schema:r}),r.items){let a=r.items.map(p=>jt({plugin:t,schema:p,state:s}).expression);if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.intersection}),parameters:a}):(i.expression=a[0],a.slice(1).forEach(c=>{i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.and}),parameters:[c]});}));}else i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:a})]});}else i=jt({plugin:t,schema:r,state:s});else {let a=Cp({plugin:t,schema:{type:"unknown"},state:s});i.expression=a.expression;}if(i.expression&&(r.accessScope==="read"&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.readonly})})),e&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.optional}),parameters:[i.expression]}),i.typeName=u.ZodOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=Hr({isBigInt:a,value:r.default});p&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.default}),parameters:[p]}));}return i},is=({id:e,plugin:t,schema:r,state:s})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...s,currentReferenceTracker:[e]},i=t.context.file({id:K}),a=t.api.getId({type:"ref",value:e});if(i.getName(a))return;let p=jt({plugin:t,schema:r,state:o}),c=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;ft({plugin:t,schema:r,schemaId:a,typeInferId:c,zodSchema:p});let m=D(e);i.updateNodeReferences(a,N({config:t.config.definitions,name:m})),c&&i.updateNodeReferences(c,N({config:t.config.definitions.types.infer,name:m}));},io=({plugin:e})=>{e.createFile({case:e.config.case,id:K,path:e.output}).import({module:br({plugin:e}),name:u.z.text}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Or({getZodSchema:s=>jt({plugin:e,schema:s,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?is({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?is({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&is({id:r.$ref,plugin:e,schema:r.schema});});};var kp=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return jp(e);case 4:return io(e);case "mini":return Ep(e);default:return io(e)}};var as={api:Ip,config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:kp,name:"zod",output:"zod",resolveConfig:(e,t)=>{let r="zod",s=t.package.getVersion(r),o=()=>s&&(s.major===4||s.major===3)?s.major:4,i=a=>{if(!a)return o();if(!s)return a;if((a===4||a===3||a==="mini")&&!t.package.satisfies(s,">=3.25.0 <5.0.0")){let p=o();return console.warn(`\u{1F50C} ${Zr__default.default.yellow("Warning:")} Installed ${Zr__default.default.cyan(r)} ${Zr__default.default.cyan(`v${s.version}`)} does not support compatibility version ${Zr__default.default.yellow(String(a))}, using ${Zr__default.default.yellow(String(p))}.`),p}return a};e.config.compatibilityVersion=i(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{offset:false},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:"PascalCase",enabled:false}},mappers:{object:(a,p)=>({...a,infer:t.valueToObject({defaultValue:{...p.infer,enabled:a.infer!==void 0?!!a.infer:p.infer.enabled},mappers:lt,value:a.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}ZodType"}}},mappers:{...lt,object:(a,p)=>({...a,types:t.valueToObject({defaultValue:p.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:lt,value:c.infer})})},value:a.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}Data",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}DataZodType"}}},mappers:{...lt,object:(a,p)=>({...a,types:t.valueToObject({defaultValue:p.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:lt,value:c.infer})})},value:a.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}Response",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}ResponseZodType"}}},mappers:{...lt,object:(a,p)=>({...a,types:t.valueToObject({defaultValue:p.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:lt,value:c.infer})})},value:a.types})})},value:e.config.responses});},tags:["validator"]};var ps={"@angular/common":Rn,"@hey-api/client-angular":An,"@hey-api/client-axios":In,"@hey-api/client-fetch":Pn,"@hey-api/client-next":En,"@hey-api/client-nuxt":Nn,"@hey-api/schemas":$n,"@hey-api/sdk":Mn,"@hey-api/transformers":Ln,"@hey-api/typescript":_n,"@tanstack/angular-query-experimental":Xn,"@tanstack/react-query":Gn,"@tanstack/solid-query":Jn,"@tanstack/svelte-query":Yn,"@tanstack/vue-query":es,fastify:ts,"legacy/angular":jn,"legacy/axios":Cn,"legacy/fetch":kn,"legacy/node":vn,"legacy/xhr":wn,valibot:ns,zod:as};var vp=["@hey-api/typescript","@hey-api/sdk"],Uu=({dependencies:e,userPlugins:t,userPluginsConfig:r})=>{let s=new Set,o=new Set,i={},a=p=>{if(s.has(p))throw new Error(`Circular reference detected at '${p}'`);if(o.has(p))return;s.add(p);let c=ps[p],m=r[p];if(!c&&!m)throw new Error(`unknown plugin dependency "${p}" - do you need to register a custom plugin with this name?`);let f={...c,...m,config:{...c?.config,...m?.config},dependencies:new Set([...c?.dependencies||[],...m?.dependencies||[]])};if(f.resolveConfig){let l={package:mn(e),pluginByTag:(d,y={})=>{let{defaultPlugin:g,errorMessage:x}=y;for(let S of t){let O=ps[S]||r[S];if(O&&O.tags?.includes(d)&&S!==p)return S}if(g){let S=ps[g]||r[g];if(S&&S.tags?.includes(d)&&g!==p)return g}throw new Error(x||`missing plugin - no plugin with tag "${d}" found`)},valueToObject:kt};f.resolveConfig(f,l);}for(let l of f.dependencies)a(l);s.delete(p),o.add(p),i[p]=f;};for(let p of t)a(p);return {pluginOrder:Array.from(o),plugins:i}},Qu=e=>typeof e=="string"?e.startsWith("@hey-api/client")||e.startsWith("legacy/"):e.name.startsWith("@hey-api/client")||e.name.startsWith("legacy/")||e.tags&&e.tags.includes("client"),wp=({dependencies:e,userConfig:t})=>{let r={},s=vp;t.plugins&&(t.plugins=t.plugins.filter(i=>typeof i=="string"&&i||typeof i!="string"&&i.name),t.plugins.length===1&&Qu(t.plugins[0])?s=[...vp,...t.plugins]:s=t.plugins);let o=s.map(i=>{if(typeof i=="string")return i;let a=i.name;return a&&(i.handler?r[a]=i:(r[a]={config:{...i}},delete r[a].config.name)),a}).filter(Boolean);return Uu({dependencies:e,userPlugins:o,userPluginsConfig:r})};var Ju=async e=>{let t;if(e?.configFile){let p=e.configFile.split(".");t=p.slice(0,p.length-1).join(".");}let{config:r,configFile:s}=await c12.loadConfig({configFile:t,name:"openapi-ts"}),o=go(Object.keys(r).length?s:void 0),i=Array.isArray(e)?e:Array.isArray(r)?r.map(p=>fs(p,e)):[fs(r,e)],a=[];for(let p of i){let{base:c,configFile:m="",dryRun:f=false,experimentalParser:l=true,exportCore:d=true,interactive:y=false,name:g,request:x,useOptions:S=true}=p,O=[],v=lo(p);v.level==="debug"&&console.warn("userConfig:",p);let _=fo(p),$=uo(p),F=ho(p);_.path||O.push(new Sr("missing input - which OpenAPI specification should we use to generate your output?")),$.path||O.push(new Sr("missing output - where should we generate your output?")),S||console.warn("\u2757\uFE0F Deprecation warning: useOptions set to false. This setting will be removed in future versions. Please migrate useOptions to true https://heyapi.dev/openapi-ts/migrating.html#v0-27-38"),$.path=sr__default.default.resolve(process.cwd(),$.path);let W;try{W=wp({dependencies:o,userConfig:p});}catch(C){O.push(C),W={pluginOrder:[],plugins:{}};}let L=co({...W,base:c,configFile:m,dryRun:f,experimentalParser:l,exportCore:false,input:_,interactive:y,logs:v,name:g,output:$,parser:F,request:x,useOptions:S});L.exportCore=X(L)?d:false,v.level==="debug"&&console.warn("config:",L),a.push({config:L,errors:O});}return {dependencies:o,results:a}};var ms=(...e)=>{let t=new Headers;for(let r of e){if(!r||typeof r!="object")continue;let s=r instanceof Headers?r.entries():Object.entries(r);for(let[o,i]of s)if(i===null)t.delete(o);else if(Array.isArray(i))for(let a of i)t.append(o,a);else i!==void 0&&t.set(o,typeof i=="object"?JSON.stringify(i):i);}return t};var pd=async({fetchOptions:e,inputPath:t,timeout:r,watch:s})=>{let o=new jsonSchemaRefParser.$RefParser,i=jsonSchemaRefParser.getResolvedInput({pathOrUrlOrSchema:t}),a,p,c;if(i.type==="url"){if(s.lastValue&&s.isHeadMethodSupported!==false){try{let f=await jsonSchemaRefParser.sendRequest({fetchOptions:{method:"HEAD",...e,headers:ms(e?.headers,s.headers)},timeout:r,url:i.path});if(f.response.status>=300)return {error:"not-ok",response:f.response};c=f.response;}catch(f){return {error:"not-ok",response:new Response(f.message)}}if(!c.ok&&s.isHeadMethodSupported)return {error:"not-ok",response:c};if(s.isHeadMethodSupported===void 0&&(s.isHeadMethodSupported=c.ok),c.status===304)return {error:"not-modified",response:c};if(p===void 0){let f=c.headers.get("ETag");f&&(p=f!==s.headers.get("If-None-Match"),p&&s.headers.set("If-None-Match",f));}if(p===void 0){let f=c.headers.get("Last-Modified");f&&(p=f!==s.headers.get("If-Modified-Since"),p&&s.headers.set("If-Modified-Since",f));}if(p===false)return {error:"not-modified",response:c}}try{let f=await jsonSchemaRefParser.sendRequest({fetchOptions:{method:"GET",...e},timeout:r,url:i.path});if(f.response.status>=300)return {error:"not-ok",response:f.response};c=f.response;}catch(f){return {error:"not-ok",response:new Response(f.message)}}if(!c.ok)return {error:"not-ok",response:c};if(a=c.body?await c.arrayBuffer():new ArrayBuffer(0),p===void 0){let f=new TextDecoder().decode(a);p=f!==s.lastValue,s.lastValue=f;}}else s.lastValue?p=false:s.lastValue=i.type;return p===false?{error:"not-modified",response:c}:{data:await o.bundle({arrayBuffer:a,pathOrUrlOrSchema:void 0,resolvedInput:i})}};
12
+ `}),L):$.nodes.push(L),$.methods.add(x.methodName),i.set(S,$);});});let c=m=>{if(a.has(m.className))return;if(m.classes.size)for(let l of m.classes){let d=i.get(l);c(d),m.nodes.push(n.propertyDeclaration({initializer:e.config.instance?n.newExpression({argumentsArray:e.config.instance?[n.objectExpression({multiLine:false,obj:[{key:"client",value:n.propertyAccessExpression({expression:n.this(),name:"_client"})}]})]:[],expression:n.identifier({text:d.className})}):n.identifier({text:d.className}),modifier:e.config.instance?void 0:"static",name:E({case:"camelCase",value:d.className})}));}let f=n.classDeclaration({decorator:m.root&&r?{args:[{providedIn:"root"}],name:"Injectable"}:void 0,exportClass:m.root,extendedClasses:e.config.instance?["_HeyApiClient"]:void 0,name:m.className,nodes:m.nodes});o.add(f),a.add(m.className);};if(p.length){let m=n.classDeclaration({exportClass:false,name:"_HeyApiClient",nodes:p});o.add(m);}for(let m of i.values())c(m);},cl=({plugin:e})=>{let t=j(e.context.config),r=t.name==="@hey-api/client-nuxt",s=e.context.file({id:J});e.forEach("operation",({operation:o})=>{let i=le({context:e.context,operation:o}),a=e.getPlugin("@hey-api/typescript"),p=e.context.file({id:T}),c=s.import({asType:true,module:s.relativePathToFile({context:e.context,id:T}),name:r?p.getName(a.api.getId({operation:o,type:"response"})):void 0}),m=Vs({file:s,isRequiredOptions:i,operation:o,plugin:e}),f=_s({isRequiredOptions:i,opParameters:m,operation:o,plugin:e}),l=n.constVariable({comment:ie({operation:o}),exportConst:true,expression:n.arrowFunction({parameters:m.parameters,returnType:void 0,statements:f,types:r?[{extends:n.typeNode("Composable"),name:rr},{default:c.name?n.typeReferenceNode({typeName:c.name}):n.typeNode("undefined"),extends:c.name?n.typeReferenceNode({typeName:c.name}):void 0,name:$e}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]}),name:Re({config:e.context.config,handleIllegal:true,id:o.id,operation:o})});s.add(l);});},La=({plugin:e})=>{let t=e.createFile({id:J,path:e.output}),r=Q({config:e.context.config,sourceOutput:t.nameWithoutExtension()}),s=t.import({...z.Options,alias:"ClientOptions",module:r}),o=j(e.context.config),i=o.name==="@hey-api/client-angular";o.name==="@hey-api/client-nuxt"&&t.import({asType:true,module:r,name:"Composable"}),i&&e.config.asClass&&t.import({module:"@angular/core",name:"Injectable"}),Fa({clientOptions:s,plugin:e}),e.config.asClass?pl({plugin:e}):cl({plugin:e});};var Mn={config:{asClass:false,auth:true,classNameBuilder:"{{name}}",classStructure:"auto",client:true,exportFromIndex:true,instance:false,operationId:true,params_EXPERIMENTAL:"default",response:"body",responseStyle:"fields",transformer:false,validator:false},dependencies:["@hey-api/typescript"],handler:La,handlerLegacy:Ma,name:"@hey-api/sdk",output:"sdk",resolveConfig:(e,t)=>{e.config.client?(typeof e.config.client=="boolean"&&(e.config.client=t.pluginByTag("client",{defaultPlugin:"@hey-api/client-fetch"})),e.dependencies.add(e.config.client)):e.config.client=false,e.config.transformer?(typeof e.config.transformer=="boolean"&&(e.config.transformer=t.pluginByTag("transformer")),e.dependencies.add(e.config.transformer)):e.config.transformer=false,typeof e.config.validator!="object"&&(e.config.validator={request:e.config.validator,response:e.config.validator}),e.config.validator.request?(typeof e.config.validator.request=="boolean"&&(e.config.validator.request=t.pluginByTag("validator")),e.dependencies.add(e.config.validator.request)):e.config.validator.request=false,e.config.validator.response?(typeof e.config.validator.response=="boolean"&&(e.config.validator.response=t.pluginByTag("validator")),e.dependencies.add(e.config.validator.response)):e.config.validator.response=false,e.config.instance?(typeof e.config.instance!="string"&&(e.config.instance="Sdk"),e.config.asClass=true):e.config.instance=false,e.config.classNameBuilder==="{{name}}"&&e.config.client==="@hey-api/client-angular"&&(e.config.classNameBuilder="{{name}}Service");}};var fl="$OpenApiTs",oe={$refs:[],base:"",description:null,enum:[],enums:[],export:"interface",imports:[],in:"",isDefinition:false,isNullable:false,isReadOnly:false,isRequired:false,link:null,name:"",properties:[],template:null,type:""},ll=({comments:e,leadingComment:t,meta:r,obj:s,onNode:o,...i})=>{if(!r)return;let{created:a,name:p}=Te({create:true,meta:r,...i});if(a){let c=n.enumDeclaration({comments:e,leadingComment:t,name:p,obj:s});o(c);}},mt=({comment:e,meta:t,onCreated:r,onNode:s,type:o,...i})=>{if(!t)return {created:false,name:""};let a=Te({create:true,meta:t,...i}),{created:p,name:c}=a;if(p){let m=n.typeAliasDeclaration({comment:e,exportType:true,name:c,type:o});s(m),r?.(c);}return a},ul=e=>{let t=[];Da(e),e.model.enums.forEach(r=>yl({...e,model:r,onNode:s=>{t.push(s);}})),t.length&&e.onNode(n.namespaceDeclaration({name:e.model.name,statements:t}));},dl=({client:e,model:t,onNode:r})=>{let s=I(),o={},i={};t.enum.forEach(c=>{let{key:m,value:f}=qs(c);o[m]=f;let l=c.customDescription||c.description;l&&(i[m]=[B(l)]);});let a=[t.description&&B(t.description),t.deprecated&&"@deprecated"],p=s.plugins["@hey-api/typescript"];if(p?.config&&typeof p.config.enums=="object"&&p.config.enums.enabled&&p.config.enums.mode==="typescript"){ll({client:e,comments:i,leadingComment:a,meta:t.meta,obj:o,onNode:r});return}mt({client:e,comment:a,meta:t.meta,onCreated:c=>{let m=s.plugins["@hey-api/typescript"];if(m?.config&&typeof m.config.enums=="object"&&m.config.enums.enabled&&m.config.enums.mode==="javascript"){let f=n.objectExpression({multiLine:true,obj:Object.entries(o).map(([d,y])=>({comments:i[d],key:d,value:y})),unescape:true}),l=n.constVariable({assertion:"const",comment:a,exportConst:true,expression:f,name:c});r(l);}},onNode:r,type:ia(t.enum)});},yl=({model:e,onNode:t})=>{let r={},s={};e.enum.forEach(o=>{let{key:i,value:a}=qs(o);r[i]=a;let p=o.customDescription||o.description;p&&(s[i]=[B(p)]);}),t(n.enumDeclaration({comments:s,leadingComment:[e.description&&B(e.description),e.deprecated&&"@deprecated"],name:e.meta?.name||e.name,obj:r}));},Da=({client:e,model:t,onNode:r})=>{mt({client:e,comment:[t.description&&B(t.description),t.deprecated&&"@deprecated"],meta:t.meta,onNode:r,type:Se(t)});},gl=e=>{switch(e.model.export){case "all-of":case "any-of":case "one-of":case "interface":return ul(e);case "enum":return dl(e);default:return Da(e)}},hl=({client:e,onNode:t})=>{let r={},s=I();if(!s.plugins["@hey-api/sdk"]&&!s.plugins["@hey-api/typescript"]?.config.tree)return;let o=X(s);for(let a of e.services)for(let p of a.operations){if(!p.parameters.length&&!p.responses.length)continue;r[p.path]||(r[p.path]={});let c=r[p.path];c[p.method]||(c[p.method]={});let m=c[p.method];if(m.$ref=p.name,p.responses.length>0){if(m.res||(m.res={}),Array.isArray(m.res))continue;p.responses.forEach(l=>{m.res[l.code]=l;});}if(p.parameters.length>0){let l={mediaType:null,...oe,in:"body",name:"body",prop:"body"},d=p.parameters.filter(O=>O.in==="body");d.length||(d=p.parameters.filter(O=>O.in==="formData")),d.length===1?l={...oe,...d[0],in:"body",isRequired:d[0].isRequired,name:"body",prop:"body"}:d.length>1&&(l={...oe,in:"body",isRequired:d.some(O=>O.isRequired),mediaType:"multipart/form-data",name:"body",prop:"body",properties:d});let y={...oe,in:"header",isRequired:He(p.parameters.filter(O=>O.in==="header")),mediaType:null,name:o?"header":"headers",prop:o?"header":"headers",properties:p.parameters.filter(O=>O.in==="header").sort(qr)},g={...oe,in:"path",isRequired:He(p.parameters.filter(O=>O.in==="path")),mediaType:null,name:"path",prop:"path",properties:p.parameters.filter(O=>O.in==="path").sort(qr)},x={...oe,in:"query",isRequired:He(p.parameters.filter(O=>O.in==="query")),mediaType:null,name:"query",prop:"query",properties:p.parameters.filter(O=>O.in==="query").sort(qr)},S=o?oa([...p.parameters]):[l,y,g,x].filter(O=>O.properties.length||O.$refs.length||O.mediaType);m.req=S,mt({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:Ht,onNode:t,type:Se({...oe,properties:S})});}let f=p.responses.filter(l=>l.responseTypes.includes("success"));if(f.length>0){mt({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:Xe,onNode:t,type:Se({...oe,export:"any-of",properties:f})});let l=p.responses.filter(d=>d.responseTypes.includes("error"));o||mt({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:gr,onNode:t,type:Se(l.length?{...oe,export:"one-of",properties:l}:{...oe,base:"unknown"})});}}let i=Object.entries(r).map(([a,p])=>{let c=Object.entries(p).map(([f,l])=>{let d=f,y=[];if(l.req){let x=l.$ref,{name:S}=Te({client:e,meta:{$ref:x,name:x},nameTransformer:Ht}),O={...oe,base:S,export:"reference",isRequired:true,name:"req",properties:[],type:S};y=[...y,O];}if(l.res){let x=Object.entries(l.res).map(([O,v])=>({...oe,...v,isRequired:true,name:String(O)})),S={...oe,isRequired:true,name:"res",properties:x};y=[...y,S];}return {...oe,isRequired:true,name:d.toLocaleLowerCase(),properties:y}}).filter(Boolean);return {...oe,isRequired:true,name:`'${a}'`,properties:c}});s.plugins["@hey-api/typescript"]?.config.tree&&mt({client:e,meta:{$ref:"@hey-api/openapi-ts",name:fl},onNode:t,type:Se({...oe,properties:i})});},Va=({client:e,files:t,plugin:r})=>{let s=I();t.types=new Me({dir:s.output.path,exportFromIndex:r.config.exportFromIndex,id:"types",name:"types.ts"});let o=i=>{t.types?.add(i);};for(let i of e.models)gl({client:e,model:i,onNode:o});hl({client:e,onNode:o});};var It="data",xl=e=>e.base==="unknown"&&e.export==="generic"&&e.type==="unknown",_a=({client:e,model:t})=>t.$refs.map(s=>{let o=e.models.find(i=>i.meta?.$ref===s);if(!o)throw new Error(`Ref ${s} could not be found. Transformers cannot be generated without having access to all refs.`);return o}),Ba=e=>{let t=e.model.meta.name,{name:r}=mt({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:$a,onCreated:o=>{let i=Fn({...e,meta:{$ref:`transformers/${t}`,name:o},path:[It]});za({...e,async:false,name:o,statements:i});},type:`(${It}: any) => ${t}`});return {created:!!e.client.types[r],name:r}},bl=e=>{let{model:t}=e,r=_a(e);if(r.length===1){let{created:s,name:o}=Ba({...e,model:r[0]});return s?[n.transformArrayMutation({path:e.path,transformerName:o})]:[]}return $r(t)||t.link&&!Array.isArray(t.link)&&t.link.export==="any-of"&&t.link.properties.find(s=>$r(s))?[n.transformArrayMap({path:e.path,transformExpression:n.conditionalExpression({condition:n.identifier({text:"item"}),whenFalse:n.identifier({text:"item"}),whenTrue:n.transformNewDate({parameterName:"item"})})})]:[]},Ol=e=>{let{model:t}=e,r=[...e.path,t.name];return t.type==="string"&&t.export!=="array"&&$r(t)?[n.transformDateMutation({path:r})]:Fn({...e,model:t,path:r})},Fn=e=>{let{model:t}=e;switch(t.export){case "array":return bl(e);case "interface":return t.properties.flatMap(r=>Ol({...e,model:r}));case "reference":{if(t.$refs.length!==1)return [];let r=_a(e),{created:s,name:o}=Ba({...e,model:r[0]});return s?t.in==="response"?[n.expressionToStatement({expression:n.callExpression({functionName:o,parameters:[It]})})]:n.transformFunctionMutation({path:e.path,transformerName:o}):[]}default:return []}},za=({async:e,client:t,name:r,onNode:s,onRemoveNode:o,statements:i})=>{let a={created:false,name:r};if(!i.length)return pa({client:t,name:r}),o?.(),a;let p=n.arrowFunction({async:e,multiLine:true,parameters:[{name:It}],statements:[...i,n.returnVariable({expression:It})]}),c=n.constVariable({exportConst:true,expression:p,name:r,typeName:r});return s(c),{created:true,name:r}},Ka=({client:e,files:t})=>{let r=I(),s=i=>{t.types?.add(i);},o=()=>{t.types?.removeNode_LEGACY();};for(let i of e.services)for(let a of i.operations){let p=a.responses.filter(f=>f.responseTypes.includes("success"));if(!p.length)continue;let c=p.filter(f=>!xl(f));if(!c.length)continue;if(c.length>1){r.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${q(a)} has ${c.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);continue}let m=Xe(a.name);mt({client:e,meta:{$ref:`transformers/${m}`,name:m},nameTransformer:Hs,onCreated:f=>{let l=p.length>1?p.flatMap(d=>{let y=Fn({client:e,meta:{$ref:`transformers/${m}`,name:m},model:d,onNode:s,onRemoveNode:o,path:[It]});return y.length?[n.ifStatement({expression:n.safeAccessExpression(["data"]),thenStatement:n.block({statements:y})})]:[]}):Fn({client:e,meta:{$ref:`transformers/${m}`,name:m},model:p[0],onNode:s,onRemoveNode:o,path:[It]});za({async:true,client:e,name:f,onNode:s,onRemoveNode:o,statements:l});},onNode:s,type:`(${It}: any) => Promise<${m}>`});}};var Ln={config:{bigInt:true,dates:true,exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:ha,handlerLegacy:Ka,name:"@hey-api/transformers",output:"transformers",tags:["transformer"]};var Ha=({context:e,name:t})=>(G.lastIndex=0,G.test(t)?t.startsWith("-")?b__default.default.factory.createStringLiteral(t):b__default.default.factory.createNumericLiteral(t):E({case:e.config.output.case,value:t}));var Ne=({schema:e})=>{let t=[];return e.title&&t.push(B(e.title)),e.description&&t.push(B(e.description)),e.deprecated&&t.push("@deprecated"),t.length?t:void 0};var Dn=n.keywordTypeNode({keyword:"string"}),Rl=({server:e})=>{let t=_e(e.url);return t.protocol&&t.host?n.literalTypeNode({literal:n.stringLiteral({text:e.url})}):n.templateLiteralType({value:[t.protocol||Dn,"://",t.host||Dn,t.port?`:${t.port}`:"",t.path||""]})},Za=({nodeInfo:e,plugin:t,servers:r})=>{let s=t.context.file({id:T}),o=j(t.context.config),i=r.map(c=>Rl({server:c}));r.length?"strictBaseUrl"in o.config&&o.config.strictBaseUrl||i.push(n.typeIntersectionNode({types:[Dn,b__default.default.factory.createTypeLiteralNode([])]})):i.push(Dn);let a=n.typeInterfaceNode({properties:[{name:Ie(t.context.config),type:n.typeUnionNode({types:i})}],useLegacyResolution:false}),p=n.typeAliasDeclaration({exportType:e.exported,name:e.node,type:a});s.add(p);};var Us=({parameters:e})=>{let t={type:"object"};if(e){let r={},s=[];for(let o in e){let i=e[o];r[i.name]=H({detectFormat:false,schema:i.schema}),i.required&&s.push(i.name);}t.properties=r,s.length&&(t.required=s);}return t},Al=({operation:e,plugin:t,state:r})=>{let s=t.context.file({id:T}),o={type:"object"},i=[];o.properties||(o.properties={}),e.body?(o.properties.body=e.body.schema,e.body.required&&i.push("body")):o.properties.body={type:"never"},e.parameters?.header&&(o.properties.headers=Us({parameters:e.parameters.header}),o.properties.headers.required&&i.push("headers")),e.parameters?.path?(o.properties.path=Us({parameters:e.parameters.path}),o.properties.path.required&&i.push("path")):o.properties.path={type:"never"},e.parameters?.query?(o.properties.query=Us({parameters:e.parameters.query}),o.properties.query.required&&i.push("query")):o.properties.query={type:"never"},o.properties.url={const:e.path,type:"string"},i.push("url"),o.required=i;let a=N({config:t.config.requests,name:e.id}),p=s.updateNode(t.api.getId({operation:e,type:"data"}),{exported:true,name:a}),c=ae({onRef:void 0,plugin:t,schema:o,state:r}),m=n.typeAliasDeclaration({exportType:p.exported,name:p.node,type:c});s.add(m);},Ua=({operation:e,plugin:t,state:r})=>{Al({operation:e,plugin:t,state:r});let s=t.context.file({id:T}),{error:o,errors:i,response:a,responses:p}=Fe(e);if(i){let c=N({config:t.config.errors,name:e.id}),m=s.updateNode(t.api.getId({operation:e,type:"errors"}),{exported:true,name:c}),f=ae({onRef:void 0,plugin:t,schema:i,state:r}),l=n.typeAliasDeclaration({exportType:m.exported,name:m.node,type:f});if(s.add(l),o){let d=N({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),y=s.updateNode(t.api.getId({operation:e,type:"error"}),{exported:true,name:d}),g=n.indexedAccessTypeNode({indexType:b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m.node),objectType:m.node}),x=n.typeAliasDeclaration({exportType:y.exported,name:y.node,type:g});s.add(x);}}if(p){let c=N({config:t.config.responses,name:e.id}),m=s.updateNode(t.api.getId({operation:e,type:"responses"}),{exported:true,name:c}),f=ae({onRef:void 0,plugin:t,schema:p,state:r}),l=n.typeAliasDeclaration({exportType:m.exported,name:m.node,type:f});if(s.add(l),a){let d=N({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),y=s.updateNode(t.api.getId({operation:e,type:"response"}),{exported:true,name:d}),g=n.indexedAccessTypeNode({indexType:b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m.node),objectType:m.node}),x=n.typeAliasDeclaration({exportType:y.exported,name:y.node,type:g});s.add(x);}}};var Il=({plugin:e,schema:t})=>{let r=[];return {obj:(t.items??[]).map((o,i)=>{let a=typeof o.const;r.includes(a)||r.push(a);let p;return o.title?p=o.title:a==="number"||a==="string"?p=`${o.const}`:a==="boolean"?p=o.const?"true":"false":o.const===null?p="null":p=`${i}`,p&&(p=E({case:e.config.enums.case,stripLeadingSeparators:false,value:p}),G.lastIndex=0,G.test(p)&&e.config.enums.enabled&&e.config.enums.mode==="typescript"&&(p=`_${p}`)),{comments:Ne({schema:o}),key:p,value:o.const}}),typeofItems:r}},Pl=({onRef:e,plugin:t,schema:r,state:s})=>{if(!r.items)return n.typeArrayNode(n.keywordTypeNode({keyword:"unknown"}));r=H({detectFormat:false,schema:r});let o=[];for(let i of r.items){let a=ae({onRef:e,plugin:t,schema:i,state:s});o.push(a);}return o.length===1?n.typeArrayNode(o[0]):r.logicalOperator==="and"?n.typeArrayNode(n.typeIntersectionNode({types:o})):n.typeArrayNode(n.typeUnionNode({types:o}))},El=({schema:e})=>e.const!==void 0?n.literalTypeNode({literal:n.ots.boolean(e.const)}):n.keywordTypeNode({keyword:"boolean"}),Nl=({onRef:e,plugin:t,schema:r,state:s})=>ae({onRef:e,plugin:t,schema:{...r,type:void 0},state:s}),jl=({plugin:e,schema:t})=>t.const!==void 0?n.literalTypeNode({literal:n.ots.number(t.const)}):t.type==="integer"&&t.format==="int64"&&e.getPlugin("@hey-api/transformers")?.config.bigInt?n.typeReferenceNode({typeName:"bigint"}):n.keywordTypeNode({keyword:"number"}),Cl=({onRef:e,plugin:t,schema:r,state:s})=>{let o,i,a=[],p=[],c=r.required??[],m=false;for(let f in r.properties){let l=r.properties[f],d=ae({onRef:e,plugin:t,schema:l,state:s}),y=c.includes(f);a.push({comment:Ne({schema:l}),isReadOnly:l.accessScope==="read",isRequired:y,name:Ha({context:t.context,name:f}),type:d}),p.push(l),y||(m=true);}return r.additionalProperties&&(r.additionalProperties.type!=="never"||!p.length)&&(r.additionalProperties.type==="never"?p=[r.additionalProperties]:p.unshift(r.additionalProperties),m&&p.push({type:"undefined"}),i={isRequired:!r.propertyNames,name:"key",type:ae({onRef:e,plugin:t,schema:p.length===1?p[0]:{items:p,logicalOperator:"or"},state:s})},r.propertyNames?.$ref&&(o=ae({onRef:e,plugin:t,schema:{$ref:r.propertyNames.$ref},state:s}))),n.typeInterfaceNode({indexKey:o,indexProperty:i,properties:a,useLegacyResolution:false})},kl=({plugin:e,schema:t,state:r})=>{if(t.const!==void 0)return n.literalTypeNode({literal:n.stringLiteral({text:t.const})});if(t.format){if(t.format==="binary")return n.typeUnionNode({types:[n.typeReferenceNode({typeName:"Blob"}),n.typeReferenceNode({typeName:"File"})]});if((t.format==="date-time"||t.format==="date")&&e.getPlugin("@hey-api/transformers")?.config.dates)return n.typeReferenceNode({typeName:"Date"});if(t.format==="typeid"&&typeof t.example=="string"){let s=String(t.example).split("_");s.pop();let o=s.join("_");r.usedTypeIDs.add(o);let i=xe(E({case:e.config.case,value:o+"_id"}));return n.typeReferenceNode({typeName:i})}}return n.keywordTypeNode({keyword:"string"})},vl=({onRef:e,plugin:t,schema:r,state:s})=>{let o=[];if(r.const&&Array.isArray(r.const))o=r.const.map(i=>n.valueToExpression({value:i})??n.identifier({text:"unknown"}));else if(r.items)for(let i of r.items){let a=ae({onRef:e,plugin:t,schema:i,state:s});o.push(a);}return n.typeTupleNode({types:o})},Xa=({onRef:e,plugin:t,schema:r,state:s})=>{let o=t.getPlugin("@hey-api/transformers");if(o?.config.typeTransformers)for(let i of o.config.typeTransformers){let a=t.context.file({id:T}),p=i({file:a,schema:r});if(p)return p}switch(r.type){case "array":return Pl({onRef:e,plugin:t,schema:r,state:s});case "boolean":return El({schema:r});case "enum":return Nl({onRef:e,plugin:t,schema:r,state:s});case "integer":case "number":return jl({plugin:t,schema:r});case "never":return n.keywordTypeNode({keyword:"never"});case "null":return n.literalTypeNode({literal:n.null()});case "object":return Cl({onRef:e,plugin:t,schema:r,state:s});case "string":return kl({plugin:t,schema:r,state:s});case "tuple":return vl({onRef:e,plugin:t,schema:r,state:s});case "undefined":return n.keywordTypeNode({keyword:"undefined"});case "unknown":return n.keywordTypeNode({keyword:"unknown"});case "void":return n.keywordTypeNode({keyword:"void"})}},ae=({onRef:e,plugin:t,schema:r,state:s})=>{let o=t.context.file({id:T});if(r.$ref)return e&&e(t.api.getId({type:"ref",value:r.$ref})),o.getNode(t.api.getId({type:"ref",value:r.$ref})).node;if(r.type)return Xa({onRef:e,plugin:t,schema:r,state:s});if(r.items){if(r=H({detectFormat:false,schema:r}),r.items){let i=[];for(let a of r.items){let p=ae({onRef:e,plugin:t,schema:a,state:s});i.push(p);}return r.logicalOperator==="and"?n.typeIntersectionNode({types:i}):n.typeUnionNode({types:i})}return ae({onRef:e,plugin:t,schema:r,state:s})}return Xa({onRef:e,plugin:t,schema:{type:"unknown"},state:s})},wl=({id:e,plugin:t,schema:r,type:s})=>{let o=t.context.file({id:T}),i=o.getNode(t.api.getId({type:"ref",value:e}));if(r.type==="enum"&&t.config.enums.enabled){let p=Il({plugin:t,schema:r});if(t.config.enums.mode==="javascript"){t.config.enums.constantsIgnoreNull&&p.typeofItems.includes("object")&&(p.obj=p.obj.filter(d=>d.value!==null));let c=n.constVariable({assertion:"const",comment:Ne({schema:r}),exportConst:i.exported,expression:n.objectExpression({multiLine:true,obj:p.obj}),name:i.node});o.add(c);let m=n.typeOfExpression({text:i.node.typeName}),f=b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m),l=n.typeAliasDeclaration({comment:Ne({schema:r}),exportType:i.exported,name:i.node,type:n.indexedAccessTypeNode({indexType:f,objectType:m})});o.add(l);return}else if(t.config.enums.mode==="typescript"&&!p.typeofItems.some(m=>m!=="number"&&m!=="string")){let m=n.enumDeclaration({leadingComment:Ne({schema:r}),name:i.node,obj:p.obj});o.add(m);return}}let a=n.typeAliasDeclaration({comment:Ne({schema:r}),exportType:i.exported,name:i.node,type:s});o.add(a);},Qs=({id:e,plugin:t,schema:r,state:s})=>{let o=t.context.file({id:T}),i=ae({onRef:void 0,plugin:t,schema:r,state:s}),a=N({config:t.config.definitions,name:D(e)});o.updateNode(t.api.getId({type:"ref",value:e}),{exported:true,name:a}),wl({id:e,plugin:t,schema:r,type:i});},Ga=({plugin:e})=>{let t={usedTypeIDs:new Set},r=e.createFile({case:e.config.case,id:T,path:e.output}),s=N({config:{case:e.config.case},name:"ClientOptions"}),o=r.updateNode(e.api.getId({type:"ClientOptions"}),{exported:true,name:s}),i=[];if(e.forEach("operation","parameter","requestBody","schema","server",a=>{a.type==="operation"?Ua({operation:a.operation,plugin:e,state:t}):a.type==="parameter"?Qs({id:a.$ref,plugin:e,schema:a.parameter.schema,state:t}):a.type==="requestBody"?Qs({id:a.$ref,plugin:e,schema:a.requestBody.schema,state:t}):a.type==="schema"?Qs({id:a.$ref,plugin:e,schema:a.schema,state:t}):a.type==="server"&&i.push(a.server);}),t.usedTypeIDs.size){let a=n.typeParameterDeclaration({constraint:n.keywordTypeNode({keyword:"string"}),name:"T"}),p=n.typeAliasDeclaration({exportType:true,name:"TypeID",type:n.templateLiteralType({value:[n.typeReferenceNode({typeName:"T"}),"_",n.keywordTypeNode({keyword:"string"})]}),typeParameters:[a]});r.add(p);for(let c of t.usedTypeIDs.values()){let m=xe(E({case:e.config.case,value:c+"_id"})),f=n.typeAliasDeclaration({exportType:true,name:m,type:n.typeReferenceNode({typeArguments:[n.literalTypeNode({literal:n.stringLiteral({text:c})})],typeName:"TypeID"})});r.add(f);}}Za({nodeInfo:o,plugin:e,servers:i});};var ql=e=>{switch(e.type){case "data":case "error":case "errors":case "response":case "responses":return `${e.operation.id}-${e.type}`;case "ref":return e.value;default:return e.type}},Ja={getId:ql,schemaToType:e=>ae({onRef:void 0,...e})};var _n={api:Ja,config:{case:"PascalCase",exportFromIndex:true,style:"preserve",tree:false},handler:Ga,handlerLegacy:Va,name:"@hey-api/typescript",output:"types",resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.definitions}),e.config.enums=t.valueToObject({defaultValue:{case:"SCREAMING_SNAKE_CASE",constantsIgnoreNull:false,enabled:!!e.config.enums,mode:"javascript"},mappers:{boolean:r=>({enabled:r}),string:r=>({mode:r})},value:e.config.enums}),e.config.errors=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",error:"{{name}}Error",name:"{{name}}Errors"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.errors}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}Data"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}Responses",response:"{{name}}Response"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.responses});}};var hr=(e,t,r)=>{let s=e.config[r].meta;if(typeof s!="function")return;let o=s(t);return n.valueToExpression({value:o})};var Pt=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),s=t.getPlugin("@hey-api/sdk");return Ds({file:r,operation:e,plugin:s})},Bn=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),s=t.getPlugin("@hey-api/typescript"),o=t.context.file({id:T}),a={asType:true,name:r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:o.getName(s.api.getId({operation:e,type:"error"}))}).name||""};if(a.name||(a=r.import({asType:true,module:t.name,name:"DefaultError"})),j(t.context.config).name==="@hey-api/client-axios"){let c=r.import({asType:true,module:"axios",name:"AxiosError"});a={...c,name:`${c.name}<${a.name}>`};}return a},zn=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),s=t.getPlugin("@hey-api/typescript"),o=t.context.file({id:T});return r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:o.getName(s.api.getId({operation:e,type:"response"}))}).name||"unknown"};var ep="createQueryKey",Wn="QueryKey",Vr="TOptions",Ya=n.identifier({text:"infinite"}),Kn=n.identifier({text:"options"}),Hn=({plugin:e})=>{let t=e.context.file({id:e.name}),r=t.identifier({$ref:`#/tanstack-query-create-query-key/${ep}`,case:e.config.case,create:true,namespace:"value"});if(r.name){let s=n.indexedAccessTypeNode({indexType:n.literalTypeNode({literal:n.ots.number(0)}),objectType:n.typeReferenceNode({typeArguments:[n.typeReferenceNode({typeName:Vr})],typeName:Wn})}),o=Ie(e.context.config),i=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"id",type:n.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:n.typeReferenceNode({typeName:Vr})},{isRequired:false,name:"infinite",type:n.typeReferenceNode({typeName:"boolean"})},{isRequired:false,name:"tags",type:n.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],returnType:n.typeTupleNode({types:[s]}),statements:[n.constVariable({assertion:s,expression:n.objectExpression({multiLine:false,obj:[{key:"_id",value:n.identifier({text:"id"})},{key:o,value:n.identifier({text:`options?.${o} || (options?.client ?? _heyApiClient).getConfig().${o}`})}]}),name:"params",typeName:s}),n.ifStatement({expression:Ya,thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"_infinite"}),right:Ya})})]})}),n.ifStatement({expression:n.identifier({text:"tags"}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"tags"}),right:n.identifier({text:"tags"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:Kn,isOptional:true,name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.propertyAccessExpression({expression:"options",name:"body"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:Kn,isOptional:true,name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:Kn,isOptional:true,name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.propertyAccessExpression({expression:"options",name:"path"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:Kn,isOptional:true,name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.propertyAccessExpression({expression:"options",name:"query"})})})]})}),n.returnStatement({expression:n.arrayLiteralExpression({elements:[n.identifier({text:"params"})]})})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:z.Options.name})}),name:Vr}]}),name:r.name});t.add(i);}},Ml=({id:e,isInfinite:t,operation:r,plugin:s})=>{let i=s.context.file({id:s.name}).identifier({$ref:`#/tanstack-query-create-query-key/${ep}`,case:s.config.case,namespace:"value"}),a=t?s.config.infiniteQueryKeys:s.config.queryKeys,p;return a.tags&&r.tags&&r.tags.length>0&&(p=n.arrayLiteralExpression({elements:r.tags.map(m=>n.stringLiteral({text:m}))})),n.callExpression({functionName:i.name||"",parameters:[n.ots.string(e),"options",t||p?n.ots.boolean(!!t):void 0,p||void 0]})},Zn=({plugin:e})=>{let t=e.context.file({id:e.name}),r=[{name:"_id",type:n.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:n.keywordTypeNode({keyword:"boolean"})},{isRequired:false,name:"tags",type:n.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],s=n.typeAliasDeclaration({exportType:true,name:Wn,type:n.typeTupleNode({types:[n.typeIntersectionNode({types:[n.typeReferenceNode({typeName:`Pick<${Vr}, '${Ie(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),n.typeInterfaceNode({properties:r,useLegacyResolution:true})]})]}),typeParameters:[{extends:n.typeReferenceNode({typeName:n.identifier({text:z.Options.name})}),name:Vr}]});t.add(s);},Un=({isInfinite:e,operation:t,plugin:r,typeQueryKey:s})=>{let o=r.context.file({id:r.name}),i=Pt({operation:t,plugin:r}),a=e?o.identifier({$ref:`#/tanstack-query-infinite-query-key/${t.id}`,case:r.config.infiniteQueryKeys.case,create:true,nameTransformer:r.config.infiniteQueryKeys.name,namespace:"value"}):o.identifier({$ref:`#/tanstack-query-query-key/${t.id}`,case:r.config.queryKeys.case,create:true,nameTransformer:r.config.queryKeys.name,namespace:"value"});return n.constVariable({exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:pn(t),name:"options",type:i}],returnType:e?s:void 0,statements:Ml({id:t.id,isInfinite:e,operation:t,plugin:r})}),name:a.name||""})};var rp="createInfiniteParams",tp="infiniteQueryOptions",Ll=({plugin:e})=>{let t=e.context.file({id:e.name}),r=t.identifier({$ref:`#/tanstack-query-create-infinite-params/${rp}`,case:e.config.case,create:true,namespace:"value"}),s=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:n.typeReferenceNode({typeName:`QueryKey<${z.Options.name}>`})},{name:"page",type:n.typeReferenceNode({typeName:"K"})}],statements:[n.constVariable({expression:n.objectExpression({obj:[{spread:n.propertyAccessExpression({expression:"queryKey",name:0})}]}),name:"params"}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].path"},{assertion:"any",spread:"page.path"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].query"},{assertion:"any",spread:"page.query"}]})})})]})}),n.returnVariable({expression:n.asExpression({expression:n.asExpression({expression:n.identifier({text:"params"}),type:n.keywordTypeNode({keyword:"unknown"})}),type:b__default.default.factory.createTypeQueryNode(n.identifier({text:"page"}))})})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:`Pick<QueryKey<${z.Options.name}>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:"K"}]}),name:r.name||""});t.add(s);},np=({operation:e,plugin:t,queryFn:r,state:s})=>{if(!t.config.infiniteQueryOptions||!["get","post"].includes(e.method))return s;let o=di({context:t.context,operation:e});if(!o)return s;let i=t.context.file({id:t.name}),a=le({context:t.context,operation:e});s.hasInfiniteQueries||(s.hasInfiniteQueries=true,s.hasCreateQueryKeyParamsFunction||(Zn({plugin:t}),Hn({plugin:t}),s.hasCreateQueryKeyParamsFunction=true),s.hasCreateInfiniteParamsFunction||(Ll({plugin:t}),s.hasCreateInfiniteParamsFunction=true),i.import({module:t.name,name:tp}),s.typeInfiniteData=i.import({asType:true,module:t.name,name:"InfiniteData"})),s.hasUsedQueryFn=true;let p=Pt({operation:e,plugin:t}),c=Bn({operation:e,plugin:t}),m=zn({operation:e,plugin:t}),f=`${Wn}<${p}>`,l=`Pick<${f}[0], 'body' | 'headers' | 'path' | 'query'>`,d=t.getPlugin("@hey-api/typescript"),y={usedTypeIDs:new Set},g=d.api.schemaToType({plugin:d,schema:o.schema,state:y}),x=`${ke({node:g,unescape:true})} | ${l}`,S=Un({isInfinite:true,operation:e,plugin:t,typeQueryKey:f});i.add(S);let O=i.identifier({$ref:`#/tanstack-query-infinite-query-key/${e.id}`,case:t.config.infiniteQueryKeys.case,nameTransformer:t.config.infiniteQueryKeys.name,namespace:"value"}),v=n.awaitExpression({expression:n.callExpression({functionName:r,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),_=i.identifier({$ref:`#/tanstack-query-create-infinite-params/${rp}`,case:t.config.case,namespace:"value"}),$=[n.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:n.conditionalExpression({condition:n.binaryExpression({left:n.typeOfExpression({text:"pageParam"}),operator:"===",right:n.ots.string("object")}),whenFalse:n.objectExpression({multiLine:true,obj:[{key:o.in,value:n.objectExpression({multiLine:true,obj:[{key:o.name,value:n.identifier({text:"pageParam"})}]})}]}),whenTrue:n.identifier({text:"pageParam"})}),name:"page",typeName:l}),n.constVariable({expression:n.callExpression({functionName:_.name||"",parameters:["queryKey","page"]}),name:"params"})];t.getPlugin("@hey-api/sdk")?.config.responseStyle==="data"?$.push(n.returnVariable({expression:v})):$.push(n.constVariable({destructure:true,expression:v,name:"data"}),n.returnVariable({expression:"data"}));let F=i.identifier({$ref:`#/tanstack-query-infinite-query-options/${e.id}`,case:t.config.infiniteQueryOptions.case,create:true,nameTransformer:t.config.infiniteQueryOptions.name,namespace:"value"}),W=[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:$})},{key:"queryKey",value:n.callExpression({functionName:O.name||"",parameters:["options"]})}],L=hr(t,e,"infiniteQueryOptions");L&&W.push({key:"meta",value:L});let C=n.constVariable({comment:t.config.comments?ie({operation:e}):void 0,exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:a,name:"options",type:p}],statements:[n.returnFunctionCall({args:[n.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:W})],name:tp,types:[m,c.name||"unknown",`${typeof s.typeInfiniteData=="string"?s.typeInfiniteData:s.typeInfiniteData.name}<${m}>`,f,x]})]}),name:F.name||""});i.add(C);};var sp="mutationOptions",op=({operation:e,plugin:t,queryFn:r,state:s})=>{if(!t.config.mutationOptions.enabled||!["delete","patch","post","put"].includes(e.method))return s;let o=t.name==="@tanstack/angular-query-experimental"||t.name==="@tanstack/svelte-query"||t.name==="@tanstack/solid-query"?"MutationOptions":"UseMutationOptions",i=t.context.file({id:t.name});s.hasMutations||(s.hasMutations=true,i.import({asType:true,module:t.name,name:o})),s.hasUsedQueryFn=true;let a=Pt({operation:e,plugin:t}),p=Bn({operation:e,plugin:t}),c=zn({operation:e,plugin:t}),m=`${o}<${c}, ${p.name}, ${a}>`,f=n.awaitExpression({expression:n.callExpression({functionName:r,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"localOptions"},{key:"throwOnError",value:true}]})]})}),l=[];t.getPlugin("@hey-api/sdk")?.config.responseStyle==="data"?l.push(n.returnVariable({expression:f})):l.push(n.constVariable({destructure:true,expression:f,name:"data"}),n.returnVariable({expression:"data"}));let d=i.identifier({$ref:`#/tanstack-query-mutation-options/${e.id}`,case:t.config.mutationOptions.case,create:true,nameTransformer:t.config.mutationOptions.name,namespace:"value"}),y=[{key:"mutationFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{name:"localOptions"}],statements:l})}],g=hr(t,e,"mutationOptions");g&&y.push({key:"meta",value:g});let x=n.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${a}>`}],returnType:m,statements:[n.constVariable({expression:n.objectExpression({obj:y}),name:sp,typeName:m}),n.returnVariable({expression:sp})]}),S=n.constVariable({comment:t.config.comments?ie({operation:e}):void 0,exportConst:true,expression:x,name:d.name||""});return i.add(S),s};var ip="queryOptions",ap=({operation:e,plugin:t,queryFn:r,state:s})=>{if(!t.config.queryOptions||!["get","post"].includes(e.method))return s;let o=t.context.file({id:t.name}),i=le({context:t.context,operation:e});s.hasQueries||(s.hasQueries=true,s.hasCreateQueryKeyParamsFunction||(Zn({plugin:t}),Hn({plugin:t}),s.hasCreateQueryKeyParamsFunction=true),o.import({module:t.name,name:ip})),s.hasUsedQueryFn=true;let a=Un({isInfinite:false,operation:e,plugin:t});o.add(a);let p=Pt({operation:e,plugin:t}),c=o.identifier({$ref:`#/tanstack-query-query-key/${e.id}`,case:t.config.queryKeys.case,nameTransformer:t.config.queryKeys.name,namespace:"value"}),m=n.awaitExpression({expression:n.callExpression({functionName:r,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),f=[];t.getPlugin("@hey-api/sdk")?.config.responseStyle==="data"?f.push(n.returnVariable({expression:m})):f.push(n.constVariable({destructure:true,expression:m,name:"data"}),n.returnVariable({expression:"data"}));let l=o.identifier({$ref:`#/tanstack-query-query-options/${e.id}`,case:t.config.queryOptions.case,create:true,nameTransformer:t.config.queryOptions.name,namespace:"value"}),d=[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:f})},{key:"queryKey",value:n.callExpression({functionName:c.name||"",parameters:["options"]})}],y=hr(t,e,"queryOptions");y&&d.push({key:"meta",value:y});let g=n.constVariable({comment:t.config.comments?ie({operation:e}):void 0,exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:i,name:"options",type:p}],statements:[n.returnFunctionCall({args:[n.objectExpression({obj:d})],name:ip})]}),name:l.name||""});return o.add(g),s};var Ge=({plugin:e})=>{let t=e.createFile({case:e.config.case,id:e.name,path:e.output}),r={hasCreateInfiniteParamsFunction:false,hasCreateQueryKeyParamsFunction:false,hasInfiniteQueries:false,hasMutations:false,hasQueries:false,hasUsedQueryFn:false,typeInfiniteData:void 0};t.import({...z.Options,module:t.relativePathToFile({context:e.context,id:J})}),e.forEach("operation",({operation:s})=>{r.hasUsedQueryFn=false;let o=e.getPlugin("@hey-api/sdk"),i=o?.config.asClass?pt({context:e.context,operation:s,plugin:o}):void 0,a=i?i.values().next().value:void 0,p=(a?[a.path[0],...a.path.slice(1).map(c=>E({case:"camelCase",value:c})),a.methodName].filter(Boolean):[Re({config:e.context.config,handleIllegal:true,id:s.id,operation:s})]).join(".");ap({operation:s,plugin:e,queryFn:p,state:r}),np({operation:s,plugin:e,queryFn:p,state:r}),op({operation:s,plugin:e,queryFn:p,state:r}),r.hasUsedQueryFn&&t.import({module:t.relativePathToFile({context:e.context,id:J}),name:p.split(".")[0]});}),(r.hasQueries||r.hasInfiniteQueries)&&t.import({alias:"_heyApiClient",module:t.relativePathToFile({context:e.context,id:de}),name:"client"});};var Dl=e=>`${Re({config:I(),id:e.name,operation:e})}InfiniteOptions`,Vl=e=>`${Re({config:I(),id:e.name,operation:e})}Mutation`,_l=({config:e,id:t,operation:r})=>`${Re({config:e,id:t,operation:r})}Options`,Qn=({config:e,id:t,isInfinite:r,operation:s})=>`${Re({config:e,id:t,operation:s})}${r?"Infinite":""}QueryKey`,Bl=e=>{switch(e.in){case "formData":return "body";case "header":return "headers";default:return e.in}},zl="createInfiniteParams",gp="createQueryKey",pp="infiniteQueryOptions",cp="mutationOptions",Gs="QueryKey",mp="queryOptions",Br="TOptions",Kl=({file:e})=>{let t=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:n.typeNode(`QueryKey<${z.OptionsLegacyParser.name}>`)},{name:"page",type:n.typeNode("K")}],statements:[n.constVariable({expression:n.identifier({text:"queryKey[0]"}),name:"params"}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].path"},{spread:"page.path"}]})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"page"}),name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].query"},{spread:"page.query"}]})})})]})}),n.returnVariable({expression:b__default.default.factory.createAsExpression(b__default.default.factory.createAsExpression(n.identifier({text:"params"}),b__default.default.factory.createKeywordTypeNode(b__default.default.SyntaxKind.UnknownKeyword)),b__default.default.factory.createTypeQueryNode(n.identifier({text:"page"})))})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:`Pick<QueryKey<${z.OptionsLegacyParser.name}>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:"K"}]}),name:zl});e.add(t);},fp=({file:e})=>{let t=n.indexedAccessTypeNode({indexType:n.typeNode(0),objectType:n.typeNode(Gs,[n.typeNode(Br)])}),r=n.identifier({text:"infinite"}),s=Ie(I()),o=n.constVariable({expression:n.arrowFunction({multiLine:true,parameters:[{name:"id",type:n.typeNode("string")},{isRequired:false,name:"options",type:n.typeNode(Br)},{isRequired:false,name:"infinite",type:n.typeNode("boolean")}],returnType:t,statements:[n.constVariable({assertion:t,expression:n.objectExpression({multiLine:false,obj:[{key:"_id",value:n.identifier({text:"id"})},{key:s,value:n.identifier({text:`options?.${s} || (options?.client ?? _heyApiClient).getConfig().${s}`})}]}),name:"params",typeName:t}),n.ifStatement({expression:r,thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"_infinite"}),right:r})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"body"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"body"}),right:n.propertyAccessExpression({expression:"options",name:"body"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"headers"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"headers"}),right:n.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"path"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"path"}),right:n.propertyAccessExpression({expression:"options",name:"path"})})})]})}),n.ifStatement({expression:n.propertyAccessExpression({expression:n.identifier({text:"options"}),isOptional:true,name:n.identifier({text:"query"})}),thenStatement:n.block({statements:[n.expressionToStatement({expression:n.binaryExpression({left:n.propertyAccessExpression({expression:"params",name:"query"}),right:n.propertyAccessExpression({expression:"options",name:"query"})})})]})}),n.returnVariable({expression:"params"})],types:[{extends:n.typeReferenceNode({typeName:n.identifier({text:z.OptionsLegacyParser.name})}),name:Br}]}),name:gp});e.add(o);},lp=({file:e})=>{let t=[{name:"_id",type:n.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:n.keywordTypeNode({keyword:"boolean"})}],r=n.typeAliasDeclaration({name:Gs,type:n.typeTupleNode({types:[n.typeIntersectionNode({types:[n.typeReferenceNode({typeName:`Pick<${Br}, '${Ie(I())}' | 'body' | 'headers' | 'path' | 'query'>`}),n.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:n.typeReferenceNode({typeName:n.identifier({text:z.OptionsLegacyParser.name})}),name:Br}]});e.add(r);},Xs=({client:e,file:t,operation:r,typesModulePath:s})=>{let{name:o}=Wt({client:e,meta:r.parameters.length?{$ref:r.name,name:r.name}:void 0,nameTransformer:Ht,onImport:a=>{t.import({asType:true,module:s,name:a});}});return {typeData:Zs({importedType:o})}},up=({client:e,file:t,operation:r,pluginName:s,typesModulePath:o})=>{let i=I(),{name:a}=Wt({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:gr,onImport:m=>{t.import({asType:true,module:o,name:m});}}),p={asType:true,name:a};if(p.name||(p=t.import({asType:true,module:s,name:"DefaultError"})),j(i).name==="@hey-api/client-axios"){let m=t.import({asType:true,module:"axios",name:"AxiosError"});p={...m,name:`${m.name}<${p.name}>`};}return {typeError:p}},dp=({client:e,file:t,operation:r,typesModulePath:s})=>{let{name:o}=Wt({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Xe,onImport:a=>{t.import({asType:true,module:s,name:a});}});return {typeResponse:o||"void"}},yp=({id:e,isInfinite:t})=>n.arrayLiteralExpression({elements:[n.callExpression({functionName:gp,parameters:[n.ots.string(e),"options",t?n.ots.boolean(true):void 0]})],multiLine:false}),Je=({client:e,files:t,plugin:r})=>{let s=I();if(X(s))throw new Error("TanStack Query plugin does not support legacy clients");let o=t[r.name];o.import({...z.OptionsLegacyParser,module:Q({config:s,sourceOutput:r.output})});let i=Ut({moduleOutput:t.types.nameWithoutExtension(),sourceOutput:r.output}),a=r.name==="@tanstack/angular-query-experimental"||r.name==="@tanstack/svelte-query"||r.name==="@tanstack/solid-query"?"MutationOptions":"UseMutationOptions",p,c=false,m=false,f=false,l=false,d=false,y=new Map;for(let g of e.services)for(let x of g.operations){let S=q(x);if(y.has(S))continue;y.set(S,true);let O=[s.plugins["@hey-api/sdk"]?.config.asClass&&dr({config:s,name:g.name}),Re({config:s,handleIllegal:!s.plugins["@hey-api/sdk"]?.config.asClass,id:x.name,operation:x})].filter(Boolean).join("."),v=false;if(r.config.queryOptions&&["GET","POST"].includes(x.method)){d||(d=true,m||(lp({file:o}),fp({file:o}),m=true),o.import({module:r.name,name:mp})),v=true;let{typeData:_}=Xs({client:e,file:o,operation:x,typesModulePath:i}),$=He(x.parameters),F=n.constVariable({exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:$,name:"options",type:_}],statements:yp({id:x.name})}),name:Qn({config:s,id:x.name,operation:x})});o.add(F);let W=n.constVariable({comment:[],exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:$,name:"options",type:_}],statements:[n.returnFunctionCall({args:[n.objectExpression({obj:[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:[n.constVariable({destructure:true,expression:n.awaitExpression({expression:n.callExpression({functionName:O,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),n.returnVariable({expression:"data"})]})},{key:"queryKey",value:n.callExpression({functionName:Qn({config:s,id:x.name,operation:x}),parameters:["options"]})}]})],name:mp})]}),name:_l({config:s,id:x.name,operation:x})});o.add(W);}if(r.config.infiniteQueryOptions&&["GET","POST"].includes(x.method)){let _,$=x.parameters.find(F=>{if(fe(s.parser.pagination).test(F.name))return _=F,true;if(F.in==="body"){if(F.export==="reference"){let L=F.$refs[0];return e.models.find(Z=>Z.meta?.$ref===L)?.properties.find(Z=>{if(fe(s.parser.pagination).test(Z.name))return _=Z,true})}return F.properties.find(L=>{if(fe(s.parser.pagination).test(L.name))return _=L,true})}});if($&&_){f||(f=true,m||(lp({file:o}),fp({file:o}),m=true),c||(Kl({file:o}),c=true),o.import({module:r.name,name:pp}),p=o.import({asType:true,module:r.name,name:"InfiniteData"})),v=true;let{typeData:F}=Xs({client:e,file:o,operation:x,typesModulePath:i}),{typeError:W}=up({client:e,file:o,operation:x,pluginName:r.name,typesModulePath:i}),{typeResponse:L}=dp({client:e,file:o,operation:x,typesModulePath:i}),C=He(x.parameters),Z=`${Gs}<${F}>`,Ae=`Pick<${Z}[0], 'body' | 'headers' | 'path' | 'query'>`,Ce=`${_.base} | ${Ae}`,Zt=n.constVariable({exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:C,name:"options",type:F}],returnType:Z,statements:yp({id:x.name,isInfinite:true})}),name:Qn({config:s,id:x.name,isInfinite:true,operation:x})});o.add(Zt);let Fp=n.constVariable({comment:[],exportConst:true,expression:n.arrowFunction({parameters:[{isRequired:C,name:"options",type:F}],statements:[n.returnFunctionCall({args:[n.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:[{key:"queryFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:[n.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:n.conditionalExpression({condition:n.binaryExpression({left:n.typeOfExpression({text:"pageParam"}),operator:"===",right:n.ots.string("object")}),whenFalse:n.objectExpression({multiLine:true,obj:[{key:Bl($),value:n.objectExpression({multiLine:true,obj:[{key:_.name,value:n.identifier({text:"pageParam"})}]})}]}),whenTrue:n.identifier({text:"pageParam"})}),name:"page",typeName:Ae}),n.constVariable({expression:n.callExpression({functionName:"createInfiniteParams",parameters:["queryKey","page"]}),name:"params"}),n.constVariable({destructure:true,expression:n.awaitExpression({expression:n.callExpression({functionName:O,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:n.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),n.returnVariable({expression:"data"})]})},{key:"queryKey",value:n.callExpression({functionName:Qn({config:s,id:x.name,isInfinite:true,operation:x}),parameters:["options"]})}]})],name:pp,types:[L,W.name,`${typeof p=="string"?p:p.name}<${L}>`,Z,Ce]})]}),name:Dl(x)});o.add(Fp);}}if(r.config.mutationOptions&&["DELETE","PATCH","POST","PUT"].includes(x.method)){l||(l=true,o.import({asType:true,module:r.name,name:a})),v=true;let{typeData:_}=Xs({client:e,file:o,operation:x,typesModulePath:i}),{typeError:$}=up({client:e,file:o,operation:x,pluginName:r.name,typesModulePath:i}),{typeResponse:F}=dp({client:e,file:o,operation:x,typesModulePath:i}),W=n.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${_}>`}],statements:[n.constVariable({expression:n.objectExpression({obj:[{key:"mutationFn",value:n.arrowFunction({async:true,multiLine:true,parameters:[{name:"localOptions"}],statements:[n.constVariable({destructure:true,expression:n.awaitExpression({expression:n.callExpression({functionName:O,parameters:[n.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"localOptions"},{key:"throwOnError",value:true}]})]})}),name:"data"}),n.returnVariable({expression:"data"})]})}]}),name:cp,typeName:`${a}<${F}, ${$.name}, ${_}>`}),n.returnVariable({expression:cp})]}),L=n.constVariable({comment:[],exportConst:true,expression:W,name:Vl(x)});o.add(L);}(d||f)&&o.import({alias:"_heyApiClient",module:Ut({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:r.output}),name:"client"}),v&&o.import({module:Ut({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:r.output}),name:O.split(".")[0]});}};var Xn={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ge,handlerLegacy:Je,name:"@tanstack/angular-query-experimental",output:"@tanstack/angular-query-experimental",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Gn={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ge,handlerLegacy:Je,name:"@tanstack/react-query",output:"@tanstack/react-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Jn={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ge,handlerLegacy:Je,name:"@tanstack/solid-query",output:"@tanstack/solid-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Yn={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ge,handlerLegacy:Je,name:"@tanstack/svelte-query",output:"@tanstack/svelte-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var es={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:Ge,handlerLegacy:Je,name:"@tanstack/vue-query",output:"@tanstack/vue-query",resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}InfiniteQueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}InfiniteOptions"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Mutation"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"{{name}}QueryKey",tags:false},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,meta:false,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var hp="fastify",Xl=({operation:e,plugin:t})=>{let r=t.context.file({id:hp}),s=[],o=t.getPlugin("@hey-api/typescript"),i=t.context.file({id:T}),a=i.getName(o.api.getId({operation:e,type:"data"}));a&&(e.body&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:a}),s.push({isRequired:e.body.required,name:"Body",type:`${a}['body']`})),e.parameters&&(e.parameters.header&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:a}),s.push({isRequired:yt(e.parameters.header),name:"Headers",type:`${a}['headers']`})),e.parameters.path&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:a}),s.push({isRequired:yt(e.parameters.path),name:"Params",type:`${a}['path']`})),e.parameters.query&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:a}),s.push({isRequired:yt(e.parameters.query),name:"Querystring",type:`${a}['query']`}))));let{errors:p,responses:c}=Fe(e),m,f=i.getName(o.api.getId({operation:e,type:"errors"}));if(f&&p&&p.properties){let x=Object.keys(p.properties);if(x.length){if(!x.includes("default"))r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:f}),m=n.typeReferenceNode({typeName:f});else if(x.length>1){r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:f});let O=n.typeReferenceNode({typeName:f}),v=n.literalTypeNode({literal:n.stringLiteral({text:"default"})});m=n.typeReferenceNode({typeArguments:[O,v],typeName:"Omit"});}}}let l,d=i.getName(o.api.getId({operation:e,type:"responses"}));if(d&&c&&c.properties){let x=Object.keys(c.properties);if(x.length){if(!x.includes("default"))r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:d}),l=n.typeReferenceNode({typeName:d});else if(x.length>1){r.import({asType:true,module:r.relativePathToFile({context:t.context,id:T}),name:d});let O=n.typeReferenceNode({typeName:d}),v=n.literalTypeNode({literal:n.stringLiteral({text:"default"})});l=n.typeReferenceNode({typeArguments:[O,v],typeName:"Omit"});}}}let y=[m,l].filter(Boolean);return y.length&&s.push({name:"Reply",type:n.typeIntersectionNode({types:y})}),s.length?{name:e.id,type:n.typeNode("RouteHandler",[n.typeInterfaceNode({properties:s,useLegacyResolution:false})])}:void 0},xp=({plugin:e})=>{let t=e.createFile({id:hp,path:e.output}),r=[];e.forEach("operation",({operation:o})=>{let i=Xl({operation:o,plugin:e});i&&r.push(i);});let s=t.identifier({$ref:"RouteHandlers",create:true,namespace:"type"});s.name&&(r.length&&t.import({asType:true,module:"fastify",name:"RouteHandler"}),t.add(n.typeAliasDeclaration({exportType:true,name:s.name,type:n.typeInterfaceNode({properties:r,useLegacyResolution:false})})));};var ts={config:{exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:xp,name:"fastify",output:"fastify"};var h={actions:{args:n.identifier({text:"args"}),base64:n.identifier({text:"base64"}),bic:n.identifier({text:"bic"}),brand:n.identifier({text:"brand"}),bytes:n.identifier({text:"bytes"}),check:n.identifier({text:"check"}),checkItems:n.identifier({text:"checkItems"}),creditCard:n.identifier({text:"creditCard"}),cuid2:n.identifier({text:"cuid2"}),decimal:n.identifier({text:"decimal"}),description:n.identifier({text:"description"}),digits:n.identifier({text:"digits"}),email:n.identifier({text:"email"}),emoji:n.identifier({text:"emoji"}),empty:n.identifier({text:"empty"}),endsWith:n.identifier({text:"endsWith"}),entries:n.identifier({text:"entries"}),everyItem:n.identifier({text:"everyItem"}),excludes:n.identifier({text:"excludes"}),filterItems:n.identifier({text:"filterItems"}),findItem:n.identifier({text:"findItem"}),finite:n.identifier({text:"finite"}),flavor:n.identifier({text:"flavor"}),graphemes:n.identifier({text:"graphemes"}),gtValue:n.identifier({text:"gtValue"}),hash:n.identifier({text:"hash"}),hexColor:n.identifier({text:"hexColor"}),hexadecimal:n.identifier({text:"hexadecimal"}),imei:n.identifier({text:"imei"}),includes:n.identifier({text:"includes"}),integer:n.identifier({text:"integer"}),ip:n.identifier({text:"ip"}),ipv4:n.identifier({text:"ipv4"}),ipv6:n.identifier({text:"ipv6"}),isoDate:n.identifier({text:"isoDate"}),isoDateTime:n.identifier({text:"isoDateTime"}),isoTime:n.identifier({text:"isoTime"}),isoTimeSecond:n.identifier({text:"isoTimeSecond"}),isoTimestamp:n.identifier({text:"isoTimestamp"}),isoWeek:n.identifier({text:"isoWeek"}),length:n.identifier({text:"length"}),ltValue:n.identifier({text:"ltValue"}),mac:n.identifier({text:"mac"}),mac48:n.identifier({text:"mac48"}),mac64:n.identifier({text:"mac64"}),mapItems:n.identifier({text:"mapItems"}),maxBytes:n.identifier({text:"maxBytes"}),maxEntries:n.identifier({text:"maxEntries"}),maxGraphemes:n.identifier({text:"maxGraphemes"}),maxLength:n.identifier({text:"maxLength"}),maxSize:n.identifier({text:"maxSize"}),maxValue:n.identifier({text:"maxValue"}),maxWords:n.identifier({text:"maxWords"}),metadata:n.identifier({text:"metadata"}),mimeType:n.identifier({text:"mimeType"}),minBytes:n.identifier({text:"minBytes"}),minEntries:n.identifier({text:"minEntries"}),minGraphemes:n.identifier({text:"minGraphemes"}),minLength:n.identifier({text:"minLength"}),minSize:n.identifier({text:"minSize"}),minValue:n.identifier({text:"minValue"}),minWords:n.identifier({text:"minWords"}),multipleOf:n.identifier({text:"multipleOf"}),nanoid:n.identifier({text:"nanoid"}),nonEmpty:n.identifier({text:"nonEmpty"}),normalize:n.identifier({text:"normalize"}),notBytes:n.identifier({text:"notBytes"}),notEntries:n.identifier({text:"notEntries"}),notGraphemes:n.identifier({text:"notGraphemes"}),notLength:n.identifier({text:"notLength"}),notSize:n.identifier({text:"notSize"}),notValue:n.identifier({text:"notValue"}),notValues:n.identifier({text:"notValues"}),notWords:n.identifier({text:"notWords"}),octal:n.identifier({text:"octal"}),parseJson:n.identifier({text:"parseJson"}),partialCheck:n.identifier({text:"partialCheck"}),rawCheck:n.identifier({text:"rawCheck"}),rawTransform:n.identifier({text:"rawTransform"}),readonly:n.identifier({text:"readonly"}),reduceItems:n.identifier({text:"reduceItems"}),regex:n.identifier({text:"regex"}),returns:n.identifier({text:"returns"}),rfcEmail:n.identifier({text:"rfcEmail"}),safeInteger:n.identifier({text:"safeInteger"}),size:n.identifier({text:"size"}),slug:n.identifier({text:"slug"}),someItem:n.identifier({text:"someItem"}),sortItems:n.identifier({text:"sortItems"}),startsWith:n.identifier({text:"startsWith"}),stringifyJson:n.identifier({text:"stringifyJson"}),title:n.identifier({text:"title"}),toLowerCase:n.identifier({text:"toLowerCase"}),toMaxValue:n.identifier({text:"toMaxValue"}),toMinValue:n.identifier({text:"toMinValue"}),toUpperCase:n.identifier({text:"toUpperCase"}),transform:n.identifier({text:"transform"}),trim:n.identifier({text:"trim"}),trimEnd:n.identifier({text:"trimEnd"}),trimStart:n.identifier({text:"trimStart"}),ulid:n.identifier({text:"ulid"}),url:n.identifier({text:"url"}),uuid:n.identifier({text:"uuid"}),value:n.identifier({text:"value"}),values:n.identifier({text:"values"}),words:n.identifier({text:"words"})},async:{argsAsync:n.identifier({text:"argsAsync"}),arrayAsync:n.identifier({text:"arrayAsync"}),awaitAsync:n.identifier({text:"awaitAsync"}),checkAsync:n.identifier({text:"checkAsync"}),checkItemsAsync:n.identifier({text:"checkItemsAsync"}),customAsync:n.identifier({text:"customAsync"}),exactOptionalAsync:n.identifier({text:"exactOptionalAsync"}),fallbackAsync:n.identifier({text:"fallbackAsync"}),forwardAsync:n.identifier({text:"forwardAsync"}),getDefaultsAsync:n.identifier({text:"getDefaultsAsync"}),getFallbacksAsync:n.identifier({text:"getFallbacksAsync"}),intersectAsync:n.identifier({text:"intersectAsync"}),lazyAsync:n.identifier({text:"lazyAsync"}),looseObjectAsync:n.identifier({text:"looseObjectAsync"}),looseTupleAsync:n.identifier({text:"looseTupleAsync"}),mapAsync:n.identifier({text:"mapAsync"}),nonNullableAsync:n.identifier({text:"nonNullableAsync"}),nonNullishAsync:n.identifier({text:"nonNullishAsync"}),nonOptionalAsync:n.identifier({text:"nonOptionalAsync"}),nullableAsync:n.identifier({text:"nullableAsync"}),nullishAsync:n.identifier({text:"nullishAsync"}),objectAsync:n.identifier({text:"objectAsync"}),objectWithRestAsync:n.identifier({text:"objectWithRestAsync"}),optionalAsync:n.identifier({text:"optionalAsync"}),parseAsync:n.identifier({text:"parseAsync"}),parserAsync:n.identifier({text:"parserAsync"}),partialAsync:n.identifier({text:"partialAsync"}),partialCheckAsync:n.identifier({text:"partialCheckAsync"}),pipeAsync:n.identifier({text:"pipeAsync"}),rawCheckAsync:n.identifier({text:"rawCheckAsync"}),rawTransformAsync:n.identifier({text:"rawTransformAsync"}),recordAsync:n.identifier({text:"recordAsync"}),requiredAsync:n.identifier({text:"requiredAsync"}),returnsAsync:n.identifier({text:"returnsAsync"}),safeParseAsync:n.identifier({text:"safeParseAsync"}),safeParserAsync:n.identifier({text:"safeParserAsync"}),setAsync:n.identifier({text:"setAsync"}),strictObjectAsync:n.identifier({text:"strictObjectAsync"}),strictTupleAsync:n.identifier({text:"strictTupleAsync"}),transformAsync:n.identifier({text:"transformAsync"}),tupleAsync:n.identifier({text:"tupleAsync"}),tupleWithRestAsync:n.identifier({text:"tupleWithRestAsync"}),undefinedableAsync:n.identifier({text:"undefinedableAsync"}),unionAsync:n.identifier({text:"unionAsync"}),variantAsync:n.identifier({text:"variantAsync"})},methods:{assert:n.identifier({text:"assert"}),config:n.identifier({text:"config"}),fallback:n.identifier({text:"fallback"}),flatten:n.identifier({text:"flatten"}),forward:n.identifier({text:"forward"}),getDefault:n.identifier({text:"getDefault"}),getDefaults:n.identifier({text:"getDefaults"}),getDescription:n.identifier({text:"getDescription"}),getFallback:n.identifier({text:"getFallback"}),getFallbacks:n.identifier({text:"getFallbacks"}),getMetadata:n.identifier({text:"getMetadata"}),getTitle:n.identifier({text:"getTitle"}),is:n.identifier({text:"is"}),keyof:n.identifier({text:"keyof"}),message:n.identifier({text:"message"}),omit:n.identifier({text:"omit"}),parse:n.identifier({text:"parse"}),parser:n.identifier({text:"parser"}),partial:n.identifier({text:"partial"}),pick:n.identifier({text:"pick"}),pipe:n.identifier({text:"pipe"}),required:n.identifier({text:"required"}),safeParse:n.identifier({text:"safeParse"}),safeParser:n.identifier({text:"safeParser"}),summarize:n.identifier({text:"summarize"}),unwrap:n.identifier({text:"unwrap"})},schemas:{any:n.identifier({text:"any"}),array:n.identifier({text:"array"}),bigInt:n.identifier({text:"bigint"}),blob:n.identifier({text:"blob"}),boolean:n.identifier({text:"boolean"}),custom:n.identifier({text:"custom"}),date:n.identifier({text:"date"}),enum:n.identifier({text:"enum"}),exactOptional:n.identifier({text:"exactOptional"}),file:n.identifier({text:"file"}),function:n.identifier({text:"function"}),instance:n.identifier({text:"instance"}),intersect:n.identifier({text:"intersect"}),lazy:n.identifier({text:"lazy"}),literal:n.identifier({text:"literal"}),looseObject:n.identifier({text:"looseObject"}),looseTuple:n.identifier({text:"looseTuple"}),map:n.identifier({text:"map"}),nan:n.identifier({text:"nan"}),never:n.identifier({text:"never"}),nonNullable:n.identifier({text:"nonNullable"}),nonNullish:n.identifier({text:"nonNullish"}),nonOptional:n.identifier({text:"nonOptional"}),null:n.identifier({text:"null"}),nullable:n.identifier({text:"nullable"}),nullish:n.identifier({text:"nullish"}),number:n.identifier({text:"number"}),object:n.identifier({text:"object"}),objectWithRest:n.identifier({text:"objectWithRest"}),optional:n.identifier({text:"optional"}),picklist:n.identifier({text:"picklist"}),promise:n.identifier({text:"promise"}),record:n.identifier({text:"record"}),set:n.identifier({text:"set"}),strictObject:n.identifier({text:"strictObject"}),strictTuple:n.identifier({text:"strictTuple"}),string:n.identifier({text:"string"}),symbol:n.identifier({text:"symbol"}),tuple:n.identifier({text:"tuple"}),tupleWithRest:n.identifier({text:"tupleWithRest"}),undefined:n.identifier({text:"undefined"}),undefinedable:n.identifier({text:"undefinedable"}),union:n.identifier({text:"union"}),unknown:n.identifier({text:"unknown"}),variant:n.identifier({text:"variant"}),void:n.identifier({text:"void"})},types:{GenericSchema:n.identifier({text:"GenericSchema"})},v:n.identifier({text:"v"})},Ye="valibot";var Jl=({file:e,operation:t,plugin:r})=>{let{requests:s}=r.config,o=r.context.file({id:Ye}).identifier({$ref:`#/valibot-response/${t.id}`,nameTransformer:typeof s=="object"?s.name:void 0,namespace:"value"});if(!o.name)return;e.import({module:e.relativePathToFile({context:r.context,id:Ye}),name:o.name}),e.import({alias:h.v.text,module:"valibot",name:"*"});let i="data";return n.arrowFunction({async:true,parameters:[{name:i}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.async.parseAsync}),parameters:[n.identifier({text:o.name}),n.identifier({text:i})]})})})]})},Yl=({file:e,operation:t,plugin:r})=>{let{responses:s}=r.config,o=r.context.file({id:Ye}).identifier({$ref:`#/valibot-response/${t.id}`,nameTransformer:typeof s=="object"?s.name:void 0,namespace:"value"});if(!o.name)return;e.import({module:e.relativePathToFile({context:r.context,id:Ye}),name:o.name}),e.import({alias:h.v.text,module:"valibot",name:"*"});let i="data";return n.arrowFunction({async:true,parameters:[{name:i}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.async.parseAsync}),parameters:[n.identifier({text:o.name}),n.identifier({text:i})]})})})]})},bp={createRequestValidator:Jl,createResponseValidator:Yl};var rs={int16:{max:32767,maxError:"Invalid value: Expected int16 to be <= 2^15-1",min:-32768,minError:"Invalid value: Expected int16 to be >= -2^15",needsBigInt:false},int32:{max:2147483647,maxError:"Invalid value: Expected int32 to be <= 2^31-1",min:-2147483648,minError:"Invalid value: Expected int32 to be >= -2^31",needsBigInt:false},int64:{max:"9223372036854775807",maxError:"Invalid value: Expected int64 to be <= 2^63-1",min:"-9223372036854775808",minError:"Invalid value: Expected int64 to be >= -2^63",needsBigInt:true},int8:{max:127,maxError:"Invalid value: Expected int8 to be <= 2^7-1",min:-128,minError:"Invalid value: Expected int8 to be >= -2^7",needsBigInt:false},uint16:{max:65535,maxError:"Invalid value: Expected uint16 to be <= 2^16-1",min:0,minError:"Invalid value: Expected uint16 to be >= 0",needsBigInt:false},uint32:{max:4294967295,maxError:"Invalid value: Expected uint32 to be <= 2^32-1",min:0,minError:"Invalid value: Expected uint32 to be >= 0",needsBigInt:false},uint64:{max:"18446744073709551615",maxError:"Invalid value: Expected uint64 to be <= 2^64-1",min:"0",minError:"Invalid value: Expected uint64 to be >= 0",needsBigInt:true},uint8:{max:255,maxError:"Invalid value: Expected uint8 to be <= 2^8-1",min:0,minError:"Invalid value: Expected uint8 to be >= 0",needsBigInt:false}},Js=e=>e!==void 0&&e in rs,Op=e=>Js(e)&&rs[e].needsBigInt,xr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r};var Sp=({operation:e,plugin:t,state:r})=>{let s=t.context.file({id:Ye});if(t.config.requests.enabled){let o=new Set,i={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let p={},c=[];for(let m in e.parameters.header){let f=e.parameters.header[m];p[f.name]=f.schema,f.required&&(c.push(f.name),o.add("headers"));}Object.keys(p).length&&(i.properties.headers={properties:p,required:c,type:"object"});}if(e.parameters.path){let p={},c=[];for(let m in e.parameters.path){let f=e.parameters.path[m];p[f.name]=f.schema,f.required&&(c.push(f.name),o.add("path"));}Object.keys(p).length&&(i.properties.path={properties:p,required:c,type:"object"});}if(e.parameters.query){let p={},c=[];for(let m in e.parameters.query){let f=e.parameters.query[m];p[f.name]=f.schema,f.required&&(c.push(f.name),o.add("query"));}Object.keys(p).length&&(i.properties.query={properties:p,required:c,type:"object"});}}e.body&&(i.properties.body=e.body.schema,e.body.required&&o.add("body")),i.required=[...o];let a=s.identifier({$ref:`#/valibot-data/${e.id}`,case:t.config.requests.case,create:true,nameTransformer:t.config.requests.name,namespace:"value"});ue({$ref:`#/valibot-data/${e.id}`,identifier:a,plugin:t,schema:i,state:r});}if(t.config.responses.enabled&&e.responses){let{response:o}=Fe(e);if(o){let i=s.identifier({$ref:`#/valibot-response/${e.id}`,case:t.config.responses.case,create:true,nameTransformer:t.config.responses.name,namespace:"value"});ue({$ref:`#/valibot-response/${e.id}`,identifier:i,plugin:t,schema:o,state:r});}}};var je=e=>e.length===1?e[0]:n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.methods.pipe}),parameters:e}),eu=({plugin:e,schema:t,state:r})=>{let s=n.propertyAccessExpression({expression:h.v,name:h.schemas.array}),o=[];if(t.items){t=H({schema:t});let i=t.items.map(a=>{let p=ue({plugin:e,schema:a,state:r});return je(p)});if(i.length===1){let a=n.callExpression({functionName:s,parameters:i});o.push(a);}else {t.logicalOperator;let a=n.callExpression({functionName:s,parameters:[zr()]});o.push(a);}}else {let i=n.callExpression({functionName:s,parameters:[zr()]});o.push(i);}if(t.minItems===t.maxItems&&t.minItems!==void 0){let i=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.length}),parameters:[n.valueToExpression({value:t.minItems})]});o.push(i);}else {if(t.minItems!==void 0){let i=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.minLength}),parameters:[n.valueToExpression({value:t.minItems})]});o.push(i);}if(t.maxItems!==void 0){let i=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.maxLength}),parameters:[n.valueToExpression({value:t.maxItems})]});o.push(i);}}return je(o)},tu=({schema:e})=>typeof e.const=="boolean"?n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[n.ots.boolean(e.const)]}):n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.boolean})}),ru=({schema:e})=>{let t=[],r=false;for(let o of e.items??[])o.type==="string"&&typeof o.const=="string"?t.push(n.stringLiteral({text:o.const})):(o.type==="null"||o.const===null)&&(r=true);if(!t.length)return zr();let s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.picklist}),parameters:[n.arrayLiteralExpression({elements:t,multiLine:false})]});return r&&(s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.nullable}),parameters:[s]})),s},nu=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.never})}),su=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.null})}),Tp=({schema:e})=>{let t=e.format,r=e.type==="integer",s=Op(t),o=Js(t)?rs[t]:null;if(e.const!==void 0&&e.const!==null){let a=e.const,p;if(typeof a=="number"&&!t)p=n.ots.number(a);else if(typeof a=="number"&&t)s?p=n.callExpression({functionName:"BigInt",parameters:[n.ots.string(a.toString())]}):p=n.ots.number(a);else if(typeof a=="string"&&s){let c=a.endsWith("n")?a.slice(0,-1):a;p=n.callExpression({functionName:"BigInt",parameters:[n.ots.string(c)]});}else if(typeof a=="bigint"){let c=a.toString(),m=c.endsWith("n")?c.slice(0,-1):c;p=n.callExpression({functionName:"BigInt",parameters:[n.ots.string(m)]});}else p=n.valueToExpression({value:a});return n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[p]})}let i=[];if(s){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.union}),parameters:[n.arrayLiteralExpression({elements:[n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.number})}),n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.string})}),n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.bigInt})})],multiLine:false})]});i.push(a);let p=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.transform}),parameters:[n.arrowFunction({parameters:[{name:"x"}],statements:n.callExpression({functionName:"BigInt",parameters:[n.identifier({text:"x"})]})})]});i.push(p);}else {let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.number})});i.push(a);}if(!s&&r){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.integer})});i.push(a);}if(o){let a=o.min,p=o.max,c=o.minError,m=o.maxError,f=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.minValue}),parameters:[s?n.callExpression({functionName:"BigInt",parameters:[n.ots.string(a.toString())]}):n.ots.number(a),n.ots.string(c)]});i.push(f);let l=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.maxValue}),parameters:[s?n.callExpression({functionName:"BigInt",parameters:[n.ots.string(p.toString())]}):n.ots.number(p),n.ots.string(m)]});i.push(l);}if(e.exclusiveMinimum!==void 0){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.gtValue}),parameters:[xr({isBigInt:s,value:e.exclusiveMinimum})]});i.push(a);}else if(e.minimum!==void 0){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.minValue}),parameters:[xr({isBigInt:s,value:e.minimum})]});i.push(a);}if(e.exclusiveMaximum!==void 0){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.ltValue}),parameters:[xr({isBigInt:s,value:e.exclusiveMaximum})]});i.push(a);}else if(e.maximum!==void 0){let a=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.maxValue}),parameters:[xr({isBigInt:s,value:e.maximum})]});i.push(a);}return je(i)},ou=({plugin:e,schema:t,state:r})=>{let s=[],o=t.required??[];for(let a in t.properties){let p=t.properties[a],c=o.includes(a),m=ue({optional:!c,plugin:e,schema:p,state:r});G.lastIndex=0;let f;G.test(a)?f=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):f=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(f=`'${a}'`),s.push(n.propertyAssignment({initializer:je(m),name:f}));}if(t.additionalProperties&&t.additionalProperties.type==="object"&&!Object.keys(s).length){let a=ue({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.record}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.string}),parameters:[]}),je(a)]})}}let i=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(s,true)]});return {anyType:h.types.GenericSchema.text,expression:i}},iu=({schema:e})=>{if(typeof e.const=="string")return n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[n.ots.string(e.const)]});let t=[],r=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.string})});if(t.push(r),e.format)switch(e.format){case "date":t.push(n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.isoDate})}));break;case "date-time":t.push(n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.isoTimestamp})}));break;case "ipv4":case "ipv6":t.push(n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.ip})}));break;case "uri":t.push(n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.url})}));break;case "email":case "time":case "uuid":t.push(n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:n.identifier({text:e.format})})}));break}if(e.minLength===e.maxLength&&e.minLength!==void 0){let s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.length}),parameters:[n.valueToExpression({value:e.minLength})]});t.push(s);}else {if(e.minLength!==void 0){let s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.minLength}),parameters:[n.valueToExpression({value:e.minLength})]});t.push(s);}if(e.maxLength!==void 0){let s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.maxLength}),parameters:[n.valueToExpression({value:e.maxLength})]});t.push(s);}}if(e.pattern){let s=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.regex}),parameters:[n.regularExpressionLiteral({text:e.pattern})]});t.push(s);}return je(t)},au=({plugin:e,schema:t,state:r})=>{if(t.const&&Array.isArray(t.const)){let s=t.const.map(i=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[n.valueToExpression({value:i})]}));return n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.tuple}),parameters:[n.arrayLiteralExpression({elements:s})]})}if(t.items){let s=t.items.map(i=>{let a=ue({plugin:e,schema:i,state:r});return je(a)});return n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.tuple}),parameters:[n.arrayLiteralExpression({elements:s})]})}return zr()},pu=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.undefined})}),zr=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.unknown})}),cu=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.void})}),Rp=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:eu({plugin:e,schema:t,state:r})};case "boolean":return {expression:tu({schema:t})};case "enum":return {expression:ru({schema:t})};case "integer":case "number":return {expression:Tp({schema:t})};case "never":return {expression:nu()};case "null":return {expression:su()};case "object":return ou({plugin:e,schema:t,state:r});case "string":return t.format==="int64"||t.format==="uint64"?{expression:Tp({schema:t})}:{expression:iu({schema:t})};case "tuple":return {expression:au({plugin:e,schema:t,state:r})};case "undefined":return {expression:pu()};case "unknown":return {expression:zr()};case "void":return {expression:cu()}}},ue=({$ref:e,identifier:t,optional:r,plugin:s,schema:o,state:i})=>{let a=s.context.file({id:Ye}),p,c=t,m=[];if(e&&(i.circularReferenceTracker.add(e),c||(c=a.identifier({$ref:e,case:i.nameCase,create:true,nameTransformer:i.nameTransformer,namespace:"value"}))),o.$ref){let f=i.circularReferenceTracker.has(o.$ref),l=a.identifier({$ref:o.$ref,case:i.nameCase,nameTransformer:i.nameTransformer,namespace:"value"});if(!l.name){let d=s.context.resolveIrRef(o.$ref),y=ue({$ref:o.$ref,plugin:s,schema:d,state:i});m.push(...y),l=a.identifier({$ref:o.$ref,case:i.nameCase,nameTransformer:i.nameTransformer,namespace:"value"});}if(l.name){let d=n.identifier({text:l.name});if(f){let y=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.lazy}),parameters:[n.arrowFunction({statements:[n.returnStatement({expression:d})]})]});m.push(y),i.hasCircularReference=true;}else m.push(d);}}else if(o.type){let f=Rp({plugin:s,schema:o,state:i});if(p=f.anyType,m.push(f.expression),s.config.metadata&&o.description){let l=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.metadata}),parameters:[n.objectExpression({obj:[{key:"description",value:n.stringLiteral({text:o.description})}]})]});m.push(l);}}else if(o.items)if(o=H({schema:o}),o.items){let f=o.items.map(l=>{let d=ue({plugin:s,schema:l,state:i});return je(d)});if(o.logicalOperator==="and"){let l=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.intersect}),parameters:[n.arrayLiteralExpression({elements:f})]});m.push(l);}else {let l=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.union}),parameters:[n.arrayLiteralExpression({elements:f})]});m.push(l);}}else {let f=ue({plugin:s,schema:o,state:i});m.push(...f);}else {let f=Rp({plugin:s,schema:{type:"unknown"},state:i});p=f.anyType,m.push(f.expression);}if(e&&i.circularReferenceTracker.delete(e),m.length&&o.accessScope==="read"){let f=n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.actions.readonly})});m.push(f);}if(m.length){let f;if(o.default!==void 0){let l=o.type==="integer"&&o.format==="int64";f=xr({isBigInt:l,value:o.default}),f&&(m=[n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.optional}),parameters:[je(m),f]})]);}r&&!f&&(m=[n.callExpression({functionName:n.propertyAccessExpression({expression:h.v,name:h.schemas.optional}),parameters:[je(m)]})]);}if(c&&c.name&&c.created){let f=n.constVariable({comment:s.config.comments?Ne({schema:o}):void 0,exportConst:true,expression:je(m),name:c.name,typeName:i.hasCircularReference?n.propertyAccessExpression({expression:h.v,name:p||h.types.GenericSchema.text}):void 0});return a.add(f),[]}return m},Ap=({plugin:e})=>{e.createFile({case:e.config.case,id:Ye,path:e.output}).import({alias:h.v.text,module:"valibot",name:"*"}),e.forEach("operation","parameter","requestBody","schema",r=>{let s={circularReferenceTracker:new Set,hasCircularReference:false,nameCase:e.config.definitions.case,nameTransformer:e.config.definitions.name};r.type==="operation"?Sp({operation:r.operation,plugin:e,state:s}):r.type==="parameter"?ue({$ref:r.$ref,plugin:e,schema:r.parameter.schema,state:s}):r.type==="requestBody"?ue({$ref:r.$ref,plugin:e,schema:r.requestBody.schema,state:s}):r.type==="schema"&&ue({$ref:r.$ref,plugin:e,schema:r.schema,state:s});});};var ns={api:bp,config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:Ap,name:"valibot",output:"valibot",resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}Data"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}Response"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.responses});},tags:["validator"]};var u={ZodMiniOptional:n.identifier({text:"ZodMiniOptional"}),ZodOptional:n.identifier({text:"ZodOptional"}),_default:n.identifier({text:"_default"}),and:n.identifier({text:"and"}),array:n.identifier({text:"array"}),bigint:n.identifier({text:"bigint"}),boolean:n.identifier({text:"boolean"}),check:n.identifier({text:"check"}),coerce:n.identifier({text:"coerce"}),date:n.identifier({text:"date"}),datetime:n.identifier({text:"datetime"}),default:n.identifier({text:"default"}),describe:n.identifier({text:"describe"}),email:n.identifier({text:"email"}),enum:n.identifier({text:"enum"}),globalRegistry:n.identifier({text:"globalRegistry"}),gt:n.identifier({text:"gt"}),gte:n.identifier({text:"gte"}),infer:n.identifier({text:"infer"}),int:n.identifier({text:"int"}),intersection:n.identifier({text:"intersection"}),ip:n.identifier({text:"ip"}),ipv4:n.identifier({text:"ipv4"}),ipv6:n.identifier({text:"ipv6"}),iso:n.identifier({text:"iso"}),lazy:n.identifier({text:"lazy"}),length:n.identifier({text:"length"}),literal:n.identifier({text:"literal"}),lt:n.identifier({text:"lt"}),lte:n.identifier({text:"lte"}),max:n.identifier({text:"max"}),maxLength:n.identifier({text:"maxLength"}),min:n.identifier({text:"min"}),minLength:n.identifier({text:"minLength"}),never:n.identifier({text:"never"}),null:n.identifier({text:"null"}),nullable:n.identifier({text:"nullable"}),number:n.identifier({text:"number"}),object:n.identifier({text:"object"}),optional:n.identifier({text:"optional"}),parseAsync:n.identifier({text:"parseAsync"}),readonly:n.identifier({text:"readonly"}),record:n.identifier({text:"record"}),regex:n.identifier({text:"regex"}),register:n.identifier({text:"register"}),string:n.identifier({text:"string"}),time:n.identifier({text:"time"}),tuple:n.identifier({text:"tuple"}),undefined:n.identifier({text:"undefined"}),union:n.identifier({text:"union"}),unknown:n.identifier({text:"unknown"}),url:n.identifier({text:"url"}),uuid:n.identifier({text:"uuid"}),void:n.identifier({text:"void"}),z:n.identifier({text:"z"})},K="zod";var fu=({file:e,operation:t,plugin:r})=>{let o=r.context.file({id:K}).getName(r.api.getId({operation:t,type:"data"}));if(!o)return;e.import({module:e.relativePathToFile({context:r.context,id:K}),name:o});let i="data";return n.arrowFunction({async:true,parameters:[{name:i}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:n.identifier({text:o}),name:u.parseAsync}),parameters:[n.identifier({text:i})]})})})]})},lu=({file:e,operation:t,plugin:r})=>{let o=r.context.file({id:K}).getName(r.api.getId({operation:t,type:"responses"}));if(!o)return;e.import({module:e.relativePathToFile({context:r.context,id:K}),name:o});let i="data";return n.arrowFunction({async:true,parameters:[{name:i}],statements:[n.returnStatement({expression:n.awaitExpression({expression:n.callExpression({functionName:n.propertyAccessExpression({expression:n.identifier({text:o}),name:u.parseAsync}),parameters:[n.identifier({text:i})]})})})]})},uu=e=>{switch(e.type){case "data":case "responses":case "type-infer-data":case "type-infer-responses":return `${e.operation.id}-${e.type}`;case "ref":case "type-infer-ref":default:return `${e.type}-${e.value}`}},Ip={createRequestValidator:fu,createResponseValidator:lu,getId:uu};var ft=({plugin:e,schema:t,schemaId:r,typeInferId:s,zodSchema:o})=>{let i=e.context.file({id:K}),a=i.addNodeReference(r,{factory:c=>n.typeReferenceNode({typeName:c})}),p=n.constVariable({comment:e.config.comments?Ne({schema:t}):void 0,exportConst:true,expression:o.expression,name:a,typeName:o.typeName?n.propertyAccessExpression({expression:u.z,name:o.typeName}):void 0});if(i.add(p),s){let c=i.addNodeReference(s,{factory:l=>n.typeReferenceNode({typeName:l})}),m=i.addNodeReference(r,{factory:l=>n.identifier({text:l})}),f=n.typeAliasDeclaration({exportType:true,name:c,type:n.typeReferenceNode({typeArguments:[n.typeOfExpression({text:m})],typeName:n.propertyAccessExpression({expression:u.z,name:u.infer})})});i.add(f);}};var br=({plugin:e})=>{let t=e.package.getVersion("zod");if(t&&e.package.satisfies(t,"<4.0.0"))switch(e.config.compatibilityVersion){case 3:default:return "zod";case 4:return "zod/v4";case "mini":return "zod/v4-mini"}switch(e.config.compatibilityVersion){case 3:return "zod/v3";case 4:default:return "zod";case "mini":return "zod/mini"}};var Or=({getZodSchema:e,operation:t,plugin:r})=>{let s=r.context.file({id:K});if(r.config.requests.enabled){let o=new Set,i={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(t.parameters){if(t.parameters.header){let m={},f=[];for(let l in t.parameters.header){let d=t.parameters.header[l];m[d.name]=d.schema,d.required&&(f.push(d.name),o.add("headers"));}Object.keys(m).length&&(i.properties.headers={properties:m,required:f,type:"object"});}if(t.parameters.path){let m={},f=[];for(let l in t.parameters.path){let d=t.parameters.path[l];m[d.name]=d.schema,d.required&&(f.push(d.name),o.add("path"));}Object.keys(m).length&&(i.properties.path={properties:m,required:f,type:"object"});}if(t.parameters.query){let m={},f=[];for(let l in t.parameters.query){let d=t.parameters.query[l];m[d.name]=d.schema,d.required&&(f.push(d.name),o.add("query"));}Object.keys(m).length&&(i.properties.query={properties:m,required:f,type:"object"});}}t.body&&(i.properties.body=t.body.schema,t.body.required&&o.add("body")),i.required=[...o];let a=e(i),p=r.api.getId({operation:t,type:"data"}),c=r.config.requests.types.infer.enabled?r.api.getId({operation:t,type:"type-infer-data"}):void 0;ft({plugin:r,schema:i,schemaId:p,typeInferId:c,zodSchema:a}),s.updateNodeReferences(p,N({config:r.config.requests,name:t.id})),c&&s.updateNodeReferences(c,N({config:r.config.requests.types.infer,name:t.id}));}if(r.config.responses.enabled&&t.responses){let{response:o}=Fe(t);if(o){let i=e(o),a=r.api.getId({operation:t,type:"responses"}),p=r.config.responses.types.infer.enabled?r.api.getId({operation:t,type:"type-infer-responses"}):void 0;ft({plugin:r,schema:o,schemaId:a,typeInferId:p,zodSchema:i}),s.updateNodeReferences(a,N({config:r.config.responses,name:t.id})),p&&s.updateNodeReferences(p,N({config:r.config.responses.types.infer,name:t.id}));}}};var du=({plugin:e,schema:t,state:r})=>{let s={},o=n.propertyAccessExpression({expression:u.z,name:u.array});if(!t.items)s.expression=n.callExpression({functionName:o,parameters:[to().expression]});else {t=H({schema:t});let a=t.items.map(p=>{let c=Et({plugin:e,schema:p,state:r});return c.hasCircularReference&&(s.hasCircularReference=true),c.expression});a.length===1?s.expression=n.callExpression({functionName:o,parameters:a}):(t.logicalOperator,s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.array}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:a})]})]}));}let i=[];return t.minItems===t.maxItems&&t.minItems!==void 0?i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.length}),parameters:[n.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.minLength}),parameters:[n.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&i.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.maxLength}),parameters:[n.valueToExpression({value:t.maxItems})]}))),i.length&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.check}),parameters:i})),s},yu=({schema:e})=>{let t={};return typeof e.const=="boolean"?(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.boolean(e.const)]}),t):(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.boolean})}),t)},gu=({schema:e})=>{let t={},r=[],s=false;for(let o of e.items??[])o.type==="string"&&typeof o.const=="string"?r.push(n.stringLiteral({text:o.const})):(o.type==="null"||o.const===null)&&(s=true);return r.length?(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.enum}),parameters:[n.arrayLiteralExpression({elements:r,multiLine:false})]}),s&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.nullable}),parameters:[t.expression]})),t):to()},hu=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.never})}),t},xu=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.null})}),t},Kr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r},bu=({schema:e})=>{let t={},r=e.type==="integer"&&e.format==="int64";if(typeof e.const=="number")return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.number(e.const)]}),t;t.expression=n.callExpression({functionName:r?n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.coerce}),name:u.bigint}):n.propertyAccessExpression({expression:u.z,name:u.number})}),!r&&e.type==="integer"&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.int})}));let s=[];return e.exclusiveMinimum!==void 0?s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.gt}),parameters:[Kr({isBigInt:r,value:e.exclusiveMinimum})]})):e.minimum!==void 0&&s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.gte}),parameters:[Kr({isBigInt:r,value:e.minimum})]})),e.exclusiveMaximum!==void 0?s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.lt}),parameters:[Kr({isBigInt:r,value:e.exclusiveMaximum})]})):e.maximum!==void 0&&s.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.lte}),parameters:[Kr({isBigInt:r,value:e.maximum})]})),s.length&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.expression,name:u.check}),parameters:s})),t},Ou=({plugin:e,schema:t,state:r})=>{let s={},o=[],i=t.required??[];for(let a in t.properties){let p=t.properties[a],c=i.includes(a),m=Et({optional:!c,plugin:e,schema:p,state:r});m.hasCircularReference&&(s.hasCircularReference=true),G.lastIndex=0;let f;G.test(a)?f=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):f=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(f=`'${a}'`),m.hasCircularReference?o.push(n.getAccessorDeclaration({name:f,returnType:m.typeName?n.propertyAccessExpression({expression:u.z,name:m.typeName}):void 0,statements:[n.returnStatement({expression:m.expression})]})):o.push(n.propertyAssignment({initializer:m.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Et({plugin:e,schema:t.additionalProperties,state:r});return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.record}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.string}),parameters:[]}),a.expression]}),a.hasCircularReference&&(s.hasCircularReference=true),s}return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(o,true)]}),s},Su=({plugin:e,schema:t})=>{let r={};if(typeof t.const=="string")return r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.string(t.const)]}),r;r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.string})});let s=[];if(e.config.dates.offset&&s.push({key:"offset",value:true}),e.config.dates.local&&s.push({key:"local",value:true}),t.format)switch(t.format){case "date":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.date})});break;case "date-time":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.datetime}),parameters:s.length>0?[n.objectExpression({obj:s})]:[]});break;case "email":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.email})});break;case "ipv4":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.ipv4})});break;case "ipv6":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.ipv6})});break;case "time":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.time})});break;case "uri":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.url})});break;case "uuid":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.uuid})});break}let o=[];return t.minLength===t.maxLength&&t.minLength!==void 0?o.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.length}),parameters:[n.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&o.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.minLength}),parameters:[n.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&o.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.maxLength}),parameters:[n.valueToExpression({value:t.maxLength})]}))),t.pattern&&o.push(n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.regex}),parameters:[n.regularExpressionLiteral({text:t.pattern})]})),o.length&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.check}),parameters:o})),r},Tu=({plugin:e,schema:t,state:r})=>{let s={};if(t.const&&Array.isArray(t.const)){let i=t.const.map(a=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.valueToExpression({value:a})]}));return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:i})]}),s}let o=[];for(let i of t.items??[]){let a=Et({plugin:e,schema:i,state:r});o.push(a.expression),a.hasCircularReference&&(s.hasCircularReference=true);}return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:o})]}),s},Ru=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.undefined})}),t},to=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.unknown})}),t},Au=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.void})}),t},Pp=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return du({plugin:e,schema:t,state:r});case "boolean":return yu({schema:t});case "enum":return gu({schema:t});case "integer":case "number":return bu({schema:t});case "never":return hu();case "null":return xu();case "object":return Ou({plugin:e,schema:t,state:r});case "string":return Su({plugin:e,schema:t});case "tuple":return Tu({plugin:e,schema:t,state:r});case "undefined":return Ru();case "unknown":return to();case "void":return Au()}},Et=({optional:e,plugin:t,schema:r,state:s})=>{let o=t.context.file({id:K}),i={};if(r.$ref){let a=s.circularReferenceTracker.includes(r.$ref),p=s.currentReferenceTracker.includes(r.$ref);s.circularReferenceTracker.push(r.$ref),s.currentReferenceTracker.push(r.$ref);let c=t.api.getId({type:"ref",value:r.$ref});if(a){let m=o.addNodeReference(c,{factory:f=>n.identifier({text:f})});p?i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.lazy}),parameters:[n.arrowFunction({returnType:n.keywordTypeNode({keyword:"any"}),statements:[n.returnStatement({expression:m})]})]}):i.expression=m,i.hasCircularReference=true;}else if(!o.getName(c)){let m=t.context.resolveIrRef(r.$ref);ss({id:r.$ref,plugin:t,schema:m,state:s});}if(!a){let m=o.addNodeReference(c,{factory:f=>n.identifier({text:f})});i.expression=m;}s.circularReferenceTracker.pop(),s.currentReferenceTracker.pop();}else if(r.type){let a=Pp({plugin:t,schema:r,state:s});i.expression=a.expression,i.hasCircularReference=a.hasCircularReference,t.config.metadata&&r.description&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.register}),parameters:[n.propertyAccessExpression({expression:u.z,name:u.globalRegistry}),n.objectExpression({obj:[{key:"description",value:n.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=H({schema:r}),r.items){let a=r.items.map(p=>Et({plugin:t,schema:p,state:s}).expression);if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.intersection}),parameters:a}):(i.expression=a[0],a.slice(1).forEach(c=>{i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.intersection}),parameters:[i.expression,c]});}));}else i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:a})]});}else i=Et({plugin:t,schema:r,state:s});else {let a=Pp({plugin:t,schema:{type:"unknown"},state:s});i.expression=a.expression;}if(i.expression&&(r.accessScope==="read"&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.readonly}),parameters:[i.expression]})),e&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.optional}),parameters:[i.expression]}),i.typeName=u.ZodMiniOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=Kr({isBigInt:a,value:r.default});p&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u._default}),parameters:[i.expression,p]}));}return i},ss=({id:e,plugin:t,schema:r,state:s})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...s,currentReferenceTracker:[e]},i=t.context.file({id:K}),a=t.api.getId({type:"ref",value:e});if(i.getName(a))return;let p=Et({plugin:t,schema:r,state:o}),c=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;ft({plugin:t,schema:r,schemaId:a,typeInferId:c,zodSchema:p});let m=D(e);i.updateNodeReferences(a,N({config:t.config.definitions,name:m})),c&&i.updateNodeReferences(c,N({config:t.config.definitions.types.infer,name:m}));},Ep=({plugin:e})=>{e.createFile({case:e.config.case,id:K,path:e.output}).import({alias:u.z.text,module:br({plugin:e}),name:"*"}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Or({getZodSchema:s=>Et({plugin:e,schema:s,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?ss({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?ss({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&ss({id:r.$ref,plugin:e,schema:r.schema});});};var Iu=({plugin:e,schema:t,state:r})=>{let s=n.propertyAccessExpression({expression:u.z,name:u.array}),o;if(!t.items)o=n.callExpression({functionName:s,parameters:[no()]});else {t=H({schema:t});let i=t.items.map(a=>Nt({plugin:e,schema:a,state:r}).expression);i.length===1?o=n.callExpression({functionName:s,parameters:i}):(t.logicalOperator,o=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.array}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:i})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?o=n.callExpression({functionName:n.propertyAccessExpression({expression:o,name:u.length}),parameters:[n.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(o=n.callExpression({functionName:n.propertyAccessExpression({expression:o,name:u.min}),parameters:[n.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(o=n.callExpression({functionName:n.propertyAccessExpression({expression:o,name:u.max}),parameters:[n.valueToExpression({value:t.maxItems})]}))),o},Pu=({schema:e})=>typeof e.const=="boolean"?n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.boolean(e.const)]}):n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.boolean})}),Eu=({schema:e})=>{let t=[],r=false;for(let o of e.items??[])o.type==="string"&&typeof o.const=="string"?t.push(n.stringLiteral({text:o.const})):(o.type==="null"||o.const===null)&&(r=true);if(!t.length)return no();let s=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.enum}),parameters:[n.arrayLiteralExpression({elements:t,multiLine:false})]});return r&&(s=n.callExpression({functionName:n.propertyAccessExpression({expression:s,name:u.nullable})})),s},Nu=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.never})}),ju=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.null})}),Wr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r},Cu=({schema:e})=>{let t=e.type==="integer"&&e.format==="int64";if(typeof e.const=="number")return n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.number(e.const)]});let r=n.callExpression({functionName:t?n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.coerce}),name:u.bigint}):n.propertyAccessExpression({expression:u.z,name:u.number})});return !t&&e.type==="integer"&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.int})})),e.exclusiveMinimum!==void 0?r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.gt}),parameters:[Wr({isBigInt:t,value:e.exclusiveMinimum})]}):e.minimum!==void 0&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.gte}),parameters:[Wr({isBigInt:t,value:e.minimum})]})),e.exclusiveMaximum!==void 0?r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.lt}),parameters:[Wr({isBigInt:t,value:e.exclusiveMaximum})]}):e.maximum!==void 0&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.lte}),parameters:[Wr({isBigInt:t,value:e.maximum})]})),r},ku=({plugin:e,schema:t,state:r})=>{let s=[],o=t.required??[];for(let a in t.properties){let p=t.properties[a],c=o.includes(a),m=Nt({optional:!c,plugin:e,schema:p,state:r}).expression;G.lastIndex=0;let f;G.test(a)?f=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):f=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(f=`'${a}'`),s.push(n.propertyAssignment({initializer:m,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Nt({plugin:e,schema:t.additionalProperties,state:r}).expression;return {anyType:"AnyZodObject",expression:n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.record}),parameters:[a]})}}return {anyType:"AnyZodObject",expression:n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(s,true)]})}},vu=({plugin:e,schema:t})=>{if(typeof t.const=="string")return n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.string(t.const)]});let r=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.string})}),s=[];if(e.config.dates.offset&&s.push({key:"offset",value:true}),e.config.dates.local&&s.push({key:"local",value:true}),t.format)switch(t.format){case "date":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.date})});break;case "date-time":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.datetime}),parameters:s.length>0?[n.objectExpression({obj:s})]:[]});break;case "email":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.email})});break;case "ipv4":case "ipv6":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.ip})});break;case "time":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.time})});break;case "uri":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.url})});break;case "uuid":r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.length}),parameters:[n.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.min}),parameters:[n.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.max}),parameters:[n.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=n.callExpression({functionName:n.propertyAccessExpression({expression:r,name:u.regex}),parameters:[n.regularExpressionLiteral({text:t.pattern})]})),r},wu=({plugin:e,schema:t,state:r})=>{if(t.const&&Array.isArray(t.const)){let i=t.const.map(p=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.valueToExpression({value:p})]}));return n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:i})]})}let s=[];for(let i of t.items??[])s.push(Nt({plugin:e,schema:i,state:r}).expression);return n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:s})]})},qu=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.undefined})}),no=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.unknown})}),$u=e=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.void})}),Np=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:Iu({plugin:e,schema:t,state:r})};case "boolean":return {expression:Pu({schema:t})};case "enum":return {expression:Eu({schema:t})};case "integer":case "number":return {expression:Cu({schema:t})};case "never":return {expression:Nu()};case "null":return {expression:ju()};case "object":return ku({plugin:e,schema:t,state:r});case "string":return {expression:vu({plugin:e,schema:t})};case "tuple":return {expression:wu({plugin:e,schema:t,state:r})};case "undefined":return {expression:qu()};case "unknown":return {expression:no()};case "void":return {expression:$u()}}},Nt=({optional:e,plugin:t,schema:r,state:s})=>{let o=t.context.file({id:K}),i={};if(r.$ref){let a=s.circularReferenceTracker.includes(r.$ref);s.circularReferenceTracker.push(r.$ref),s.currentReferenceTracker.push(r.$ref);let p=t.api.getId({type:"ref",value:r.$ref});if(a){let c=o.addNodeReference(p,{factory:m=>n.identifier({text:m})});i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.lazy}),parameters:[n.arrowFunction({statements:[n.returnStatement({expression:c})]})]}),s.hasCircularReference=true;}else if(!o.getName(p)){let c=t.context.resolveIrRef(r.$ref);os({id:r.$ref,plugin:t,schema:c,state:s});}if(!a){let c=o.addNodeReference(p,{factory:m=>n.identifier({text:m})});i.expression=c;}s.circularReferenceTracker.pop(),s.currentReferenceTracker.pop();}else if(r.type){let a=Np({plugin:t,schema:r,state:s});i.expression=a.expression,i.typeName=a.anyType,t.config.metadata&&r.description&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.describe}),parameters:[n.stringLiteral({text:r.description})]}));}else if(r.items)if(r=H({schema:r}),r.items){let a=r.items.map(p=>Nt({plugin:t,schema:p,state:s}).expression);if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.intersection}),parameters:a}):(i.expression=a[0],a.slice(1).forEach(c=>{i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.and}),parameters:[c]});}));}else i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:a})]});}else i=Nt({plugin:t,schema:r,state:s});else {let a=Np({plugin:t,schema:{type:"unknown"},state:s});i.expression=a.expression,i.typeName=a.anyType;}if(i.expression&&(r.accessScope==="read"&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.readonly})})),e&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.optional})})),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=Wr({isBigInt:a,value:r.default});p&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.default}),parameters:[p]}));}return s.hasCircularReference?i.typeName||(i.typeName="ZodTypeAny"):i.typeName=void 0,i},os=({id:e,plugin:t,schema:r,state:s})=>{s||(s={circularReferenceTracker:[e],currentReferenceTracker:[e],hasCircularReference:false});let o=t.context.file({id:K}),i=t.api.getId({type:"ref",value:e});if(o.getName(i))return;let a=Nt({plugin:t,schema:r,state:s}),p=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;ft({plugin:t,schema:r,schemaId:i,typeInferId:p,zodSchema:a});let c=D(e);o.updateNodeReferences(i,N({config:t.config.definitions,name:c})),p&&o.updateNodeReferences(p,N({config:t.config.definitions.types.infer,name:c}));},jp=({plugin:e})=>{e.createFile({case:e.config.case,id:K,path:e.output}).import({module:br({plugin:e}),name:u.z.text}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Or({getZodSchema:s=>Nt({plugin:e,schema:s,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?os({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?os({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&os({id:r.$ref,plugin:e,schema:r.schema});});};var Mu=({plugin:e,schema:t,state:r})=>{let s={},o=n.propertyAccessExpression({expression:u.z,name:u.array});if(!t.items)s.expression=n.callExpression({functionName:o,parameters:[oo().expression]});else {t=H({schema:t});let i=t.items.map(a=>{let p=jt({plugin:e,schema:a,state:r});return p.hasCircularReference&&(s.hasCircularReference=true),p.expression});i.length===1?s.expression=n.callExpression({functionName:o,parameters:i}):(t.logicalOperator,s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.array}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:i})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.length}),parameters:[n.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.min}),parameters:[n.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:s.expression,name:u.max}),parameters:[n.valueToExpression({value:t.maxItems})]}))),s},Fu=({schema:e})=>{let t={};return typeof e.const=="boolean"?(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.boolean(e.const)]}),t):(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.boolean})}),t)},Lu=({schema:e})=>{let t={},r=[],s=false;for(let o of e.items??[])o.type==="string"&&typeof o.const=="string"?r.push(n.stringLiteral({text:o.const})):(o.type==="null"||o.const===null)&&(s=true);return r.length?(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.enum}),parameters:[n.arrayLiteralExpression({elements:r,multiLine:false})]}),s&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.nullable}),parameters:[t.expression]})),t):oo()},Du=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.never})}),t},Vu=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.null})}),t},Hr=({isBigInt:e,value:t})=>{let r=n.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?n.callExpression({functionName:"BigInt",parameters:[r]}):r},_u=({schema:e})=>{let t={},r=e.type==="integer"&&e.format==="int64";return typeof e.const=="number"?(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.number(e.const)]}),t):(t.expression=n.callExpression({functionName:r?n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.coerce}),name:u.bigint}):n.propertyAccessExpression({expression:u.z,name:u.number})}),!r&&e.type==="integer"&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.int})})),e.exclusiveMinimum!==void 0?t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.expression,name:u.gt}),parameters:[Hr({isBigInt:r,value:e.exclusiveMinimum})]}):e.minimum!==void 0&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.expression,name:u.gte}),parameters:[Hr({isBigInt:r,value:e.minimum})]})),e.exclusiveMaximum!==void 0?t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.expression,name:u.lt}),parameters:[Hr({isBigInt:r,value:e.exclusiveMaximum})]}):e.maximum!==void 0&&(t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:t.expression,name:u.lte}),parameters:[Hr({isBigInt:r,value:e.maximum})]})),t)},Bu=({plugin:e,schema:t,state:r})=>{let s={},o=[],i=t.required??[];for(let a in t.properties){let p=t.properties[a],c=i.includes(a),m=jt({optional:!c,plugin:e,schema:p,state:r});m.hasCircularReference&&(s.hasCircularReference=true),G.lastIndex=0;let f;G.test(a)?f=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):f=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(f=`'${a}'`),m.hasCircularReference?o.push(n.getAccessorDeclaration({name:f,returnType:m.typeName?n.propertyAccessExpression({expression:u.z,name:m.typeName}):void 0,statements:[n.returnStatement({expression:m.expression})]})):o.push(n.propertyAssignment({initializer:m.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=jt({plugin:e,schema:t.additionalProperties,state:r});return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.record}),parameters:[n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.string}),parameters:[]}),a.expression]}),a.hasCircularReference&&(s.hasCircularReference=true),s.hasCircularReference?{...s,typeName:"ZodType"}:s}return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(o,true)]}),s.hasCircularReference?{...s,typeName:"ZodType"}:s},zu=({plugin:e,schema:t})=>{let r={};if(typeof t.const=="string")return r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.ots.string(t.const)]}),r;r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.string})});let s=[];if(e.config.dates.offset&&s.push({key:"offset",value:true}),e.config.dates.local&&s.push({key:"local",value:true}),t.format)switch(t.format){case "date":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.date})});break;case "date-time":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.datetime}),parameters:s.length>0?[n.objectExpression({obj:s})]:[]});break;case "email":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.email})});break;case "ipv4":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.ipv4})});break;case "ipv6":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.ipv6})});break;case "time":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:n.propertyAccessExpression({expression:u.z,name:u.iso}),name:u.time})});break;case "uri":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.url})});break;case "uuid":r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.length}),parameters:[n.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.min}),parameters:[n.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.max}),parameters:[n.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:r.expression,name:u.regex}),parameters:[n.regularExpressionLiteral({text:t.pattern})]})),r},Ku=({plugin:e,schema:t,state:r})=>{let s={};if(t.const&&Array.isArray(t.const)){let i=t.const.map(a=>n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.literal}),parameters:[n.valueToExpression({value:a})]}));return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:i})]}),s}let o=[];for(let i of t.items??[]){let a=jt({plugin:e,schema:i,state:r});o.push(a.expression),a.hasCircularReference&&(s.hasCircularReference=true);}return s.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.tuple}),parameters:[n.arrayLiteralExpression({elements:o})]}),s},Wu=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.undefined})}),t},oo=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.unknown})}),t},Hu=e=>{let t={};return t.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.void})}),t},Cp=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return Mu({plugin:e,schema:t,state:r});case "boolean":return Fu({schema:t});case "enum":return Lu({schema:t});case "integer":case "number":return _u({schema:t});case "never":return Du();case "null":return Vu();case "object":return Bu({plugin:e,schema:t,state:r});case "string":return zu({plugin:e,schema:t});case "tuple":return Ku({plugin:e,schema:t,state:r});case "undefined":return Wu();case "unknown":return oo();case "void":return Hu()}},jt=({optional:e,plugin:t,schema:r,state:s})=>{let o=t.context.file({id:K}),i={};if(r.$ref){let a=s.circularReferenceTracker.includes(r.$ref),p=s.currentReferenceTracker.includes(r.$ref);s.circularReferenceTracker.push(r.$ref),s.currentReferenceTracker.push(r.$ref);let c=t.api.getId({type:"ref",value:r.$ref});if(a){let m=o.addNodeReference(c,{factory:f=>n.identifier({text:f})});p?i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.lazy}),parameters:[n.arrowFunction({returnType:n.keywordTypeNode({keyword:"any"}),statements:[n.returnStatement({expression:m})]})]}):i.expression=m,i.hasCircularReference=true;}else if(!o.getName(c)){let m=t.context.resolveIrRef(r.$ref);is({id:r.$ref,plugin:t,schema:m,state:s});}if(!a){let m=o.addNodeReference(c,{factory:f=>n.identifier({text:f})});i.expression=m;}s.circularReferenceTracker.pop(),s.currentReferenceTracker.pop();}else if(r.type){let a=Cp({plugin:t,schema:r,state:s});i.expression=a.expression,i.hasCircularReference=a.hasCircularReference,t.config.metadata&&r.description&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.register}),parameters:[n.propertyAccessExpression({expression:u.z,name:u.globalRegistry}),n.objectExpression({obj:[{key:"description",value:n.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=H({schema:r}),r.items){let a=r.items.map(p=>jt({plugin:t,schema:p,state:s}).expression);if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.intersection}),parameters:a}):(i.expression=a[0],a.slice(1).forEach(c=>{i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.and}),parameters:[c]});}));}else i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.union}),parameters:[n.arrayLiteralExpression({elements:a})]});}else i=jt({plugin:t,schema:r,state:s});else {let a=Cp({plugin:t,schema:{type:"unknown"},state:s});i.expression=a.expression;}if(i.expression&&(r.accessScope==="read"&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.readonly})})),e&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:u.z,name:u.optional}),parameters:[i.expression]}),i.typeName=u.ZodOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=Hr({isBigInt:a,value:r.default});p&&(i.expression=n.callExpression({functionName:n.propertyAccessExpression({expression:i.expression,name:u.default}),parameters:[p]}));}return i},is=({id:e,plugin:t,schema:r,state:s})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...s,currentReferenceTracker:[e]},i=t.context.file({id:K}),a=t.api.getId({type:"ref",value:e});if(i.getName(a))return;let p=jt({plugin:t,schema:r,state:o}),c=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;ft({plugin:t,schema:r,schemaId:a,typeInferId:c,zodSchema:p});let m=D(e);i.updateNodeReferences(a,N({config:t.config.definitions,name:m})),c&&i.updateNodeReferences(c,N({config:t.config.definitions.types.infer,name:m}));},io=({plugin:e})=>{e.createFile({case:e.config.case,id:K,path:e.output}).import({module:br({plugin:e}),name:u.z.text}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Or({getZodSchema:s=>jt({plugin:e,schema:s,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?is({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?is({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&is({id:r.$ref,plugin:e,schema:r.schema});});};var kp=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return jp(e);case 4:return io(e);case "mini":return Ep(e);default:return io(e)}};var as={api:Ip,config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:kp,name:"zod",output:"zod",resolveConfig:(e,t)=>{let r="zod",s=t.package.getVersion(r),o=()=>s&&(s.major===4||s.major===3)?s.major:4,i=a=>{if(!a)return o();if(!s)return a;if((a===4||a===3||a==="mini")&&!t.package.satisfies(s,">=3.25.0 <5.0.0")){let p=o();return console.warn(`\u{1F50C} ${Zr__default.default.yellow("Warning:")} Installed ${Zr__default.default.cyan(r)} ${Zr__default.default.cyan(`v${s.version}`)} does not support compatibility version ${Zr__default.default.yellow(String(a))}, using ${Zr__default.default.yellow(String(p))}.`),p}return a};e.config.compatibilityVersion=i(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{local:false,offset:false},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:"PascalCase",enabled:false}},mappers:{object:(a,p)=>({...a,infer:t.valueToObject({defaultValue:{...p.infer,enabled:a.infer!==void 0?!!a.infer:p.infer.enabled},mappers:lt,value:a.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}ZodType"}}},mappers:{...lt,object:(a,p)=>({...a,types:t.valueToObject({defaultValue:p.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:lt,value:c.infer})})},value:a.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}Data",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}DataZodType"}}},mappers:{...lt,object:(a,p)=>({...a,types:t.valueToObject({defaultValue:p.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:lt,value:c.infer})})},value:a.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}Response",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}ResponseZodType"}}},mappers:{...lt,object:(a,p)=>({...a,types:t.valueToObject({defaultValue:p.types,mappers:{object:(c,m)=>({...c,infer:t.valueToObject({defaultValue:{...m.infer,enabled:c.infer!==void 0?!!c.infer:m.infer.enabled},mappers:lt,value:c.infer})})},value:a.types})})},value:e.config.responses});},tags:["validator"]};var ps={"@angular/common":Rn,"@hey-api/client-angular":An,"@hey-api/client-axios":In,"@hey-api/client-fetch":Pn,"@hey-api/client-next":En,"@hey-api/client-nuxt":Nn,"@hey-api/schemas":$n,"@hey-api/sdk":Mn,"@hey-api/transformers":Ln,"@hey-api/typescript":_n,"@tanstack/angular-query-experimental":Xn,"@tanstack/react-query":Gn,"@tanstack/solid-query":Jn,"@tanstack/svelte-query":Yn,"@tanstack/vue-query":es,fastify:ts,"legacy/angular":jn,"legacy/axios":Cn,"legacy/fetch":kn,"legacy/node":vn,"legacy/xhr":wn,valibot:ns,zod:as};var vp=["@hey-api/typescript","@hey-api/sdk"],Uu=({dependencies:e,userPlugins:t,userPluginsConfig:r})=>{let s=new Set,o=new Set,i={},a=p=>{if(s.has(p))throw new Error(`Circular reference detected at '${p}'`);if(o.has(p))return;s.add(p);let c=ps[p],m=r[p];if(!c&&!m)throw new Error(`unknown plugin dependency "${p}" - do you need to register a custom plugin with this name?`);let f={...c,...m,config:{...c?.config,...m?.config},dependencies:new Set([...c?.dependencies||[],...m?.dependencies||[]])};if(f.resolveConfig){let l={package:mn(e),pluginByTag:(d,y={})=>{let{defaultPlugin:g,errorMessage:x}=y;for(let S of t){let O=ps[S]||r[S];if(O&&O.tags?.includes(d)&&S!==p)return S}if(g){let S=ps[g]||r[g];if(S&&S.tags?.includes(d)&&g!==p)return g}throw new Error(x||`missing plugin - no plugin with tag "${d}" found`)},valueToObject:kt};f.resolveConfig(f,l);}for(let l of f.dependencies)a(l);s.delete(p),o.add(p),i[p]=f;};for(let p of t)a(p);return {pluginOrder:Array.from(o),plugins:i}},Qu=e=>typeof e=="string"?e.startsWith("@hey-api/client")||e.startsWith("legacy/"):e.name.startsWith("@hey-api/client")||e.name.startsWith("legacy/")||e.tags&&e.tags.includes("client"),wp=({dependencies:e,userConfig:t})=>{let r={},s=vp;t.plugins&&(t.plugins=t.plugins.filter(i=>typeof i=="string"&&i||typeof i!="string"&&i.name),t.plugins.length===1&&Qu(t.plugins[0])?s=[...vp,...t.plugins]:s=t.plugins);let o=s.map(i=>{if(typeof i=="string")return i;let a=i.name;return a&&(i.handler?r[a]=i:(r[a]={config:{...i}},delete r[a].config.name)),a}).filter(Boolean);return Uu({dependencies:e,userPlugins:o,userPluginsConfig:r})};var Ju=async e=>{let t;if(e?.configFile){let p=e.configFile.split(".");t=p.slice(0,p.length-1).join(".");}let{config:r,configFile:s}=await c12.loadConfig({configFile:t,name:"openapi-ts"}),o=go(Object.keys(r).length?s:void 0),i=Array.isArray(e)?e:Array.isArray(r)?r.map(p=>fs(p,e)):[fs(r,e)],a=[];for(let p of i){let{base:c,configFile:m="",dryRun:f=false,experimentalParser:l=true,exportCore:d=true,interactive:y=false,name:g,request:x,useOptions:S=true}=p,O=[],v=lo(p);v.level==="debug"&&console.warn("userConfig:",p);let _=fo(p),$=uo(p),F=ho(p);_.path||O.push(new Sr("missing input - which OpenAPI specification should we use to generate your output?")),$.path||O.push(new Sr("missing output - where should we generate your output?")),S||console.warn("\u2757\uFE0F Deprecation warning: useOptions set to false. This setting will be removed in future versions. Please migrate useOptions to true https://heyapi.dev/openapi-ts/migrating.html#v0-27-38"),$.path=sr__default.default.resolve(process.cwd(),$.path);let W;try{W=wp({dependencies:o,userConfig:p});}catch(C){O.push(C),W={pluginOrder:[],plugins:{}};}let L=co({...W,base:c,configFile:m,dryRun:f,experimentalParser:l,exportCore:false,input:_,interactive:y,logs:v,name:g,output:$,parser:F,request:x,useOptions:S});L.exportCore=X(L)?d:false,v.level==="debug"&&console.warn("config:",L),a.push({config:L,errors:O});}return {dependencies:o,results:a}};var ms=(...e)=>{let t=new Headers;for(let r of e){if(!r||typeof r!="object")continue;let s=r instanceof Headers?r.entries():Object.entries(r);for(let[o,i]of s)if(i===null)t.delete(o);else if(Array.isArray(i))for(let a of i)t.append(o,a);else i!==void 0&&t.set(o,typeof i=="object"?JSON.stringify(i):i);}return t};var pd=async({fetchOptions:e,inputPath:t,timeout:r,watch:s})=>{let o=new jsonSchemaRefParser.$RefParser,i=jsonSchemaRefParser.getResolvedInput({pathOrUrlOrSchema:t}),a,p,c;if(i.type==="url"){if(s.lastValue&&s.isHeadMethodSupported!==false){try{let f=await jsonSchemaRefParser.sendRequest({fetchOptions:{method:"HEAD",...e,headers:ms(e?.headers,s.headers)},timeout:r,url:i.path});if(f.response.status>=300)return {error:"not-ok",response:f.response};c=f.response;}catch(f){return {error:"not-ok",response:new Response(f.message)}}if(!c.ok&&s.isHeadMethodSupported)return {error:"not-ok",response:c};if(s.isHeadMethodSupported===void 0&&(s.isHeadMethodSupported=c.ok),c.status===304)return {error:"not-modified",response:c};if(p===void 0){let f=c.headers.get("ETag");f&&(p=f!==s.headers.get("If-None-Match"),p&&s.headers.set("If-None-Match",f));}if(p===void 0){let f=c.headers.get("Last-Modified");f&&(p=f!==s.headers.get("If-Modified-Since"),p&&s.headers.set("If-Modified-Since",f));}if(p===false)return {error:"not-modified",response:c}}try{let f=await jsonSchemaRefParser.sendRequest({fetchOptions:{method:"GET",...e},timeout:r,url:i.path});if(f.response.status>=300)return {error:"not-ok",response:f.response};c=f.response;}catch(f){return {error:"not-ok",response:new Response(f.message)}}if(!c.ok)return {error:"not-ok",response:c};if(a=c.body?await c.arrayBuffer():new ArrayBuffer(0),p===void 0){let f=new TextDecoder().decode(a);p=f!==s.lastValue,s.lastValue=f;}}else s.lastValue?p=false:s.lastValue=i.type;return p===false?{error:"not-modified",response:c}:{data:await o.bundle({arrayBuffer:a,pathOrUrlOrSchema:void 0,resolvedInput:i})}};
13
13
  exports.getSpec=pd;exports.initConfigs=Ju;exports.parseOpenApiSpec=Nf;//# sourceMappingURL=internal.cjs.map
14
14
  //# sourceMappingURL=internal.cjs.map