@hey-api/openapi-ts 0.85.0 → 0.85.1
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/{chunk-JIKOAZJ5.js → chunk-SA4IKOSG.js} +3 -3
- package/dist/chunk-SA4IKOSG.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.js +1 -1
- package/package.json +3 -3
- package/dist/chunk-JIKOAZJ5.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -41,7 +41,7 @@ ${n}`,Se__default.default.writeFileSync(e,n,"utf8");},vo=({meta:e,outputPath:t,p
|
|
|
41
41
|
`,r=null){if(this.isEmpty()){this.remove({force:true});return}let n=this._path;if(typeof this._path=="string"){let o=this._path.split(L__default.default.sep);n=o.slice(0,o.length-1).join(L__default.default.sep);}Be(n),Se__default.default.writeFileSync(this._path,this._toString(t,r));}},om=e=>{let t=e.match(/\.[0-9a-z]+$/i),r=t?t[0].slice(1):"",n=e.slice(0,e.length-(r?r.length+1:0));return {extension:r,name:n}};var Pi=(e,t)=>{let r=T();if(Array.isArray(e))return e.map(o=>Pi(o));if(typeof e!="object"||e===null)return e;let n={...e};return Object.entries(n).forEach(([o,s])=>{if(r.plugins["@hey-api/schemas"]?.config.type==="form"&&["description","x-enum-descriptions","x-enum-varnames","x-enumNames","title"].includes(o)&&t!=="properties"){delete n[o];return}o==="$ref"&&typeof s=="string"&&(n[o]=decodeURIComponent(s)),s&&typeof s=="object"&&(n[o]=Pi(s,o));}),n},Wg=(e,t)=>{let r=T(),n=He(e),o=r.plugins["@hey-api/schemas"];return o?.config.nameBuilder?typeof o.config.nameBuilder=="function"?o.config.nameBuilder(n,t):o.config.nameBuilder.replace("{{name}}",n):`${n}Schema`},sm=({files:e,openApi:t,plugin:r})=>{let n=T();e.schemas=new De({dir:n.output.path,exportFromIndex:r.config.exportFromIndex,id:"schemas",name:"schemas.ts"});let o=(s,a)=>{let p=Pi(a),c=i.objectExpression({obj:p}),m=i.constVariable({assertion:"const",exportConst:true,expression:c,name:Wg(s,a)});e.schemas.add(m);};"swagger"in t&&Object.entries(t.definitions??{}).forEach(([s,a])=>{o(s,a);}),"openapi"in t&&Object.entries(t.components?.schemas??{}).forEach(([s,a])=>{o(s,a);});};var Zo={api:new Uo({name:"@hey-api/schemas"}),config:{exportFromIndex:false,nameBuilder:e=>`${e}Schema`,type:"json"},handler:rm,handlerLegacy:sm,name:"@hey-api/schemas"};var Xo=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var cr=({meta:e,onImport:t,...r})=>{if(!e)return {created:false,name:""};let{created:n,name:o}=Me({meta:e,...r});return o&&t(o),{created:n,name:o}},mm=e=>`${e}ModelResponseTransformer`,mr=e=>`${N({case:"PascalCase",value:e})}Data`,Hr=e=>`${N({case:"PascalCase",value:e})}Error`,Ai=e=>`${e}Transformer`,dt=e=>`${N({case:"PascalCase",value:e})}Response`,Ei=({importedType:e,throwOnError:t})=>{let r="OptionsLegacyParser";return t?`${r}<${e||"unknown"}, ${t}>`:e?`${r}<${e}>`:r},im=(e,t)=>{let r=T(),{name:n}=Me({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:mr}),o=mt(t.parameters);if(!W(r))return [{isRequired:o,name:"options",type:Ei({importedType:n,throwOnError:"ThrowOnError"})}];if(!t.parameters.length)return [];let s=a=>{if(a.default!==void 0)return JSON.stringify(a.default,null,4)};return r.useOptions?[{default:o?void 0:{},name:"data",type:n}]:t.parameters.map(a=>{let p=`${n}['${a.name}']`;return {default:a?.default,isRequired:(!a.isRequired&&!s(a)?"?":"")=="",name:a.name,type:p}})},am=(e,t)=>{let r=T(),n=i.typeNode("void");if(t.responses.filter(a=>a.responseTypes.includes("success")).length){let{name:a}=Me({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:dt});n=i.typeUnionNode({types:[a]});}return r.useOptions&&r.plugins["@hey-api/sdk"]?.config.response==="response"&&(n=i.typeNode("ApiResult",[n])),E(r).name==="legacy/angular"?n=i.typeNode("Observable",[n]):n=i.typeNode("CancelablePromise",[n]),n},pm=e=>{let t=T();if(!W(t))return [e.deprecated&&"@deprecated",e.summary&&z(e.summary),e.description&&z(e.description)];let r=[];e.parameters.length&&(t.useOptions?r=["@param data The data for the request.",...e.parameters.map(s=>`@param data.${s.name} ${s.description?z(s.description):""}`)]:r=e.parameters.map(s=>`@param ${s.name} ${s.description?z(s.description):""}`));let n=e.responses.filter(s=>s.responseTypes.includes("success"));return [e.deprecated&&"@deprecated",e.summary&&z(e.summary),e.description&&z(e.description),...r,...n.map(s=>`@returns ${s.type} ${s.description?z(s.description):""}`),"@throws ApiError"]},zg=({client:e,onClientImport:t,onImport:r,operation:n})=>{let o=T(),s=dt(n.name),{name:a}=Me({client:e,meta:{$ref:`transformers/${s}`,name:s},nameTransformer:Ai});if(a&&r(a),!W(o)){let l=[{spread:"options"}],u=n.parameters.filter(d=>d.in==="body"||d.in==="formData").map(d=>d.mediaType||(d.in==="formData"?"multipart/form-data":void 0)).filter(Boolean).filter(de);return u.length===1&&(u[0]==="multipart/form-data"&&(l=[...l,{spread:"formDataBodySerializer"},{key:"headers",value:[{key:"Content-Type",value:null},{spread:"options?.headers"}]}],t?.("formDataBodySerializer")),u[0]==="application/x-www-form-urlencoded"&&(l=[...l,{spread:"urlSearchParamsBodySerializer"},{key:"headers",value:[{key:"Content-Type",value:u[0]},{spread:"options?.headers"}]}],t?.("urlSearchParamsBodySerializer"))),l=[...l,{key:"url",value:n.path}],a&&(l=[...l,{key:"responseTransformer",value:a}]),i.objectExpression({identifiers:["responseTransformer"],obj:l})}let p=l=>l.reduce((f,u)=>{let d=u.prop,y=o.useOptions?`data.${u.name}`:u.name;return d===y?f[d]=d:je(d)===d?f[d]=y:f[`'${d}'`]=y,f},{}),c={method:n.method,url:n.path};n.parametersPath.length&&(c.path=p(n.parametersPath)),n.parametersCookie.length&&(c.cookies=p(n.parametersCookie)),n.parametersHeader.length&&(c.headers=p(n.parametersHeader)),n.parametersQuery.length&&(c.query=p(n.parametersQuery)),n.parametersForm.length&&(c.formData=p(n.parametersForm)),n.parametersBody&&(n.parametersBody.in==="formData"&&(o.useOptions?c.formData=`data.${n.parametersBody.name}`:c.formData=n.parametersBody.name),n.parametersBody.in==="body"&&(o.useOptions?c.body=`data.${n.parametersBody.name}`:c.body=n.parametersBody.name)),n.parametersBody?.mediaType&&(c.mediaType=n.parametersBody?.mediaType),n.responseHeader&&(c.responseHeader=n.responseHeader),a&&(c.responseTransformer=a);let m=n.responses.filter(l=>l.responseTypes.includes("error"));if(m.length>0){let l={};m.forEach(f=>{l[f.code]=f.description??"";}),c.errors=l;}return i.objectExpression({identifiers:["body","cookies","formData","headers","path","query","responseTransformer"],obj:c,shorthand:true})},ut=({config:e,handleIllegal:t,id:r,operation:n})=>e.plugins["@hey-api/sdk"]?.config.methodNameBuilder?e.plugins["@hey-api/sdk"].config.methodNameBuilder(n):t&&r.match(he)?`${r}_`:r,cm=({client:e,onClientImport:t,onImport:r,operation:n})=>{let o=T(),s=zg({client:e,onClientImport:t,onImport:r,operation:n});if(!W(o)){let p=Me({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:Hr}).name,m=n.responses.filter(l=>l.responseTypes.includes("success")).length?Me({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:dt}).name:"void";return [i.returnFunctionCall({args:[s],name:`(options?.client ?? client).${n.method.toLocaleLowerCase()}`,types:p&&m?[m,p,"ThrowOnError"]:p?["unknown",p,"ThrowOnError"]:m?[m,"unknown","ThrowOnError"]:[]})]}return X(o)?[i.returnFunctionCall({args:[s],name:"this.httpRequest.request"})]:E(o).name==="legacy/angular"?[i.returnFunctionCall({args:["OpenAPI","this.http",s],name:"__request"})]:[i.returnFunctionCall({args:["OpenAPI",s],name:"__request"})]},Qg=({client:e,onClientImport:t,onImport:r,onNode:n,service:o})=>{let s=T(),a=E(s),p=W(s);for(let u of o.operations)u.parameters.length&&cr({client:e,meta:{$ref:u.name,name:u.name},nameTransformer:mr,onImport:r}),p||cr({client:e,meta:{$ref:u.name,name:u.name},nameTransformer:Hr,onImport:r}),u.responses.filter(y=>y.responseTypes.includes("success")).length&&cr({client:e,meta:{$ref:u.name,name:u.name},nameTransformer:dt,onImport:r});let c={default:("throwOnError"in a.config?a.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"};if(!s.plugins["@hey-api/sdk"]?.config.asClass&&!X(s)){for(let u of o.operations){let d={parameters:im(e,u),returnType:p?am(e,u):void 0,statements:cm({client:e,onClientImport:t,onImport:r,operation:u}),types:p?void 0:[c]},y=a.name==="legacy/angular"?i.anonymousFunction(d):i.arrowFunction(d),h=i.constVariable({comment:pm(u),exportConst:true,expression:y,name:ut({config:s,handleIllegal:true,id:u.name,operation:u})});n(h);}return}let m=o.operations.map(u=>i.methodDeclaration({accessLevel:"public",comment:pm(u),isStatic:X(s)===void 0&&a.name!=="legacy/angular",name:ut({config:s,id:u.name,operation:u}),parameters:im(e,u),returnType:p?am(e,u):void 0,statements:cm({client:e,onClientImport:t,onImport:r,operation:u}),types:p?void 0:[c]}));if(!m.length)return;X(s)?m=[i.constructorDeclaration({multiLine:false,parameters:[{accessLevel:"public",isReadOnly:true,name:"httpRequest",type:"BaseHttpRequest"}]}),...m]:a.name==="legacy/angular"&&(m=[i.constructorDeclaration({multiLine:false,parameters:[{accessLevel:"public",isReadOnly:true,name:"http",type:"HttpClient"}]}),...m]);let l=[];m.forEach((u,d)=>{d&&l.push(i.identifier({text:`
|
|
42
42
|
`})),l.push(u);});let f=i.classDeclaration({decorator:a.name==="legacy/angular"?{args:[{providedIn:"root"}],name:"Injectable"}:void 0,exportClass:true,name:Bt({config:s,name:o.name}),nodes:l});n(f);},lm=({client:e,files:t,plugin:r})=>{let n=T(),o=W(n),s="sdk";if(t.sdk=new De({dir:n.output.path,exportFromIndex:r.config.exportFromIndex,id:"sdk",name:`${s}.ts`}),!o)t.sdk.import({module:pr({config:n,sourceOutput:s}),name:"createClient"}),t.sdk.import({module:pr({config:n,sourceOutput:s}),name:"createConfig"}),t.sdk.import({asType:true,module:pr({config:n,sourceOutput:s}),name:"OptionsLegacyParser"});else if(E(n).name==="legacy/angular"?(t.sdk.import({module:"@angular/core",name:"Injectable"}),X(n)||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"}),n.plugins["@hey-api/sdk"]?.config.response==="response"&&t.sdk.import({asType:true,module:"./core/ApiResult",name:"ApiResult"}),X(n)){let p=E(n);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=E(n),p=i.constVariable({exportConst:true,expression:i.callExpression({functionName:"createClient",parameters:[i.callExpression({functionName:"createConfig",parameters:["throwOnError"in a&&a.throwOnError?i.objectExpression({obj:[{key:"throwOnError",value:true}]}):void 0]})]}),name:"client"});t.sdk.add(p);}for(let a of e.services)Qg({client:e,onClientImport:p=>{t.sdk.import({module:pr({config:n,sourceOutput:s}),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 fm=({plugin:e})=>{let t=ft(e.context.config),n=E(e.context.config).name==="@hey-api/client-nuxt",o=e.registerSymbol({external:t,meta:{kind:"type"},name:"TDataShape"}),s=e.registerSymbol({external:t,meta:{kind:"type"},name:"Client",selector:e.api.getSelector("Client")}),a=e.registerSymbol({external:t,meta:{kind:"type"},name:"Options"}),p=e.registerSymbol({exported:true,meta:{kind:"type"},name:"Options",selector:e.api.getSelector("Options")}),c=i.typeAliasDeclaration({exportType:p.exported,name:p.placeholder,type:i.typeIntersectionNode({types:[i.typeReferenceNode({typeArguments:n?[i.typeReferenceNode({typeName:"TComposable"}),i.typeReferenceNode({typeName:"TData"}),i.typeReferenceNode({typeName:xi}),i.typeReferenceNode({typeName:lt})]:[i.typeReferenceNode({typeName:"TData"}),i.typeReferenceNode({typeName:"ThrowOnError"})],typeName:a.placeholder}),i.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:!e.config.client,name:"client",type:i.typeReferenceNode({typeName:s.placeholder})},{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:i.typeReferenceNode({typeArguments:[i.keywordTypeNode({keyword:"string"}),i.keywordTypeNode({keyword:"unknown"})],typeName:"Record"})}],useLegacyResolution:false})]}),typeParameters:n?[i.typeParameterDeclaration({constraint:i.typeReferenceNode({typeName:e.referenceSymbol(e.api.getSelector("Composable")).placeholder}),defaultType:i.typeNode("'$fetch'"),name:"TComposable"}),i.typeParameterDeclaration({constraint:i.typeReferenceNode({typeName:o.placeholder}),defaultType:i.typeReferenceNode({typeName:o.placeholder}),name:"TData"}),i.typeParameterDeclaration({defaultType:i.keywordTypeNode({keyword:"unknown"}),name:xi}),i.typeParameterDeclaration({defaultType:i.keywordTypeNode({keyword:"undefined"}),name:lt})]:[i.typeParameterDeclaration({constraint:i.typeReferenceNode({typeName:o.placeholder}),defaultType:i.typeReferenceNode({typeName:o.placeholder}),name:"TData"}),i.typeParameterDeclaration({constraint:i.keywordTypeNode({keyword:"boolean"}),defaultType:i.keywordTypeNode({keyword:"boolean"}),name:"ThrowOnError"})]});e.setSymbolValue(p,c);};var Ug=({plugin:e})=>{let t=i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:i.this(),name:"_client"}),operator:"=",right:i.propertyAccessExpression({expression:i.identifier({text:"args"}),name:"client"})})}),r=e.referenceSymbol(e.api.getSelector("Client")),n=E(e.context.config),o=n.api&&"getSelector"in n.api?e.getSymbol(n.api.getSelector("client")):void 0;return [i.propertyDeclaration({initializer:o?i.identifier({text:o.placeholder}):void 0,modifier:"protected",name:"_client",type:i.typeReferenceNode({typeName:r.placeholder})}),i.identifier({text:`
|
|
43
43
|
`}),i.constructorDeclaration({multiLine:true,parameters:[{isRequired:!e.config.client,name:"args",type:i.typeInterfaceNode({properties:[{isRequired:!e.config.client,name:"client",type:r.placeholder}],useLegacyResolution:false})}],statements:[e.config.client?i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"args"}),isOptional:true,name:"client"}),thenStatement:i.block({statements:[t]})}):t]})]},Zg=({plugin:e})=>{let t=E(e.context.config),r=t.name==="@hey-api/client-angular",n=t.name==="@hey-api/client-nuxt",o=new Map,s=new Set,a=e.config.instance?Ug({plugin:e}):[];e.forEach("operation",({operation:m})=>{let l=ae({context:e.context,operation:m}),f=e.getPluginOrThrow("@hey-api/typescript"),u=n?e.getSymbol(f.api.getSelector("response",m.id)):void 0,d=We({context:e.context,operation:m,plugin:e});for(let y of d.values())y.path.forEach((h,x)=>{let b=e.referenceSymbol(e.api.getSelector("class",h));o.has(b.id)||o.set(b.id,{className:h,classes:new Set,id:b.id,methods:new Set,nodes:[],root:!x});let k=y.path[x-1];if(k){let M=e.referenceSymbol(e.api.getSelector("class",k));if(M.placeholder!==b.placeholder){let F=o.get(M.id);F.classes.add(b.id),o.set(M.id,F);}}if(!(y.path.length===x+1))return;let I=o.get(b.id);if(I.methods.has(y.methodName))return;let v=bi({isRequiredOptions:l,operation:m,plugin:e}),w=Si({isRequiredOptions:l,opParameters:v,operation:m,plugin:e}),V=i.methodDeclaration({accessLevel:"public",comment:G({operation:m}),isStatic:r?false:!e.config.instance,name:y.methodName,parameters:v.parameters,returnType:void 0,statements:w,types:n?[{default:i.ots.string("$fetch"),extends:i.typeNode(e.referenceSymbol(e.api.getSelector("Composable")).placeholder),name:Fr},{default:u?i.typeReferenceNode({typeName:u.placeholder}):i.typeNode("undefined"),extends:u?i.typeReferenceNode({typeName:u.placeholder}):void 0,name:lt}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]});I.nodes.length?I.nodes.push(i.identifier({text:`
|
|
44
|
-
`}),V):I.nodes.push(V),I.methods.add(y.methodName),o.set(b.id,I);});});let p=e.registerSymbol({exported:false,name:"_HeyApiClient"}),c=m=>{if(s.has(m.id))return;if(m.classes.size)for(let u of m.classes){let d=o.get(u);c(d),m.nodes.push(i.propertyDeclaration({initializer:e.config.instance?i.newExpression({argumentsArray:e.config.instance?[i.objectExpression({multiLine:false,obj:[{key:"client",value:i.propertyAccessExpression({expression:i.this(),name:"_client"})}]})]:[],expression:i.identifier({text:e.referenceSymbol(d.id).placeholder})}):i.identifier({text:e.referenceSymbol(d.id).placeholder}),modifier:e.config.instance?void 0:"static",name:N({case:"camelCase",value:d.className})}));}let l=e.registerSymbol({exported:true,name:m.className,selector:e.api.getSelector("class",m.className)}),f=i.classDeclaration({decorator:m.root&&r?{args:[{providedIn:"root"}],name:e.referenceSymbol(e.api.getSelector("Injectable")).placeholder}:void 0,exportClass:l.exported,extendedClasses:e.config.instance?[p.placeholder]:void 0,name:l.placeholder,nodes:m.nodes});e.setSymbolValue(l,f),s.add(l.id);};if(a.length){let m=i.classDeclaration({exportClass:p.exported,name:p.placeholder,nodes:a});e.setSymbolValue(p,m);}for(let m of o.values())c(m);},Xg=({plugin:e})=>{let t=E(e.context.config),r=t.name==="@hey-api/client-nuxt";e.forEach("operation",({operation:n})=>{let o=ae({context:e.context,operation:n}),s=e.getPluginOrThrow("@hey-api/typescript"),a=r?e.getSymbol(s.api.getSelector("response",n.id)):void 0,p=bi({isRequiredOptions:o,operation:n,plugin:e}),c=Si({isRequiredOptions:o,opParameters:p,operation:n,plugin:e}),m=e.registerSymbol({name:ut({config:e.context.config,handleIllegal:true,id:n.id,operation:n}),selector:e.api.getSelector("function",n.id)}),l=i.constVariable({comment:G({operation:n}),exportConst:true,expression:i.arrowFunction({parameters:p.parameters,returnType:void 0,statements:c,types:r?[{default:i.ots.string("$fetch"),extends:i.typeNode(e.referenceSymbol(e.api.getSelector("Composable")).placeholder),name:Fr},{default:a?i.typeReferenceNode({typeName:a.placeholder}):i.typeNode("undefined"),extends:a?i.typeReferenceNode({typeName:a.placeholder}):void 0,name:lt}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]}),name:m.placeholder});e.setSymbolValue(m,l);});},um=({plugin:e})=>{let t=ft(e.context.config);e.registerSymbol({external:t,name:"formDataBodySerializer",selector:e.api.getSelector("formDataBodySerializer")}),e.registerSymbol({external:t,name:"urlSearchParamsBodySerializer",selector:e.api.getSelector("urlSearchParamsBodySerializer")}),e.registerSymbol({external:t,name:"buildClientParams",selector:e.api.getSelector("buildClientParams")});let r=E(e.context.config),n=r.name==="@hey-api/client-angular";r.name==="@hey-api/client-nuxt"&&e.registerSymbol({external:t,meta:{kind:"type"},name:"Composable",selector:e.api.getSelector("Composable")}),n&&e.config.asClass&&e.registerSymbol({external:"@angular/core",name:"Injectable",selector:e.api.getSelector("Injectable")}),fm({plugin:e}),e.config.asClass?Zg({plugin:e}):Xg({plugin:e});};var Go={api:new Xo({name:"@hey-api/sdk"}),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:um,handlerLegacy:lm,name:"@hey-api/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 Jo=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var dm=({dataExpression:e,schema:t})=>{if(t.type!=="integer"||t.format!=="int64")return;let r=e!==void 0?i.callExpression({functionName:"BigInt",parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:e,name:"toString"})})]}):void 0;if(r){if(typeof e=="string")return [r];if(e)return [i.assignment({left:e,right:r})]}},ym=({dataExpression:e,schema:t})=>{if(t.type!=="string"||!(t.format==="date"||t.format==="date-time"))return;let r=i.identifier({text:"Date"});if(typeof e=="string")return [i.newExpression({argumentsArray:[i.identifier({text:e})],expression:r})];if(e)return [i.assignment({left:e,right:i.newExpression({argumentsArray:[e],expression:r})})]};var Yo="data",hn=e=>e.map(t=>S__default.default.isStatement(t)?t:i.expressionToStatement({expression:t})),hm=({node:e})=>e.kind===S__default.default.SyntaxKind.ReturnStatement,xm=({plugin:e,schema:t})=>{let r=i.identifier({text:Yo}),n=xn({dataExpression:r,plugin:e,schema:t});return n.length&&!hm({node:n[n.length-1]})&&n.push(i.returnStatement({expression:r})),n},xn=({dataExpression:e,plugin:t,schema:r})=>{if(r.$ref){let n=t.api.getSelector("response-ref",r.$ref);if(!t.getSymbol(n)){let s=t.registerSymbol({name:R({config:{case:"camelCase",name:"{{name}}SchemaResponseTransformer"},name:H(r.$ref)}),selector:n}),a=t.context.resolveIrRef(r.$ref),p=xm({plugin:t,schema:a});if(p.length){let c=i.constVariable({expression:i.arrowFunction({async:false,multiLine:true,parameters:[{name:Yo,type:i.keywordTypeNode({keyword:"any"})}],statements:hn(p)}),name:s.placeholder});t.setSymbolValue(s,c);}else t.setSymbolValue(s,null);}let o=t.referenceSymbol(n);if(t.getSymbolValue(o)!==null){let s=i.callExpression({functionName:o.placeholder,parameters:[e]});if(e)return typeof e=="string"&&e==="item"?[i.returnStatement({expression:s})]:[typeof e=="string"?s:i.assignment({left:e,right:s})]}return []}if(r.type==="array"){if(!e||typeof e=="string")return [];let n=r.items?xn({dataExpression:"item",plugin:t,schema:r.items?.[0]?r.items[0]:{...r,type:void 0}}):[];if(!n.length)return [];let o=hn(n);return o.some(a=>hm({node:a}))||o.push(i.returnStatement({expression:i.identifier({text:"item"})})),[i.assignment({left:e,right:i.callExpression({functionName:i.propertyAccessExpression({expression:e,name:"map"}),parameters:[i.arrowFunction({multiLine:true,parameters:[{name:"item",type:"any"}],statements:o})]})})]}if(r.type==="object"){let n=[],o=r.required??[];for(let s in r.properties){let a=r.properties[s],p=i.propertyAccessExpression({expression:e||Yo,name:s}),c=xn({dataExpression:p,plugin:t,schema:a});if(!c.length)continue;let m=!a.items?.find(f=>f.type==="null");o.includes(s)&&m?n=n.concat(c):n.push(i.ifStatement({expression:p,thenStatement:i.block({statements:hn(c)})}));}return n}if(r.items){if(r.items.length===1)return xn({dataExpression:"item",plugin:t,schema:r.items[0]});let n=[];if(r.logicalOperator==="and"||r.items.length===2&&r.items.find(o=>o.type==="null"||o.type==="void")){for(let o of r.items){let s=xn({dataExpression:e||"item",plugin:t,schema:o});if(s.length)if(e)n=n.concat(s);else {let a=i.identifier({text:"item"});n.push(i.ifStatement({expression:a,thenStatement:i.block({statements:hn(s)})}),i.returnStatement({expression:a}));}}return n}r.type!=="enum"&&((r.items??[]).every(o=>["boolean","integer","null","number","string"].includes(o.type))||console.warn(`\u2757\uFE0F Transformers warning: schema ${JSON.stringify(r)} is too complex and won't be currently processed. This will likely produce an incomplete transformer which is not what you want. Please open an issue if you'd like this improved https://github.com/hey-api/openapi-ts/issues`));}for(let n of t.config.transformers){let o=n({config:t.config,dataExpression:e,schema:r});if(o)return o}return []},bm=({plugin:e})=>{e.forEach("operation",({operation:t})=>{let{response:r}=tt(t);if(!r)return;if(r.items&&r.items.length>1){e.context.config.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${B(t)} has ${r.items.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`);return}let n=e.getPluginOrThrow("@hey-api/typescript"),o=e.getSymbol(n.api.getSelector("response",t.id));if(!o)return;let s=e.registerSymbol({exported:true,name:R({config:{case:"camelCase",name:"{{name}}ResponseTransformer"},name:t.id}),selector:e.api.getSelector("response",t.id)}),a=xm({plugin:e,schema:r});if(a.length){let p=i.constVariable({exportConst:s.exported,expression:i.arrowFunction({async:true,multiLine:true,parameters:[{name:Yo,type:i.keywordTypeNode({keyword:"any"})}],returnType:i.typeReferenceNode({typeArguments:[i.typeReferenceNode({typeName:o.placeholder})],typeName:"Promise"}),statements:hn(a)}),name:s.placeholder});e.setSymbolValue(s,p);}else e.setSymbolValue(s,null);});};var Jg="$OpenApiTs",fe={$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:""},Yg=({comments:e,leadingComment:t,meta:r,obj:n,onNode:o,...s})=>{if(!r)return;let{created:a,name:p}=Me({create:true,meta:r,...s});if(a){let m=T().plugins["@hey-api/typescript"],l=i.enumDeclaration({asConst:typeof m?.config.enums=="object"&&m.config.enums.mode==="typescript-const",comments:e,leadingComment:t,name:p,obj:n});o(l);}},It=({comment:e,meta:t,onCreated:r,onNode:n,type:o,...s})=>{if(!t)return {created:false,name:""};let a=Me({create:true,meta:t,...s}),{created:p,name:c}=a;if(p){let m=i.typeAliasDeclaration({comment:e,exportType:true,name:c,type:o});n(m),r?.(c);}return a},eh=e=>{let t=[];Sm(e),e.model.enums.forEach(r=>rh({...e,model:r,onNode:n=>{t.push(n);}})),t.length&&e.onNode(i.namespaceDeclaration({name:e.model.name,statements:t}));},th=({client:e,model:t,onNode:r})=>{let n=T(),o={},s={};t.enum.forEach(c=>{let{key:m,value:l}=co(c);o[m]=l;let f=c.customDescription||c.description;f&&(s[m]=[z(f)]);});let a=[t.description&&z(t.description),t.deprecated&&"@deprecated"],p=n.plugins["@hey-api/typescript"];if(p?.config&&typeof p.config.enums=="object"&&p.config.enums.enabled&&(p.config.enums.mode==="typescript"||p.config.enums.mode==="typescript-const")){Yg({asConst:p.config.enums.mode==="typescript-const",client:e,comments:s,leadingComment:a,meta:t.meta,obj:o,onNode:r});return}It({client:e,comment:a,meta:t.meta,onCreated:c=>{let m=n.plugins["@hey-api/typescript"];if(m?.config&&typeof m.config.enums=="object"&&m.config.enums.enabled&&m.config.enums.mode==="javascript"){let l=i.objectExpression({multiLine:true,obj:Object.entries(o).map(([u,d])=>({comments:s[u],key:u,value:d})),unescape:true}),f=i.constVariable({assertion:"const",comment:a,exportConst:true,expression:l,name:c});r(f);}},onNode:r,type:yc(t.enum)});},rh=({model:e,onNode:t})=>{let r={},n={};e.enum.forEach(a=>{let{key:p,value:c}=co(a);r[p]=c;let m=a.customDescription||a.description;m&&(n[p]=[z(m)]);});let s=T().plugins["@hey-api/typescript"];t(i.enumDeclaration({asConst:typeof s?.config.enums=="object"&&s.config.enums.mode==="typescript-const",comments:n,leadingComment:[e.description&&z(e.description),e.deprecated&&"@deprecated"],name:e.meta?.name||e.name,obj:r}));},Sm=({client:e,model:t,onNode:r})=>{It({client:e,comment:[t.description&&z(t.description),t.deprecated&&"@deprecated"],meta:t.meta,onNode:r,type:$e(t)});},nh=e=>{switch(e.model.export){case "all-of":case "any-of":case "one-of":case "interface":return eh(e);case "enum":return th(e);default:return Sm(e)}},oh=({client:e,onNode:t})=>{let r={},n=T();if(!n.plugins["@hey-api/sdk"]&&!n.plugins["@hey-api/typescript"]?.config.tree)return;let o=W(n);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(f=>{m.res[f.code]=f;});}if(p.parameters.length>0){let f={mediaType:null,...fe,in:"body",name:"body",prop:"body"},u=p.parameters.filter(b=>b.in==="body");u.length||(u=p.parameters.filter(b=>b.in==="formData")),u.length===1?f={...fe,...u[0],in:"body",isRequired:u[0].isRequired,name:"body",prop:"body"}:u.length>1&&(f={...fe,in:"body",isRequired:u.some(b=>b.isRequired),mediaType:"multipart/form-data",name:"body",prop:"body",properties:u});let d={...fe,in:"header",isRequired:mt(p.parameters.filter(b=>b.in==="header")),mediaType:null,name:o?"header":"headers",prop:o?"header":"headers",properties:p.parameters.filter(b=>b.in==="header").sort(un)},y={...fe,in:"path",isRequired:mt(p.parameters.filter(b=>b.in==="path")),mediaType:null,name:"path",prop:"path",properties:p.parameters.filter(b=>b.in==="path").sort(un)},h={...fe,in:"query",isRequired:mt(p.parameters.filter(b=>b.in==="query")),mediaType:null,name:"query",prop:"query",properties:p.parameters.filter(b=>b.in==="query").sort(un)},x=o?dn([...p.parameters]):[f,d,y,h].filter(b=>b.properties.length||b.$refs.length||b.mediaType);m.req=x,It({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:mr,onNode:t,type:$e({...fe,properties:x})});}let l=p.responses.filter(f=>f.responseTypes.includes("success"));if(l.length>0){It({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:dt,onNode:t,type:$e({...fe,export:"any-of",properties:l})});let f=p.responses.filter(u=>u.responseTypes.includes("error"));o||It({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:Hr,onNode:t,type:$e(f.length?{...fe,export:"one-of",properties:f}:{...fe,base:"unknown"})});}}let s=Object.entries(r).map(([a,p])=>{let c=Object.entries(p).map(([l,f])=>{let u=l,d=[];if(f.req){let h=f.$ref,{name:x}=Me({client:e,meta:{$ref:h,name:h},nameTransformer:mr}),b={...fe,base:x,export:"reference",isRequired:true,name:"req",properties:[],type:x};d=[...d,b];}if(f.res){let h=Object.entries(f.res).map(([b,k])=>({...fe,...k,isRequired:true,name:String(b)})),x={...fe,isRequired:true,name:"res",properties:h};d=[...d,x];}return {...fe,isRequired:true,name:u.toLocaleLowerCase(),properties:d}}).filter(Boolean);return {...fe,isRequired:true,name:`'${a}'`,properties:c}});n.plugins["@hey-api/typescript"]?.config.tree&&It({client:e,meta:{$ref:"@hey-api/openapi-ts",name:Jg},onNode:t,type:$e({...fe,properties:s})});},Om=({client:e,files:t,plugin:r})=>{let n=T();t.types=new De({dir:n.output.path,exportFromIndex:r.config.exportFromIndex,id:"types",name:"types.ts"});let o=s=>{t.types?.add(s);};for(let s of e.models)nh({client:e,model:s,onNode:o});oh({client:e,onNode:o});};var _t="data",sh=e=>e.base==="unknown"&&e.export==="generic"&&e.type==="unknown",Rm=({client:e,model:t})=>t.$refs.map(n=>{let o=e.models.find(s=>s.meta?.$ref===n);if(!o)throw new Error(`Ref ${n} could not be found. Transformers cannot be generated without having access to all refs.`);return o}),Tm=e=>{let t=e.model.meta.name,{name:r}=It({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:mm,onCreated:o=>{let s=es({...e,meta:{$ref:`transformers/${t}`,name:o},path:[_t]});Pm({...e,async:false,name:o,statements:s});},type:`(${_t}: any) => ${t}`});return {created:!!e.client.types[r],name:r}},ih=e=>{let{model:t}=e,r=Rm(e);if(r.length===1){let{created:n,name:o}=Tm({...e,model:r[0]});return n?[i.transformArrayMutation({path:e.path,transformerName:o})]:[]}return yn(t)||t.link&&!Array.isArray(t.link)&&t.link.export==="any-of"&&t.link.properties.find(n=>yn(n))?[i.transformArrayMap({path:e.path,transformExpression:i.conditionalExpression({condition:i.identifier({text:"item"}),whenFalse:i.identifier({text:"item"}),whenTrue:i.transformNewDate({parameterName:"item"})})})]:[]},ah=e=>{let{model:t}=e,r=[...e.path,t.name];return t.type==="string"&&t.export!=="array"&&yn(t)?[i.transformDateMutation({path:r})]:es({...e,model:t,path:r})},es=e=>{let{model:t}=e;switch(t.export){case "array":return ih(e);case "interface":return t.properties.flatMap(r=>ah({...e,model:r}));case "reference":{if(t.$refs.length!==1)return [];let r=Rm(e),{created:n,name:o}=Tm({...e,model:r[0]});return n?t.in==="response"?[i.expressionToStatement({expression:i.callExpression({functionName:o,parameters:[_t]})})]:i.transformFunctionMutation({path:e.path,transformerName:o}):[]}default:return []}},Pm=({async:e,client:t,name:r,onNode:n,onRemoveNode:o,statements:s})=>{let a={created:false,name:r};if(!s.length)return xc({client:t,name:r}),o?.(),a;let p=i.arrowFunction({async:e,multiLine:true,parameters:[{name:_t}],statements:[...s,i.returnVariable({expression:_t})]}),c=i.constVariable({exportConst:true,expression:p,name:r,typeName:r});return n(c),{created:true,name:r}},Am=({client:e,files:t})=>{let r=T(),n=s=>{t.types?.add(s);},o=()=>{t.types?.removeNode_LEGACY();};for(let s of e.services)for(let a of s.operations){let p=a.responses.filter(l=>l.responseTypes.includes("success"));if(!p.length)continue;let c=p.filter(l=>!sh(l));if(!c.length)continue;if(c.length>1){r.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${B(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=dt(a.name);It({client:e,meta:{$ref:`transformers/${m}`,name:m},nameTransformer:Ai,onCreated:l=>{let f=p.length>1?p.flatMap(u=>{let d=es({client:e,meta:{$ref:`transformers/${m}`,name:m},model:u,onNode:n,onRemoveNode:o,path:[_t]});return d.length?[i.ifStatement({expression:i.safeAccessExpression(["data"]),thenStatement:i.block({statements:d})})]:[]}):es({client:e,meta:{$ref:`transformers/${m}`,name:m},model:p[0],onNode:n,onRemoveNode:o,path:[_t]});Pm({async:true,client:e,name:l,onNode:n,onRemoveNode:o,statements:f});},onNode:n,type:`(${_t}: any) => Promise<${m}>`});}};var ts={api:new Jo({name:"@hey-api/transformers"}),config:{bigInt:true,dates:true,exportFromIndex:false,transformers:[],typeTransformers:[]},dependencies:["@hey-api/typescript"],handler:bm,handlerLegacy:Am,name:"@hey-api/transformers",resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,ym]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,dm]);},tags:["transformer"]};var Cm=({context:e,name:t})=>(oe.lastIndex=0,oe.test(t)?t.startsWith("-")?S__default.default.factory.createStringLiteral(t):S__default.default.factory.createNumericLiteral(t):N({case:e.config.output.case,value:t}));var Oe=({schema:e})=>{let t=[];return e.title&&t.push(z(e.title)),e.description&&t.push(z(e.description)),e.deprecated&&t.push("@deprecated"),t.length?t:void 0};var rs=i.keywordTypeNode({keyword:"string"}),mh=({server:e})=>{let t=it(e.url);return t.protocol&&t.host?i.literalTypeNode({literal:i.stringLiteral({text:e.url})}):i.templateLiteralType({value:[t.protocol||rs,"://",t.host||rs,t.port?`:${t.port}`:"",t.path||""]})},km=({plugin:e,servers:t,symbolClientOptions:r})=>{let n=E(e.context.config),o=t.map(p=>mh({server:p}));t.length?"strictBaseUrl"in n.config&&n.config.strictBaseUrl||o.push(i.typeIntersectionNode({types:[rs,S__default.default.factory.createTypeLiteralNode([])]})):o.push(rs);let s=i.typeInterfaceNode({properties:[{name:ge(e.context.config),type:i.typeUnionNode({types:o})}],useLegacyResolution:false}),a=i.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:s});e.setSymbolValue(r,a);};var lh=({plugin:e,schema:t})=>{let r=[];return {obj:(t.items??[]).map((o,s)=>{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=`${s}`,p&&(p=N({case:e.config.enums.case,stripLeadingSeparators:false,value:p}),oe.lastIndex=0,oe.test(p)&&e.config.enums.enabled&&(e.config.enums.mode==="typescript"||e.config.enums.mode==="typescript-const")&&(p=`_${p}`)),{comments:Oe({schema:o}),key:p,value:o.const}}),typeofItems:r}},Im=({plugin:e,schema:t,symbol:r,type:n})=>{if(t.type==="enum"&&e.config.enums.enabled){let s=lh({plugin:e,schema:t});if(e.config.enums.mode==="javascript"){e.config.enums.constantsIgnoreNull&&s.typeofItems.includes("object")&&(s.obj=s.obj.filter(m=>m.value!==null));let a=i.constVariable({assertion:"const",comment:Oe({schema:t}),exportConst:true,expression:i.objectExpression({multiLine:true,obj:s.obj}),name:r.placeholder}),p=i.typeOfExpression({text:r.placeholder}),c=i.typeAliasDeclaration({comment:Oe({schema:t}),exportType:true,name:r.placeholder,type:i.indexedAccessTypeNode({indexType:i.typeOperatorNode({operator:"keyof",type:p}),objectType:p})});e.setSymbolValue(r,[a,c]);return}else if((e.config.enums.mode==="typescript"||e.config.enums.mode==="typescript-const")&&!s.typeofItems.some(p=>p!=="number"&&p!=="string")){let p=i.enumDeclaration({asConst:e.config.enums.mode==="typescript-const",leadingComment:Oe({schema:t}),name:r.placeholder,obj:s.obj});e.setSymbolValue(r,p);return}}let o=i.typeAliasDeclaration({comment:Oe({schema:t}),exportType:r.exported,name:r.placeholder,type:n});e.setSymbolValue(r,o);};var Ci=({parameters:e})=>{let t={type:"object"};if(e){let r={},n=[];for(let o in e){let s=e[o];r[s.name]=J({detectFormat:false,schema:s.schema}),s.required&&n.push(s.name);}t.properties=r,n.length&&(t.required=n);}return t},fh=({operation:e,plugin:t})=>{let r={type:"object"},n=[];r.properties||(r.properties={}),e.body?(r.properties.body=e.body.schema,e.body.required&&n.push("body")):r.properties.body={type:"never"},e.parameters?.header&&(r.properties.headers=Ci({parameters:e.parameters.header}),r.properties.headers.required&&n.push("headers")),e.parameters?.path?(r.properties.path=Ci({parameters:e.parameters.path}),r.properties.path.required&&n.push("path")):r.properties.path={type:"never"},e.parameters?.query?(r.properties.query=Ci({parameters:e.parameters.query}),r.properties.query.required&&n.push("query")):r.properties.query={type:"never"},r.properties.url={const:e.path,type:"string"},n.push("url"),r.required=n;let o=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.requests,name:e.id}),selector:t.api.getSelector("data",e.id)}),s=ne({plugin:t,schema:r}),a=i.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:s});t.setSymbolValue(o,a);},vm=({operation:e,plugin:t})=>{fh({operation:e,plugin:t});let{error:r,errors:n,response:o,responses:s}=tt(e);if(n){let a=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.errors,name:e.id}),selector:t.api.getSelector("errors",e.id)}),p=ne({plugin:t,schema:n}),c=i.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:p});if(t.setSymbolValue(a,c),r){let m=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),selector:t.api.getSelector("error",e.id)}),l=i.indexedAccessTypeNode({indexType:i.typeOperatorNode({operator:"keyof",type:i.typeReferenceNode({typeName:a.placeholder})}),objectType:i.typeReferenceNode({typeName:a.placeholder})}),f=i.typeAliasDeclaration({exportType:m.exported,name:m.placeholder,type:l});t.setSymbolValue(m,f);}}if(s){let a=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.responses,name:e.id}),selector:t.api.getSelector("responses",e.id)}),p=ne({plugin:t,schema:s}),c=i.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:p});if(t.setSymbolValue(a,c),o){let m=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),selector:t.api.getSelector("response",e.id)}),l=i.indexedAccessTypeNode({indexType:i.typeOperatorNode({operator:"keyof",type:i.typeReferenceNode({typeName:a.placeholder})}),objectType:i.typeReferenceNode({typeName:a.placeholder})}),f=i.typeAliasDeclaration({exportType:m.exported,name:m.placeholder,type:l});t.setSymbolValue(m,f);}}};var uh=({operation:e,plugin:t})=>{let r={type:"object"},n=[];if(r.properties||(r.properties={}),e.body){let p=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id}),selector:t.api.getSelector("webhook-payload",e.id)}),c=ne({plugin:t,schema:e.body.schema}),m=i.typeAliasDeclaration({comment:Oe({schema:e.body.schema}),exportType:p.exported,name:p.placeholder,type:c});t.setSymbolValue(p,m),t.registerSymbol({exported:true,meta:{kind:"type"},name:p.name,placeholder:p.placeholder,selector:t.api.getSelector("ref",p.placeholder)}),r.properties.body={$ref:p.placeholder},n.push("body");}else r.properties.body={type:"never"};r.properties.key={const:e.path,type:"string"},n.push("key"),r.properties.path={type:"never"},r.properties.query={type:"never"},r.required=n;let o=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.webhooks,name:e.id}),selector:t.api.getSelector("webhook-request",e.id)}),s=ne({plugin:t,schema:r}),a=i.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:s});return t.setSymbolValue(o,a),o.placeholder},jm=({operation:e,plugin:t})=>uh({operation:e,plugin:t});var Nm=({plugin:e,symbolWebhooks:t,webhookNames:r})=>{if(!r.length)return;let n=i.typeUnionNode({types:r.map(s=>i.typeReferenceNode({typeName:s}))}),o=i.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:n});e.setSymbolValue(t,o);};var dh=({plugin:e,schema:t})=>{if(!t.items)return i.typeArrayNode(i.keywordTypeNode({keyword:e.config.topType}));t=J({detectFormat:true,schema:t});let r=[];for(let n of t.items){let o=ne({plugin:e,schema:n});r.push(o);}return r.length===1?i.typeArrayNode(r[0]):t.logicalOperator==="and"?i.typeArrayNode(i.typeIntersectionNode({types:r})):i.typeArrayNode(i.typeUnionNode({types:r}))},yh=({schema:e})=>e.const!==void 0?i.literalTypeNode({literal:i.ots.boolean(e.const)}):i.keywordTypeNode({keyword:"boolean"}),gh=({plugin:e,schema:t})=>ne({plugin:e,schema:{...t,type:void 0}}),hh=({plugin:e,schema:t})=>t.const!==void 0?i.literalTypeNode({literal:i.ots.number(t.const)}):t.type==="integer"&&t.format==="int64"&&e.getPlugin("@hey-api/transformers")?.config.bigInt?i.typeReferenceNode({typeName:"bigint"}):i.keywordTypeNode({keyword:"number"}),xh=({plugin:e,schema:t})=>{let r,n,o=[],s=[],a=t.required??[],p=false;for(let u in t.properties){let d=t.properties[u],y=ne({plugin:e,schema:d}),h=a.includes(u);o.push({comment:Oe({schema:d}),isReadOnly:d.accessScope==="read",isRequired:h,name:Cm({context:e.context,name:u}),type:y}),s.push(d),h||(p=true);}if(t.patternProperties)for(let u in t.patternProperties){let d=t.patternProperties[u];s.unshift(d);}let c=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,m=t.additionalProperties,l=m!==false&&m?m:void 0;if(c||!!l&&(l.type!=="never"||!s.length)){let u=l;u&&u.type!=="never"?s.unshift(u):!c&&!s.length&&u&&u.type==="never"&&(s=[u]),p&&s.push({type:"undefined"}),n={isRequired:!t.propertyNames,name:"key",type:s.length===1?ne({plugin:e,schema:s[0]}):ne({plugin:e,schema:{items:s,logicalOperator:"or"}})},t.propertyNames?.$ref&&(r=ne({plugin:e,schema:{$ref:t.propertyNames.$ref}}));}return i.typeInterfaceNode({indexKey:r,indexProperty:n,properties:o,useLegacyResolution:false})},bh=({plugin:e,schema:t})=>{if(t.const!==void 0)return i.literalTypeNode({literal:i.stringLiteral({text:t.const})});if(t.format){if(t.format==="binary")return i.typeUnionNode({types:[i.typeReferenceNode({typeName:"Blob"}),i.typeReferenceNode({typeName:"File"})]});if((t.format==="date-time"||t.format==="date")&&e.getPlugin("@hey-api/transformers")?.config.dates)return i.typeReferenceNode({typeName:"Date"});if(t.format==="typeid"&&typeof t.example=="string"){let r=String(t.example).split("_");r.pop();let n=r.join("_"),o=e.api.getSelector("TypeID",n);if(!e.getSymbol(o)){let a=e.api.getSelector("TypeID");if(!e.getSymbol(a)){let l=e.registerSymbol({exported:true,meta:{kind:"type"},name:"TypeID",selector:a}),f=i.typeAliasDeclaration({exportType:l.exported,name:l.placeholder,type:i.templateLiteralType({value:[i.typeReferenceNode({typeName:"T"}),"_",i.keywordTypeNode({keyword:"string"})]}),typeParameters:[i.typeParameterDeclaration({constraint:i.keywordTypeNode({keyword:"string"}),name:"T"})]});e.setSymbolValue(l,f);}let p=e.referenceSymbol(a),c=e.registerSymbol({exported:true,meta:{kind:"type"},name:N({case:e.config.case,value:`${n}_id`}),selector:o}),m=i.typeAliasDeclaration({exportType:c.exported,name:c.placeholder,type:i.typeReferenceNode({typeArguments:[i.literalTypeNode({literal:i.stringLiteral({text:n})})],typeName:p.placeholder})});e.setSymbolValue(c,m);}let s=e.referenceSymbol(o);return i.typeReferenceNode({typeName:s.placeholder})}}return i.keywordTypeNode({keyword:"string"})},Sh=({plugin:e,schema:t})=>{let r=[];if(t.const&&Array.isArray(t.const))r=t.const.map(n=>i.valueToExpression({value:n})??i.identifier({text:e.config.topType}));else if(t.items)for(let n of t.items){let o=ne({plugin:e,schema:n});r.push(o);}return i.typeTupleNode({types:r})},wm=({plugin:e,schema:t})=>{let r=e.getPlugin("@hey-api/transformers");if(r?.config.typeTransformers)for(let n of r.config.typeTransformers){let o=n({schema:t});if(o)return o}switch(t.type){case "array":return dh({plugin:e,schema:t});case "boolean":return yh({schema:t});case "enum":return gh({plugin:e,schema:t});case "integer":case "number":return hh({plugin:e,schema:t});case "never":return i.keywordTypeNode({keyword:"never"});case "null":return i.literalTypeNode({literal:i.null()});case "object":return xh({plugin:e,schema:t});case "string":return bh({plugin:e,schema:t});case "tuple":return Sh({plugin:e,schema:t});case "undefined":return i.keywordTypeNode({keyword:"undefined"});case "unknown":return i.keywordTypeNode({keyword:e.config.topType});case "void":return i.keywordTypeNode({keyword:"void"})}},ne=({plugin:e,schema:t})=>{if(t.$ref){let r=e.referenceSymbol(e.api.getSelector("ref",t.$ref));return i.typeReferenceNode({typeName:r.placeholder})}if(t.type)return wm({plugin:e,schema:t});if(t.items){if(t=J({detectFormat:false,schema:t}),t.items){let r=[];for(let n of t.items){let o=ne({plugin:e,schema:n});r.push(o);}return t.logicalOperator==="and"?i.typeIntersectionNode({types:r}):i.typeUnionNode({types:r})}return ne({plugin:e,schema:t})}return wm({plugin:e,schema:{type:"unknown"}})},ki=({id:e,plugin:t,schema:r})=>{let n=ne({plugin:t,schema:r}),o=r.type==="enum"&&t.config.enums.enabled,s=t.registerSymbol({exported:true,meta:{kind:o?void 0:"type"},name:R({config:t.config.definitions,name:H(e)}),selector:t.api.getSelector("ref",e)});Im({plugin:t,schema:r,symbol:s,type:n});},qm=({plugin:e})=>{let t=e.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:{case:e.config.case},name:"ClientOptions"}),selector:e.api.getSelector("ClientOptions")}),r=e.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:{case:e.config.case},name:"Webhooks"}),selector:e.api.getSelector("Webhooks")}),n=[],o=[];e.forEach("operation","parameter","requestBody","schema","server","webhook",s=>{switch(s.type){case "operation":vm({operation:s.operation,plugin:e});break;case "parameter":ki({id:s.$ref,plugin:e,schema:s.parameter.schema});break;case "requestBody":ki({id:s.$ref,plugin:e,schema:s.requestBody.schema});break;case "schema":ki({id:s.$ref,plugin:e,schema:s.schema});break;case "server":n.push(s.server);break;case "webhook":o.push(jm({operation:s.operation,plugin:e}));break}}),km({plugin:e,servers:n,symbolClientOptions:t}),Nm({plugin:e,symbolWebhooks:r,webhookNames:o});};var ns=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}schemaToType(t){return ne(t)}};var os={api:new ns({name:"@hey-api/typescript"}),config:{case:"PascalCase",exportFromIndex:true,style:"preserve",topType:"unknown",tree:false},handler:qm,handlerLegacy:Om,name:"@hey-api/typescript",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}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}WebhookRequest",payload:"{{name}}WebhookPayload"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.webhooks});}};var ss=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var is=(e,t,r)=>{let n=e.config[r].meta;if(!n)return;let o=n(t);if(Object.keys(o).length)return i.valueToExpression({value:o})};var _r=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/sdk");return gn({operation:e,plugin:r})},$m=({operation:e,plugin:t})=>{let r=E(t.context.config),n=t.getPluginOrThrow("@hey-api/typescript"),s=t.getSymbol(n.api.getSelector("error",e.id))?.placeholder;return s||(s="Error"),r.name==="@hey-api/client-axios"&&(s=`${t.referenceSymbol(t.api.getSelector("AxiosError")).placeholder}<${s}>`),s},Mm=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/typescript");return t.getSymbol(r.api.getSelector("response",e.id))?.placeholder||"unknown"};var Wr=({plugin:e,typeData:t})=>{let n=E(e.context.config).name==="@hey-api/client-nuxt",o=n?`Omit<${t}, 'composable'>`:t;return {isNuxtClient:n,strippedTypeData:o}};var Dm=({operation:e,plugin:t,queryFn:r})=>{let n=t.referenceSymbol(t.api.getSelector("UseMutationOptions")),o=_r({operation:e,plugin:t}),s=$m({operation:e,plugin:t}),a=Mm({operation:e,plugin:t}),{isNuxtClient:p,strippedTypeData:c}=Wr({plugin:t,typeData:o}),m=p?`${n.placeholder}<${a}, ${c}, ${s}>`:`${n.placeholder}<${a}, ${o}, ${s}>`,l="fnOptions",f=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:l},{key:"throwOnError",value:true}]})]})}),u=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?u.push(i.returnVariable({expression:f})):u.push(i.constVariable({destructure:true,expression:f,name:"data"}),i.returnVariable({expression:"data"}));let d=[{key:"mutation",value:i.arrowFunction({async:true,multiLine:true,parameters:[p?{name:l,type:`Partial<${c}>`}:{name:l}],statements:u})}],y=is(t,e,"mutationOptions");y&&d.push({key:"meta",value:y});let h=t.registerSymbol({exported:true,name:R({config:t.config.mutationOptions,name:e.id})}),x=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:h.exported,expression:i.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${c}>`}],returnType:m,statements:[i.returnStatement({expression:i.objectExpression({obj:d})})]}),name:h.placeholder});t.setSymbolValue(h.id,x);};var bn="TOptions",Ii=i.identifier({text:"options"}),Lm=({plugin:e})=>{let t=e.registerSymbol({name:R({config:{case:e.config.case},name:"createQueryKey"}),selector:e.api.getSelector("createQueryKey")}),r=e.referenceSymbol(e.api.getSelector("QueryKey")),n=e.referenceSymbol(e.api.getSelector("_JSONValue")),o=i.indexedAccessTypeNode({indexType:i.literalTypeNode({literal:i.ots.number(0)}),objectType:i.typeReferenceNode({typeArguments:[i.typeReferenceNode({typeName:bn})],typeName:r.placeholder})}),s=ge(e.context.config),a=e.getPluginOrThrow("@hey-api/sdk"),p=e.referenceSymbol(a.api.getSelector("Options")),c=E(e.context.config),m=c.api&&"getSelector"in c.api?e.getSymbol(c.api.getSelector("client")):void 0,l=ft(e.context.config),f=e.registerSymbol({external:l,name:"serializeQueryKeyValue"}),u=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"id",type:i.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:i.typeReferenceNode({typeName:bn})},{isRequired:false,name:"tags",type:i.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],returnType:i.typeTupleNode({types:[o]}),statements:[i.constVariable({assertion:o,expression:i.objectExpression({multiLine:false,obj:[{key:"_id",value:i.identifier({text:"id"})},{key:s,value:i.identifier({text:`options?.${s} || (options?.client ?? ${m?.placeholder}).getConfig().${s}`})}]}),name:"params",typeName:o}),i.ifStatement({expression:i.identifier({text:"tags"}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"tags"}),right:i.asExpression({expression:i.asExpression({expression:i.identifier({text:"tags"}),type:i.keywordTypeNode({keyword:"unknown"})}),type:i.typeReferenceNode({typeName:n.placeholder})})})})]})}),i.ifStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:Ii,isOptional:true,name:i.identifier({text:"body"})}),operator:"!==",right:"undefined"}),thenStatement:i.block({statements:[i.constVariable({expression:i.callExpression({functionName:f.placeholder,parameters:[i.propertyAccessExpression({expression:"options",name:"body"})]}),name:"normalizedBody"}),i.ifStatement({expression:i.binaryExpression({left:i.identifier({text:"normalizedBody"}),operator:"!==",right:"undefined"}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"body"}),right:i.identifier({text:"normalizedBody"})})})]})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:Ii,isOptional:true,name:i.identifier({text:"path"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"path"}),right:i.propertyAccessExpression({expression:"options",name:"path"})})})]})}),i.ifStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:Ii,isOptional:true,name:i.identifier({text:"query"})}),operator:"!==",right:"undefined"}),thenStatement:i.block({statements:[i.constVariable({expression:i.callExpression({functionName:f.placeholder,parameters:[i.propertyAccessExpression({expression:"options",name:"query"})]}),name:"normalizedQuery"}),i.ifStatement({expression:i.binaryExpression({left:i.identifier({text:"normalizedQuery"}),operator:"!==",right:"undefined"}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"query"}),right:i.identifier({text:"normalizedQuery"})})})]})})]})}),i.returnStatement({expression:i.arrayLiteralExpression({elements:[i.identifier({text:"params"})]})})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:p.placeholder})}),name:bn}]}),name:t.placeholder});e.setSymbolValue(t,u);},Rh=({id:e,operation:t,plugin:r})=>{let n=r.config.queryKeys,o;n.tags&&t.tags&&t.tags.length>0&&(o=i.arrayLiteralExpression({elements:t.tags.map(p=>i.stringLiteral({text:p}))}));let s=r.referenceSymbol(r.api.getSelector("createQueryKey"));return i.callExpression({functionName:s.placeholder,parameters:[i.ots.string(e),"options",o]})},Fm=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("_JSONValue")),r=[{name:"_id",type:i.keywordTypeNode({keyword:"string"})},{isRequired:false,name:ge(e.context.config),type:i.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"body",type:i.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"query",type:i.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"tags",type:i.typeReferenceNode({typeName:t.placeholder})}],n=e.getPluginOrThrow("@hey-api/sdk"),o=e.referenceSymbol(n.api.getSelector("Options")),s=e.registerSymbol({exported:true,meta:{kind:"type"},name:"QueryKey",selector:e.api.getSelector("QueryKey")}),a=i.typeAliasDeclaration({exportType:s.exported,name:s.placeholder,type:i.typeTupleNode({types:[i.typeIntersectionNode({types:[i.typeReferenceNode({typeName:`Pick<${bn}, 'path'>`}),i.typeInterfaceNode({properties:r,useLegacyResolution:true})]})]}),typeParameters:[{extends:i.typeReferenceNode({typeName:i.identifier({text:o.placeholder})}),name:bn}]});e.setSymbolValue(s,a);},Bm=({operation:e,plugin:t,symbol:r})=>{let n=_r({operation:e,plugin:t}),{strippedTypeData:o}=Wr({plugin:t,typeData:n});return i.constVariable({exportConst:r.exported,expression:i.arrowFunction({parameters:[{isRequired:Pr(e),name:"options",type:o}],statements:Rh({id:e.id,operation:e,plugin:t})}),name:r.placeholder})};var as="options",Vm="context",Hm=({operation:e,plugin:t,queryFn:r})=>{if(Br({operation:e}))return;let n=ae({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(Fm({plugin:t}),Lm({plugin:t}));let o;if(t.config.queryKeys.enabled){let y=t.registerSymbol({exported:true,name:R({config:t.config.queryKeys,name:e.id})}),h=Bm({operation:e,plugin:t,symbol:y});t.setSymbolValue(y,h),o=i.callExpression({functionName:y.placeholder,parameters:[as]});}else {let y=t.referenceSymbol(t.api.getSelector("createQueryKey")),h;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(h=i.arrayLiteralExpression({elements:e.tags.map(x=>i.stringLiteral({text:x}))})),o=i.callExpression({functionName:y.placeholder,parameters:[i.ots.string(e.id),as,h]});}let s=_r({operation:e,plugin:t}),{strippedTypeData:a}=Wr({plugin:t,typeData:s}),p=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:as},{spread:Vm},{key:"throwOnError",value:true}]})]})}),c=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?c.push(i.returnVariable({expression:p})):c.push(i.constVariable({destructure:true,expression:p,name:"data"}),i.returnVariable({expression:"data"}));let m=[{key:"key",value:o},{key:"query",value:i.arrowFunction({async:true,multiLine:true,parameters:[{name:Vm}],statements:c})}],l=is(t,e,"queryOptions");l&&m.push({key:"meta",value:l});let f=t.registerSymbol({exported:true,name:R({config:t.config.queryOptions,name:e.id}),selector:t.api.getSelector("queryOptionsFn",e.id)}),u=t.registerSymbol({external:t.name,name:"defineQueryOptions",selector:t.api.getSelector("defineQueryOptions")}),d=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:f.exported,expression:i.callExpression({functionName:u.placeholder,parameters:[i.arrowFunction({parameters:[{isRequired:n,name:as,type:a}],statements:i.objectExpression({obj:m})})]}),name:f.placeholder});t.setSymbolValue(f,d);};var _m=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:"type"},name:"UseMutationOptions",selector:e.api.getSelector("UseMutationOptions")}),e.registerSymbol({external:e.name,meta:{kind:"type"},name:"UseQueryOptions",selector:e.api.getSelector("UseQueryOptions")}),e.registerSymbol({external:e.name,meta:{kind:"type"},name:"_JSONValue",selector:e.api.getSelector("_JSONValue")}),e.registerSymbol({external:"axios",meta:{kind:"type"},name:"AxiosError",selector:e.api.getSelector("AxiosError")});let t=e.getPluginOrThrow("@hey-api/sdk");e.forEach("operation",({operation:r})=>{let n=t.config.asClass?We({context:e.context,operation:r,plugin:t}):void 0,o=n?n.values().next().value:void 0,s=o?[e.referenceSymbol(t.api.getSelector("class",o.path[0])).placeholder,...o.path.slice(1).map(a=>N({case:"camelCase",value:a})),o.methodName].filter(Boolean).join("."):e.referenceSymbol(t.api.getSelector("function",r.id)).placeholder;e.hooks.operation.isQuery(r)&&e.config.queryOptions.enabled&&Hm({operation:r,plugin:e,queryFn:s}),e.hooks.operation.isMutation(r)&&e.config.mutationOptions.enabled&&Dm({operation:r,plugin:e,queryFn:s});});};var ps={api:new ss({name:"@pinia/colada"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/typescript","@hey-api/sdk"],handler:_m,name:"@pinia/colada",resolveConfig:(e,t)=>{e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,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,name:"{{name}}Query"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Kr=(e,t,r)=>{let n=e.config[r].meta;if(!n)return;let o=n(t);if(Object.keys(o).length)return i.valueToExpression({value:o})};var yt=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/sdk");return gn({operation:e,plugin:r})},cs=({operation:e,plugin:t})=>{let r=E(t.context.config),n=t.getPluginOrThrow("@hey-api/typescript"),s=t.getSymbol(n.api.getSelector("error",e.id))?.placeholder;return s||(s=t.referenceSymbol(t.api.getSelector("DefaultError")).placeholder),r.name==="@hey-api/client-axios"&&(s=`${t.referenceSymbol(t.api.getSelector("AxiosError")).placeholder}<${s}>`),s},ms=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/typescript");return t.getSymbol(r.api.getSelector("response",e.id))?.placeholder||"unknown"};var Sn="TOptions",Wm=i.identifier({text:"infinite"}),ls=i.identifier({text:"options"}),fs=({plugin:e})=>{let t=e.registerSymbol({name:R({config:{case:e.config.case},name:"createQueryKey"}),selector:e.api.getSelector("createQueryKey")}),r=e.referenceSymbol(e.api.getSelector("QueryKey")),n=i.indexedAccessTypeNode({indexType:i.literalTypeNode({literal:i.ots.number(0)}),objectType:i.typeReferenceNode({typeArguments:[i.typeReferenceNode({typeName:Sn})],typeName:r.placeholder})}),o=ge(e.context.config),s=E(e.context.config),a=s.api&&"getSelector"in s.api?e.getSymbol(s.api.getSelector("client")):void 0,p=e.getPluginOrThrow("@hey-api/sdk"),c=e.referenceSymbol(p.api.getSelector("Options")),m=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"id",type:i.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:i.typeReferenceNode({typeName:Sn})},{isRequired:false,name:"infinite",type:i.typeReferenceNode({typeName:"boolean"})},{isRequired:false,name:"tags",type:i.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],returnType:i.typeTupleNode({types:[n]}),statements:[i.constVariable({assertion:n,expression:i.objectExpression({multiLine:false,obj:[{key:"_id",value:i.identifier({text:"id"})},{key:o,value:i.identifier({text:`options?.${o} || (options?.client ?? ${a?.placeholder}).getConfig().${o}`})}]}),name:"params",typeName:n}),i.ifStatement({expression:Wm,thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"_infinite"}),right:Wm})})]})}),i.ifStatement({expression:i.identifier({text:"tags"}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"tags"}),right:i.identifier({text:"tags"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:ls,isOptional:true,name:i.identifier({text:"body"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"body"}),right:i.propertyAccessExpression({expression:"options",name:"body"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:ls,isOptional:true,name:i.identifier({text:"headers"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"headers"}),right:i.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:ls,isOptional:true,name:i.identifier({text:"path"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"path"}),right:i.propertyAccessExpression({expression:"options",name:"path"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:ls,isOptional:true,name:i.identifier({text:"query"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"query"}),right:i.propertyAccessExpression({expression:"options",name:"query"})})})]})}),i.returnStatement({expression:i.arrayLiteralExpression({elements:[i.identifier({text:"params"})]})})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:c.placeholder})}),name:Sn}]}),name:t.placeholder});e.setSymbolValue(t,m);},Ph=({id:e,isInfinite:t,operation:r,plugin:n})=>{let o=t?n.config.infiniteQueryKeys:n.config.queryKeys,s;o.tags&&r.tags&&r.tags.length>0&&(s=i.arrayLiteralExpression({elements:r.tags.map(c=>i.stringLiteral({text:c}))}));let a=n.referenceSymbol(n.api.getSelector("createQueryKey"));return i.callExpression({functionName:a.placeholder,parameters:[i.ots.string(e),"options",t||s?i.ots.boolean(!!t):void 0,s]})},us=({plugin:e})=>{let t=[{name:"_id",type:i.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:i.keywordTypeNode({keyword:"boolean"})},{isRequired:false,name:"tags",type:i.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],r=e.getPluginOrThrow("@hey-api/sdk"),n=e.referenceSymbol(r.api.getSelector("Options")),o=e.registerSymbol({exported:true,meta:{kind:"type"},name:"QueryKey",selector:e.api.getSelector("QueryKey")}),s=i.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:i.typeTupleNode({types:[i.typeIntersectionNode({types:[i.typeReferenceNode({typeName:`Pick<${Sn}, '${ge(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),i.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:i.typeReferenceNode({typeName:i.identifier({text:n.placeholder})}),name:Sn}]});e.setSymbolValue(o,s);},ds=({isInfinite:e,operation:t,plugin:r,symbol:n,typeQueryKey:o})=>{let s=yt({operation:t,plugin:r});return i.constVariable({exportConst:n.exported,expression:i.arrowFunction({parameters:[{isRequired:Pr(t),name:"options",type:s}],returnType:e?o:void 0,statements:Ph({id:t.id,isInfinite:e,operation:t,plugin:r})}),name:n.placeholder})};var Eh=({plugin:e})=>{let t=e.registerSymbol({name:R({config:{case:e.config.case},name:"createInfiniteParams"}),selector:e.api.getSelector("createInfiniteParams")}),r=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:i.typeReferenceNode({typeName:"QueryKey<Options>"})},{name:"page",type:i.typeReferenceNode({typeName:"K"})}],statements:[i.constVariable({expression:i.objectExpression({obj:[{spread:i.propertyAccessExpression({expression:"queryKey",name:0})}]}),name:"params"}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"body"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"body"}),right:i.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"headers"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"headers"}),right:i.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"path"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"path"}),right:i.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].path"},{assertion:"any",spread:"page.path"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"query"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"query"}),right:i.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].query"},{assertion:"any",spread:"page.query"}]})})})]})}),i.returnVariable({expression:i.asExpression({expression:i.asExpression({expression:i.identifier({text:"params"}),type:i.keywordTypeNode({keyword:"unknown"})}),type:S__default.default.factory.createTypeQueryNode(i.identifier({text:"page"}))})})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:"Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>"})}),name:"K"}]}),name:t.placeholder});e.setSymbolValue(t,r);},Km=({operation:e,plugin:t,queryFn:r})=>{let n=bp({context:t.context,operation:e});if(!n)return;let o=ae({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(us({plugin:t}),fs({plugin:t})),t.getSymbol(t.api.getSelector("createInfiniteParams"))||Eh({plugin:t});let s=t.referenceSymbol(t.api.getSelector("infiniteQueryOptions")),a=t.referenceSymbol(t.api.getSelector("InfiniteData")),p=yt({operation:e,plugin:t}),c=cs({operation:e,plugin:t}),m=ms({operation:e,plugin:t}),f=`${t.referenceSymbol(t.api.getSelector("QueryKey")).placeholder}<${p}>`,u=`Pick<${f}[0], 'body' | 'headers' | 'path' | 'query'>`,d=t.getPluginOrThrow("@hey-api/typescript"),y=d.api.schemaToType({plugin:d,schema:n.schema}),h=`${ue({node:y,unescape:true})} | ${u}`,x=t.registerSymbol({exported:true,name:R({config:t.config.infiniteQueryKeys,name:e.id})}),b=ds({isInfinite:true,operation:e,plugin:t,symbol:x,typeQueryKey:f});t.setSymbolValue(x,b);let k=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:i.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),P=t.referenceSymbol(t.api.getSelector("createInfiniteParams")),I=[i.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:i.conditionalExpression({condition:i.binaryExpression({left:i.typeOfExpression({text:"pageParam"}),operator:"===",right:i.ots.string("object")}),whenFalse:i.objectExpression({multiLine:true,obj:[{key:n.in,value:i.objectExpression({multiLine:true,obj:[{key:n.name,value:i.identifier({text:"pageParam"})}]})}]}),whenTrue:i.identifier({text:"pageParam"})}),name:"page",typeName:u}),i.constVariable({expression:i.callExpression({functionName:P.placeholder,parameters:["queryKey","page"]}),name:"params"})];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?I.push(i.returnVariable({expression:k})):I.push(i.constVariable({destructure:true,expression:k,name:"data"}),i.returnVariable({expression:"data"}));let v=[{key:"queryFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:I})},{key:"queryKey",value:i.callExpression({functionName:x.placeholder,parameters:["options"]})}],w=Kr(t,e,"infiniteQueryOptions");w&&v.push({key:"meta",value:w});let V=t.registerSymbol({exported:true,name:R({config:t.config.infiniteQueryOptions,name:e.id})}),M=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:V.exported,expression:i.arrowFunction({parameters:[{isRequired:o,name:"options",type:p}],statements:[i.returnFunctionCall({args:[i.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:v})],name:s.placeholder,types:[m,c||"unknown",`${a.placeholder}<${m}>`,f,h]})]}),name:V.placeholder});t.setSymbolValue(V,M);};var zm=({operation:e,plugin:t,queryFn:r})=>{let n=t.referenceSymbol(t.api.getSelector("MutationOptions")),o=yt({operation:e,plugin:t}),s=cs({operation:e,plugin:t}),a=ms({operation:e,plugin:t}),p=`${n.placeholder}<${a}, ${s}, ${o}>`,c="fnOptions",m=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:c},{key:"throwOnError",value:true}]})]})}),l=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?l.push(i.returnVariable({expression:m})):l.push(i.constVariable({destructure:true,expression:m,name:"data"}),i.returnVariable({expression:"data"}));let f=[{key:"mutationFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{name:c}],statements:l})}],u=Kr(t,e,"mutationOptions");u&&f.push({key:"meta",value:u});let d="mutationOptions",y=i.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${o}>`}],returnType:p,statements:[i.constVariable({expression:i.objectExpression({obj:f}),name:d,typeName:p}),i.returnVariable({expression:d})]}),h=t.registerSymbol({exported:true,name:R({config:t.config.mutationOptions,name:e.id})}),x=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:h.exported,expression:y,name:h.placeholder});t.setSymbolValue(h,x);};var vi="options",Qm=({operation:e,plugin:t,queryFn:r})=>{if(Br({operation:e}))return;let n=ae({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(us({plugin:t}),fs({plugin:t}));let o=t.referenceSymbol(t.api.getSelector("queryOptions")),s=t.registerSymbol({exported:true,name:R({config:t.config.queryKeys,name:e.id})}),a=ds({isInfinite:false,operation:e,plugin:t,symbol:s});t.setSymbolValue(s,a);let p=yt({operation:e,plugin:t}),c=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:vi},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:i.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),m=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?m.push(i.returnVariable({expression:c})):m.push(i.constVariable({destructure:true,expression:c,name:"data"}),i.returnVariable({expression:"data"}));let l=[{key:"queryFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:m})},{key:"queryKey",value:i.callExpression({functionName:s.placeholder,parameters:[vi]})}],f=Kr(t,e,"queryOptions");f&&l.push({key:"meta",value:f});let u=t.registerSymbol({exported:t.config.queryOptions.exported,name:R({config:t.config.queryOptions,name:e.id}),selector:t.api.getSelector("queryOptionsFn",e.id)}),d=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:u.exported,expression:i.arrowFunction({parameters:[{isRequired:n,name:vi,type:p}],statements:[i.returnFunctionCall({args:[i.objectExpression({obj:l})],name:o.placeholder})]}),name:u.placeholder});t.setSymbolValue(u,d);};var Um="options",Zm=({operation:e,plugin:t})=>{if(Br({operation:e})||!("useQuery"in t.config))return;let r=t.registerSymbol({exported:true,name:R({config:t.config.useQuery,name:e.id})}),n=t.referenceSymbol(t.api.getSelector("useQuery")),o=ae({context:t.context,operation:e}),s=yt({operation:e,plugin:t}),a=t.referenceSymbol(t.api.getSelector("queryOptionsFn",e.id)),p=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:r.exported,expression:i.arrowFunction({parameters:[{isRequired:o,name:Um,type:s}],statements:[i.returnStatement({expression:i.callExpression({functionName:n.placeholder,parameters:[i.callExpression({functionName:a.placeholder,parameters:[Um]})]})})]}),name:r.placeholder});t.setSymbolValue(r,p);};var gt=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:"type"},name:"DefaultError",selector:e.api.getSelector("DefaultError")}),e.registerSymbol({external:e.name,meta:{kind:"type"},name:"InfiniteData",selector:e.api.getSelector("InfiniteData")});let t=e.name==="@tanstack/angular-query-experimental"||e.name==="@tanstack/svelte-query"||e.name==="@tanstack/solid-query"?"MutationOptions":"UseMutationOptions";e.registerSymbol({external:e.name,meta:{kind:"type"},name:t,selector:e.api.getSelector("MutationOptions")}),e.registerSymbol({external:e.name,name:"infiniteQueryOptions",selector:e.api.getSelector("infiniteQueryOptions")}),e.registerSymbol({external:e.name,name:"queryOptions",selector:e.api.getSelector("queryOptions")}),e.registerSymbol({external:e.name,name:"useQuery",selector:e.api.getSelector("useQuery")}),e.registerSymbol({external:"axios",meta:{kind:"type"},name:"AxiosError",selector:e.api.getSelector("AxiosError")});let r=e.getPluginOrThrow("@hey-api/sdk");e.forEach("operation",({operation:n})=>{let o=r.config.asClass?We({context:e.context,operation:n,plugin:r}):void 0,s=o?o.values().next().value:void 0,a=s?[e.referenceSymbol(r.api.getSelector("class",s.path[0])).placeholder,...s.path.slice(1).map(p=>N({case:"camelCase",value:p})),s.methodName].filter(Boolean).join("."):e.referenceSymbol(r.api.getSelector("function",n.id)).placeholder;e.hooks.operation.isQuery(n)&&(e.config.queryOptions.enabled&&Qm({operation:n,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&Km({operation:n,plugin:e,queryFn:a}),"useQuery"in e.config&&e.config.useQuery.enabled&&Zm({operation:n,plugin:e})),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&zm({operation:n,plugin:e,queryFn:a});});};var Ch=e=>`${ut({config:T(),id:e.name,operation:e})}InfiniteOptions`,kh=e=>`${ut({config:T(),id:e.name,operation:e})}Mutation`,Ih=({config:e,id:t,operation:r})=>`${ut({config:e,id:t,operation:r})}Options`,ys=({config:e,id:t,isInfinite:r,operation:n})=>`${ut({config:e,id:t,operation:n})}${r?"Infinite":""}QueryKey`,vh=e=>{switch(e.in){case "formData":return "body";case "header":return "headers";default:return e.in}},jh="createInfiniteParams",ol="createQueryKey",Xm="infiniteQueryOptions",Gm="mutationOptions",Ni="QueryKey",Jm="queryOptions",Rn="TOptions",Nh=({file:e})=>{let t=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:i.typeNode("QueryKey<OptionsLegacyParser>")},{name:"page",type:i.typeNode("K")}],statements:[i.constVariable({expression:i.identifier({text:"queryKey[0]"}),name:"params"}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"body"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"body"}),right:i.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"headers"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"headers"}),right:i.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"path"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"path"}),right:i.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].path"},{spread:"page.path"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"query"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"query"}),right:i.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].query"},{spread:"page.query"}]})})})]})}),i.returnVariable({expression:S__default.default.factory.createAsExpression(S__default.default.factory.createAsExpression(i.identifier({text:"params"}),S__default.default.factory.createKeywordTypeNode(S__default.default.SyntaxKind.UnknownKeyword)),S__default.default.factory.createTypeQueryNode(i.identifier({text:"page"})))})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:"Pick<QueryKey<OptionsLegacyParser>[0], 'body' | 'headers' | 'path' | 'query'>"})}),name:"K"}]}),name:jh});e.add(t);},Ym=({file:e})=>{let t=i.indexedAccessTypeNode({indexType:i.typeNode(0),objectType:i.typeNode(Ni,[i.typeNode(Rn)])}),r=i.identifier({text:"infinite"}),n=ge(T()),o=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"id",type:i.typeNode("string")},{isRequired:false,name:"options",type:i.typeNode(Rn)},{isRequired:false,name:"infinite",type:i.typeNode("boolean")}],returnType:t,statements:[i.constVariable({assertion:t,expression:i.objectExpression({multiLine:false,obj:[{key:"_id",value:i.identifier({text:"id"})},{key:n,value:i.identifier({text:`options?.${n} || (options?.client ?? _heyApiClient).getConfig().${n}`})}]}),name:"params",typeName:t}),i.ifStatement({expression:r,thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"_infinite"}),right:r})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"options"}),isOptional:true,name:i.identifier({text:"body"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"body"}),right:i.propertyAccessExpression({expression:"options",name:"body"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"options"}),isOptional:true,name:i.identifier({text:"headers"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"headers"}),right:i.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"options"}),isOptional:true,name:i.identifier({text:"path"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"path"}),right:i.propertyAccessExpression({expression:"options",name:"path"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"options"}),isOptional:true,name:i.identifier({text:"query"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"query"}),right:i.propertyAccessExpression({expression:"options",name:"query"})})})]})}),i.returnVariable({expression:"params"})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:"OptionsLegacyParser"})}),name:Rn}]}),name:ol});e.add(o);},el=({file:e})=>{let t=[{name:"_id",type:i.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:i.keywordTypeNode({keyword:"boolean"})}],r=i.typeAliasDeclaration({name:Ni,type:i.typeTupleNode({types:[i.typeIntersectionNode({types:[i.typeReferenceNode({typeName:`Pick<${Rn}, '${ge(T())}' | 'body' | 'headers' | 'path' | 'query'>`}),i.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:i.typeReferenceNode({typeName:i.identifier({text:"OptionsLegacyParser"})}),name:Rn}]});e.add(r);},ji=({client:e,file:t,operation:r,typesModulePath:n})=>{let{name:o}=cr({client:e,meta:r.parameters.length?{$ref:r.name,name:r.name}:void 0,nameTransformer:mr,onImport:a=>{t.import({asType:true,module:n,name:a});}});return {typeData:Ei({importedType:o})}},tl=({client:e,file:t,operation:r,pluginName:n,typesModulePath:o})=>{let s=T(),{name:a}=cr({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Hr,onImport:m=>{t.import({asType:true,module:o,name:m});}}),p={asType:true,name:a};if(p.name||(p=t.import({asType:true,module:n,name:"DefaultError"})),E(s).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}},rl=({client:e,file:t,operation:r,typesModulePath:n})=>{let{name:o}=cr({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:dt,onImport:a=>{t.import({asType:true,module:n,name:a});}});return {typeResponse:o||"void"}},nl=({id:e,isInfinite:t})=>i.arrayLiteralExpression({elements:[i.callExpression({functionName:ol,parameters:[i.ots.string(e),"options",t?i.ots.boolean(true):void 0]})],multiLine:false}),ht=({client:e,files:t,plugin:r})=>{let n=T();if(W(n))throw new Error("TanStack Query plugin does not support legacy clients");let o=t[r.name];o.import({asType:true,module:pr({config:n,sourceOutput:r.output}),name:"OptionsLegacyParser"});let s=ur({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,l=false,f=false,u=false,d=new Map;for(let y of e.services)for(let h of y.operations){let x=B(h);if(d.has(x))continue;d.set(x,true);let b=[n.plugins["@hey-api/sdk"]?.config.asClass&&Bt({config:n,name:y.name}),ut({config:n,handleIllegal:!n.plugins["@hey-api/sdk"]?.config.asClass,id:h.name,operation:h})].filter(Boolean).join("."),k=false;if(r.config.queryOptions.enabled&&["GET","POST"].includes(h.method)){u||(u=true,m||(el({file:o}),Ym({file:o}),m=true),o.import({module:r.name,name:Jm})),k=true;let{typeData:P}=ji({client:e,file:o,operation:h,typesModulePath:s}),I=mt(h.parameters),v=i.constVariable({exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:I,name:"options",type:P}],statements:nl({id:h.name})}),name:ys({config:n,id:h.name,operation:h})});o.add(v);let w=i.constVariable({comment:[],exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:I,name:"options",type:P}],statements:[i.returnFunctionCall({args:[i.objectExpression({obj:[{key:"queryFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:[i.constVariable({destructure:true,expression:i.awaitExpression({expression:i.callExpression({functionName:b,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:i.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),i.returnVariable({expression:"data"})]})},{key:"queryKey",value:i.callExpression({functionName:ys({config:n,id:h.name,operation:h}),parameters:["options"]})}]})],name:Jm})]}),name:Ih({config:n,id:h.name,operation:h})});o.add(w);}if(r.config.infiniteQueryOptions&&["GET","POST"].includes(h.method)){let P,I=h.parameters.find(v=>{if(Ce(n.parser.pagination).test(v.name))return P=v,true;if(v.in==="body"){if(v.export==="reference"){let V=v.$refs[0];return e.models.find(F=>F.meta?.$ref===V)?.properties.find(F=>{if(Ce(n.parser.pagination).test(F.name))return P=F,true})}return v.properties.find(V=>{if(Ce(n.parser.pagination).test(V.name))return P=V,true})}});if(I&&P){l||(l=true,m||(el({file:o}),Ym({file:o}),m=true),c||(Nh({file:o}),c=true),o.import({module:r.name,name:Xm}),p=o.import({asType:true,module:r.name,name:"InfiniteData"})),k=true;let{typeData:v}=ji({client:e,file:o,operation:h,typesModulePath:s}),{typeError:w}=tl({client:e,file:o,operation:h,pluginName:r.name,typesModulePath:s}),{typeResponse:V}=rl({client:e,file:o,operation:h,typesModulePath:s}),M=mt(h.parameters),F=`${Ni}<${v}>`,wt=`Pick<${F}[0], 'body' | 'headers' | 'path' | 'query'>`,Qe=`${P.base} | ${wt}`,fr=i.constVariable({exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:M,name:"options",type:v}],returnType:F,statements:nl({id:h.name,isInfinite:true})}),name:ys({config:n,id:h.name,isInfinite:true,operation:h})});o.add(fr);let hu=i.constVariable({comment:[],exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:M,name:"options",type:v}],statements:[i.returnFunctionCall({args:[i.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:[{key:"queryFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:[i.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:i.conditionalExpression({condition:i.binaryExpression({left:i.typeOfExpression({text:"pageParam"}),operator:"===",right:i.ots.string("object")}),whenFalse:i.objectExpression({multiLine:true,obj:[{key:vh(I),value:i.objectExpression({multiLine:true,obj:[{key:P.name,value:i.identifier({text:"pageParam"})}]})}]}),whenTrue:i.identifier({text:"pageParam"})}),name:"page",typeName:wt}),i.constVariable({expression:i.callExpression({functionName:"createInfiniteParams",parameters:["queryKey","page"]}),name:"params"}),i.constVariable({destructure:true,expression:i.awaitExpression({expression:i.callExpression({functionName:b,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:i.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),i.returnVariable({expression:"data"})]})},{key:"queryKey",value:i.callExpression({functionName:ys({config:n,id:h.name,isInfinite:true,operation:h}),parameters:["options"]})}]})],name:Xm,types:[V,w.name,`${typeof p=="string"?p:p.name}<${V}>`,F,Qe]})]}),name:Ch(h)});o.add(hu);}}if(r.config.mutationOptions&&["DELETE","PATCH","POST","PUT"].includes(h.method)){f||(f=true,o.import({asType:true,module:r.name,name:a})),k=true;let{typeData:P}=ji({client:e,file:o,operation:h,typesModulePath:s}),{typeError:I}=tl({client:e,file:o,operation:h,pluginName:r.name,typesModulePath:s}),{typeResponse:v}=rl({client:e,file:o,operation:h,typesModulePath:s}),w="fnOptions",V=i.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${P}>`}],statements:[i.constVariable({expression:i.objectExpression({obj:[{key:"mutationFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{name:w}],statements:[i.constVariable({destructure:true,expression:i.awaitExpression({expression:i.callExpression({functionName:b,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:w},{key:"throwOnError",value:true}]})]})}),name:"data"}),i.returnVariable({expression:"data"})]})}]}),name:Gm,typeName:`${a}<${v}, ${I.name}, ${P}>`}),i.returnVariable({expression:Gm})]}),M=i.constVariable({comment:[],exportConst:true,expression:V,name:kh(h)});o.add(M);}(u||l)&&o.import({alias:"_heyApiClient",module:ur({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:r.output}),name:"client"}),k&&o.import({module:ur({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:r.output}),name:b.split(".")[0]});}};var gs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var hs={api:new gs({name:"@tanstack/angular-query-experimental"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:gt,handlerLegacy:ht,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,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,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,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var xs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var bs={api:new xs({name:"@tanstack/react-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:gt,handlerLegacy:ht,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,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,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,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions}),e.config.useQuery=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:false,name:"use{{name}}Query"},mappers:{boolean:r=>({enabled:r}),function:r=>({enabled:true,name:r}),object:r=>({enabled:true,...r}),string:r=>({enabled:true,name:r})},value:e.config.useQuery}),e.config.useQuery.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=true,e.config.queryOptions.exported=false));}};var Ss=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Os={api:new Ss({name:"@tanstack/solid-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:gt,handlerLegacy:ht,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,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,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,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Rs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Ts={api:new Rs({name:"@tanstack/svelte-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:gt,handlerLegacy:ht,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,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,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,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Ps=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var As={api:new Ps({name:"@tanstack/vue-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:gt,handlerLegacy:ht,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,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,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,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Es=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Lh=({operation:e,plugin:t})=>{let r=[],n=t.getPluginOrThrow("@hey-api/typescript"),o=t.getSymbol(n.api.getSelector("data",e.id));o&&(e.body&&r.push({isRequired:e.body.required,name:"Body",type:`${o.placeholder}['body']`}),e.parameters&&(e.parameters.header&&r.push({isRequired:$t(e.parameters.header),name:"Headers",type:`${o.placeholder}['headers']`}),e.parameters.path&&r.push({isRequired:$t(e.parameters.path),name:"Params",type:`${o.placeholder}['path']`}),e.parameters.query&&r.push({isRequired:$t(e.parameters.query),name:"Querystring",type:`${o.placeholder}['query']`})));let{errors:s,responses:a}=tt(e),p,c=t.getSymbol(n.api.getSelector("errors",e.id));if(c&&s&&s.properties){let y=Object.keys(s.properties);if(y.length){if(!y.includes("default"))p=i.typeReferenceNode({typeName:c.placeholder});else if(y.length>1){let x=i.typeReferenceNode({typeName:c.placeholder}),b=i.literalTypeNode({literal:i.stringLiteral({text:"default"})});p=i.typeReferenceNode({typeArguments:[x,b],typeName:"Omit"});}}}let m,l=t.getSymbol(n.api.getSelector("responses",e.id));if(l&&a&&a.properties){let y=Object.keys(a.properties);if(y.length){if(!y.includes("default"))m=i.typeReferenceNode({typeName:l.placeholder});else if(y.length>1){let x=i.typeReferenceNode({typeName:l.placeholder}),b=i.literalTypeNode({literal:i.stringLiteral({text:"default"})});m=i.typeReferenceNode({typeArguments:[x,b],typeName:"Omit"});}}}let f=[p,m].filter(Boolean);if(f.length&&r.push({name:"Reply",type:i.typeIntersectionNode({types:f})}),!r.length)return;let u=t.referenceSymbol(t.api.getSelector("RouteHandler"));return {name:e.id,type:i.typeReferenceNode({typeArguments:[i.typeInterfaceNode({properties:r,useLegacyResolution:false})],typeName:u.placeholder})}},sl=({plugin:e})=>{e.registerSymbol({external:"fastify",meta:{kind:"type"},name:"RouteHandler",selector:e.api.getSelector("RouteHandler")});let t=e.registerSymbol({exported:true,meta:{kind:"type"},name:"RouteHandlers"}),r=[];e.forEach("operation",({operation:o})=>{let s=Lh({operation:o,plugin:e});s&&r.push(s);});let n=i.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:i.typeInterfaceNode({properties:r,useLegacyResolution:false})});e.setSymbolValue(t,n);};var Cs={api:new Es({name:"fastify"}),config:{exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:sl,name:"fastify"};var A={actions:{args:i.identifier({text:"args"}),base64:i.identifier({text:"base64"}),bic:i.identifier({text:"bic"}),brand:i.identifier({text:"brand"}),bytes:i.identifier({text:"bytes"}),check:i.identifier({text:"check"}),checkItems:i.identifier({text:"checkItems"}),creditCard:i.identifier({text:"creditCard"}),cuid2:i.identifier({text:"cuid2"}),decimal:i.identifier({text:"decimal"}),description:i.identifier({text:"description"}),digits:i.identifier({text:"digits"}),email:i.identifier({text:"email"}),emoji:i.identifier({text:"emoji"}),empty:i.identifier({text:"empty"}),endsWith:i.identifier({text:"endsWith"}),entries:i.identifier({text:"entries"}),everyItem:i.identifier({text:"everyItem"}),excludes:i.identifier({text:"excludes"}),filterItems:i.identifier({text:"filterItems"}),findItem:i.identifier({text:"findItem"}),finite:i.identifier({text:"finite"}),flavor:i.identifier({text:"flavor"}),graphemes:i.identifier({text:"graphemes"}),gtValue:i.identifier({text:"gtValue"}),hash:i.identifier({text:"hash"}),hexColor:i.identifier({text:"hexColor"}),hexadecimal:i.identifier({text:"hexadecimal"}),imei:i.identifier({text:"imei"}),includes:i.identifier({text:"includes"}),integer:i.identifier({text:"integer"}),ip:i.identifier({text:"ip"}),ipv4:i.identifier({text:"ipv4"}),ipv6:i.identifier({text:"ipv6"}),isoDate:i.identifier({text:"isoDate"}),isoDateTime:i.identifier({text:"isoDateTime"}),isoTime:i.identifier({text:"isoTime"}),isoTimeSecond:i.identifier({text:"isoTimeSecond"}),isoTimestamp:i.identifier({text:"isoTimestamp"}),isoWeek:i.identifier({text:"isoWeek"}),length:i.identifier({text:"length"}),ltValue:i.identifier({text:"ltValue"}),mac:i.identifier({text:"mac"}),mac48:i.identifier({text:"mac48"}),mac64:i.identifier({text:"mac64"}),mapItems:i.identifier({text:"mapItems"}),maxBytes:i.identifier({text:"maxBytes"}),maxEntries:i.identifier({text:"maxEntries"}),maxGraphemes:i.identifier({text:"maxGraphemes"}),maxLength:i.identifier({text:"maxLength"}),maxSize:i.identifier({text:"maxSize"}),maxValue:i.identifier({text:"maxValue"}),maxWords:i.identifier({text:"maxWords"}),metadata:i.identifier({text:"metadata"}),mimeType:i.identifier({text:"mimeType"}),minBytes:i.identifier({text:"minBytes"}),minEntries:i.identifier({text:"minEntries"}),minGraphemes:i.identifier({text:"minGraphemes"}),minLength:i.identifier({text:"minLength"}),minSize:i.identifier({text:"minSize"}),minValue:i.identifier({text:"minValue"}),minWords:i.identifier({text:"minWords"}),multipleOf:i.identifier({text:"multipleOf"}),nanoid:i.identifier({text:"nanoid"}),nonEmpty:i.identifier({text:"nonEmpty"}),normalize:i.identifier({text:"normalize"}),notBytes:i.identifier({text:"notBytes"}),notEntries:i.identifier({text:"notEntries"}),notGraphemes:i.identifier({text:"notGraphemes"}),notLength:i.identifier({text:"notLength"}),notSize:i.identifier({text:"notSize"}),notValue:i.identifier({text:"notValue"}),notValues:i.identifier({text:"notValues"}),notWords:i.identifier({text:"notWords"}),octal:i.identifier({text:"octal"}),parseJson:i.identifier({text:"parseJson"}),partialCheck:i.identifier({text:"partialCheck"}),rawCheck:i.identifier({text:"rawCheck"}),rawTransform:i.identifier({text:"rawTransform"}),readonly:i.identifier({text:"readonly"}),reduceItems:i.identifier({text:"reduceItems"}),regex:i.identifier({text:"regex"}),returns:i.identifier({text:"returns"}),rfcEmail:i.identifier({text:"rfcEmail"}),safeInteger:i.identifier({text:"safeInteger"}),size:i.identifier({text:"size"}),slug:i.identifier({text:"slug"}),someItem:i.identifier({text:"someItem"}),sortItems:i.identifier({text:"sortItems"}),startsWith:i.identifier({text:"startsWith"}),stringifyJson:i.identifier({text:"stringifyJson"}),title:i.identifier({text:"title"}),toLowerCase:i.identifier({text:"toLowerCase"}),toMaxValue:i.identifier({text:"toMaxValue"}),toMinValue:i.identifier({text:"toMinValue"}),toUpperCase:i.identifier({text:"toUpperCase"}),transform:i.identifier({text:"transform"}),trim:i.identifier({text:"trim"}),trimEnd:i.identifier({text:"trimEnd"}),trimStart:i.identifier({text:"trimStart"}),ulid:i.identifier({text:"ulid"}),url:i.identifier({text:"url"}),uuid:i.identifier({text:"uuid"}),value:i.identifier({text:"value"}),values:i.identifier({text:"values"}),words:i.identifier({text:"words"})},async:{argsAsync:i.identifier({text:"argsAsync"}),arrayAsync:i.identifier({text:"arrayAsync"}),awaitAsync:i.identifier({text:"awaitAsync"}),checkAsync:i.identifier({text:"checkAsync"}),checkItemsAsync:i.identifier({text:"checkItemsAsync"}),customAsync:i.identifier({text:"customAsync"}),exactOptionalAsync:i.identifier({text:"exactOptionalAsync"}),fallbackAsync:i.identifier({text:"fallbackAsync"}),forwardAsync:i.identifier({text:"forwardAsync"}),getDefaultsAsync:i.identifier({text:"getDefaultsAsync"}),getFallbacksAsync:i.identifier({text:"getFallbacksAsync"}),intersectAsync:i.identifier({text:"intersectAsync"}),lazyAsync:i.identifier({text:"lazyAsync"}),looseObjectAsync:i.identifier({text:"looseObjectAsync"}),looseTupleAsync:i.identifier({text:"looseTupleAsync"}),mapAsync:i.identifier({text:"mapAsync"}),nonNullableAsync:i.identifier({text:"nonNullableAsync"}),nonNullishAsync:i.identifier({text:"nonNullishAsync"}),nonOptionalAsync:i.identifier({text:"nonOptionalAsync"}),nullableAsync:i.identifier({text:"nullableAsync"}),nullishAsync:i.identifier({text:"nullishAsync"}),objectAsync:i.identifier({text:"objectAsync"}),objectWithRestAsync:i.identifier({text:"objectWithRestAsync"}),optionalAsync:i.identifier({text:"optionalAsync"}),parseAsync:i.identifier({text:"parseAsync"}),parserAsync:i.identifier({text:"parserAsync"}),partialAsync:i.identifier({text:"partialAsync"}),partialCheckAsync:i.identifier({text:"partialCheckAsync"}),pipeAsync:i.identifier({text:"pipeAsync"}),rawCheckAsync:i.identifier({text:"rawCheckAsync"}),rawTransformAsync:i.identifier({text:"rawTransformAsync"}),recordAsync:i.identifier({text:"recordAsync"}),requiredAsync:i.identifier({text:"requiredAsync"}),returnsAsync:i.identifier({text:"returnsAsync"}),safeParseAsync:i.identifier({text:"safeParseAsync"}),safeParserAsync:i.identifier({text:"safeParserAsync"}),setAsync:i.identifier({text:"setAsync"}),strictObjectAsync:i.identifier({text:"strictObjectAsync"}),strictTupleAsync:i.identifier({text:"strictTupleAsync"}),transformAsync:i.identifier({text:"transformAsync"}),tupleAsync:i.identifier({text:"tupleAsync"}),tupleWithRestAsync:i.identifier({text:"tupleWithRestAsync"}),undefinedableAsync:i.identifier({text:"undefinedableAsync"}),unionAsync:i.identifier({text:"unionAsync"}),variantAsync:i.identifier({text:"variantAsync"})},methods:{assert:i.identifier({text:"assert"}),config:i.identifier({text:"config"}),fallback:i.identifier({text:"fallback"}),flatten:i.identifier({text:"flatten"}),forward:i.identifier({text:"forward"}),getDefault:i.identifier({text:"getDefault"}),getDefaults:i.identifier({text:"getDefaults"}),getDescription:i.identifier({text:"getDescription"}),getFallback:i.identifier({text:"getFallback"}),getFallbacks:i.identifier({text:"getFallbacks"}),getMetadata:i.identifier({text:"getMetadata"}),getTitle:i.identifier({text:"getTitle"}),is:i.identifier({text:"is"}),keyof:i.identifier({text:"keyof"}),message:i.identifier({text:"message"}),omit:i.identifier({text:"omit"}),parse:i.identifier({text:"parse"}),parser:i.identifier({text:"parser"}),partial:i.identifier({text:"partial"}),pick:i.identifier({text:"pick"}),pipe:i.identifier({text:"pipe"}),required:i.identifier({text:"required"}),safeParse:i.identifier({text:"safeParse"}),safeParser:i.identifier({text:"safeParser"}),summarize:i.identifier({text:"summarize"}),unwrap:i.identifier({text:"unwrap"})},schemas:{any:i.identifier({text:"any"}),array:i.identifier({text:"array"}),bigInt:i.identifier({text:"bigint"}),blob:i.identifier({text:"blob"}),boolean:i.identifier({text:"boolean"}),custom:i.identifier({text:"custom"}),date:i.identifier({text:"date"}),enum:i.identifier({text:"enum"}),exactOptional:i.identifier({text:"exactOptional"}),file:i.identifier({text:"file"}),function:i.identifier({text:"function"}),instance:i.identifier({text:"instance"}),intersect:i.identifier({text:"intersect"}),lazy:i.identifier({text:"lazy"}),literal:i.identifier({text:"literal"}),looseObject:i.identifier({text:"looseObject"}),looseTuple:i.identifier({text:"looseTuple"}),map:i.identifier({text:"map"}),nan:i.identifier({text:"nan"}),never:i.identifier({text:"never"}),nonNullable:i.identifier({text:"nonNullable"}),nonNullish:i.identifier({text:"nonNullish"}),nonOptional:i.identifier({text:"nonOptional"}),null:i.identifier({text:"null"}),nullable:i.identifier({text:"nullable"}),nullish:i.identifier({text:"nullish"}),number:i.identifier({text:"number"}),object:i.identifier({text:"object"}),objectWithRest:i.identifier({text:"objectWithRest"}),optional:i.identifier({text:"optional"}),picklist:i.identifier({text:"picklist"}),promise:i.identifier({text:"promise"}),record:i.identifier({text:"record"}),set:i.identifier({text:"set"}),strictObject:i.identifier({text:"strictObject"}),strictTuple:i.identifier({text:"strictTuple"}),string:i.identifier({text:"string"}),symbol:i.identifier({text:"symbol"}),tuple:i.identifier({text:"tuple"}),tupleWithRest:i.identifier({text:"tupleWithRest"}),undefined:i.identifier({text:"undefined"}),undefinedable:i.identifier({text:"undefinedable"}),union:i.identifier({text:"union"}),unknown:i.identifier({text:"unknown"}),variant:i.identifier({text:"variant"}),void:i.identifier({text:"void"})},types:{GenericSchema:i.identifier({text:"GenericSchema"})}};var ks=class{constructor(t){this.meta=t;}createRequestValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("data",t.id));if(!n)return;let o=r.referenceSymbol(r.api.getSelector("import","valibot")),s="data";return i.arrowFunction({async:true,parameters:[{name:s}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:A.async.parseAsync}),parameters:[i.identifier({text:n.placeholder}),i.identifier({text:s})]})})})]})}createResponseValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("responses",t.id));if(!n)return;let o=r.referenceSymbol(r.api.getSelector("import","valibot")),s="data";return i.arrowFunction({async:true,parameters:[{name:s}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:A.async.parseAsync}),parameters:[i.identifier({text:n.placeholder}),i.identifier({text:s})]})})})]})}getSelector(...t){return [this.meta.name,...t]}};var Is={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}},wi=e=>e!==void 0&&e in Is,il=e=>wi(e)&&Is[e].needsBigInt,zr=({isBigInt:e,value:t})=>{let r=i.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?i.callExpression({functionName:"BigInt",parameters:[r]}):r};var al=({operation:e,plugin:t,state:r})=>{if(t.config.requests.enabled){let n=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let a={},p=[];for(let c in e.parameters.header){let m=e.parameters.header[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("headers"));}Object.keys(a).length&&(o.properties.headers={properties:a,required:p,type:"object"});}if(e.parameters.path){let a={},p=[];for(let c in e.parameters.path){let m=e.parameters.path[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("path"));}Object.keys(a).length&&(o.properties.path={properties:a,required:p,type:"object"});}if(e.parameters.query){let a={},p=[];for(let c in e.parameters.query){let m=e.parameters.query[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("query"));}Object.keys(a).length&&(o.properties.query={properties:a,required:p,type:"object"});}}e.body&&(o.properties.body=e.body.schema,e.body.required&&n.add("body")),o.required=[...n];let s=t.registerSymbol({exported:true,name:R({config:t.config.requests,name:e.id}),selector:t.api.getSelector("data",e.id)});ye({plugin:t,schema:o,state:r,symbol:s});}if(t.config.responses.enabled&&e.responses){let{response:n}=tt(e);if(n){let o=t.registerSymbol({exported:true,name:R({config:t.config.responses,name:e.id}),selector:t.api.getSelector("responses",e.id)});ye({plugin:t,schema:n,state:r,symbol:o});}}};var pl=({operation:e,plugin:t,state:r})=>{if(t.config.webhooks.enabled){let n=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let a={},p=[];for(let c in e.parameters.header){let m=e.parameters.header[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("headers"));}Object.keys(a).length&&(o.properties.headers={properties:a,required:p,type:"object"});}if(e.parameters.path){let a={},p=[];for(let c in e.parameters.path){let m=e.parameters.path[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("path"));}Object.keys(a).length&&(o.properties.path={properties:a,required:p,type:"object"});}if(e.parameters.query){let a={},p=[];for(let c in e.parameters.query){let m=e.parameters.query[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("query"));}Object.keys(a).length&&(o.properties.query={properties:a,required:p,type:"object"});}}e.body&&(o.properties.body=e.body.schema,e.body.required&&n.add("body")),o.required=[...n];let s=t.registerSymbol({exported:true,name:R({config:t.config.webhooks,name:e.id}),selector:t.api.getSelector("webhook-request",e.id)});ye({plugin:t,schema:o,state:r,symbol:s});}};var Ke=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let r=t.referenceSymbol(t.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.methods.pipe}),parameters:e})},Bh=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","valibot")),o=i.propertyAccessExpression({expression:n.placeholder,name:A.schemas.array}),s=[];if(t.items){t=J({schema:t});let a=t.items.map(p=>{let c=ye({plugin:e,schema:p,state:r});return Ke({pipes:c,plugin:e})});if(a.length===1){let p=i.callExpression({functionName:o,parameters:a});s.push(p);}else {t.logicalOperator;let p=i.callExpression({functionName:o,parameters:[Tn({plugin:e})]});s.push(p);}}else {let a=i.callExpression({functionName:o,parameters:[Tn({plugin:e})]});s.push(a);}if(t.minItems===t.maxItems&&t.minItems!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.actions.length}),parameters:[i.valueToExpression({value:t.minItems})]});s.push(a);}else {if(t.minItems!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.actions.minLength}),parameters:[i.valueToExpression({value:t.minItems})]});s.push(a);}if(t.maxItems!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.actions.maxLength}),parameters:[i.valueToExpression({value:t.maxItems})]});s.push(a);}}return Ke({pipes:s,plugin:e})},Vh=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","valibot"));return typeof t.const=="boolean"?i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.schemas.literal}),parameters:[i.ots.boolean(t.const)]}):i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.schemas.boolean})})},Hh=({plugin:e,schema:t})=>{let r=[],n=false;for(let a of t.items??[])a.type==="string"&&typeof a.const=="string"?r.push(i.stringLiteral({text:a.const})):(a.type==="null"||a.const===null)&&(n=true);if(!r.length)return Tn({plugin:e});let o=e.referenceSymbol(e.api.getSelector("import","valibot")),s=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:A.schemas.picklist}),parameters:[i.arrayLiteralExpression({elements:r,multiLine:false})]});return n&&(s=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:A.schemas.nullable}),parameters:[s]})),s},_h=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:A.schemas.never})})},Wh=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:A.schemas.null})})},cl=({plugin:e,schema:t})=>{let r=t.format,n=t.type==="integer",o=il(r),s=wi(r)?Is[r]:null,a=e.referenceSymbol(e.api.getSelector("import","valibot"));if(t.const!==void 0&&t.const!==null){let c=t.const,m;if(typeof c=="number"&&!r)m=i.ots.number(c);else if(typeof c=="number"&&r)o?m=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(c.toString())]}):m=i.ots.number(c);else if(typeof c=="string"&&o){let l=c.endsWith("n")?c.slice(0,-1):c;m=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(l)]});}else if(typeof c=="bigint"){let l=c.toString(),f=l.endsWith("n")?l.slice(0,-1):l;m=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(f)]});}else m=i.valueToExpression({value:c});return i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.literal}),parameters:[m]})}let p=[];if(o){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.union}),parameters:[i.arrayLiteralExpression({elements:[i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.number})}),i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.string})}),i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.bigInt})})],multiLine:false})]});p.push(c);let m=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.transform}),parameters:[i.arrowFunction({parameters:[{name:"x"}],statements:i.callExpression({functionName:"BigInt",parameters:[i.identifier({text:"x"})]})})]});p.push(m);}else {let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.number})});p.push(c);}if(!o&&n){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.integer})});p.push(c);}if(s){let c=s.min,m=s.max,l=s.minError,f=s.maxError,u=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.minValue}),parameters:[o?i.callExpression({functionName:"BigInt",parameters:[i.ots.string(c.toString())]}):i.ots.number(c),i.ots.string(l)]});p.push(u);let d=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.maxValue}),parameters:[o?i.callExpression({functionName:"BigInt",parameters:[i.ots.string(m.toString())]}):i.ots.number(m),i.ots.string(f)]});p.push(d);}if(t.exclusiveMinimum!==void 0){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.gtValue}),parameters:[zr({isBigInt:o,value:t.exclusiveMinimum})]});p.push(c);}else if(t.minimum!==void 0){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.minValue}),parameters:[zr({isBigInt:o,value:t.minimum})]});p.push(c);}if(t.exclusiveMaximum!==void 0){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.ltValue}),parameters:[zr({isBigInt:o,value:t.exclusiveMaximum})]});p.push(c);}else if(t.maximum!==void 0){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.maxValue}),parameters:[zr({isBigInt:o,value:t.maximum})]});p.push(c);}return Ke({pipes:p,plugin:e})},Kh=({plugin:e,schema:t,state:r})=>{let n=[],o=t.required??[];for(let p in t.properties){let c=t.properties[p],m=o.includes(p),l=ye({optional:!m,plugin:e,schema:c,state:r});oe.lastIndex=0;let f;oe.test(p)?f=p.startsWith("-")?S__default.default.factory.createStringLiteral(p):S__default.default.factory.createNumericLiteral(p):f=p,(p.match(/^[0-9]/)&&p.match(/\D+/g)||p.match(/\W/g))&&!p.startsWith("'")&&!p.endsWith("'")&&(f=`'${p}'`),n.push(i.propertyAssignment({initializer:Ke({pipes:l,plugin:e}),name:f}));}let s=e.referenceSymbol(e.api.getSelector("import","valibot"));if(t.additionalProperties&&t.additionalProperties.type==="object"&&!Object.keys(n).length){let p=ye({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:A.schemas.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:A.schemas.string}),parameters:[]}),Ke({pipes:p,plugin:e})]})}}let a=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:A.schemas.object}),parameters:[S__default.default.factory.createObjectLiteralExpression(n,true)]});return {anyType:A.types.GenericSchema.text,expression:a}},zh=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","valibot"));if(typeof t.const=="string")return i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.schemas.literal}),parameters:[i.ots.string(t.const)]});let n=[],o=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.schemas.string})});if(n.push(o),t.format)switch(t.format){case "date":n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.isoDate})}));break;case "date-time":n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.isoTimestamp})}));break;case "ipv4":case "ipv6":n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.ip})}));break;case "uri":n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.url})}));break;case "email":case "time":case "uuid":n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:i.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let s=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.length}),parameters:[i.valueToExpression({value:t.minLength})]});n.push(s);}else {if(t.minLength!==void 0){let s=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.minLength}),parameters:[i.valueToExpression({value:t.minLength})]});n.push(s);}if(t.maxLength!==void 0){let s=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.maxLength}),parameters:[i.valueToExpression({value:t.maxLength})]});n.push(s);}}if(t.pattern){let s=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]});n.push(s);}return Ke({pipes:n,plugin:e})},Qh=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","valibot"));if(t.const&&Array.isArray(t.const)){let o=t.const.map(a=>i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.schemas.literal}),parameters:[i.valueToExpression({value:a})]}));return i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.schemas.tuple}),parameters:[i.arrayLiteralExpression({elements:o})]})}if(t.items){let o=t.items.map(a=>{let p=ye({plugin:e,schema:a,state:r});return Ke({pipes:p,plugin:e})});return i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.schemas.tuple}),parameters:[i.arrayLiteralExpression({elements:o})]})}return Tn({plugin:e})},Uh=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:A.schemas.undefined})})},Tn=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:A.schemas.unknown})})},Zh=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:A.schemas.void})})},ml=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:Bh({plugin:e,schema:t,state:r})};case "boolean":return {expression:Vh({plugin:e,schema:t})};case "enum":return {expression:Hh({plugin:e,schema:t})};case "integer":case "number":return {expression:cl({plugin:e,schema:t})};case "never":return {expression:_h({plugin:e})};case "null":return {expression:Wh({plugin:e})};case "object":return Kh({plugin:e,schema:t,state:r});case "string":return t.format==="int64"||t.format==="uint64"?{expression:cl({plugin:e,schema:t})}:{expression:zh({plugin:e,schema:t})};case "tuple":return {expression:Qh({plugin:e,schema:t,state:r})};case "undefined":return {expression:Uh({plugin:e})};case "unknown":return {expression:Tn({plugin:e})};case "void":return {expression:Zh({plugin:e})}}},ye=({$ref:e,optional:t,plugin:r,schema:n,state:o,symbol:s})=>{let a,p=[];if(e&&(o.circularReferenceTracker.add(e),!s)){let m=r.api.getSelector("ref",e);r.getSymbol(m)||(s=r.referenceSymbol(m));}let c=r.referenceSymbol(r.api.getSelector("import","valibot"));if(n.$ref){let m=o.circularReferenceTracker.has(n.$ref),l=r.api.getSelector("ref",n.$ref),f=r.getSymbol(l);if(!f){let u=r.context.resolveIrRef(n.$ref),d=ye({$ref:n.$ref,plugin:r,schema:u,state:o});p.push(...d),f=r.getSymbol(l);}if(f){let u=i.identifier({text:f.placeholder});if(m){let d=i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.schemas.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:u})]})]});p.push(d),o.hasCircularReference=true;}else p.push(u);}}else if(n.type){let m=ml({plugin:r,schema:n,state:o});if(a=m.anyType,p.push(m.expression),r.config.metadata&&n.description){let l=i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.actions.metadata}),parameters:[i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:n.description})}]})]});p.push(l);}}else if(n.items)if(n=J({schema:n}),n.items){let m=n.items.map(l=>{let f=ye({plugin:r,schema:l,state:o});return Ke({pipes:f,plugin:r})});if(n.logicalOperator==="and"){let l=i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.schemas.intersect}),parameters:[i.arrayLiteralExpression({elements:m})]});p.push(l);}else {let l=i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.schemas.union}),parameters:[i.arrayLiteralExpression({elements:m})]});p.push(l);}}else {let m=ye({plugin:r,schema:n,state:o});p.push(...m);}else {let m=ml({plugin:r,schema:{type:"unknown"},state:o});a=m.anyType,p.push(m.expression);}if(e&&o.circularReferenceTracker.delete(e),p.length&&n.accessScope==="read"){let m=i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.actions.readonly})});p.push(m);}if(p.length){let m;if(n.default!==void 0){let l=n.type==="integer"&&n.format==="int64";m=zr({isBigInt:l,value:n.default}),m&&(p=[i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.schemas.optional}),parameters:[Ke({pipes:p,plugin:r}),m]})]);}t&&!m&&(p=[i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.schemas.optional}),parameters:[Ke({pipes:p,plugin:r})]})]);}if(s){e&&(s=r.registerSymbol({exported:true,name:R({config:{case:o.nameCase,name:o.nameTransformer},name:H(e)}),selector:r.api.getSelector("ref",e)}));let m=i.constVariable({comment:r.config.comments?Oe({schema:n}):void 0,exportConst:s.exported,expression:Ke({pipes:p,plugin:r}),name:s.placeholder,typeName:o.hasCircularReference?i.propertyAccessExpression({expression:c.placeholder,name:a||A.types.GenericSchema.text}):void 0});return r.setSymbolValue(s,m),[]}return p},ll=({plugin:e})=>{e.registerSymbol({external:"valibot",meta:{importKind:"namespace"},name:"v",selector:e.api.getSelector("import","valibot")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{let r={circularReferenceTracker:new Set,hasCircularReference:false,nameCase:e.config.definitions.case,nameTransformer:e.config.definitions.name};switch(t.type){case "operation":al({operation:t.operation,plugin:e,state:r});break;case "parameter":ye({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:r});break;case "requestBody":ye({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:r});break;case "schema":ye({$ref:t.$ref,plugin:e,schema:t.schema,state:r});break;case "webhook":pl({operation:t.operation,plugin:e,state:r});break}});};var vs={api:new ks({name:"valibot"}),config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:ll,name:"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}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}WebhookRequest"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.webhooks});},tags:["validator"]};var g={ZodMiniOptional:i.identifier({text:"ZodMiniOptional"}),ZodOptional:i.identifier({text:"ZodOptional"}),_default:i.identifier({text:"_default"}),and:i.identifier({text:"and"}),array:i.identifier({text:"array"}),bigint:i.identifier({text:"bigint"}),boolean:i.identifier({text:"boolean"}),check:i.identifier({text:"check"}),coerce:i.identifier({text:"coerce"}),date:i.identifier({text:"date"}),datetime:i.identifier({text:"datetime"}),default:i.identifier({text:"default"}),describe:i.identifier({text:"describe"}),email:i.identifier({text:"email"}),enum:i.identifier({text:"enum"}),globalRegistry:i.identifier({text:"globalRegistry"}),gt:i.identifier({text:"gt"}),gte:i.identifier({text:"gte"}),infer:i.identifier({text:"infer"}),int:i.identifier({text:"int"}),intersection:i.identifier({text:"intersection"}),ip:i.identifier({text:"ip"}),ipv4:i.identifier({text:"ipv4"}),ipv6:i.identifier({text:"ipv6"}),iso:i.identifier({text:"iso"}),lazy:i.identifier({text:"lazy"}),length:i.identifier({text:"length"}),literal:i.identifier({text:"literal"}),lt:i.identifier({text:"lt"}),lte:i.identifier({text:"lte"}),max:i.identifier({text:"max"}),maxLength:i.identifier({text:"maxLength"}),min:i.identifier({text:"min"}),minLength:i.identifier({text:"minLength"}),never:i.identifier({text:"never"}),null:i.identifier({text:"null"}),nullable:i.identifier({text:"nullable"}),number:i.identifier({text:"number"}),object:i.identifier({text:"object"}),optional:i.identifier({text:"optional"}),parseAsync:i.identifier({text:"parseAsync"}),readonly:i.identifier({text:"readonly"}),record:i.identifier({text:"record"}),regex:i.identifier({text:"regex"}),register:i.identifier({text:"register"}),string:i.identifier({text:"string"}),time:i.identifier({text:"time"}),tuple:i.identifier({text:"tuple"}),undefined:i.identifier({text:"undefined"}),union:i.identifier({text:"union"}),unknown:i.identifier({text:"unknown"}),url:i.identifier({text:"url"}),uuid:i.identifier({text:"uuid"}),void:i.identifier({text:"void"})};var js=class{constructor(t){this.meta=t;}createRequestValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("data",t.id));if(!n)return;let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.parseAsync}),parameters:[i.identifier({text:o})]})})})]})}createResponseValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("responses",t.id));if(!n)return;let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.parseAsync}),parameters:[i.identifier({text:o})]})})})]})}getSelector(...t){return [this.meta.name,...t]}};var ze=({plugin:e,schema:t,symbol:r,typeInferSymbol:n,zodSchema:o})=>{let s=e.referenceSymbol(e.api.getSelector("import","zod")),a=i.constVariable({comment:e.config.comments?Oe({schema:t}):void 0,exportConst:r.exported,expression:o.expression,name:r.placeholder,typeName:o.typeName?i.propertyAccessExpression({expression:s.placeholder,name:o.typeName}):void 0});if(e.setSymbolValue(r,a),n){let p=i.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:i.typeReferenceNode({typeArguments:[i.typeOfExpression({text:r.placeholder})],typeName:i.propertyAccessExpression({expression:s.placeholder,name:g.infer})})});e.setSymbolValue(n,p);}};var Qr=({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 Ur=({getZodSchema:e,operation:t,plugin:r})=>{if(r.config.requests.enabled){let n=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(t.parameters){if(t.parameters.header){let c={},m=[];for(let l in t.parameters.header){let f=t.parameters.header[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("headers"));}Object.keys(c).length&&(o.properties.headers={properties:c,required:m,type:"object"});}if(t.parameters.path){let c={},m=[];for(let l in t.parameters.path){let f=t.parameters.path[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("path"));}Object.keys(c).length&&(o.properties.path={properties:c,required:m,type:"object"});}if(t.parameters.query){let c={},m=[];for(let l in t.parameters.query){let f=t.parameters.query[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("query"));}Object.keys(c).length&&(o.properties.query={properties:c,required:m,type:"object"});}}t.body&&(o.properties.body=t.body.schema,t.body.required&&n.add("body")),o.required=[...n];let s=e(o),a=r.registerSymbol({exported:true,name:R({config:r.config.requests,name:t.id}),selector:r.api.getSelector("data",t.id)}),p=r.config.requests.types.infer.enabled?r.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:r.config.requests.types.infer,name:t.id}),selector:r.api.getSelector("type-infer-data",t.id)}):void 0;ze({plugin:r,schema:o,symbol:a,typeInferSymbol:p,zodSchema:s});}if(r.config.responses.enabled&&t.responses){let{response:n}=tt(t);if(n){let o=e(n),s=r.registerSymbol({exported:true,name:R({config:r.config.responses,name:t.id}),selector:r.api.getSelector("responses",t.id)}),a=r.config.responses.types.infer.enabled?r.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:r.config.responses.types.infer,name:t.id}),selector:r.api.getSelector("type-infer-responses",t.id)}):void 0;ze({plugin:r,schema:n,symbol:s,typeInferSymbol:a,zodSchema:o});}}};var Zr=({getZodSchema:e,operation:t,plugin:r})=>{if(r.config.webhooks.enabled){let n=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(t.parameters){if(t.parameters.header){let c={},m=[];for(let l in t.parameters.header){let f=t.parameters.header[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("headers"));}Object.keys(c).length&&(o.properties.headers={properties:c,required:m,type:"object"});}if(t.parameters.path){let c={},m=[];for(let l in t.parameters.path){let f=t.parameters.path[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("path"));}Object.keys(c).length&&(o.properties.path={properties:c,required:m,type:"object"});}if(t.parameters.query){let c={},m=[];for(let l in t.parameters.query){let f=t.parameters.query[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("query"));}Object.keys(c).length&&(o.properties.query={properties:c,required:m,type:"object"});}}t.body&&(o.properties.body=t.body.schema,t.body.required&&n.add("body")),o.required=[...n];let s=e(o),a=r.registerSymbol({exported:true,name:R({config:r.config.webhooks,name:t.id}),selector:r.api.getSelector("webhook-request",t.id)}),p=r.config.webhooks.types.infer.enabled?r.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:r.config.webhooks.types.infer,name:t.id}),selector:r.api.getSelector("type-infer-webhook-request",t.id)}):void 0;ze({plugin:r,schema:o,symbol:a,typeInferSymbol:p,zodSchema:s});}};var Gh=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o={},s=i.propertyAccessExpression({expression:n.placeholder,name:g.array});if(!t.items)o.expression=i.callExpression({functionName:s,parameters:[Mi({plugin:e}).expression]});else {t=J({schema:t});let p=t.items.map(c=>{let m=vt({plugin:e,schema:c,state:r});return m.hasCircularReference&&(o.hasCircularReference=true),m.expression});p.length===1?o.expression=i.callExpression({functionName:s,parameters:p}):(t.logicalOperator,o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:p})]})]}));}let a=[];return t.minItems===t.maxItems&&t.minItems!==void 0?a.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.length}),parameters:[i.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&a.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.minLength}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&a.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.maxLength}),parameters:[i.valueToExpression({value:t.maxItems})]}))),a.length&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.check}),parameters:a})),o},Jh=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={};return typeof t.const=="boolean"?(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.boolean(t.const)]}),n):(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.boolean})}),n)},Yh=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={},o=[],s=[],a=false,p=true;for(let c of t.items??[])if(c.type==="string"&&typeof c.const=="string"){let m=i.stringLiteral({text:c.const});o.push(m),s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else if((c.type==="number"||c.type==="integer")&&typeof c.const=="number"){p=false;let m=i.ots.number(c.const);s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else if(c.type==="boolean"&&typeof c.const=="boolean"){p=false;let m=i.ots.boolean(c.const);s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else (c.type==="null"||c.const===null)&&(a=true);return s.length?(p&&o.length>0?n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.enum}),parameters:[i.arrayLiteralExpression({elements:o,multiLine:false})]}):s.length===1?n.expression=s[0]:n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:s,multiLine:s.length>3})]}),a&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.nullable}),parameters:[n.expression]})),n):Mi({plugin:e})},ex=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.never})}),r},tx=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.null})}),r},Pn=({isBigInt:e,value:t})=>{let r=i.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?i.callExpression({functionName:"BigInt",parameters:[r]}):r},rx=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={},o=t.type==="integer"&&t.format==="int64";if(typeof t.const=="number")return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.number(t.const)]}),n;n.expression=i.callExpression({functionName:o?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:r.placeholder,name:g.coerce}),name:g.bigint}):i.propertyAccessExpression({expression:r.placeholder,name:g.number})}),!o&&t.type==="integer"&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.int})}));let s=[];return t.exclusiveMinimum!==void 0?s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.gt}),parameters:[Pn({isBigInt:o,value:t.exclusiveMinimum})]})):t.minimum!==void 0&&s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.gte}),parameters:[Pn({isBigInt:o,value:t.minimum})]})),t.exclusiveMaximum!==void 0?s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.lt}),parameters:[Pn({isBigInt:o,value:t.exclusiveMaximum})]})):t.maximum!==void 0&&s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.lte}),parameters:[Pn({isBigInt:o,value:t.maximum})]})),s.length&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:g.check}),parameters:s})),n},nx=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o={},s=[],a=t.required??[];for(let p in t.properties){let c=t.properties[p],m=a.includes(p),l=vt({optional:!m,plugin:e,schema:c,state:r});l.hasCircularReference&&(o.hasCircularReference=true),oe.lastIndex=0;let f;oe.test(p)?f=p.startsWith("-")?S__default.default.factory.createStringLiteral(p):S__default.default.factory.createNumericLiteral(p):f=p,(p.match(/^[0-9]/)&&p.match(/\D+/g)||p.match(/\W/g))&&!p.startsWith("'")&&!p.endsWith("'")&&(f=`'${p}'`),l.hasCircularReference?s.push(i.getAccessorDeclaration({name:f,returnType:l.typeName?i.propertyAccessExpression({expression:n.placeholder,name:l.typeName}):void 0,statements:[i.returnStatement({expression:l.expression})]})):s.push(i.propertyAssignment({initializer:l.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let p=vt({plugin:e,schema:t.additionalProperties,state:r});return o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.string}),parameters:[]}),p.expression]}),p.hasCircularReference&&(o.hasCircularReference=true),o}return o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.object}),parameters:[S__default.default.factory.createObjectLiteralExpression(s,true)]}),o},ox=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={};if(typeof t.const=="string")return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.string(t.const)]}),n;n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.string})});let o=[];if(e.config.dates.offset&&o.push({key:"offset",value:true}),e.config.dates.local&&o.push({key:"local",value:true}),t.format)switch(t.format){case "date":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:r.placeholder,name:g.iso}),name:g.date})});break;case "date-time":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:r.placeholder,name:g.iso}),name:g.datetime}),parameters:o.length>0?[i.objectExpression({obj:o})]:[]});break;case "email":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.email})});break;case "ipv4":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.ipv4})});break;case "ipv6":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.ipv6})});break;case "time":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:r.placeholder,name:g.iso}),name:g.time})});break;case "uri":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.url})});break;case "uuid":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.uuid})});break}let s=[];return t.minLength===t.maxLength&&t.minLength!==void 0?s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.length}),parameters:[i.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.minLength}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.maxLength}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),s.length&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:g.check}),parameters:s})),n},sx=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o={};if(t.const&&Array.isArray(t.const)){let a=t.const.map(p=>i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[i.valueToExpression({value:p})]}));return o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:a})]}),o}let s=[];for(let a of t.items??[]){let p=vt({plugin:e,schema:a,state:r});s.push(p.expression),p.hasCircularReference&&(o.hasCircularReference=true);}return o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:s})]}),o},ix=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.undefined})}),r},Mi=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.unknown})}),r},ax=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.void})}),r},fl=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return Gh({plugin:e,schema:t,state:r});case "boolean":return Jh({plugin:e,schema:t});case "enum":return Yh({plugin:e,schema:t});case "integer":case "number":return rx({plugin:e,schema:t});case "never":return ex({plugin:e});case "null":return tx({plugin:e});case "object":return nx({plugin:e,schema:t,state:r});case "string":return ox({plugin:e,schema:t});case "tuple":return sx({plugin:e,schema:t,state:r});case "undefined":return ix({plugin:e});case "unknown":return Mi({plugin:e});case "void":return ax({plugin:e})}},vt=({optional:e,plugin:t,schema:r,state:n})=>{let o={},s=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let a=n.circularReferenceTracker.includes(r.$ref),p=n.currentReferenceTracker.includes(r.$ref);n.circularReferenceTracker.push(r.$ref),n.currentReferenceTracker.push(r.$ref);let c=t.api.getSelector("ref",r.$ref),m=t.getSymbol(c);if(a)m||(m=t.referenceSymbol(c)),p?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.lazy}),parameters:[i.arrowFunction({returnType:i.keywordTypeNode({keyword:"any"}),statements:[i.returnStatement({expression:i.identifier({text:m.placeholder})})]})]}):o.expression=i.identifier({text:m.placeholder}),o.hasCircularReference=r.circular;else {if(m)o.hasCircularReference=r.circular;else {let f=t.context.resolveIrRef(r.$ref);Ns({id:r.$ref,plugin:t,schema:f,state:n});}let l=t.referenceSymbol(c);o.expression=i.identifier({text:l.placeholder});}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=fl({plugin:t,schema:r,state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,t.config.metadata&&r.description&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.register}),parameters:[i.propertyAccessExpression({expression:s.placeholder,name:g.globalRegistry}),i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=J({schema:r}),r.items){let a=r.items.map(p=>vt({plugin:t,schema:p,state:n}));if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.intersection}),parameters:a.map(c=>c.expression)}):(o.expression=a[0].expression,a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.intersection}),parameters:[o.expression,c.hasCircularReference?i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:c.expression})]})]}):c.expression]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:a.map(p=>p.expression)})]});}else o=vt({plugin:t,schema:r,state:n});else {let a=fl({plugin:t,schema:{type:"unknown"},state:n});o.expression=a.expression;}if(o.expression&&(r.accessScope==="read"&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.readonly}),parameters:[o.expression]})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.optional}),parameters:[o.expression]}),o.typeName=g.ZodMiniOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=Pn({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g._default}),parameters:[o.expression,p]}));}return o},Ns=({id:e,plugin:t,schema:r,state:n})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...n,currentReferenceTracker:[e]},s=t.api.getSelector("ref",e),a=t.getSymbol(s);if(a&&!t.getSymbolValue(a))return;let p=vt({plugin:t,schema:r,state:o}),c=H(e);a=t.registerSymbol({exported:true,name:R({config:t.config.definitions,name:c}),selector:s});let m=t.config.definitions.types.infer.enabled?t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.definitions.types.infer,name:c}),selector:t.api.getSelector("type-infer-ref",e)}):void 0;ze({plugin:t,schema:r,symbol:a,typeInferSymbol:m,zodSchema:p});},ul=({plugin:e})=>{e.registerSymbol({external:Qr({plugin:e}),meta:{importKind:"namespace"},name:"z",selector:e.api.getSelector("import","zod")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{switch(t.type){case "operation":Ur({getZodSchema:r=>vt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":Ns({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":Ns({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":Ns({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Zr({getZodSchema:r=>vt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var px=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o=i.propertyAccessExpression({expression:n.placeholder,name:g.array}),s,a=false;if(!t.items)s=i.callExpression({functionName:o,parameters:[Li({plugin:e})]});else {t=J({schema:t});let p=t.items.map(c=>{let m=jt({plugin:e,schema:c,state:r});return m.hasCircularReference&&(a=true),m.expression});p.length===1?s=i.callExpression({functionName:o,parameters:p}):(t.logicalOperator,s=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:p})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:g.length}),parameters:[i.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:g.min}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:g.max}),parameters:[i.valueToExpression({value:t.maxItems})]}))),{expression:s,hasCircularReference:a}},cx=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="boolean"?i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.boolean(t.const)]}):i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.boolean})})},mx=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n=[],o=[],s=false,a=true;for(let c of t.items??[])if(c.type==="string"&&typeof c.const=="string"){let m=i.stringLiteral({text:c.const});n.push(m),o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else if((c.type==="number"||c.type==="integer")&&typeof c.const=="number"){a=false;let m=i.ots.number(c.const);o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else if(c.type==="boolean"&&typeof c.const=="boolean"){a=false;let m=i.ots.boolean(c.const);o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else (c.type==="null"||c.const===null)&&(s=true);if(!o.length)return Li({plugin:e});let p;return a&&n.length>0?p=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.enum}),parameters:[i.arrayLiteralExpression({elements:n,multiLine:false})]}):o.length===1?p=o[0]:p=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(p=i.callExpression({functionName:i.propertyAccessExpression({expression:p,name:g.nullable})})),p},lx=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.never})})},fx=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.null})})},An=({isBigInt:e,value:t})=>{let r=i.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?i.callExpression({functionName:"BigInt",parameters:[r]}):r},ux=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n=t.type==="integer"&&t.format==="int64";if(typeof t.const=="number")return i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.number(t.const)]});let o=i.callExpression({functionName:n?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:r.placeholder,name:g.coerce}),name:g.bigint}):i.propertyAccessExpression({expression:r.placeholder,name:g.number})});return !n&&t.type==="integer"&&(o=i.callExpression({functionName:i.propertyAccessExpression({expression:o,name:g.int})})),t.exclusiveMinimum!==void 0?o=i.callExpression({functionName:i.propertyAccessExpression({expression:o,name:g.gt}),parameters:[An({isBigInt:n,value:t.exclusiveMinimum})]}):t.minimum!==void 0&&(o=i.callExpression({functionName:i.propertyAccessExpression({expression:o,name:g.gte}),parameters:[An({isBigInt:n,value:t.minimum})]})),t.exclusiveMaximum!==void 0?o=i.callExpression({functionName:i.propertyAccessExpression({expression:o,name:g.lt}),parameters:[An({isBigInt:n,value:t.exclusiveMaximum})]}):t.maximum!==void 0&&(o=i.callExpression({functionName:i.propertyAccessExpression({expression:o,name:g.lte}),parameters:[An({isBigInt:n,value:t.maximum})]})),o},dx=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o=false,s=[],a=t.required??[];for(let c in t.properties){let m=t.properties[c],l=a.includes(c),f=jt({optional:!l,plugin:e,schema:m,state:r});f.hasCircularReference&&(o=true),oe.lastIndex=0;let u;oe.test(c)?u=c.startsWith("-")?S__default.default.factory.createStringLiteral(c):S__default.default.factory.createNumericLiteral(c):u=c,(c.match(/^[0-9]/)&&c.match(/\D+/g)||c.match(/\W/g))&&!c.startsWith("'")&&!c.endsWith("'")&&(u=`'${c}'`),s.push(i.propertyAssignment({initializer:f.expression,name:u}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let c=jt({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.record}),parameters:[c.expression]}),hasCircularReference:c.hasCircularReference}}return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.object}),parameters:[S__default.default.factory.createObjectLiteralExpression(s,true)]}),hasCircularReference:o}},yx=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod"));if(typeof t.const=="string")return i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.string(t.const)]});let n=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.string})}),o=[];if(e.config.dates.offset&&o.push({key:"offset",value:true}),e.config.dates.local&&o.push({key:"local",value:true}),t.format)switch(t.format){case "date":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.date})});break;case "date-time":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.datetime}),parameters:o.length>0?[i.objectExpression({obj:o})]:[]});break;case "email":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.email})});break;case "ipv4":case "ipv6":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.ip})});break;case "time":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.time})});break;case "uri":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.url})});break;case "uuid":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.length}),parameters:[i.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.min}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.max}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&(n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),n},gx=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o=false;if(t.const&&Array.isArray(t.const)){let p=t.const.map(m=>i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[i.valueToExpression({value:m})]}));return {expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:p})]}),hasCircularReference:o}}let s=[];for(let p of t.items??[]){let c=jt({plugin:e,schema:p,state:r});c.hasCircularReference&&(o=true),s.push(c.expression);}return {expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:s})]}),hasCircularReference:o}},hx=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.undefined})})},Li=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.unknown})})},xx=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.void})})},dl=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return px({plugin:e,schema:t,state:r});case "boolean":return {expression:cx({plugin:e,schema:t})};case "enum":return {expression:mx({plugin:e,schema:t})};case "integer":case "number":return {expression:ux({plugin:e,schema:t})};case "never":return {expression:lx({plugin:e})};case "null":return {expression:fx({plugin:e})};case "object":return dx({plugin:e,schema:t,state:r});case "string":return {expression:yx({plugin:e,schema:t})};case "tuple":return gx({plugin:e,schema:t,state:r});case "undefined":return {expression:hx({plugin:e})};case "unknown":return {expression:Li({plugin:e})};case "void":return {expression:xx({plugin:e})}}},jt=({optional:e,plugin:t,schema:r,state:n})=>{let o={},s=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let a=n.circularReferenceTracker.includes(r.$ref);n.circularReferenceTracker.push(r.$ref),n.currentReferenceTracker.push(r.$ref);let p=t.api.getSelector("ref",r.$ref),c=t.getSymbol(p);if(a)c||(c=t.referenceSymbol(p)),o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:i.identifier({text:c.placeholder})})]})]}),o.hasCircularReference=r.circular;else {if(c)o.hasCircularReference=r.circular;else {let l=t.context.resolveIrRef(r.$ref);ws({id:r.$ref,plugin:t,schema:l,state:{...n,currentReferenceTracker:[r.$ref]}});}let m=t.referenceSymbol(p);o.expression=i.identifier({text:m.placeholder});}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=dl({plugin:t,schema:r,state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,o.typeName=a.anyType,t.config.metadata&&r.description&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.describe}),parameters:[i.stringLiteral({text:r.description})]}));}else if(r.items)if(r=J({schema:r}),r.items){let a=r.items.map(p=>{let c=jt({plugin:t,schema:p,state:n});return c.hasCircularReference&&(o.hasCircularReference=true),c.expression});if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.intersection}),parameters:a}):(o.expression=a[0],a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.and}),parameters:[c]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:a})]});}else o=jt({plugin:t,schema:r,state:n});else {let a=dl({plugin:t,schema:{type:"unknown"},state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,o.typeName=a.anyType;}if(o.expression&&(r.accessScope==="read"&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.readonly})})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.optional})})),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=An({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.default}),parameters:[p]}));}return o.hasCircularReference?o.typeName||(o.typeName="ZodTypeAny"):o.typeName&&(o.typeName=void 0),o},ws=({id:e,plugin:t,schema:r,state:n})=>{n||(n={circularReferenceTracker:[e],currentReferenceTracker:[e],hasCircularReference:false});let o=t.api.getSelector("ref",e),s=t.getSymbol(o);if(s)return;let a=jt({plugin:t,schema:r,state:n}),p=H(e);s=t.registerSymbol({exported:true,name:R({config:t.config.definitions,name:p}),selector:o});let c=t.config.definitions.types.infer.enabled?t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.definitions.types.infer,name:p}),selector:t.api.getSelector("type-infer-ref",e)}):void 0;ze({plugin:t,schema:r,symbol:s,typeInferSymbol:c,zodSchema:a});},yl=({plugin:e})=>{e.registerSymbol({external:Qr({plugin:e}),name:"z",selector:e.api.getSelector("import","zod")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{switch(t.type){case "operation":Ur({getZodSchema:r=>jt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":ws({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":ws({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":ws({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Zr({getZodSchema:r=>jt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var bx=({plugin:e,schema:t,state:r})=>{let n={},o=e.referenceSymbol(e.api.getSelector("import","zod")),s=i.propertyAccessExpression({expression:o.placeholder,name:g.array});if(!t.items)n.expression=i.callExpression({functionName:s,parameters:[Bi({plugin:e}).expression]});else {t=J({schema:t});let a=t.items.map(p=>{let c=Nt({plugin:e,schema:p,state:r});return c.hasCircularReference&&(n.hasCircularReference=true),c.expression});a.length===1?n.expression=i.callExpression({functionName:s,parameters:a}):(t.logicalOperator,n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:a})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:g.length}),parameters:[i.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:g.min}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:g.max}),parameters:[i.valueToExpression({value:t.maxItems})]}))),n},Sx=({plugin:e,schema:t})=>{let r={},n=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="boolean"?(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[i.ots.boolean(t.const)]}),r):(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.boolean})}),r)},Ox=({plugin:e,schema:t})=>{let r={},n=e.referenceSymbol(e.api.getSelector("import","zod")),o=[],s=[],a=false,p=true;for(let c of t.items??[])if(c.type==="string"&&typeof c.const=="string"){let m=i.stringLiteral({text:c.const});o.push(m),s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[m]}));}else if((c.type==="number"||c.type==="integer")&&typeof c.const=="number"){p=false;let m=i.ots.number(c.const);s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[m]}));}else if(c.type==="boolean"&&typeof c.const=="boolean"){p=false;let m=i.ots.boolean(c.const);s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[m]}));}else (c.type==="null"||c.const===null)&&(a=true);return s.length?(p&&o.length>0?r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.enum}),parameters:[i.arrayLiteralExpression({elements:o,multiLine:false})]}):s.length===1?r.expression=s[0]:r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:s,multiLine:s.length>3})]}),a&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.nullable}),parameters:[r.expression]})),r):Bi({plugin:e})},Rx=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.never})}),t},Tx=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.null})}),t},En=({isBigInt:e,value:t})=>{let r=i.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?i.callExpression({functionName:"BigInt",parameters:[r]}):r},Px=({plugin:e,schema:t})=>{let r={},n=t.type==="integer"&&t.format==="int64",o=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="number"?(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.literal}),parameters:[i.ots.number(t.const)]}),r):(r.expression=i.callExpression({functionName:n?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:o.placeholder,name:g.coerce}),name:g.bigint}):i.propertyAccessExpression({expression:o.placeholder,name:g.number})}),!n&&t.type==="integer"&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.int})})),t.exclusiveMinimum!==void 0?r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.gt}),parameters:[En({isBigInt:n,value:t.exclusiveMinimum})]}):t.minimum!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.gte}),parameters:[En({isBigInt:n,value:t.minimum})]})),t.exclusiveMaximum!==void 0?r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.lt}),parameters:[En({isBigInt:n,value:t.exclusiveMaximum})]}):t.maximum!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.lte}),parameters:[En({isBigInt:n,value:t.maximum})]})),r)},Ax=({plugin:e,schema:t,state:r})=>{let n={},o=[],s=t.required??[],a=e.referenceSymbol(e.api.getSelector("import","zod"));for(let p in t.properties){let c=t.properties[p],m=s.includes(p),l=Nt({optional:!m,plugin:e,schema:c,state:r});l.hasCircularReference&&(n.hasCircularReference=true),oe.lastIndex=0;let f;oe.test(p)?f=p.startsWith("-")?S__default.default.factory.createStringLiteral(p):S__default.default.factory.createNumericLiteral(p):f=p,(p.match(/^[0-9]/)&&p.match(/\D+/g)||p.match(/\W/g))&&!p.startsWith("'")&&!p.endsWith("'")&&(f=`'${p}'`),l.hasCircularReference?o.push(i.getAccessorDeclaration({name:f,returnType:l.typeName?i.propertyAccessExpression({expression:a.placeholder,name:l.typeName}):void 0,statements:[i.returnStatement({expression:l.expression})]})):o.push(i.propertyAssignment({initializer:l.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let p=Nt({plugin:e,schema:t.additionalProperties,state:r});return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:g.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:g.string}),parameters:[]}),p.expression]}),p.hasCircularReference&&(n.hasCircularReference=true),n.hasCircularReference?{...n,typeName:"ZodType"}:n}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:g.object}),parameters:[S__default.default.factory.createObjectLiteralExpression(o,true)]}),n.hasCircularReference?{...n,typeName:"ZodType"}:n},Ex=({plugin:e,schema:t})=>{let r={},n=e.referenceSymbol(e.api.getSelector("import","zod"));if(typeof t.const=="string")return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[i.ots.string(t.const)]}),r;r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.string})});let o=[];if(e.config.dates.offset&&o.push({key:"offset",value:true}),e.config.dates.local&&o.push({key:"local",value:true}),t.format)switch(t.format){case "date":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:n.placeholder,name:g.iso}),name:g.date})});break;case "date-time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:n.placeholder,name:g.iso}),name:g.datetime}),parameters:o.length>0?[i.objectExpression({obj:o})]:[]});break;case "email":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.email})});break;case "ipv4":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.ipv4})});break;case "ipv6":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.ipv6})});break;case "time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:n.placeholder,name:g.iso}),name:g.time})});break;case "uri":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.url})});break;case "uuid":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.length}),parameters:[i.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.min}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.max}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),r},Cx=({plugin:e,schema:t,state:r})=>{let n={},o=e.referenceSymbol(e.api.getSelector("import","zod"));if(t.const&&Array.isArray(t.const)){let a=t.const.map(p=>i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.literal}),parameters:[i.valueToExpression({value:p})]}));return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:a})]}),n}let s=[];for(let a of t.items??[]){let p=Nt({plugin:e,schema:a,state:r});s.push(p.expression),p.hasCircularReference&&(n.hasCircularReference=true);}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:s})]}),n},kx=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.undefined})}),t},Bi=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.unknown})}),t},Ix=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.void})}),t},gl=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return bx({plugin:e,schema:t,state:r});case "boolean":return Sx({plugin:e,schema:t});case "enum":return Ox({plugin:e,schema:t});case "integer":case "number":return Px({plugin:e,schema:t});case "never":return Rx({plugin:e});case "null":return Tx({plugin:e});case "object":return Ax({plugin:e,schema:t,state:r});case "string":return Ex({plugin:e,schema:t});case "tuple":return Cx({plugin:e,schema:t,state:r});case "undefined":return kx({plugin:e});case "unknown":return Bi({plugin:e});case "void":return Ix({plugin:e})}},Nt=({optional:e,plugin:t,schema:r,state:n})=>{let o={},s=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let a=n.circularReferenceTracker.includes(r.$ref),p=n.currentReferenceTracker.includes(r.$ref);n.circularReferenceTracker.push(r.$ref),n.currentReferenceTracker.push(r.$ref);let c=t.api.getSelector("ref",r.$ref),m=t.getSymbol(c);if(a)m||(m=t.referenceSymbol(c)),p?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.lazy}),parameters:[i.arrowFunction({returnType:i.keywordTypeNode({keyword:"any"}),statements:[i.returnStatement({expression:i.identifier({text:m.placeholder})})]})]}):o.expression=i.identifier({text:m.placeholder}),o.hasCircularReference=r.circular;else {if(m)o.hasCircularReference=r.circular;else {let f=t.context.resolveIrRef(r.$ref);qs({id:r.$ref,plugin:t,schema:f,state:n});}let l=t.referenceSymbol(c);o.expression=i.identifier({text:l.placeholder});}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=gl({plugin:t,schema:r,state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,t.config.metadata&&r.description&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.register}),parameters:[i.propertyAccessExpression({expression:s.placeholder,name:g.globalRegistry}),i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=J({schema:r}),r.items){let a=r.items.map(p=>Nt({plugin:t,schema:p,state:n}));if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.intersection}),parameters:a.map(c=>c.expression)}):(o.expression=a[0].expression,a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.and}),parameters:[c.hasCircularReference?i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:c.expression})]})]}):c.expression]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:a.map(p=>p.expression)})]});}else o=Nt({plugin:t,schema:r,state:n});else {let a=gl({plugin:t,schema:{type:"unknown"},state:n});o.expression=a.expression;}if(o.expression&&(r.accessScope==="read"&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.readonly})})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.optional}),parameters:[o.expression]}),o.typeName=g.ZodOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=En({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.default}),parameters:[p]}));}return o},qs=({id:e,plugin:t,schema:r,state:n})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...n,currentReferenceTracker:[e]},s=t.api.getSelector("ref",e),a=t.getSymbol(s);if(a&&!t.getSymbolValue(a))return;let p=Nt({plugin:t,schema:r,state:o}),c=H(e);a=t.registerSymbol({exported:true,name:R({config:t.config.definitions,name:c}),selector:s});let m=t.config.definitions.types.infer.enabled?t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.definitions.types.infer,name:c}),selector:t.api.getSelector("type-infer-ref",e)}):void 0;ze({plugin:t,schema:r,symbol:a,typeInferSymbol:m,zodSchema:p});},Vi=({plugin:e})=>{e.registerSymbol({external:Qr({plugin:e}),name:"z",selector:e.api.getSelector("import","zod")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{switch(t.type){case "operation":Ur({getZodSchema:r=>Nt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":qs({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":qs({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":qs({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Zr({getZodSchema:r=>Nt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var hl=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return yl(e);case 4:return Vi(e);case "mini":return ul(e);default:return Vi(e)}};var $s={api:new js({name:"zod"}),config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:hl,name:"zod",resolveConfig:(e,t)=>{let n=t.package.getVersion("zod"),o=()=>n&&(n.major===4||n.major===3)?n.major:4,s=a=>{if(!a)return o();if(!n)return a;if((a===4||a===3||a==="mini")&&!t.package.satisfies(n,">=3.25.0 <5.0.0")){let p=o();return console.warn(`\u{1F50C} ${Z__default.default.yellow("Warning:")} Installed ${Z__default.default.cyan("zod")} ${Z__default.default.cyan(`v${n.version}`)} does not support compatibility version ${Z__default.default.yellow(String(a))}, using ${Z__default.default.yellow(String(p))}.`),p}return a};e.config.compatibilityVersion=s(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:Ge,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:{...Ge,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:Ge,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:{...Ge,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:Ge,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:{...Ge,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:Ge,value:c.infer})})},value:a.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}WebhookRequest",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}WebhookRequestZodType"}}},mappers:{...Ge,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:Ge,value:c.infer})})},value:a.types})})},value:e.config.webhooks});},tags:["validator"]};var Ms={"@angular/common":ko,"@hey-api/client-angular":No,"@hey-api/client-axios":qo,"@hey-api/client-fetch":Mo,"@hey-api/client-next":Lo,"@hey-api/client-nuxt":Bo,"@hey-api/client-ofetch":Ho,"@hey-api/schemas":Zo,"@hey-api/sdk":Go,"@hey-api/transformers":ts,"@hey-api/typescript":os,"@pinia/colada":ps,"@tanstack/angular-query-experimental":hs,"@tanstack/react-query":bs,"@tanstack/solid-query":Os,"@tanstack/svelte-query":Ts,"@tanstack/vue-query":As,fastify:Cs,"legacy/angular":_o,"legacy/axios":Wo,"legacy/fetch":Ko,"legacy/node":zo,"legacy/xhr":Qo,valibot:vs,zod:$s};var Hi=["@hey-api/typescript","@hey-api/sdk"],jx=({dependencies:e,userPlugins:t,userPluginsConfig:r})=>{let n=new Set,o=new Set,s={},a=p=>{if(n.has(p))throw new Error(`Circular reference detected at '${p}'`);if(o.has(p))return;n.add(p);let c=Ms[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 l={...c,...m,config:{...c?.config,...m?.config},dependencies:new Set([...c?.dependencies||[],...m?.dependencies||[]])};if(l.resolveConfig){let f={package:Qn(e),pluginByTag:(u,d={})=>{let{defaultPlugin:y,errorMessage:h}=d;for(let x of t){let b=Ms[x]||r[x];if(b&&b.tags?.includes(u)&&x!==p)return x}if(y){let x=Ms[y]||r[y];if(x&&x.tags?.includes(u)&&y!==p)return y}throw new Error(h||`missing plugin - no plugin with tag "${u}" found`)},valueToObject:Pe};l.resolveConfig(l,f);}for(let f of l.dependencies)a(f);n.delete(p),o.add(p),s[p]=l;};for(let p of t)a(p);return {pluginOrder:Array.from(o),plugins:s}},Nx=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"),xl=({dependencies:e,userConfig:t})=>{let r={},n=Hi;t.plugins&&(t.plugins=t.plugins.filter(s=>typeof s=="string"&&s||typeof s!="string"&&s.name),t.plugins.length===1&&Nx(t.plugins[0])?n=[...Hi,...t.plugins]:n=t.plugins);let o=n.map(s=>{if(typeof s=="string")return s;let a=s.name;return a&&(s.handler?r[a]=s:(r[a]={config:{...s}},delete r[a].config.name)),a}).filter(Boolean);return jx({dependencies:e,userPlugins:o,userPluginsConfig:r})};var $x=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),bl=async({logger:e,userConfigs:t})=>{let r=[],n={},o=e.timeEvent("load");for(let p of t){let c;if(p?.configFile){let d=p.configFile.split(".");c=d.slice(0,d.length-1).join(".");}let m=e.timeEvent("c12"),{config:l,configFile:f}=await c12.loadConfig({configFile:c,name:"openapi-ts"});m.timeEnd(),Object.keys(n).length||(n=Ta(Object.keys(l).length?f:void 0));let u=l instanceof Array?l.map(d=>Ws(d,p)):[Ws(l,p)];for(let d of u){let y=_s(d);if(d.output instanceof Array){let h=y.length,x=d.output.length;if(x>1)if(h!==x){console.warn(`\u2699\uFE0F ${Z__default.default.yellow("Warning:")} You provided ${Z__default.default.cyan(String(h))} ${Z__default.default.cyan(h===1?"input":"inputs")} and ${Z__default.default.yellow(String(x))} ${Z__default.default.yellow("outputs")}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let b of d.output)r.push({...d,input:y,output:b});}else d.output.forEach((b,k)=>{r.push({...d,input:y[k],output:b});});else r.push({...d,input:y,output:d.output[0]??""});}else r.push({...d,input:y});}}o.timeEnd();let s=[],a=e.timeEvent("build");for(let p of r){let{base:c,configFile:m="",dryRun:l=false,experimentalParser:f=true,exportCore:u=true,name:d,request:y,useOptions:h=true}=p,x=p.interactive!==void 0?p.interactive:$x(),b=Yr(p),k=_s(p),P=Oa(p),I=Aa(p),v=[];k.length||v.push(new Xe("missing input - which OpenAPI specification should we use to generate your output?")),P.path||v.push(new Xe("missing output - where should we generate your output?")),h||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"),P.path=L__default.default.resolve(process.cwd(),P.path);let w;try{w=xl({dependencies:n,userConfig:p});}catch(F){v.push(F),w={pluginOrder:[],plugins:{}};}let V=ga({...w,base:c,configFile:m,dryRun:l,experimentalParser:f,exportCore:false,input:k,interactive:x,logs:b,name:d,output:P,parser:I,request:y,useOptions:h});V.exportCore=W(V)?u:false;let M=s.length;if(b.level==="debug"){let F=Z__default.default.gray(`[Job ${M+1}] `);console.warn(`${F}${Z__default.default.cyan("config:")}`,V);}s.push({config:V,errors:v,jobIndex:M});}return a.timeEnd(),{dependencies:n,results:s}};var Ds=e=>{switch(e){case "legacy/angular":return "AngularHttpRequest";case "legacy/axios":return "AxiosHttpRequest";case "legacy/fetch":return "FetchHttpRequest";case "legacy/node":return "NodeHttpRequest";case "legacy/xhr":return "XHRHttpRequest";default:return ""}};var Sl=async(e,t,r,n)=>{let o=T(),s=E(o),a=n.client({$config:o,...r,httpRequest:Ds(s.name),models:dn(r.models),services:dn(r.services)});X(o)&&(Be(t),Se__default.default.writeFileSync(L__default.default.resolve(t,`${X(o)}.ts`),a));};var Ol=async(e,t,r)=>{let n=T();if(n.exportCore){let o=E(n),s={httpRequest:Ds(o.name),server:n.base!==void 0?n.base:t.server,version:t.version};if(Se__default.default.rmSync(L__default.default.resolve(e),{force:true,recursive:true}),Se__default.default.mkdirSync(L__default.default.resolve(e),{recursive:true}),await Se__default.default.writeFileSync(L__default.default.resolve(e,"OpenAPI.ts"),r.core.settings({$config:n,...s})),await Se__default.default.writeFileSync(L__default.default.resolve(e,"ApiError.ts"),r.core.apiError({$config:n,...s})),await Se__default.default.writeFileSync(L__default.default.resolve(e,"ApiRequestOptions.ts"),r.core.apiRequestOptions({$config:n,...s})),await Se__default.default.writeFileSync(L__default.default.resolve(e,"ApiResult.ts"),r.core.apiResult({$config:n,...s})),o.name!=="legacy/angular"&&await Se__default.default.writeFileSync(L__default.default.resolve(e,"CancelablePromise.ts"),r.core.cancelablePromise({$config:n,...s})),await Se__default.default.writeFileSync(L__default.default.resolve(e,"request.ts"),r.core.request({$config:n,...s})),X(n)&&(await Se__default.default.writeFileSync(L__default.default.resolve(e,"BaseHttpRequest.ts"),r.core.baseHttpRequest({$config:n,...s})),await Se__default.default.writeFileSync(L__default.default.resolve(e,`${s.httpRequest}.ts`),r.core.httpRequest({$config:n,...s}))),n.request){let a=L__default.default.resolve(process.cwd(),n.request);if(!await Se__default.default.existsSync(a))throw new Error(`Custom request file "${a}" does not exists`);await Se__default.default.copyFileSync(a,L__default.default.resolve(e,"request.ts"));}}};var Rl=({files:e})=>{let t=T();e.index=new De({dir:t.output.path,id:"index",name:"index.ts"}),X(t)&&e.index.add(i.exportNamedDeclaration({exports:X(t),module:`./${X(t)}`})),t.exportCore&&(e.index.add(i.exportNamedDeclaration({exports:"ApiError",module:"./core/ApiError"})),t.plugins["@hey-api/sdk"]?.config.response==="response"&&e.index.add(i.exportNamedDeclaration({exports:{asType:true,name:"ApiResult"},module:"./core/ApiResult"})),X(t)&&e.index.add(i.exportNamedDeclaration({exports:"BaseHttpRequest",module:"./core/BaseHttpRequest"})),E(t).name!=="legacy/angular"&&e.index.add(i.exportNamedDeclaration({exports:["CancelablePromise","CancelError"],module:"./core/CancelablePromise"})),e.index.add(i.exportNamedDeclaration({exports:["OpenAPI",{asType:true,name:"OpenAPIConfig"}],module:"./core/OpenAPI"}))),Object.keys(e).sort().forEach(r=>{let n=e[r];r==="index"||n.isEmpty()||n.exportFromIndex&&e.index.add(i.exportAllDeclaration({module:`./${n.nameWithoutExtension()}`}));});};var Tl=async({client:e,openApi:t,templates:r})=>{let n=T(),o=t;if(e){if(n.plugins["@hey-api/sdk"]?.config.include&&n.plugins["@hey-api/sdk"].config.asClass){let c=new RegExp(n.plugins["@hey-api/sdk"].config.include);e.services=e.services.filter(m=>c.test(m.name));}if(n.plugins["@hey-api/typescript"]?.config.include){let c=new RegExp(n.plugins["@hey-api/typescript"].config.include);e.models=e.models.filter(m=>c.test(m.name));}}let s=L__default.default.resolve(n.output.path);n.output.clean&&qn(s);let a=E(n);if(!W(n)&&"bundle"in a.config&&a.config.bundle){let c={importFileExtension:n.output.importFileExtension};vo({meta:c,outputPath:s,plugin:a});}await Sl(o,s,e,r),await Ol(L__default.default.resolve(n.output.path,"core"),e,r);let p={};for(let c of n.pluginOrder){let m=n.plugins[c],l=(m.output??"").split("/"),f=L__default.default.resolve(n.output.path,...l.slice(0,l.length-1));p[m.name]=new De({dir:f,id:`legacy-unused-${m.name}`,name:`${l[l.length-1]}.ts`}),m.handlerLegacy?.({client:e,files:p,openApi:o,plugin:m});}Rl({files:p}),Object.entries(p).forEach(([c,m])=>{n.dryRun||(c==="index"?m.write(`
|
|
44
|
+
`}),V):I.nodes.push(V),I.methods.add(y.methodName),o.set(b.id,I);});});let p=e.registerSymbol({exported:false,name:"_HeyApiClient"}),c=m=>{if(s.has(m.id))return;if(m.classes.size)for(let u of m.classes){let d=o.get(u);c(d),m.nodes.push(i.propertyDeclaration({initializer:e.config.instance?i.newExpression({argumentsArray:e.config.instance?[i.objectExpression({multiLine:false,obj:[{key:"client",value:i.propertyAccessExpression({expression:i.this(),name:"_client"})}]})]:[],expression:i.identifier({text:e.referenceSymbol(d.id).placeholder})}):i.identifier({text:e.referenceSymbol(d.id).placeholder}),modifier:e.config.instance?void 0:"static",name:N({case:"camelCase",value:d.className})}));}let l=e.registerSymbol({exported:true,name:m.className,selector:e.api.getSelector("class",m.className)}),f=i.classDeclaration({decorator:m.root&&r?{args:[{providedIn:"root"}],name:e.referenceSymbol(e.api.getSelector("Injectable")).placeholder}:void 0,exportClass:l.exported,extendedClasses:e.config.instance?[p.placeholder]:void 0,name:l.placeholder,nodes:m.nodes});e.setSymbolValue(l,f),s.add(l.id);};if(a.length){let m=i.classDeclaration({exportClass:p.exported,name:p.placeholder,nodes:a});e.setSymbolValue(p,m);}for(let m of o.values())c(m);},Xg=({plugin:e})=>{let t=E(e.context.config),r=t.name==="@hey-api/client-nuxt";e.forEach("operation",({operation:n})=>{let o=ae({context:e.context,operation:n}),s=e.getPluginOrThrow("@hey-api/typescript"),a=r?e.getSymbol(s.api.getSelector("response",n.id)):void 0,p=bi({isRequiredOptions:o,operation:n,plugin:e}),c=Si({isRequiredOptions:o,opParameters:p,operation:n,plugin:e}),m=e.registerSymbol({name:ut({config:e.context.config,handleIllegal:true,id:n.id,operation:n}),selector:e.api.getSelector("function",n.id)}),l=i.constVariable({comment:G({operation:n}),exportConst:true,expression:i.arrowFunction({parameters:p.parameters,returnType:void 0,statements:c,types:r?[{default:i.ots.string("$fetch"),extends:i.typeNode(e.referenceSymbol(e.api.getSelector("Composable")).placeholder),name:Fr},{default:a?i.typeReferenceNode({typeName:a.placeholder}):i.typeNode("undefined"),extends:a?i.typeReferenceNode({typeName:a.placeholder}):void 0,name:lt}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]}),name:m.placeholder});e.setSymbolValue(m,l);});},um=({plugin:e})=>{let t=ft(e.context.config);e.registerSymbol({external:t,name:"formDataBodySerializer",selector:e.api.getSelector("formDataBodySerializer")}),e.registerSymbol({external:t,name:"urlSearchParamsBodySerializer",selector:e.api.getSelector("urlSearchParamsBodySerializer")}),e.registerSymbol({external:t,name:"buildClientParams",selector:e.api.getSelector("buildClientParams")});let r=E(e.context.config),n=r.name==="@hey-api/client-angular";r.name==="@hey-api/client-nuxt"&&e.registerSymbol({external:t,meta:{kind:"type"},name:"Composable",selector:e.api.getSelector("Composable")}),n&&e.config.asClass&&e.registerSymbol({external:"@angular/core",name:"Injectable",selector:e.api.getSelector("Injectable")}),fm({plugin:e}),e.config.asClass?Zg({plugin:e}):Xg({plugin:e});};var Go={api:new Xo({name:"@hey-api/sdk"}),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:um,handlerLegacy:lm,name:"@hey-api/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 Jo=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var dm=({dataExpression:e,schema:t})=>{if(t.type!=="integer"||t.format!=="int64")return;let r=e!==void 0?i.callExpression({functionName:"BigInt",parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:e,name:"toString"})})]}):void 0;if(r){if(typeof e=="string")return [r];if(e)return [i.assignment({left:e,right:r})]}},ym=({dataExpression:e,schema:t})=>{if(t.type!=="string"||!(t.format==="date"||t.format==="date-time"))return;let r=i.identifier({text:"Date"});if(typeof e=="string")return [i.newExpression({argumentsArray:[i.identifier({text:e})],expression:r})];if(e)return [i.assignment({left:e,right:i.newExpression({argumentsArray:[e],expression:r})})]};var Yo="data",hn=e=>e.map(t=>S__default.default.isStatement(t)?t:i.expressionToStatement({expression:t})),hm=({node:e})=>e.kind===S__default.default.SyntaxKind.ReturnStatement,xm=({plugin:e,schema:t})=>{let r=i.identifier({text:Yo}),n=xn({dataExpression:r,plugin:e,schema:t});return n.length&&!hm({node:n[n.length-1]})&&n.push(i.returnStatement({expression:r})),n},xn=({dataExpression:e,plugin:t,schema:r})=>{if(r.$ref){let n=t.api.getSelector("response-ref",r.$ref);if(!t.getSymbol(n)){let s=t.registerSymbol({name:R({config:{case:"camelCase",name:"{{name}}SchemaResponseTransformer"},name:H(r.$ref)}),selector:n}),a=t.context.resolveIrRef(r.$ref),p=xm({plugin:t,schema:a});if(p.length){let c=i.constVariable({expression:i.arrowFunction({async:false,multiLine:true,parameters:[{name:Yo,type:i.keywordTypeNode({keyword:"any"})}],statements:hn(p)}),name:s.placeholder});t.setSymbolValue(s,c);}else t.setSymbolValue(s,null);}let o=t.referenceSymbol(n);if(t.getSymbolValue(o)!==null){let s=i.callExpression({functionName:o.placeholder,parameters:[e]});if(e)return typeof e=="string"&&e==="item"?[i.returnStatement({expression:s})]:[typeof e=="string"?s:i.assignment({left:e,right:s})]}return []}if(r.type==="array"){if(!e||typeof e=="string")return [];let n=r.items?xn({dataExpression:"item",plugin:t,schema:r.items?.[0]?r.items[0]:{...r,type:void 0}}):[];if(!n.length)return [];let o=hn(n);return o.some(a=>hm({node:a}))||o.push(i.returnStatement({expression:i.identifier({text:"item"})})),[i.assignment({left:e,right:i.callExpression({functionName:i.propertyAccessExpression({expression:e,name:"map"}),parameters:[i.arrowFunction({multiLine:true,parameters:[{name:"item",type:"any"}],statements:o})]})})]}if(r.type==="object"){let n=[],o=r.required??[];for(let s in r.properties){let a=r.properties[s],p=i.propertyAccessExpression({expression:e||Yo,name:s}),c=xn({dataExpression:p,plugin:t,schema:a});if(!c.length)continue;let m=!a.items?.find(f=>f.type==="null");o.includes(s)&&m?n=n.concat(c):n.push(i.ifStatement({expression:p,thenStatement:i.block({statements:hn(c)})}));}return n}if(r.items){if(r.items.length===1)return xn({dataExpression:"item",plugin:t,schema:r.items[0]});let n=[];if(r.logicalOperator==="and"||r.items.length===2&&r.items.find(o=>o.type==="null"||o.type==="void")){for(let o of r.items){let s=xn({dataExpression:e||"item",plugin:t,schema:o});if(s.length)if(e)n=n.concat(s);else {let a=i.identifier({text:"item"});n.push(i.ifStatement({expression:a,thenStatement:i.block({statements:hn(s)})}),i.returnStatement({expression:a}));}}return n}r.type!=="enum"&&((r.items??[]).every(o=>["boolean","integer","null","number","string"].includes(o.type))||console.warn(`\u2757\uFE0F Transformers warning: schema ${JSON.stringify(r)} is too complex and won't be currently processed. This will likely produce an incomplete transformer which is not what you want. Please open an issue if you'd like this improved https://github.com/hey-api/openapi-ts/issues`));}for(let n of t.config.transformers){let o=n({config:t.config,dataExpression:e,schema:r});if(o)return o}return []},bm=({plugin:e})=>{e.forEach("operation",({operation:t})=>{let{response:r}=tt(t);if(!r)return;if(r.items&&r.items.length>1){e.context.config.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${B(t)} has ${r.items.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`);return}let n=e.getPluginOrThrow("@hey-api/typescript"),o=e.getSymbol(n.api.getSelector("response",t.id));if(!o)return;let s=e.registerSymbol({exported:true,name:R({config:{case:"camelCase",name:"{{name}}ResponseTransformer"},name:t.id}),selector:e.api.getSelector("response",t.id)}),a=xm({plugin:e,schema:r});if(a.length){let p=i.constVariable({exportConst:s.exported,expression:i.arrowFunction({async:true,multiLine:true,parameters:[{name:Yo,type:i.keywordTypeNode({keyword:"any"})}],returnType:i.typeReferenceNode({typeArguments:[i.typeReferenceNode({typeName:o.placeholder})],typeName:"Promise"}),statements:hn(a)}),name:s.placeholder});e.setSymbolValue(s,p);}else e.setSymbolValue(s,null);});};var Jg="$OpenApiTs",fe={$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:""},Yg=({comments:e,leadingComment:t,meta:r,obj:n,onNode:o,...s})=>{if(!r)return;let{created:a,name:p}=Me({create:true,meta:r,...s});if(a){let m=T().plugins["@hey-api/typescript"],l=i.enumDeclaration({asConst:typeof m?.config.enums=="object"&&m.config.enums.mode==="typescript-const",comments:e,leadingComment:t,name:p,obj:n});o(l);}},It=({comment:e,meta:t,onCreated:r,onNode:n,type:o,...s})=>{if(!t)return {created:false,name:""};let a=Me({create:true,meta:t,...s}),{created:p,name:c}=a;if(p){let m=i.typeAliasDeclaration({comment:e,exportType:true,name:c,type:o});n(m),r?.(c);}return a},eh=e=>{let t=[];Sm(e),e.model.enums.forEach(r=>rh({...e,model:r,onNode:n=>{t.push(n);}})),t.length&&e.onNode(i.namespaceDeclaration({name:e.model.name,statements:t}));},th=({client:e,model:t,onNode:r})=>{let n=T(),o={},s={};t.enum.forEach(c=>{let{key:m,value:l}=co(c);o[m]=l;let f=c.customDescription||c.description;f&&(s[m]=[z(f)]);});let a=[t.description&&z(t.description),t.deprecated&&"@deprecated"],p=n.plugins["@hey-api/typescript"];if(p?.config&&typeof p.config.enums=="object"&&p.config.enums.enabled&&(p.config.enums.mode==="typescript"||p.config.enums.mode==="typescript-const")){Yg({asConst:p.config.enums.mode==="typescript-const",client:e,comments:s,leadingComment:a,meta:t.meta,obj:o,onNode:r});return}It({client:e,comment:a,meta:t.meta,onCreated:c=>{let m=n.plugins["@hey-api/typescript"];if(m?.config&&typeof m.config.enums=="object"&&m.config.enums.enabled&&m.config.enums.mode==="javascript"){let l=i.objectExpression({multiLine:true,obj:Object.entries(o).map(([u,d])=>({comments:s[u],key:u,value:d})),unescape:true}),f=i.constVariable({assertion:"const",comment:a,exportConst:true,expression:l,name:c});r(f);}},onNode:r,type:yc(t.enum)});},rh=({model:e,onNode:t})=>{let r={},n={};e.enum.forEach(a=>{let{key:p,value:c}=co(a);r[p]=c;let m=a.customDescription||a.description;m&&(n[p]=[z(m)]);});let s=T().plugins["@hey-api/typescript"];t(i.enumDeclaration({asConst:typeof s?.config.enums=="object"&&s.config.enums.mode==="typescript-const",comments:n,leadingComment:[e.description&&z(e.description),e.deprecated&&"@deprecated"],name:e.meta?.name||e.name,obj:r}));},Sm=({client:e,model:t,onNode:r})=>{It({client:e,comment:[t.description&&z(t.description),t.deprecated&&"@deprecated"],meta:t.meta,onNode:r,type:$e(t)});},nh=e=>{switch(e.model.export){case "all-of":case "any-of":case "one-of":case "interface":return eh(e);case "enum":return th(e);default:return Sm(e)}},oh=({client:e,onNode:t})=>{let r={},n=T();if(!n.plugins["@hey-api/sdk"]&&!n.plugins["@hey-api/typescript"]?.config.tree)return;let o=W(n);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(f=>{m.res[f.code]=f;});}if(p.parameters.length>0){let f={mediaType:null,...fe,in:"body",name:"body",prop:"body"},u=p.parameters.filter(b=>b.in==="body");u.length||(u=p.parameters.filter(b=>b.in==="formData")),u.length===1?f={...fe,...u[0],in:"body",isRequired:u[0].isRequired,name:"body",prop:"body"}:u.length>1&&(f={...fe,in:"body",isRequired:u.some(b=>b.isRequired),mediaType:"multipart/form-data",name:"body",prop:"body",properties:u});let d={...fe,in:"header",isRequired:mt(p.parameters.filter(b=>b.in==="header")),mediaType:null,name:o?"header":"headers",prop:o?"header":"headers",properties:p.parameters.filter(b=>b.in==="header").sort(un)},y={...fe,in:"path",isRequired:mt(p.parameters.filter(b=>b.in==="path")),mediaType:null,name:"path",prop:"path",properties:p.parameters.filter(b=>b.in==="path").sort(un)},h={...fe,in:"query",isRequired:mt(p.parameters.filter(b=>b.in==="query")),mediaType:null,name:"query",prop:"query",properties:p.parameters.filter(b=>b.in==="query").sort(un)},x=o?dn([...p.parameters]):[f,d,y,h].filter(b=>b.properties.length||b.$refs.length||b.mediaType);m.req=x,It({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:mr,onNode:t,type:$e({...fe,properties:x})});}let l=p.responses.filter(f=>f.responseTypes.includes("success"));if(l.length>0){It({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:dt,onNode:t,type:$e({...fe,export:"any-of",properties:l})});let f=p.responses.filter(u=>u.responseTypes.includes("error"));o||It({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:Hr,onNode:t,type:$e(f.length?{...fe,export:"one-of",properties:f}:{...fe,base:"unknown"})});}}let s=Object.entries(r).map(([a,p])=>{let c=Object.entries(p).map(([l,f])=>{let u=l,d=[];if(f.req){let h=f.$ref,{name:x}=Me({client:e,meta:{$ref:h,name:h},nameTransformer:mr}),b={...fe,base:x,export:"reference",isRequired:true,name:"req",properties:[],type:x};d=[...d,b];}if(f.res){let h=Object.entries(f.res).map(([b,k])=>({...fe,...k,isRequired:true,name:String(b)})),x={...fe,isRequired:true,name:"res",properties:h};d=[...d,x];}return {...fe,isRequired:true,name:u.toLocaleLowerCase(),properties:d}}).filter(Boolean);return {...fe,isRequired:true,name:`'${a}'`,properties:c}});n.plugins["@hey-api/typescript"]?.config.tree&&It({client:e,meta:{$ref:"@hey-api/openapi-ts",name:Jg},onNode:t,type:$e({...fe,properties:s})});},Om=({client:e,files:t,plugin:r})=>{let n=T();t.types=new De({dir:n.output.path,exportFromIndex:r.config.exportFromIndex,id:"types",name:"types.ts"});let o=s=>{t.types?.add(s);};for(let s of e.models)nh({client:e,model:s,onNode:o});oh({client:e,onNode:o});};var _t="data",sh=e=>e.base==="unknown"&&e.export==="generic"&&e.type==="unknown",Rm=({client:e,model:t})=>t.$refs.map(n=>{let o=e.models.find(s=>s.meta?.$ref===n);if(!o)throw new Error(`Ref ${n} could not be found. Transformers cannot be generated without having access to all refs.`);return o}),Tm=e=>{let t=e.model.meta.name,{name:r}=It({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:mm,onCreated:o=>{let s=es({...e,meta:{$ref:`transformers/${t}`,name:o},path:[_t]});Pm({...e,async:false,name:o,statements:s});},type:`(${_t}: any) => ${t}`});return {created:!!e.client.types[r],name:r}},ih=e=>{let{model:t}=e,r=Rm(e);if(r.length===1){let{created:n,name:o}=Tm({...e,model:r[0]});return n?[i.transformArrayMutation({path:e.path,transformerName:o})]:[]}return yn(t)||t.link&&!Array.isArray(t.link)&&t.link.export==="any-of"&&t.link.properties.find(n=>yn(n))?[i.transformArrayMap({path:e.path,transformExpression:i.conditionalExpression({condition:i.identifier({text:"item"}),whenFalse:i.identifier({text:"item"}),whenTrue:i.transformNewDate({parameterName:"item"})})})]:[]},ah=e=>{let{model:t}=e,r=[...e.path,t.name];return t.type==="string"&&t.export!=="array"&&yn(t)?[i.transformDateMutation({path:r})]:es({...e,model:t,path:r})},es=e=>{let{model:t}=e;switch(t.export){case "array":return ih(e);case "interface":return t.properties.flatMap(r=>ah({...e,model:r}));case "reference":{if(t.$refs.length!==1)return [];let r=Rm(e),{created:n,name:o}=Tm({...e,model:r[0]});return n?t.in==="response"?[i.expressionToStatement({expression:i.callExpression({functionName:o,parameters:[_t]})})]:i.transformFunctionMutation({path:e.path,transformerName:o}):[]}default:return []}},Pm=({async:e,client:t,name:r,onNode:n,onRemoveNode:o,statements:s})=>{let a={created:false,name:r};if(!s.length)return xc({client:t,name:r}),o?.(),a;let p=i.arrowFunction({async:e,multiLine:true,parameters:[{name:_t}],statements:[...s,i.returnVariable({expression:_t})]}),c=i.constVariable({exportConst:true,expression:p,name:r,typeName:r});return n(c),{created:true,name:r}},Am=({client:e,files:t})=>{let r=T(),n=s=>{t.types?.add(s);},o=()=>{t.types?.removeNode_LEGACY();};for(let s of e.services)for(let a of s.operations){let p=a.responses.filter(l=>l.responseTypes.includes("success"));if(!p.length)continue;let c=p.filter(l=>!sh(l));if(!c.length)continue;if(c.length>1){r.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${B(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=dt(a.name);It({client:e,meta:{$ref:`transformers/${m}`,name:m},nameTransformer:Ai,onCreated:l=>{let f=p.length>1?p.flatMap(u=>{let d=es({client:e,meta:{$ref:`transformers/${m}`,name:m},model:u,onNode:n,onRemoveNode:o,path:[_t]});return d.length?[i.ifStatement({expression:i.safeAccessExpression(["data"]),thenStatement:i.block({statements:d})})]:[]}):es({client:e,meta:{$ref:`transformers/${m}`,name:m},model:p[0],onNode:n,onRemoveNode:o,path:[_t]});Pm({async:true,client:e,name:l,onNode:n,onRemoveNode:o,statements:f});},onNode:n,type:`(${_t}: any) => Promise<${m}>`});}};var ts={api:new Jo({name:"@hey-api/transformers"}),config:{bigInt:true,dates:true,exportFromIndex:false,transformers:[],typeTransformers:[]},dependencies:["@hey-api/typescript"],handler:bm,handlerLegacy:Am,name:"@hey-api/transformers",resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,ym]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,dm]);},tags:["transformer"]};var Cm=({context:e,name:t})=>(oe.lastIndex=0,oe.test(t)?t.startsWith("-")?S__default.default.factory.createStringLiteral(t):S__default.default.factory.createNumericLiteral(t):N({case:e.config.output.case,value:t}));var Oe=({schema:e})=>{let t=[];return e.title&&t.push(z(e.title)),e.description&&t.push(z(e.description)),e.deprecated&&t.push("@deprecated"),t.length?t:void 0};var rs=i.keywordTypeNode({keyword:"string"}),mh=({server:e})=>{let t=it(e.url);return t.protocol&&t.host?i.literalTypeNode({literal:i.stringLiteral({text:e.url})}):i.templateLiteralType({value:[t.protocol||rs,"://",t.host||rs,t.port?`:${t.port}`:"",t.path||""]})},km=({plugin:e,servers:t,symbolClientOptions:r})=>{let n=E(e.context.config),o=t.map(p=>mh({server:p}));t.length?"strictBaseUrl"in n.config&&n.config.strictBaseUrl||o.push(i.typeIntersectionNode({types:[rs,S__default.default.factory.createTypeLiteralNode([])]})):o.push(rs);let s=i.typeInterfaceNode({properties:[{name:ge(e.context.config),type:i.typeUnionNode({types:o})}],useLegacyResolution:false}),a=i.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:s});e.setSymbolValue(r,a);};var lh=({plugin:e,schema:t})=>{let r=[];return {obj:(t.items??[]).map((o,s)=>{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=`${s}`,p&&(p=N({case:e.config.enums.case,stripLeadingSeparators:false,value:p}),oe.lastIndex=0,oe.test(p)&&e.config.enums.enabled&&(e.config.enums.mode==="typescript"||e.config.enums.mode==="typescript-const")&&(p=`_${p}`)),{comments:Oe({schema:o}),key:p,value:o.const}}),typeofItems:r}},Im=({plugin:e,schema:t,symbol:r,type:n})=>{if(t.type==="enum"&&e.config.enums.enabled){let s=lh({plugin:e,schema:t});if(e.config.enums.mode==="javascript"){e.config.enums.constantsIgnoreNull&&s.typeofItems.includes("object")&&(s.obj=s.obj.filter(m=>m.value!==null));let a=i.constVariable({assertion:"const",comment:Oe({schema:t}),exportConst:true,expression:i.objectExpression({multiLine:true,obj:s.obj}),name:r.placeholder}),p=i.typeOfExpression({text:r.placeholder}),c=i.typeAliasDeclaration({comment:Oe({schema:t}),exportType:true,name:r.placeholder,type:i.indexedAccessTypeNode({indexType:i.typeOperatorNode({operator:"keyof",type:p}),objectType:p})});e.setSymbolValue(r,[a,c]);return}else if((e.config.enums.mode==="typescript"||e.config.enums.mode==="typescript-const")&&!s.typeofItems.some(p=>p!=="number"&&p!=="string")){let p=i.enumDeclaration({asConst:e.config.enums.mode==="typescript-const",leadingComment:Oe({schema:t}),name:r.placeholder,obj:s.obj});e.setSymbolValue(r,p);return}}let o=i.typeAliasDeclaration({comment:Oe({schema:t}),exportType:r.exported,name:r.placeholder,type:n});e.setSymbolValue(r,o);};var Ci=({parameters:e})=>{let t={type:"object"};if(e){let r={},n=[];for(let o in e){let s=e[o];r[s.name]=J({detectFormat:false,schema:s.schema}),s.required&&n.push(s.name);}t.properties=r,n.length&&(t.required=n);}return t},fh=({operation:e,plugin:t})=>{let r={type:"object"},n=[];r.properties||(r.properties={}),e.body?(r.properties.body=e.body.schema,e.body.required&&n.push("body")):r.properties.body={type:"never"},e.parameters?.header&&(r.properties.headers=Ci({parameters:e.parameters.header}),r.properties.headers.required&&n.push("headers")),e.parameters?.path?(r.properties.path=Ci({parameters:e.parameters.path}),r.properties.path.required&&n.push("path")):r.properties.path={type:"never"},e.parameters?.query?(r.properties.query=Ci({parameters:e.parameters.query}),r.properties.query.required&&n.push("query")):r.properties.query={type:"never"},r.properties.url={const:e.path,type:"string"},n.push("url"),r.required=n;let o=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.requests,name:e.id}),selector:t.api.getSelector("data",e.id)}),s=ne({plugin:t,schema:r}),a=i.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:s});t.setSymbolValue(o,a);},vm=({operation:e,plugin:t})=>{fh({operation:e,plugin:t});let{error:r,errors:n,response:o,responses:s}=tt(e);if(n){let a=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.errors,name:e.id}),selector:t.api.getSelector("errors",e.id)}),p=ne({plugin:t,schema:n}),c=i.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:p});if(t.setSymbolValue(a,c),r){let m=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),selector:t.api.getSelector("error",e.id)}),l=i.indexedAccessTypeNode({indexType:i.typeOperatorNode({operator:"keyof",type:i.typeReferenceNode({typeName:a.placeholder})}),objectType:i.typeReferenceNode({typeName:a.placeholder})}),f=i.typeAliasDeclaration({exportType:m.exported,name:m.placeholder,type:l});t.setSymbolValue(m,f);}}if(s){let a=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.responses,name:e.id}),selector:t.api.getSelector("responses",e.id)}),p=ne({plugin:t,schema:s}),c=i.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:p});if(t.setSymbolValue(a,c),o){let m=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),selector:t.api.getSelector("response",e.id)}),l=i.indexedAccessTypeNode({indexType:i.typeOperatorNode({operator:"keyof",type:i.typeReferenceNode({typeName:a.placeholder})}),objectType:i.typeReferenceNode({typeName:a.placeholder})}),f=i.typeAliasDeclaration({exportType:m.exported,name:m.placeholder,type:l});t.setSymbolValue(m,f);}}};var uh=({operation:e,plugin:t})=>{let r={type:"object"},n=[];if(r.properties||(r.properties={}),e.body){let p=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id}),selector:t.api.getSelector("webhook-payload",e.id)}),c=ne({plugin:t,schema:e.body.schema}),m=i.typeAliasDeclaration({comment:Oe({schema:e.body.schema}),exportType:p.exported,name:p.placeholder,type:c});t.setSymbolValue(p,m),t.registerSymbol({exported:true,meta:{kind:"type"},name:p.name,placeholder:p.placeholder,selector:t.api.getSelector("ref",p.placeholder)}),r.properties.body={$ref:p.placeholder},n.push("body");}else r.properties.body={type:"never"};r.properties.key={const:e.path,type:"string"},n.push("key"),r.properties.path={type:"never"},r.properties.query={type:"never"},r.required=n;let o=t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.webhooks,name:e.id}),selector:t.api.getSelector("webhook-request",e.id)}),s=ne({plugin:t,schema:r}),a=i.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:s});return t.setSymbolValue(o,a),o.placeholder},jm=({operation:e,plugin:t})=>uh({operation:e,plugin:t});var Nm=({plugin:e,symbolWebhooks:t,webhookNames:r})=>{if(!r.length)return;let n=i.typeUnionNode({types:r.map(s=>i.typeReferenceNode({typeName:s}))}),o=i.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:n});e.setSymbolValue(t,o);};var dh=({plugin:e,schema:t})=>{if(!t.items)return i.typeArrayNode(i.keywordTypeNode({keyword:e.config.topType}));t=J({detectFormat:true,schema:t});let r=[];for(let n of t.items){let o=ne({plugin:e,schema:n});r.push(o);}return r.length===1?i.typeArrayNode(r[0]):t.logicalOperator==="and"?i.typeArrayNode(i.typeIntersectionNode({types:r})):i.typeArrayNode(i.typeUnionNode({types:r}))},yh=({schema:e})=>e.const!==void 0?i.literalTypeNode({literal:i.ots.boolean(e.const)}):i.keywordTypeNode({keyword:"boolean"}),gh=({plugin:e,schema:t})=>ne({plugin:e,schema:{...t,type:void 0}}),hh=({plugin:e,schema:t})=>t.const!==void 0?i.literalTypeNode({literal:i.ots.number(t.const)}):t.type==="integer"&&t.format==="int64"&&e.getPlugin("@hey-api/transformers")?.config.bigInt?i.typeReferenceNode({typeName:"bigint"}):i.keywordTypeNode({keyword:"number"}),xh=({plugin:e,schema:t})=>{let r,n,o=[],s=[],a=t.required??[],p=false;for(let u in t.properties){let d=t.properties[u],y=ne({plugin:e,schema:d}),h=a.includes(u);o.push({comment:Oe({schema:d}),isReadOnly:d.accessScope==="read",isRequired:h,name:Cm({context:e.context,name:u}),type:y}),s.push(d),h||(p=true);}if(t.patternProperties)for(let u in t.patternProperties){let d=t.patternProperties[u];s.unshift(d);}let c=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,m=t.additionalProperties,l=m!==false&&m?m:void 0;if(c||!!l&&(l.type!=="never"||!s.length)){let u=l;u&&u.type!=="never"?s.unshift(u):!c&&!s.length&&u&&u.type==="never"&&(s=[u]),p&&s.push({type:"undefined"}),n={isRequired:!t.propertyNames,name:"key",type:s.length===1?ne({plugin:e,schema:s[0]}):ne({plugin:e,schema:{items:s,logicalOperator:"or"}})},t.propertyNames?.$ref&&(r=ne({plugin:e,schema:{$ref:t.propertyNames.$ref}}));}return i.typeInterfaceNode({indexKey:r,indexProperty:n,properties:o,useLegacyResolution:false})},bh=({plugin:e,schema:t})=>{if(t.const!==void 0)return i.literalTypeNode({literal:i.stringLiteral({text:t.const})});if(t.format){if(t.format==="binary")return i.typeUnionNode({types:[i.typeReferenceNode({typeName:"Blob"}),i.typeReferenceNode({typeName:"File"})]});if((t.format==="date-time"||t.format==="date")&&e.getPlugin("@hey-api/transformers")?.config.dates)return i.typeReferenceNode({typeName:"Date"});if(t.format==="typeid"&&typeof t.example=="string"){let r=String(t.example).split("_");r.pop();let n=r.join("_"),o=e.api.getSelector("TypeID",n);if(!e.getSymbol(o)){let a=e.api.getSelector("TypeID");if(!e.getSymbol(a)){let l=e.registerSymbol({exported:true,meta:{kind:"type"},name:"TypeID",selector:a}),f=i.typeAliasDeclaration({exportType:l.exported,name:l.placeholder,type:i.templateLiteralType({value:[i.typeReferenceNode({typeName:"T"}),"_",i.keywordTypeNode({keyword:"string"})]}),typeParameters:[i.typeParameterDeclaration({constraint:i.keywordTypeNode({keyword:"string"}),name:"T"})]});e.setSymbolValue(l,f);}let p=e.referenceSymbol(a),c=e.registerSymbol({exported:true,meta:{kind:"type"},name:N({case:e.config.case,value:`${n}_id`}),selector:o}),m=i.typeAliasDeclaration({exportType:c.exported,name:c.placeholder,type:i.typeReferenceNode({typeArguments:[i.literalTypeNode({literal:i.stringLiteral({text:n})})],typeName:p.placeholder})});e.setSymbolValue(c,m);}let s=e.referenceSymbol(o);return i.typeReferenceNode({typeName:s.placeholder})}}return i.keywordTypeNode({keyword:"string"})},Sh=({plugin:e,schema:t})=>{let r=[];if(t.const&&Array.isArray(t.const))r=t.const.map(n=>i.valueToExpression({value:n})??i.identifier({text:e.config.topType}));else if(t.items)for(let n of t.items){let o=ne({plugin:e,schema:n});r.push(o);}return i.typeTupleNode({types:r})},wm=({plugin:e,schema:t})=>{let r=e.getPlugin("@hey-api/transformers");if(r?.config.typeTransformers)for(let n of r.config.typeTransformers){let o=n({schema:t});if(o)return o}switch(t.type){case "array":return dh({plugin:e,schema:t});case "boolean":return yh({schema:t});case "enum":return gh({plugin:e,schema:t});case "integer":case "number":return hh({plugin:e,schema:t});case "never":return i.keywordTypeNode({keyword:"never"});case "null":return i.literalTypeNode({literal:i.null()});case "object":return xh({plugin:e,schema:t});case "string":return bh({plugin:e,schema:t});case "tuple":return Sh({plugin:e,schema:t});case "undefined":return i.keywordTypeNode({keyword:"undefined"});case "unknown":return i.keywordTypeNode({keyword:e.config.topType});case "void":return i.keywordTypeNode({keyword:"void"})}},ne=({plugin:e,schema:t})=>{if(t.$ref){let r=e.referenceSymbol(e.api.getSelector("ref",t.$ref));return i.typeReferenceNode({typeName:r.placeholder})}if(t.type)return wm({plugin:e,schema:t});if(t.items){if(t=J({detectFormat:false,schema:t}),t.items){let r=[];for(let n of t.items){let o=ne({plugin:e,schema:n});r.push(o);}return t.logicalOperator==="and"?i.typeIntersectionNode({types:r}):i.typeUnionNode({types:r})}return ne({plugin:e,schema:t})}return wm({plugin:e,schema:{type:"unknown"}})},ki=({id:e,plugin:t,schema:r})=>{let n=ne({plugin:t,schema:r}),o=r.type==="enum"&&t.config.enums.enabled,s=t.registerSymbol({exported:true,meta:{kind:o?void 0:"type"},name:R({config:t.config.definitions,name:H(e)}),selector:t.api.getSelector("ref",e)});Im({plugin:t,schema:r,symbol:s,type:n});},qm=({plugin:e})=>{let t=e.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:{case:e.config.case},name:"ClientOptions"}),selector:e.api.getSelector("ClientOptions")}),r=e.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:{case:e.config.case},name:"Webhooks"}),selector:e.api.getSelector("Webhooks")}),n=[],o=[];e.forEach("operation","parameter","requestBody","schema","server","webhook",s=>{switch(s.type){case "operation":vm({operation:s.operation,plugin:e});break;case "parameter":ki({id:s.$ref,plugin:e,schema:s.parameter.schema});break;case "requestBody":ki({id:s.$ref,plugin:e,schema:s.requestBody.schema});break;case "schema":ki({id:s.$ref,plugin:e,schema:s.schema});break;case "server":n.push(s.server);break;case "webhook":o.push(jm({operation:s.operation,plugin:e}));break}}),km({plugin:e,servers:n,symbolClientOptions:t}),Nm({plugin:e,symbolWebhooks:r,webhookNames:o});};var ns=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}schemaToType(t){return ne(t)}};var os={api:new ns({name:"@hey-api/typescript"}),config:{case:"PascalCase",exportFromIndex:true,style:"preserve",topType:"unknown",tree:false},handler:qm,handlerLegacy:Om,name:"@hey-api/typescript",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}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}WebhookRequest",payload:"{{name}}WebhookPayload"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.webhooks});}};var ss=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var is=(e,t,r)=>{let n=e.config[r].meta;if(!n)return;let o=n(t);if(Object.keys(o).length)return i.valueToExpression({value:o})};var _r=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/sdk");return gn({operation:e,plugin:r})},$m=({operation:e,plugin:t})=>{let r=E(t.context.config),n=t.getPluginOrThrow("@hey-api/typescript"),s=t.getSymbol(n.api.getSelector("error",e.id))?.placeholder;return s||(s="Error"),r.name==="@hey-api/client-axios"&&(s=`${t.referenceSymbol(t.api.getSelector("AxiosError")).placeholder}<${s}>`),s},Mm=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/typescript");return t.getSymbol(r.api.getSelector("response",e.id))?.placeholder||"unknown"};var Wr=({plugin:e,typeData:t})=>{let n=E(e.context.config).name==="@hey-api/client-nuxt",o=n?`Omit<${t}, 'composable'>`:t;return {isNuxtClient:n,strippedTypeData:o}};var Dm=({operation:e,plugin:t,queryFn:r})=>{let n=t.referenceSymbol(t.api.getSelector("UseMutationOptions")),o=_r({operation:e,plugin:t}),s=$m({operation:e,plugin:t}),a=Mm({operation:e,plugin:t}),{isNuxtClient:p,strippedTypeData:c}=Wr({plugin:t,typeData:o}),m=p?`${n.placeholder}<${a}, ${c}, ${s}>`:`${n.placeholder}<${a}, ${o}, ${s}>`,l="fnOptions",f=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:l},{key:"throwOnError",value:true}]})]})}),u=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?u.push(i.returnVariable({expression:f})):u.push(i.constVariable({destructure:true,expression:f,name:"data"}),i.returnVariable({expression:"data"}));let d=[{key:"mutation",value:i.arrowFunction({async:true,multiLine:true,parameters:[p?{name:l,type:`Partial<${c}>`}:{name:l}],statements:u})}],y=is(t,e,"mutationOptions");y&&d.push({key:"meta",value:y});let h=t.registerSymbol({exported:true,name:R({config:t.config.mutationOptions,name:e.id})}),x=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:h.exported,expression:i.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${c}>`}],returnType:m,statements:[i.returnStatement({expression:i.objectExpression({obj:d})})]}),name:h.placeholder});t.setSymbolValue(h.id,x);};var bn="TOptions",Ii=i.identifier({text:"options"}),Lm=({plugin:e})=>{let t=e.registerSymbol({name:R({config:{case:e.config.case},name:"createQueryKey"}),selector:e.api.getSelector("createQueryKey")}),r=e.referenceSymbol(e.api.getSelector("QueryKey")),n=e.referenceSymbol(e.api.getSelector("_JSONValue")),o=i.indexedAccessTypeNode({indexType:i.literalTypeNode({literal:i.ots.number(0)}),objectType:i.typeReferenceNode({typeArguments:[i.typeReferenceNode({typeName:bn})],typeName:r.placeholder})}),s=ge(e.context.config),a=e.getPluginOrThrow("@hey-api/sdk"),p=e.referenceSymbol(a.api.getSelector("Options")),c=E(e.context.config),m=c.api&&"getSelector"in c.api?e.getSymbol(c.api.getSelector("client")):void 0,l=ft(e.context.config),f=e.registerSymbol({external:l,name:"serializeQueryKeyValue"}),u=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"id",type:i.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:i.typeReferenceNode({typeName:bn})},{isRequired:false,name:"tags",type:i.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],returnType:i.typeTupleNode({types:[o]}),statements:[i.constVariable({assertion:o,expression:i.objectExpression({multiLine:false,obj:[{key:"_id",value:i.identifier({text:"id"})},{key:s,value:i.identifier({text:`options?.${s} || (options?.client ?? ${m?.placeholder}).getConfig().${s}`})}]}),name:"params",typeName:o}),i.ifStatement({expression:i.identifier({text:"tags"}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"tags"}),right:i.asExpression({expression:i.asExpression({expression:i.identifier({text:"tags"}),type:i.keywordTypeNode({keyword:"unknown"})}),type:i.typeReferenceNode({typeName:n.placeholder})})})})]})}),i.ifStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:Ii,isOptional:true,name:i.identifier({text:"body"})}),operator:"!==",right:"undefined"}),thenStatement:i.block({statements:[i.constVariable({expression:i.callExpression({functionName:f.placeholder,parameters:[i.propertyAccessExpression({expression:"options",name:"body"})]}),name:"normalizedBody"}),i.ifStatement({expression:i.binaryExpression({left:i.identifier({text:"normalizedBody"}),operator:"!==",right:"undefined"}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"body"}),right:i.identifier({text:"normalizedBody"})})})]})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:Ii,isOptional:true,name:i.identifier({text:"path"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"path"}),right:i.propertyAccessExpression({expression:"options",name:"path"})})})]})}),i.ifStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:Ii,isOptional:true,name:i.identifier({text:"query"})}),operator:"!==",right:"undefined"}),thenStatement:i.block({statements:[i.constVariable({expression:i.callExpression({functionName:f.placeholder,parameters:[i.propertyAccessExpression({expression:"options",name:"query"})]}),name:"normalizedQuery"}),i.ifStatement({expression:i.binaryExpression({left:i.identifier({text:"normalizedQuery"}),operator:"!==",right:"undefined"}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"query"}),right:i.identifier({text:"normalizedQuery"})})})]})})]})}),i.returnStatement({expression:i.arrayLiteralExpression({elements:[i.identifier({text:"params"})]})})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:p.placeholder})}),name:bn}]}),name:t.placeholder});e.setSymbolValue(t,u);},Rh=({id:e,operation:t,plugin:r})=>{let n=r.config.queryKeys,o;n.tags&&t.tags&&t.tags.length>0&&(o=i.arrayLiteralExpression({elements:t.tags.map(p=>i.stringLiteral({text:p}))}));let s=r.referenceSymbol(r.api.getSelector("createQueryKey"));return i.callExpression({functionName:s.placeholder,parameters:[i.ots.string(e),"options",o]})},Fm=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("_JSONValue")),r=[{name:"_id",type:i.keywordTypeNode({keyword:"string"})},{isRequired:false,name:ge(e.context.config),type:i.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"body",type:i.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"query",type:i.typeReferenceNode({typeName:t.placeholder})},{isRequired:false,name:"tags",type:i.typeReferenceNode({typeName:t.placeholder})}],n=e.getPluginOrThrow("@hey-api/sdk"),o=e.referenceSymbol(n.api.getSelector("Options")),s=e.registerSymbol({exported:true,meta:{kind:"type"},name:"QueryKey",selector:e.api.getSelector("QueryKey")}),a=i.typeAliasDeclaration({exportType:s.exported,name:s.placeholder,type:i.typeTupleNode({types:[i.typeIntersectionNode({types:[i.typeReferenceNode({typeName:`Pick<${bn}, 'path'>`}),i.typeInterfaceNode({properties:r,useLegacyResolution:true})]})]}),typeParameters:[{extends:i.typeReferenceNode({typeName:i.identifier({text:o.placeholder})}),name:bn}]});e.setSymbolValue(s,a);},Bm=({operation:e,plugin:t,symbol:r})=>{let n=_r({operation:e,plugin:t}),{strippedTypeData:o}=Wr({plugin:t,typeData:n});return i.constVariable({exportConst:r.exported,expression:i.arrowFunction({parameters:[{isRequired:Pr(e),name:"options",type:o}],statements:Rh({id:e.id,operation:e,plugin:t})}),name:r.placeholder})};var as="options",Vm="context",Hm=({operation:e,plugin:t,queryFn:r})=>{if(Br({operation:e}))return;let n=ae({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(Fm({plugin:t}),Lm({plugin:t}));let o;if(t.config.queryKeys.enabled){let y=t.registerSymbol({exported:true,name:R({config:t.config.queryKeys,name:e.id})}),h=Bm({operation:e,plugin:t,symbol:y});t.setSymbolValue(y,h),o=i.callExpression({functionName:y.placeholder,parameters:[as]});}else {let y=t.referenceSymbol(t.api.getSelector("createQueryKey")),h;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(h=i.arrayLiteralExpression({elements:e.tags.map(x=>i.stringLiteral({text:x}))})),o=i.callExpression({functionName:y.placeholder,parameters:[i.ots.string(e.id),as,h]});}let s=_r({operation:e,plugin:t}),{strippedTypeData:a}=Wr({plugin:t,typeData:s}),p=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:as},{spread:Vm},{key:"throwOnError",value:true}]})]})}),c=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?c.push(i.returnVariable({expression:p})):c.push(i.constVariable({destructure:true,expression:p,name:"data"}),i.returnVariable({expression:"data"}));let m=[{key:"key",value:o},{key:"query",value:i.arrowFunction({async:true,multiLine:true,parameters:[{name:Vm}],statements:c})}],l=is(t,e,"queryOptions");l&&m.push({key:"meta",value:l});let f=t.registerSymbol({exported:true,name:R({config:t.config.queryOptions,name:e.id}),selector:t.api.getSelector("queryOptionsFn",e.id)}),u=t.registerSymbol({external:t.name,name:"defineQueryOptions",selector:t.api.getSelector("defineQueryOptions")}),d=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:f.exported,expression:i.callExpression({functionName:u.placeholder,parameters:[i.arrowFunction({parameters:[{isRequired:n,name:as,type:a}],statements:i.objectExpression({obj:m})})]}),name:f.placeholder});t.setSymbolValue(f,d);};var _m=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:"type"},name:"UseMutationOptions",selector:e.api.getSelector("UseMutationOptions")}),e.registerSymbol({external:e.name,meta:{kind:"type"},name:"UseQueryOptions",selector:e.api.getSelector("UseQueryOptions")}),e.registerSymbol({external:e.name,meta:{kind:"type"},name:"_JSONValue",selector:e.api.getSelector("_JSONValue")}),e.registerSymbol({external:"axios",meta:{kind:"type"},name:"AxiosError",selector:e.api.getSelector("AxiosError")});let t=e.getPluginOrThrow("@hey-api/sdk");e.forEach("operation",({operation:r})=>{let n=t.config.asClass?We({context:e.context,operation:r,plugin:t}):void 0,o=n?n.values().next().value:void 0,s=o?[e.referenceSymbol(t.api.getSelector("class",o.path[0])).placeholder,...o.path.slice(1).map(a=>N({case:"camelCase",value:a})),o.methodName].filter(Boolean).join("."):e.referenceSymbol(t.api.getSelector("function",r.id)).placeholder;e.hooks.operation.isQuery(r)&&e.config.queryOptions.enabled&&Hm({operation:r,plugin:e,queryFn:s}),e.hooks.operation.isMutation(r)&&e.config.mutationOptions.enabled&&Dm({operation:r,plugin:e,queryFn:s});});};var ps={api:new ss({name:"@pinia/colada"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/typescript","@hey-api/sdk"],handler:_m,name:"@pinia/colada",resolveConfig:(e,t)=>{e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,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,name:"{{name}}Query"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Kr=(e,t,r)=>{let n=e.config[r].meta;if(!n)return;let o=n(t);if(Object.keys(o).length)return i.valueToExpression({value:o})};var yt=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/sdk");return gn({operation:e,plugin:r})},cs=({operation:e,plugin:t})=>{let r=E(t.context.config),n=t.getPluginOrThrow("@hey-api/typescript"),s=t.getSymbol(n.api.getSelector("error",e.id))?.placeholder;return s||(s=t.referenceSymbol(t.api.getSelector("DefaultError")).placeholder),r.name==="@hey-api/client-axios"&&(s=`${t.referenceSymbol(t.api.getSelector("AxiosError")).placeholder}<${s}>`),s},ms=({operation:e,plugin:t})=>{let r=t.getPluginOrThrow("@hey-api/typescript");return t.getSymbol(r.api.getSelector("response",e.id))?.placeholder||"unknown"};var Sn="TOptions",Wm=i.identifier({text:"infinite"}),ls=i.identifier({text:"options"}),fs=({plugin:e})=>{let t=e.registerSymbol({name:R({config:{case:e.config.case},name:"createQueryKey"}),selector:e.api.getSelector("createQueryKey")}),r=e.referenceSymbol(e.api.getSelector("QueryKey")),n=i.indexedAccessTypeNode({indexType:i.literalTypeNode({literal:i.ots.number(0)}),objectType:i.typeReferenceNode({typeArguments:[i.typeReferenceNode({typeName:Sn})],typeName:r.placeholder})}),o=ge(e.context.config),s=E(e.context.config),a=s.api&&"getSelector"in s.api?e.getSymbol(s.api.getSelector("client")):void 0,p=e.getPluginOrThrow("@hey-api/sdk"),c=e.referenceSymbol(p.api.getSelector("Options")),m=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"id",type:i.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:i.typeReferenceNode({typeName:Sn})},{isRequired:false,name:"infinite",type:i.typeReferenceNode({typeName:"boolean"})},{isRequired:false,name:"tags",type:i.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],returnType:i.typeTupleNode({types:[n]}),statements:[i.constVariable({assertion:n,expression:i.objectExpression({multiLine:false,obj:[{key:"_id",value:i.identifier({text:"id"})},{key:o,value:i.identifier({text:`options?.${o} || (options?.client ?? ${a?.placeholder}).getConfig().${o}`})}]}),name:"params",typeName:n}),i.ifStatement({expression:Wm,thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"_infinite"}),right:Wm})})]})}),i.ifStatement({expression:i.identifier({text:"tags"}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"tags"}),right:i.identifier({text:"tags"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:ls,isOptional:true,name:i.identifier({text:"body"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"body"}),right:i.propertyAccessExpression({expression:"options",name:"body"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:ls,isOptional:true,name:i.identifier({text:"headers"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"headers"}),right:i.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:ls,isOptional:true,name:i.identifier({text:"path"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"path"}),right:i.propertyAccessExpression({expression:"options",name:"path"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:ls,isOptional:true,name:i.identifier({text:"query"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"query"}),right:i.propertyAccessExpression({expression:"options",name:"query"})})})]})}),i.returnStatement({expression:i.arrayLiteralExpression({elements:[i.identifier({text:"params"})]})})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:c.placeholder})}),name:Sn}]}),name:t.placeholder});e.setSymbolValue(t,m);},Ph=({id:e,isInfinite:t,operation:r,plugin:n})=>{let o=t?n.config.infiniteQueryKeys:n.config.queryKeys,s;o.tags&&r.tags&&r.tags.length>0&&(s=i.arrayLiteralExpression({elements:r.tags.map(c=>i.stringLiteral({text:c}))}));let a=n.referenceSymbol(n.api.getSelector("createQueryKey"));return i.callExpression({functionName:a.placeholder,parameters:[i.ots.string(e),"options",t||s?i.ots.boolean(!!t):void 0,s]})},us=({plugin:e})=>{let t=[{name:"_id",type:i.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:i.keywordTypeNode({keyword:"boolean"})},{isRequired:false,name:"tags",type:i.typeReferenceNode({typeName:"ReadonlyArray<string>"})}],r=e.getPluginOrThrow("@hey-api/sdk"),n=e.referenceSymbol(r.api.getSelector("Options")),o=e.registerSymbol({exported:true,meta:{kind:"type"},name:"QueryKey",selector:e.api.getSelector("QueryKey")}),s=i.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:i.typeTupleNode({types:[i.typeIntersectionNode({types:[i.typeReferenceNode({typeName:`Pick<${Sn}, '${ge(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),i.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:i.typeReferenceNode({typeName:i.identifier({text:n.placeholder})}),name:Sn}]});e.setSymbolValue(o,s);},ds=({isInfinite:e,operation:t,plugin:r,symbol:n,typeQueryKey:o})=>{let s=yt({operation:t,plugin:r});return i.constVariable({exportConst:n.exported,expression:i.arrowFunction({parameters:[{isRequired:Pr(t),name:"options",type:s}],returnType:e?o:void 0,statements:Ph({id:t.id,isInfinite:e,operation:t,plugin:r})}),name:n.placeholder})};var Eh=({plugin:e})=>{let t=e.registerSymbol({name:R({config:{case:e.config.case},name:"createInfiniteParams"}),selector:e.api.getSelector("createInfiniteParams")}),r=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:i.typeReferenceNode({typeName:"QueryKey<Options>"})},{name:"page",type:i.typeReferenceNode({typeName:"K"})}],statements:[i.constVariable({expression:i.objectExpression({obj:[{spread:i.propertyAccessExpression({expression:"queryKey",name:0})}]}),name:"params"}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"body"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"body"}),right:i.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"headers"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"headers"}),right:i.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"path"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"path"}),right:i.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].path"},{assertion:"any",spread:"page.path"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"query"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"query"}),right:i.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].query"},{assertion:"any",spread:"page.query"}]})})})]})}),i.returnVariable({expression:i.asExpression({expression:i.asExpression({expression:i.identifier({text:"params"}),type:i.keywordTypeNode({keyword:"unknown"})}),type:S__default.default.factory.createTypeQueryNode(i.identifier({text:"page"}))})})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:"Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>"})}),name:"K"}]}),name:t.placeholder});e.setSymbolValue(t,r);},Km=({operation:e,plugin:t,queryFn:r})=>{let n=bp({context:t.context,operation:e});if(!n)return;let o=ae({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(us({plugin:t}),fs({plugin:t})),t.getSymbol(t.api.getSelector("createInfiniteParams"))||Eh({plugin:t});let s=t.referenceSymbol(t.api.getSelector("infiniteQueryOptions")),a=t.referenceSymbol(t.api.getSelector("InfiniteData")),p=yt({operation:e,plugin:t}),c=cs({operation:e,plugin:t}),m=ms({operation:e,plugin:t}),f=`${t.referenceSymbol(t.api.getSelector("QueryKey")).placeholder}<${p}>`,u=`Pick<${f}[0], 'body' | 'headers' | 'path' | 'query'>`,d=t.getPluginOrThrow("@hey-api/typescript"),y=d.api.schemaToType({plugin:d,schema:n.schema}),h=`${ue({node:y,unescape:true})} | ${u}`,x=t.registerSymbol({exported:true,name:R({config:t.config.infiniteQueryKeys,name:e.id})}),b=ds({isInfinite:true,operation:e,plugin:t,symbol:x,typeQueryKey:f});t.setSymbolValue(x,b);let k=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:i.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),P=t.referenceSymbol(t.api.getSelector("createInfiniteParams")),I=[i.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:i.conditionalExpression({condition:i.binaryExpression({left:i.typeOfExpression({text:"pageParam"}),operator:"===",right:i.ots.string("object")}),whenFalse:i.objectExpression({multiLine:true,obj:[{key:n.in,value:i.objectExpression({multiLine:true,obj:[{key:n.name,value:i.identifier({text:"pageParam"})}]})}]}),whenTrue:i.identifier({text:"pageParam"})}),name:"page",typeName:u}),i.constVariable({expression:i.callExpression({functionName:P.placeholder,parameters:["queryKey","page"]}),name:"params"})];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?I.push(i.returnVariable({expression:k})):I.push(i.constVariable({destructure:true,expression:k,name:"data"}),i.returnVariable({expression:"data"}));let v=[{key:"queryFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:I})},{key:"queryKey",value:i.callExpression({functionName:x.placeholder,parameters:["options"]})}],w=Kr(t,e,"infiniteQueryOptions");w&&v.push({key:"meta",value:w});let V=t.registerSymbol({exported:true,name:R({config:t.config.infiniteQueryOptions,name:e.id})}),M=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:V.exported,expression:i.arrowFunction({parameters:[{isRequired:o,name:"options",type:p}],statements:[i.returnFunctionCall({args:[i.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:v})],name:s.placeholder,types:[m,c||"unknown",`${a.placeholder}<${m}>`,f,h]})]}),name:V.placeholder});t.setSymbolValue(V,M);};var zm=({operation:e,plugin:t,queryFn:r})=>{let n=t.referenceSymbol(t.api.getSelector("MutationOptions")),o=yt({operation:e,plugin:t}),s=cs({operation:e,plugin:t}),a=ms({operation:e,plugin:t}),p=`${n.placeholder}<${a}, ${s}, ${o}>`,c="fnOptions",m=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:c},{key:"throwOnError",value:true}]})]})}),l=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?l.push(i.returnVariable({expression:m})):l.push(i.constVariable({destructure:true,expression:m,name:"data"}),i.returnVariable({expression:"data"}));let f=[{key:"mutationFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{name:c}],statements:l})}],u=Kr(t,e,"mutationOptions");u&&f.push({key:"meta",value:u});let d="mutationOptions",y=i.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${o}>`}],returnType:p,statements:[i.constVariable({expression:i.objectExpression({obj:f}),name:d,typeName:p}),i.returnVariable({expression:d})]}),h=t.registerSymbol({exported:true,name:R({config:t.config.mutationOptions,name:e.id})}),x=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:h.exported,expression:y,name:h.placeholder});t.setSymbolValue(h,x);};var vi="options",Qm=({operation:e,plugin:t,queryFn:r})=>{if(Br({operation:e}))return;let n=ae({context:t.context,operation:e});t.getSymbol(t.api.getSelector("createQueryKey"))||(us({plugin:t}),fs({plugin:t}));let o=t.referenceSymbol(t.api.getSelector("queryOptions")),s=t.registerSymbol({exported:true,name:R({config:t.config.queryKeys,name:e.id})}),a=ds({isInfinite:false,operation:e,plugin:t,symbol:s});t.setSymbolValue(s,a);let p=yt({operation:e,plugin:t}),c=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:vi},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:i.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),m=[];t.getPluginOrThrow("@hey-api/sdk").config.responseStyle==="data"?m.push(i.returnVariable({expression:c})):m.push(i.constVariable({destructure:true,expression:c,name:"data"}),i.returnVariable({expression:"data"}));let l=[{key:"queryFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:m})},{key:"queryKey",value:i.callExpression({functionName:s.placeholder,parameters:[vi]})}],f=Kr(t,e,"queryOptions");f&&l.push({key:"meta",value:f});let u=t.registerSymbol({exported:t.config.queryOptions.exported,name:R({config:t.config.queryOptions,name:e.id}),selector:t.api.getSelector("queryOptionsFn",e.id)}),d=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:u.exported,expression:i.arrowFunction({parameters:[{isRequired:n,name:vi,type:p}],statements:[i.returnFunctionCall({args:[i.objectExpression({obj:l})],name:o.placeholder})]}),name:u.placeholder});t.setSymbolValue(u,d);};var Um="options",Zm=({operation:e,plugin:t})=>{if(Br({operation:e})||!("useQuery"in t.config))return;let r=t.registerSymbol({exported:true,name:R({config:t.config.useQuery,name:e.id})}),n=t.referenceSymbol(t.api.getSelector("useQuery")),o=ae({context:t.context,operation:e}),s=yt({operation:e,plugin:t}),a=t.referenceSymbol(t.api.getSelector("queryOptionsFn",e.id)),p=i.constVariable({comment:t.config.comments?G({operation:e}):void 0,exportConst:r.exported,expression:i.arrowFunction({parameters:[{isRequired:o,name:Um,type:s}],statements:[i.returnStatement({expression:i.callExpression({functionName:n.placeholder,parameters:[i.callExpression({functionName:a.placeholder,parameters:[Um]})]})})]}),name:r.placeholder});t.setSymbolValue(r,p);};var gt=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:"type"},name:"DefaultError",selector:e.api.getSelector("DefaultError")}),e.registerSymbol({external:e.name,meta:{kind:"type"},name:"InfiniteData",selector:e.api.getSelector("InfiniteData")});let t=e.name==="@tanstack/angular-query-experimental"||e.name==="@tanstack/svelte-query"||e.name==="@tanstack/solid-query"?"MutationOptions":"UseMutationOptions";e.registerSymbol({external:e.name,meta:{kind:"type"},name:t,selector:e.api.getSelector("MutationOptions")}),e.registerSymbol({external:e.name,name:"infiniteQueryOptions",selector:e.api.getSelector("infiniteQueryOptions")}),e.registerSymbol({external:e.name,name:"queryOptions",selector:e.api.getSelector("queryOptions")}),e.registerSymbol({external:e.name,name:"useQuery",selector:e.api.getSelector("useQuery")}),e.registerSymbol({external:"axios",meta:{kind:"type"},name:"AxiosError",selector:e.api.getSelector("AxiosError")});let r=e.getPluginOrThrow("@hey-api/sdk");e.forEach("operation",({operation:n})=>{let o=r.config.asClass?We({context:e.context,operation:n,plugin:r}):void 0,s=o?o.values().next().value:void 0,a=s?[e.referenceSymbol(r.api.getSelector("class",s.path[0])).placeholder,...s.path.slice(1).map(p=>N({case:"camelCase",value:p})),s.methodName].filter(Boolean).join("."):e.referenceSymbol(r.api.getSelector("function",n.id)).placeholder;e.hooks.operation.isQuery(n)&&(e.config.queryOptions.enabled&&Qm({operation:n,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&Km({operation:n,plugin:e,queryFn:a}),"useQuery"in e.config&&e.config.useQuery.enabled&&Zm({operation:n,plugin:e})),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&zm({operation:n,plugin:e,queryFn:a});});};var Ch=e=>`${ut({config:T(),id:e.name,operation:e})}InfiniteOptions`,kh=e=>`${ut({config:T(),id:e.name,operation:e})}Mutation`,Ih=({config:e,id:t,operation:r})=>`${ut({config:e,id:t,operation:r})}Options`,ys=({config:e,id:t,isInfinite:r,operation:n})=>`${ut({config:e,id:t,operation:n})}${r?"Infinite":""}QueryKey`,vh=e=>{switch(e.in){case "formData":return "body";case "header":return "headers";default:return e.in}},jh="createInfiniteParams",ol="createQueryKey",Xm="infiniteQueryOptions",Gm="mutationOptions",Ni="QueryKey",Jm="queryOptions",Rn="TOptions",Nh=({file:e})=>{let t=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:i.typeNode("QueryKey<OptionsLegacyParser>")},{name:"page",type:i.typeNode("K")}],statements:[i.constVariable({expression:i.identifier({text:"queryKey[0]"}),name:"params"}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"body"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"body"}),right:i.objectExpression({multiLine:true,obj:[{assertion:"any",spread:"queryKey[0].body"},{assertion:"any",spread:"page.body"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"headers"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"headers"}),right:i.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].headers"},{spread:"page.headers"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"path"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"path"}),right:i.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].path"},{spread:"page.path"}]})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"page"}),name:i.identifier({text:"query"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"query"}),right:i.objectExpression({multiLine:true,obj:[{spread:"queryKey[0].query"},{spread:"page.query"}]})})})]})}),i.returnVariable({expression:S__default.default.factory.createAsExpression(S__default.default.factory.createAsExpression(i.identifier({text:"params"}),S__default.default.factory.createKeywordTypeNode(S__default.default.SyntaxKind.UnknownKeyword)),S__default.default.factory.createTypeQueryNode(i.identifier({text:"page"})))})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:"Pick<QueryKey<OptionsLegacyParser>[0], 'body' | 'headers' | 'path' | 'query'>"})}),name:"K"}]}),name:jh});e.add(t);},Ym=({file:e})=>{let t=i.indexedAccessTypeNode({indexType:i.typeNode(0),objectType:i.typeNode(Ni,[i.typeNode(Rn)])}),r=i.identifier({text:"infinite"}),n=ge(T()),o=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"id",type:i.typeNode("string")},{isRequired:false,name:"options",type:i.typeNode(Rn)},{isRequired:false,name:"infinite",type:i.typeNode("boolean")}],returnType:t,statements:[i.constVariable({assertion:t,expression:i.objectExpression({multiLine:false,obj:[{key:"_id",value:i.identifier({text:"id"})},{key:n,value:i.identifier({text:`options?.${n} || (options?.client ?? _heyApiClient).getConfig().${n}`})}]}),name:"params",typeName:t}),i.ifStatement({expression:r,thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"_infinite"}),right:r})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"options"}),isOptional:true,name:i.identifier({text:"body"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"body"}),right:i.propertyAccessExpression({expression:"options",name:"body"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"options"}),isOptional:true,name:i.identifier({text:"headers"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"headers"}),right:i.propertyAccessExpression({expression:"options",name:"headers"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"options"}),isOptional:true,name:i.identifier({text:"path"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"path"}),right:i.propertyAccessExpression({expression:"options",name:"path"})})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:i.identifier({text:"options"}),isOptional:true,name:i.identifier({text:"query"})}),thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"query"}),right:i.propertyAccessExpression({expression:"options",name:"query"})})})]})}),i.returnVariable({expression:"params"})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:"OptionsLegacyParser"})}),name:Rn}]}),name:ol});e.add(o);},el=({file:e})=>{let t=[{name:"_id",type:i.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:i.keywordTypeNode({keyword:"boolean"})}],r=i.typeAliasDeclaration({name:Ni,type:i.typeTupleNode({types:[i.typeIntersectionNode({types:[i.typeReferenceNode({typeName:`Pick<${Rn}, '${ge(T())}' | 'body' | 'headers' | 'path' | 'query'>`}),i.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:i.typeReferenceNode({typeName:i.identifier({text:"OptionsLegacyParser"})}),name:Rn}]});e.add(r);},ji=({client:e,file:t,operation:r,typesModulePath:n})=>{let{name:o}=cr({client:e,meta:r.parameters.length?{$ref:r.name,name:r.name}:void 0,nameTransformer:mr,onImport:a=>{t.import({asType:true,module:n,name:a});}});return {typeData:Ei({importedType:o})}},tl=({client:e,file:t,operation:r,pluginName:n,typesModulePath:o})=>{let s=T(),{name:a}=cr({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Hr,onImport:m=>{t.import({asType:true,module:o,name:m});}}),p={asType:true,name:a};if(p.name||(p=t.import({asType:true,module:n,name:"DefaultError"})),E(s).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}},rl=({client:e,file:t,operation:r,typesModulePath:n})=>{let{name:o}=cr({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:dt,onImport:a=>{t.import({asType:true,module:n,name:a});}});return {typeResponse:o||"void"}},nl=({id:e,isInfinite:t})=>i.arrayLiteralExpression({elements:[i.callExpression({functionName:ol,parameters:[i.ots.string(e),"options",t?i.ots.boolean(true):void 0]})],multiLine:false}),ht=({client:e,files:t,plugin:r})=>{let n=T();if(W(n))throw new Error("TanStack Query plugin does not support legacy clients");let o=t[r.name];o.import({asType:true,module:pr({config:n,sourceOutput:r.output}),name:"OptionsLegacyParser"});let s=ur({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,l=false,f=false,u=false,d=new Map;for(let y of e.services)for(let h of y.operations){let x=B(h);if(d.has(x))continue;d.set(x,true);let b=[n.plugins["@hey-api/sdk"]?.config.asClass&&Bt({config:n,name:y.name}),ut({config:n,handleIllegal:!n.plugins["@hey-api/sdk"]?.config.asClass,id:h.name,operation:h})].filter(Boolean).join("."),k=false;if(r.config.queryOptions.enabled&&["GET","POST"].includes(h.method)){u||(u=true,m||(el({file:o}),Ym({file:o}),m=true),o.import({module:r.name,name:Jm})),k=true;let{typeData:P}=ji({client:e,file:o,operation:h,typesModulePath:s}),I=mt(h.parameters),v=i.constVariable({exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:I,name:"options",type:P}],statements:nl({id:h.name})}),name:ys({config:n,id:h.name,operation:h})});o.add(v);let w=i.constVariable({comment:[],exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:I,name:"options",type:P}],statements:[i.returnFunctionCall({args:[i.objectExpression({obj:[{key:"queryFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"queryKey"},{name:"signal"}]}],statements:[i.constVariable({destructure:true,expression:i.awaitExpression({expression:i.callExpression({functionName:b,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:i.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),i.returnVariable({expression:"data"})]})},{key:"queryKey",value:i.callExpression({functionName:ys({config:n,id:h.name,operation:h}),parameters:["options"]})}]})],name:Jm})]}),name:Ih({config:n,id:h.name,operation:h})});o.add(w);}if(r.config.infiniteQueryOptions&&["GET","POST"].includes(h.method)){let P,I=h.parameters.find(v=>{if(Ce(n.parser.pagination).test(v.name))return P=v,true;if(v.in==="body"){if(v.export==="reference"){let V=v.$refs[0];return e.models.find(F=>F.meta?.$ref===V)?.properties.find(F=>{if(Ce(n.parser.pagination).test(F.name))return P=F,true})}return v.properties.find(V=>{if(Ce(n.parser.pagination).test(V.name))return P=V,true})}});if(I&&P){l||(l=true,m||(el({file:o}),Ym({file:o}),m=true),c||(Nh({file:o}),c=true),o.import({module:r.name,name:Xm}),p=o.import({asType:true,module:r.name,name:"InfiniteData"})),k=true;let{typeData:v}=ji({client:e,file:o,operation:h,typesModulePath:s}),{typeError:w}=tl({client:e,file:o,operation:h,pluginName:r.name,typesModulePath:s}),{typeResponse:V}=rl({client:e,file:o,operation:h,typesModulePath:s}),M=mt(h.parameters),F=`${Ni}<${v}>`,wt=`Pick<${F}[0], 'body' | 'headers' | 'path' | 'query'>`,Qe=`${P.base} | ${wt}`,fr=i.constVariable({exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:M,name:"options",type:v}],returnType:F,statements:nl({id:h.name,isInfinite:true})}),name:ys({config:n,id:h.name,isInfinite:true,operation:h})});o.add(fr);let hu=i.constVariable({comment:[],exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:M,name:"options",type:v}],statements:[i.returnFunctionCall({args:[i.objectExpression({comments:[{jsdoc:false,lines:["@ts-ignore"]}],obj:[{key:"queryFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{destructure:[{name:"pageParam"},{name:"queryKey"},{name:"signal"}]}],statements:[i.constVariable({comment:[{jsdoc:false,lines:["@ts-ignore"]}],expression:i.conditionalExpression({condition:i.binaryExpression({left:i.typeOfExpression({text:"pageParam"}),operator:"===",right:i.ots.string("object")}),whenFalse:i.objectExpression({multiLine:true,obj:[{key:vh(I),value:i.objectExpression({multiLine:true,obj:[{key:P.name,value:i.identifier({text:"pageParam"})}]})}]}),whenTrue:i.identifier({text:"pageParam"})}),name:"page",typeName:wt}),i.constVariable({expression:i.callExpression({functionName:"createInfiniteParams",parameters:["queryKey","page"]}),name:"params"}),i.constVariable({destructure:true,expression:i.awaitExpression({expression:i.callExpression({functionName:b,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"params"},{key:"signal",shorthand:true,value:i.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),name:"data"}),i.returnVariable({expression:"data"})]})},{key:"queryKey",value:i.callExpression({functionName:ys({config:n,id:h.name,isInfinite:true,operation:h}),parameters:["options"]})}]})],name:Xm,types:[V,w.name,`${typeof p=="string"?p:p.name}<${V}>`,F,Qe]})]}),name:Ch(h)});o.add(hu);}}if(r.config.mutationOptions&&["DELETE","PATCH","POST","PUT"].includes(h.method)){f||(f=true,o.import({asType:true,module:r.name,name:a})),k=true;let{typeData:P}=ji({client:e,file:o,operation:h,typesModulePath:s}),{typeError:I}=tl({client:e,file:o,operation:h,pluginName:r.name,typesModulePath:s}),{typeResponse:v}=rl({client:e,file:o,operation:h,typesModulePath:s}),w="fnOptions",V=i.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${P}>`}],statements:[i.constVariable({expression:i.objectExpression({obj:[{key:"mutationFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{name:w}],statements:[i.constVariable({destructure:true,expression:i.awaitExpression({expression:i.callExpression({functionName:b,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:w},{key:"throwOnError",value:true}]})]})}),name:"data"}),i.returnVariable({expression:"data"})]})}]}),name:Gm,typeName:`${a}<${v}, ${I.name}, ${P}>`}),i.returnVariable({expression:Gm})]}),M=i.constVariable({comment:[],exportConst:true,expression:V,name:kh(h)});o.add(M);}(u||l)&&o.import({alias:"_heyApiClient",module:ur({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:r.output}),name:"client"}),k&&o.import({module:ur({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:r.output}),name:b.split(".")[0]});}};var gs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var hs={api:new gs({name:"@tanstack/angular-query-experimental"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:gt,handlerLegacy:ht,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,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,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,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var xs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var bs={api:new xs({name:"@tanstack/react-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:gt,handlerLegacy:ht,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,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,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,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions}),e.config.useQuery=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:false,name:"use{{name}}Query"},mappers:{boolean:r=>({enabled:r}),function:r=>({enabled:true,name:r}),object:r=>({enabled:true,...r}),string:r=>({enabled:true,name:r})},value:e.config.useQuery}),e.config.useQuery.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=true,e.config.queryOptions.exported=false));}};var Ss=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Os={api:new Ss({name:"@tanstack/solid-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:gt,handlerLegacy:ht,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,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,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,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Rs=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Ts={api:new Rs({name:"@tanstack/svelte-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:gt,handlerLegacy:ht,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,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,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,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Ps=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var As={api:new Ps({name:"@tanstack/vue-query"}),config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:gt,handlerLegacy:ht,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,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,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,exported:true,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Es=class{constructor(t){this.meta=t;}getSelector(...t){return [this.meta.name,...t]}};var Lh=({operation:e,plugin:t})=>{let r=[],n=t.getPluginOrThrow("@hey-api/typescript"),o=t.getSymbol(n.api.getSelector("data",e.id));o&&(e.body&&r.push({isRequired:e.body.required,name:"Body",type:`${o.placeholder}['body']`}),e.parameters&&(e.parameters.header&&r.push({isRequired:$t(e.parameters.header),name:"Headers",type:`${o.placeholder}['headers']`}),e.parameters.path&&r.push({isRequired:$t(e.parameters.path),name:"Params",type:`${o.placeholder}['path']`}),e.parameters.query&&r.push({isRequired:$t(e.parameters.query),name:"Querystring",type:`${o.placeholder}['query']`})));let{errors:s,responses:a}=tt(e),p,c=t.getSymbol(n.api.getSelector("errors",e.id));if(c&&s&&s.properties){let y=Object.keys(s.properties);if(y.length){if(!y.includes("default"))p=i.typeReferenceNode({typeName:c.placeholder});else if(y.length>1){let x=i.typeReferenceNode({typeName:c.placeholder}),b=i.literalTypeNode({literal:i.stringLiteral({text:"default"})});p=i.typeReferenceNode({typeArguments:[x,b],typeName:"Omit"});}}}let m,l=t.getSymbol(n.api.getSelector("responses",e.id));if(l&&a&&a.properties){let y=Object.keys(a.properties);if(y.length){if(!y.includes("default"))m=i.typeReferenceNode({typeName:l.placeholder});else if(y.length>1){let x=i.typeReferenceNode({typeName:l.placeholder}),b=i.literalTypeNode({literal:i.stringLiteral({text:"default"})});m=i.typeReferenceNode({typeArguments:[x,b],typeName:"Omit"});}}}let f=[p,m].filter(Boolean);if(f.length&&r.push({name:"Reply",type:i.typeIntersectionNode({types:f})}),!r.length)return;let u=t.referenceSymbol(t.api.getSelector("RouteHandler"));return {name:e.id,type:i.typeReferenceNode({typeArguments:[i.typeInterfaceNode({properties:r,useLegacyResolution:false})],typeName:u.placeholder})}},sl=({plugin:e})=>{e.registerSymbol({external:"fastify",meta:{kind:"type"},name:"RouteHandler",selector:e.api.getSelector("RouteHandler")});let t=e.registerSymbol({exported:true,meta:{kind:"type"},name:"RouteHandlers"}),r=[];e.forEach("operation",({operation:o})=>{let s=Lh({operation:o,plugin:e});s&&r.push(s);});let n=i.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:i.typeInterfaceNode({properties:r,useLegacyResolution:false})});e.setSymbolValue(t,n);};var Cs={api:new Es({name:"fastify"}),config:{exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:sl,name:"fastify"};var A={actions:{args:i.identifier({text:"args"}),base64:i.identifier({text:"base64"}),bic:i.identifier({text:"bic"}),brand:i.identifier({text:"brand"}),bytes:i.identifier({text:"bytes"}),check:i.identifier({text:"check"}),checkItems:i.identifier({text:"checkItems"}),creditCard:i.identifier({text:"creditCard"}),cuid2:i.identifier({text:"cuid2"}),decimal:i.identifier({text:"decimal"}),description:i.identifier({text:"description"}),digits:i.identifier({text:"digits"}),email:i.identifier({text:"email"}),emoji:i.identifier({text:"emoji"}),empty:i.identifier({text:"empty"}),endsWith:i.identifier({text:"endsWith"}),entries:i.identifier({text:"entries"}),everyItem:i.identifier({text:"everyItem"}),excludes:i.identifier({text:"excludes"}),filterItems:i.identifier({text:"filterItems"}),findItem:i.identifier({text:"findItem"}),finite:i.identifier({text:"finite"}),flavor:i.identifier({text:"flavor"}),graphemes:i.identifier({text:"graphemes"}),gtValue:i.identifier({text:"gtValue"}),hash:i.identifier({text:"hash"}),hexColor:i.identifier({text:"hexColor"}),hexadecimal:i.identifier({text:"hexadecimal"}),imei:i.identifier({text:"imei"}),includes:i.identifier({text:"includes"}),integer:i.identifier({text:"integer"}),ip:i.identifier({text:"ip"}),ipv4:i.identifier({text:"ipv4"}),ipv6:i.identifier({text:"ipv6"}),isoDate:i.identifier({text:"isoDate"}),isoDateTime:i.identifier({text:"isoDateTime"}),isoTime:i.identifier({text:"isoTime"}),isoTimeSecond:i.identifier({text:"isoTimeSecond"}),isoTimestamp:i.identifier({text:"isoTimestamp"}),isoWeek:i.identifier({text:"isoWeek"}),length:i.identifier({text:"length"}),ltValue:i.identifier({text:"ltValue"}),mac:i.identifier({text:"mac"}),mac48:i.identifier({text:"mac48"}),mac64:i.identifier({text:"mac64"}),mapItems:i.identifier({text:"mapItems"}),maxBytes:i.identifier({text:"maxBytes"}),maxEntries:i.identifier({text:"maxEntries"}),maxGraphemes:i.identifier({text:"maxGraphemes"}),maxLength:i.identifier({text:"maxLength"}),maxSize:i.identifier({text:"maxSize"}),maxValue:i.identifier({text:"maxValue"}),maxWords:i.identifier({text:"maxWords"}),metadata:i.identifier({text:"metadata"}),mimeType:i.identifier({text:"mimeType"}),minBytes:i.identifier({text:"minBytes"}),minEntries:i.identifier({text:"minEntries"}),minGraphemes:i.identifier({text:"minGraphemes"}),minLength:i.identifier({text:"minLength"}),minSize:i.identifier({text:"minSize"}),minValue:i.identifier({text:"minValue"}),minWords:i.identifier({text:"minWords"}),multipleOf:i.identifier({text:"multipleOf"}),nanoid:i.identifier({text:"nanoid"}),nonEmpty:i.identifier({text:"nonEmpty"}),normalize:i.identifier({text:"normalize"}),notBytes:i.identifier({text:"notBytes"}),notEntries:i.identifier({text:"notEntries"}),notGraphemes:i.identifier({text:"notGraphemes"}),notLength:i.identifier({text:"notLength"}),notSize:i.identifier({text:"notSize"}),notValue:i.identifier({text:"notValue"}),notValues:i.identifier({text:"notValues"}),notWords:i.identifier({text:"notWords"}),octal:i.identifier({text:"octal"}),parseJson:i.identifier({text:"parseJson"}),partialCheck:i.identifier({text:"partialCheck"}),rawCheck:i.identifier({text:"rawCheck"}),rawTransform:i.identifier({text:"rawTransform"}),readonly:i.identifier({text:"readonly"}),reduceItems:i.identifier({text:"reduceItems"}),regex:i.identifier({text:"regex"}),returns:i.identifier({text:"returns"}),rfcEmail:i.identifier({text:"rfcEmail"}),safeInteger:i.identifier({text:"safeInteger"}),size:i.identifier({text:"size"}),slug:i.identifier({text:"slug"}),someItem:i.identifier({text:"someItem"}),sortItems:i.identifier({text:"sortItems"}),startsWith:i.identifier({text:"startsWith"}),stringifyJson:i.identifier({text:"stringifyJson"}),title:i.identifier({text:"title"}),toLowerCase:i.identifier({text:"toLowerCase"}),toMaxValue:i.identifier({text:"toMaxValue"}),toMinValue:i.identifier({text:"toMinValue"}),toUpperCase:i.identifier({text:"toUpperCase"}),transform:i.identifier({text:"transform"}),trim:i.identifier({text:"trim"}),trimEnd:i.identifier({text:"trimEnd"}),trimStart:i.identifier({text:"trimStart"}),ulid:i.identifier({text:"ulid"}),url:i.identifier({text:"url"}),uuid:i.identifier({text:"uuid"}),value:i.identifier({text:"value"}),values:i.identifier({text:"values"}),words:i.identifier({text:"words"})},async:{argsAsync:i.identifier({text:"argsAsync"}),arrayAsync:i.identifier({text:"arrayAsync"}),awaitAsync:i.identifier({text:"awaitAsync"}),checkAsync:i.identifier({text:"checkAsync"}),checkItemsAsync:i.identifier({text:"checkItemsAsync"}),customAsync:i.identifier({text:"customAsync"}),exactOptionalAsync:i.identifier({text:"exactOptionalAsync"}),fallbackAsync:i.identifier({text:"fallbackAsync"}),forwardAsync:i.identifier({text:"forwardAsync"}),getDefaultsAsync:i.identifier({text:"getDefaultsAsync"}),getFallbacksAsync:i.identifier({text:"getFallbacksAsync"}),intersectAsync:i.identifier({text:"intersectAsync"}),lazyAsync:i.identifier({text:"lazyAsync"}),looseObjectAsync:i.identifier({text:"looseObjectAsync"}),looseTupleAsync:i.identifier({text:"looseTupleAsync"}),mapAsync:i.identifier({text:"mapAsync"}),nonNullableAsync:i.identifier({text:"nonNullableAsync"}),nonNullishAsync:i.identifier({text:"nonNullishAsync"}),nonOptionalAsync:i.identifier({text:"nonOptionalAsync"}),nullableAsync:i.identifier({text:"nullableAsync"}),nullishAsync:i.identifier({text:"nullishAsync"}),objectAsync:i.identifier({text:"objectAsync"}),objectWithRestAsync:i.identifier({text:"objectWithRestAsync"}),optionalAsync:i.identifier({text:"optionalAsync"}),parseAsync:i.identifier({text:"parseAsync"}),parserAsync:i.identifier({text:"parserAsync"}),partialAsync:i.identifier({text:"partialAsync"}),partialCheckAsync:i.identifier({text:"partialCheckAsync"}),pipeAsync:i.identifier({text:"pipeAsync"}),rawCheckAsync:i.identifier({text:"rawCheckAsync"}),rawTransformAsync:i.identifier({text:"rawTransformAsync"}),recordAsync:i.identifier({text:"recordAsync"}),requiredAsync:i.identifier({text:"requiredAsync"}),returnsAsync:i.identifier({text:"returnsAsync"}),safeParseAsync:i.identifier({text:"safeParseAsync"}),safeParserAsync:i.identifier({text:"safeParserAsync"}),setAsync:i.identifier({text:"setAsync"}),strictObjectAsync:i.identifier({text:"strictObjectAsync"}),strictTupleAsync:i.identifier({text:"strictTupleAsync"}),transformAsync:i.identifier({text:"transformAsync"}),tupleAsync:i.identifier({text:"tupleAsync"}),tupleWithRestAsync:i.identifier({text:"tupleWithRestAsync"}),undefinedableAsync:i.identifier({text:"undefinedableAsync"}),unionAsync:i.identifier({text:"unionAsync"}),variantAsync:i.identifier({text:"variantAsync"})},methods:{assert:i.identifier({text:"assert"}),config:i.identifier({text:"config"}),fallback:i.identifier({text:"fallback"}),flatten:i.identifier({text:"flatten"}),forward:i.identifier({text:"forward"}),getDefault:i.identifier({text:"getDefault"}),getDefaults:i.identifier({text:"getDefaults"}),getDescription:i.identifier({text:"getDescription"}),getFallback:i.identifier({text:"getFallback"}),getFallbacks:i.identifier({text:"getFallbacks"}),getMetadata:i.identifier({text:"getMetadata"}),getTitle:i.identifier({text:"getTitle"}),is:i.identifier({text:"is"}),keyof:i.identifier({text:"keyof"}),message:i.identifier({text:"message"}),omit:i.identifier({text:"omit"}),parse:i.identifier({text:"parse"}),parser:i.identifier({text:"parser"}),partial:i.identifier({text:"partial"}),pick:i.identifier({text:"pick"}),pipe:i.identifier({text:"pipe"}),required:i.identifier({text:"required"}),safeParse:i.identifier({text:"safeParse"}),safeParser:i.identifier({text:"safeParser"}),summarize:i.identifier({text:"summarize"}),unwrap:i.identifier({text:"unwrap"})},schemas:{any:i.identifier({text:"any"}),array:i.identifier({text:"array"}),bigInt:i.identifier({text:"bigint"}),blob:i.identifier({text:"blob"}),boolean:i.identifier({text:"boolean"}),custom:i.identifier({text:"custom"}),date:i.identifier({text:"date"}),enum:i.identifier({text:"enum"}),exactOptional:i.identifier({text:"exactOptional"}),file:i.identifier({text:"file"}),function:i.identifier({text:"function"}),instance:i.identifier({text:"instance"}),intersect:i.identifier({text:"intersect"}),lazy:i.identifier({text:"lazy"}),literal:i.identifier({text:"literal"}),looseObject:i.identifier({text:"looseObject"}),looseTuple:i.identifier({text:"looseTuple"}),map:i.identifier({text:"map"}),nan:i.identifier({text:"nan"}),never:i.identifier({text:"never"}),nonNullable:i.identifier({text:"nonNullable"}),nonNullish:i.identifier({text:"nonNullish"}),nonOptional:i.identifier({text:"nonOptional"}),null:i.identifier({text:"null"}),nullable:i.identifier({text:"nullable"}),nullish:i.identifier({text:"nullish"}),number:i.identifier({text:"number"}),object:i.identifier({text:"object"}),objectWithRest:i.identifier({text:"objectWithRest"}),optional:i.identifier({text:"optional"}),picklist:i.identifier({text:"picklist"}),promise:i.identifier({text:"promise"}),record:i.identifier({text:"record"}),set:i.identifier({text:"set"}),strictObject:i.identifier({text:"strictObject"}),strictTuple:i.identifier({text:"strictTuple"}),string:i.identifier({text:"string"}),symbol:i.identifier({text:"symbol"}),tuple:i.identifier({text:"tuple"}),tupleWithRest:i.identifier({text:"tupleWithRest"}),undefined:i.identifier({text:"undefined"}),undefinedable:i.identifier({text:"undefinedable"}),union:i.identifier({text:"union"}),unknown:i.identifier({text:"unknown"}),variant:i.identifier({text:"variant"}),void:i.identifier({text:"void"})},types:{GenericSchema:i.identifier({text:"GenericSchema"})}};var ks=class{constructor(t){this.meta=t;}createRequestValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("data",t.id));if(!n)return;let o=r.referenceSymbol(r.api.getSelector("import","valibot")),s="data";return i.arrowFunction({async:true,parameters:[{name:s}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:A.async.parseAsync}),parameters:[i.identifier({text:n.placeholder}),i.identifier({text:s})]})})})]})}createResponseValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("responses",t.id));if(!n)return;let o=r.referenceSymbol(r.api.getSelector("import","valibot")),s="data";return i.arrowFunction({async:true,parameters:[{name:s}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:A.async.parseAsync}),parameters:[i.identifier({text:n.placeholder}),i.identifier({text:s})]})})})]})}getSelector(...t){return [this.meta.name,...t]}};var Is={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}},wi=e=>e!==void 0&&e in Is,il=e=>wi(e)&&Is[e].needsBigInt,zr=({isBigInt:e,value:t})=>{let r=i.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?i.callExpression({functionName:"BigInt",parameters:[r]}):r};var al=({operation:e,plugin:t,state:r})=>{if(t.config.requests.enabled){let n=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let a={},p=[];for(let c in e.parameters.header){let m=e.parameters.header[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("headers"));}Object.keys(a).length&&(o.properties.headers={properties:a,required:p,type:"object"});}if(e.parameters.path){let a={},p=[];for(let c in e.parameters.path){let m=e.parameters.path[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("path"));}Object.keys(a).length&&(o.properties.path={properties:a,required:p,type:"object"});}if(e.parameters.query){let a={},p=[];for(let c in e.parameters.query){let m=e.parameters.query[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("query"));}Object.keys(a).length&&(o.properties.query={properties:a,required:p,type:"object"});}}e.body&&(o.properties.body=e.body.schema,e.body.required&&n.add("body")),o.required=[...n];let s=t.registerSymbol({exported:true,name:R({config:t.config.requests,name:e.id}),selector:t.api.getSelector("data",e.id)});ye({plugin:t,schema:o,state:r,symbol:s});}if(t.config.responses.enabled&&e.responses){let{response:n}=tt(e);if(n){let o=t.registerSymbol({exported:true,name:R({config:t.config.responses,name:e.id}),selector:t.api.getSelector("responses",e.id)});ye({plugin:t,schema:n,state:r,symbol:o});}}};var pl=({operation:e,plugin:t,state:r})=>{if(t.config.webhooks.enabled){let n=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let a={},p=[];for(let c in e.parameters.header){let m=e.parameters.header[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("headers"));}Object.keys(a).length&&(o.properties.headers={properties:a,required:p,type:"object"});}if(e.parameters.path){let a={},p=[];for(let c in e.parameters.path){let m=e.parameters.path[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("path"));}Object.keys(a).length&&(o.properties.path={properties:a,required:p,type:"object"});}if(e.parameters.query){let a={},p=[];for(let c in e.parameters.query){let m=e.parameters.query[c];a[m.name]=m.schema,m.required&&(p.push(m.name),n.add("query"));}Object.keys(a).length&&(o.properties.query={properties:a,required:p,type:"object"});}}e.body&&(o.properties.body=e.body.schema,e.body.required&&n.add("body")),o.required=[...n];let s=t.registerSymbol({exported:true,name:R({config:t.config.webhooks,name:e.id}),selector:t.api.getSelector("webhook-request",e.id)});ye({plugin:t,schema:o,state:r,symbol:s});}};var Ke=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let r=t.referenceSymbol(t.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.methods.pipe}),parameters:e})},Bh=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","valibot")),o=i.propertyAccessExpression({expression:n.placeholder,name:A.schemas.array}),s=[];if(t.items){t=J({schema:t});let a=t.items.map(p=>{let c=ye({plugin:e,schema:p,state:r});return Ke({pipes:c,plugin:e})});if(a.length===1){let p=i.callExpression({functionName:o,parameters:a});s.push(p);}else {t.logicalOperator;let p=i.callExpression({functionName:o,parameters:[Tn({plugin:e})]});s.push(p);}}else {let a=i.callExpression({functionName:o,parameters:[Tn({plugin:e})]});s.push(a);}if(t.minItems===t.maxItems&&t.minItems!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.actions.length}),parameters:[i.valueToExpression({value:t.minItems})]});s.push(a);}else {if(t.minItems!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.actions.minLength}),parameters:[i.valueToExpression({value:t.minItems})]});s.push(a);}if(t.maxItems!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.actions.maxLength}),parameters:[i.valueToExpression({value:t.maxItems})]});s.push(a);}}return Ke({pipes:s,plugin:e})},Vh=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","valibot"));return typeof t.const=="boolean"?i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.schemas.literal}),parameters:[i.ots.boolean(t.const)]}):i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.schemas.boolean})})},Hh=({plugin:e,schema:t})=>{let r=[],n=false;for(let a of t.items??[])a.type==="string"&&typeof a.const=="string"?r.push(i.stringLiteral({text:a.const})):(a.type==="null"||a.const===null)&&(n=true);if(!r.length)return Tn({plugin:e});let o=e.referenceSymbol(e.api.getSelector("import","valibot")),s=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:A.schemas.picklist}),parameters:[i.arrayLiteralExpression({elements:r,multiLine:false})]});return n&&(s=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:A.schemas.nullable}),parameters:[s]})),s},_h=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:A.schemas.never})})},Wh=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:A.schemas.null})})},cl=({plugin:e,schema:t})=>{let r=t.format,n=t.type==="integer",o=il(r),s=wi(r)?Is[r]:null,a=e.referenceSymbol(e.api.getSelector("import","valibot"));if(t.const!==void 0&&t.const!==null){let c=t.const,m;if(typeof c=="number"&&!r)m=i.ots.number(c);else if(typeof c=="number"&&r)o?m=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(c.toString())]}):m=i.ots.number(c);else if(typeof c=="string"&&o){let l=c.endsWith("n")?c.slice(0,-1):c;m=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(l)]});}else if(typeof c=="bigint"){let l=c.toString(),f=l.endsWith("n")?l.slice(0,-1):l;m=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(f)]});}else m=i.valueToExpression({value:c});return i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.literal}),parameters:[m]})}let p=[];if(o){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.union}),parameters:[i.arrayLiteralExpression({elements:[i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.number})}),i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.string})}),i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.bigInt})})],multiLine:false})]});p.push(c);let m=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.transform}),parameters:[i.arrowFunction({parameters:[{name:"x"}],statements:i.callExpression({functionName:"BigInt",parameters:[i.identifier({text:"x"})]})})]});p.push(m);}else {let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.schemas.number})});p.push(c);}if(!o&&n){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.integer})});p.push(c);}if(s){let c=s.min,m=s.max,l=s.minError,f=s.maxError,u=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.minValue}),parameters:[o?i.callExpression({functionName:"BigInt",parameters:[i.ots.string(c.toString())]}):i.ots.number(c),i.ots.string(l)]});p.push(u);let d=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.maxValue}),parameters:[o?i.callExpression({functionName:"BigInt",parameters:[i.ots.string(m.toString())]}):i.ots.number(m),i.ots.string(f)]});p.push(d);}if(t.exclusiveMinimum!==void 0){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.gtValue}),parameters:[zr({isBigInt:o,value:t.exclusiveMinimum})]});p.push(c);}else if(t.minimum!==void 0){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.minValue}),parameters:[zr({isBigInt:o,value:t.minimum})]});p.push(c);}if(t.exclusiveMaximum!==void 0){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.ltValue}),parameters:[zr({isBigInt:o,value:t.exclusiveMaximum})]});p.push(c);}else if(t.maximum!==void 0){let c=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:A.actions.maxValue}),parameters:[zr({isBigInt:o,value:t.maximum})]});p.push(c);}return Ke({pipes:p,plugin:e})},Kh=({plugin:e,schema:t,state:r})=>{let n=[],o=t.required??[];for(let p in t.properties){let c=t.properties[p],m=o.includes(p),l=ye({optional:!m,plugin:e,schema:c,state:r});oe.lastIndex=0;let f;oe.test(p)?f=p.startsWith("-")?S__default.default.factory.createStringLiteral(p):S__default.default.factory.createNumericLiteral(p):f=p,(p.match(/^[0-9]/)&&p.match(/\D+/g)||p.match(/\W/g))&&!p.startsWith("'")&&!p.endsWith("'")&&(f=`'${p}'`),n.push(i.propertyAssignment({initializer:Ke({pipes:l,plugin:e}),name:f}));}let s=e.referenceSymbol(e.api.getSelector("import","valibot"));if(t.additionalProperties&&t.additionalProperties.type==="object"&&!Object.keys(n).length){let p=ye({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:A.schemas.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:A.schemas.string}),parameters:[]}),Ke({pipes:p,plugin:e})]})}}let a=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:A.schemas.object}),parameters:[S__default.default.factory.createObjectLiteralExpression(n,true)]});return {anyType:A.types.GenericSchema.text,expression:a}},zh=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","valibot"));if(typeof t.const=="string")return i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.schemas.literal}),parameters:[i.ots.string(t.const)]});let n=[],o=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.schemas.string})});if(n.push(o),t.format)switch(t.format){case "date":n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.isoDate})}));break;case "date-time":n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.isoTimestamp})}));break;case "ipv4":case "ipv6":n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.ip})}));break;case "uri":n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.url})}));break;case "email":case "time":case "uuid":n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:i.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let s=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.length}),parameters:[i.valueToExpression({value:t.minLength})]});n.push(s);}else {if(t.minLength!==void 0){let s=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.minLength}),parameters:[i.valueToExpression({value:t.minLength})]});n.push(s);}if(t.maxLength!==void 0){let s=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.maxLength}),parameters:[i.valueToExpression({value:t.maxLength})]});n.push(s);}}if(t.pattern){let s=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:A.actions.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]});n.push(s);}return Ke({pipes:n,plugin:e})},Qh=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","valibot"));if(t.const&&Array.isArray(t.const)){let o=t.const.map(a=>i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.schemas.literal}),parameters:[i.valueToExpression({value:a})]}));return i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.schemas.tuple}),parameters:[i.arrayLiteralExpression({elements:o})]})}if(t.items){let o=t.items.map(a=>{let p=ye({plugin:e,schema:a,state:r});return Ke({pipes:p,plugin:e})});return i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:A.schemas.tuple}),parameters:[i.arrayLiteralExpression({elements:o})]})}return Tn({plugin:e})},Uh=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:A.schemas.undefined})})},Tn=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:A.schemas.unknown})})},Zh=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","valibot"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:A.schemas.void})})},ml=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:Bh({plugin:e,schema:t,state:r})};case "boolean":return {expression:Vh({plugin:e,schema:t})};case "enum":return {expression:Hh({plugin:e,schema:t})};case "integer":case "number":return {expression:cl({plugin:e,schema:t})};case "never":return {expression:_h({plugin:e})};case "null":return {expression:Wh({plugin:e})};case "object":return Kh({plugin:e,schema:t,state:r});case "string":return t.format==="int64"||t.format==="uint64"?{expression:cl({plugin:e,schema:t})}:{expression:zh({plugin:e,schema:t})};case "tuple":return {expression:Qh({plugin:e,schema:t,state:r})};case "undefined":return {expression:Uh({plugin:e})};case "unknown":return {expression:Tn({plugin:e})};case "void":return {expression:Zh({plugin:e})}}},ye=({$ref:e,optional:t,plugin:r,schema:n,state:o,symbol:s})=>{let a,p=[];if(e&&(o.circularReferenceTracker.add(e),!s)){let m=r.api.getSelector("ref",e);r.getSymbol(m)||(s=r.referenceSymbol(m));}let c=r.referenceSymbol(r.api.getSelector("import","valibot"));if(n.$ref){let m=o.circularReferenceTracker.has(n.$ref),l=r.api.getSelector("ref",n.$ref),f=r.getSymbol(l);if(!f){let u=r.context.resolveIrRef(n.$ref),d=ye({$ref:n.$ref,plugin:r,schema:u,state:o});p.push(...d),f=r.getSymbol(l);}if(f){let u=i.identifier({text:f.placeholder});if(m){let d=i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.schemas.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:u})]})]});p.push(d),o.hasCircularReference=true;}else p.push(u);}}else if(n.type){let m=ml({plugin:r,schema:n,state:o});if(a=m.anyType,p.push(m.expression),r.config.metadata&&n.description){let l=i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.actions.metadata}),parameters:[i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:n.description})}]})]});p.push(l);}}else if(n.items)if(n=J({schema:n}),n.items){let m=n.items.map(l=>{let f=ye({plugin:r,schema:l,state:o});return Ke({pipes:f,plugin:r})});if(n.logicalOperator==="and"){let l=i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.schemas.intersect}),parameters:[i.arrayLiteralExpression({elements:m})]});p.push(l);}else {let l=i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.schemas.union}),parameters:[i.arrayLiteralExpression({elements:m})]});p.push(l);}}else {let m=ye({plugin:r,schema:n,state:o});p.push(...m);}else {let m=ml({plugin:r,schema:{type:"unknown"},state:o});a=m.anyType,p.push(m.expression);}if(e&&o.circularReferenceTracker.delete(e),p.length&&n.accessScope==="read"){let m=i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.actions.readonly})});p.push(m);}if(p.length){let m;if(n.default!==void 0){let l=n.type==="integer"&&n.format==="int64";m=zr({isBigInt:l,value:n.default}),m&&(p=[i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.schemas.optional}),parameters:[Ke({pipes:p,plugin:r}),m]})]);}t&&!m&&(p=[i.callExpression({functionName:i.propertyAccessExpression({expression:c.placeholder,name:A.schemas.optional}),parameters:[Ke({pipes:p,plugin:r})]})]);}if(s){e&&(s=r.registerSymbol({exported:true,name:R({config:{case:o.nameCase,name:o.nameTransformer},name:H(e)}),selector:r.api.getSelector("ref",e)}));let m=i.constVariable({comment:r.config.comments?Oe({schema:n}):void 0,exportConst:s.exported,expression:Ke({pipes:p,plugin:r}),name:s.placeholder,typeName:o.hasCircularReference?i.propertyAccessExpression({expression:c.placeholder,name:a||A.types.GenericSchema.text}):void 0});return r.setSymbolValue(s,m),[]}return p},ll=({plugin:e})=>{e.registerSymbol({external:"valibot",meta:{importKind:"namespace"},name:"v",selector:e.api.getSelector("import","valibot")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{let r={circularReferenceTracker:new Set,hasCircularReference:false,nameCase:e.config.definitions.case,nameTransformer:e.config.definitions.name};switch(t.type){case "operation":al({operation:t.operation,plugin:e,state:r});break;case "parameter":ye({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:r});break;case "requestBody":ye({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:r});break;case "schema":ye({$ref:t.$ref,plugin:e,schema:t.schema,state:r});break;case "webhook":pl({operation:t.operation,plugin:e,state:r});break}});};var vs={api:new ks({name:"valibot"}),config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:ll,name:"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}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}WebhookRequest"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.webhooks});},tags:["validator"]};var g={ZodMiniOptional:i.identifier({text:"ZodMiniOptional"}),ZodOptional:i.identifier({text:"ZodOptional"}),_default:i.identifier({text:"_default"}),and:i.identifier({text:"and"}),array:i.identifier({text:"array"}),bigint:i.identifier({text:"bigint"}),boolean:i.identifier({text:"boolean"}),check:i.identifier({text:"check"}),coerce:i.identifier({text:"coerce"}),date:i.identifier({text:"date"}),datetime:i.identifier({text:"datetime"}),default:i.identifier({text:"default"}),describe:i.identifier({text:"describe"}),email:i.identifier({text:"email"}),enum:i.identifier({text:"enum"}),globalRegistry:i.identifier({text:"globalRegistry"}),gt:i.identifier({text:"gt"}),gte:i.identifier({text:"gte"}),infer:i.identifier({text:"infer"}),int:i.identifier({text:"int"}),intersection:i.identifier({text:"intersection"}),ip:i.identifier({text:"ip"}),ipv4:i.identifier({text:"ipv4"}),ipv6:i.identifier({text:"ipv6"}),iso:i.identifier({text:"iso"}),lazy:i.identifier({text:"lazy"}),length:i.identifier({text:"length"}),literal:i.identifier({text:"literal"}),lt:i.identifier({text:"lt"}),lte:i.identifier({text:"lte"}),max:i.identifier({text:"max"}),maxLength:i.identifier({text:"maxLength"}),min:i.identifier({text:"min"}),minLength:i.identifier({text:"minLength"}),never:i.identifier({text:"never"}),null:i.identifier({text:"null"}),nullable:i.identifier({text:"nullable"}),number:i.identifier({text:"number"}),object:i.identifier({text:"object"}),optional:i.identifier({text:"optional"}),parseAsync:i.identifier({text:"parseAsync"}),readonly:i.identifier({text:"readonly"}),record:i.identifier({text:"record"}),regex:i.identifier({text:"regex"}),register:i.identifier({text:"register"}),string:i.identifier({text:"string"}),time:i.identifier({text:"time"}),tuple:i.identifier({text:"tuple"}),undefined:i.identifier({text:"undefined"}),union:i.identifier({text:"union"}),unknown:i.identifier({text:"unknown"}),url:i.identifier({text:"url"}),uuid:i.identifier({text:"uuid"}),void:i.identifier({text:"void"})};var js=class{constructor(t){this.meta=t;}createRequestValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("data",t.id));if(!n)return;let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.parseAsync}),parameters:[i.identifier({text:o})]})})})]})}createResponseValidator({operation:t,plugin:r}){let n=r.getSymbol(r.api.getSelector("responses",t.id));if(!n)return;let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.parseAsync}),parameters:[i.identifier({text:o})]})})})]})}getSelector(...t){return [this.meta.name,...t]}};var ze=({plugin:e,schema:t,symbol:r,typeInferSymbol:n,zodSchema:o})=>{let s=e.referenceSymbol(e.api.getSelector("import","zod")),a=i.constVariable({comment:e.config.comments?Oe({schema:t}):void 0,exportConst:r.exported,expression:o.expression,name:r.placeholder,typeName:o.typeName?i.propertyAccessExpression({expression:s.placeholder,name:o.typeName}):void 0});if(e.setSymbolValue(r,a),n){let p=i.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:i.typeReferenceNode({typeArguments:[i.typeOfExpression({text:r.placeholder})],typeName:i.propertyAccessExpression({expression:s.placeholder,name:g.infer})})});e.setSymbolValue(n,p);}};var Qr=({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 Ur=({getZodSchema:e,operation:t,plugin:r})=>{if(r.config.requests.enabled){let n=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(t.parameters){if(t.parameters.header){let c={},m=[];for(let l in t.parameters.header){let f=t.parameters.header[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("headers"));}Object.keys(c).length&&(o.properties.headers={properties:c,required:m,type:"object"});}if(t.parameters.path){let c={},m=[];for(let l in t.parameters.path){let f=t.parameters.path[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("path"));}Object.keys(c).length&&(o.properties.path={properties:c,required:m,type:"object"});}if(t.parameters.query){let c={},m=[];for(let l in t.parameters.query){let f=t.parameters.query[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("query"));}Object.keys(c).length&&(o.properties.query={properties:c,required:m,type:"object"});}}t.body&&(o.properties.body=t.body.schema,t.body.required&&n.add("body")),o.required=[...n];let s=e(o),a=r.registerSymbol({exported:true,name:R({config:r.config.requests,name:t.id}),selector:r.api.getSelector("data",t.id)}),p=r.config.requests.types.infer.enabled?r.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:r.config.requests.types.infer,name:t.id}),selector:r.api.getSelector("type-infer-data",t.id)}):void 0;ze({plugin:r,schema:o,symbol:a,typeInferSymbol:p,zodSchema:s});}if(r.config.responses.enabled&&t.responses){let{response:n}=tt(t);if(n){let o=e(n),s=r.registerSymbol({exported:true,name:R({config:r.config.responses,name:t.id}),selector:r.api.getSelector("responses",t.id)}),a=r.config.responses.types.infer.enabled?r.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:r.config.responses.types.infer,name:t.id}),selector:r.api.getSelector("type-infer-responses",t.id)}):void 0;ze({plugin:r,schema:n,symbol:s,typeInferSymbol:a,zodSchema:o});}}};var Zr=({getZodSchema:e,operation:t,plugin:r})=>{if(r.config.webhooks.enabled){let n=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(t.parameters){if(t.parameters.header){let c={},m=[];for(let l in t.parameters.header){let f=t.parameters.header[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("headers"));}Object.keys(c).length&&(o.properties.headers={properties:c,required:m,type:"object"});}if(t.parameters.path){let c={},m=[];for(let l in t.parameters.path){let f=t.parameters.path[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("path"));}Object.keys(c).length&&(o.properties.path={properties:c,required:m,type:"object"});}if(t.parameters.query){let c={},m=[];for(let l in t.parameters.query){let f=t.parameters.query[l];c[f.name]=f.schema,f.required&&(m.push(f.name),n.add("query"));}Object.keys(c).length&&(o.properties.query={properties:c,required:m,type:"object"});}}t.body&&(o.properties.body=t.body.schema,t.body.required&&n.add("body")),o.required=[...n];let s=e(o),a=r.registerSymbol({exported:true,name:R({config:r.config.webhooks,name:t.id}),selector:r.api.getSelector("webhook-request",t.id)}),p=r.config.webhooks.types.infer.enabled?r.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:r.config.webhooks.types.infer,name:t.id}),selector:r.api.getSelector("type-infer-webhook-request",t.id)}):void 0;ze({plugin:r,schema:o,symbol:a,typeInferSymbol:p,zodSchema:s});}};var Gh=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o={},s=i.propertyAccessExpression({expression:n.placeholder,name:g.array});if(!t.items)o.expression=i.callExpression({functionName:s,parameters:[Mi({plugin:e}).expression]});else {t=J({schema:t});let p=t.items.map(c=>{let m=vt({plugin:e,schema:c,state:r});return m.hasCircularReference&&(o.hasCircularReference=true),m.expression});if(p.length===1)o.expression=i.callExpression({functionName:s,parameters:p});else if(t.logicalOperator==="and"){let c=t.items[0],m;if(c.logicalOperator==="or"||c.type&&c.type!=="object")m=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.intersection}),parameters:p});else {m=p[0];for(let l=1;l<p.length;l++)m=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.intersection}),parameters:[m,p[l]]});}o.expression=i.callExpression({functionName:s,parameters:[m]});}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:p})]})]});}let a=[];return t.minItems===t.maxItems&&t.minItems!==void 0?a.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.length}),parameters:[i.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&a.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.minLength}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&a.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.maxLength}),parameters:[i.valueToExpression({value:t.maxItems})]}))),a.length&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.check}),parameters:a})),o},Jh=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={};return typeof t.const=="boolean"?(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.boolean(t.const)]}),n):(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.boolean})}),n)},Yh=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={},o=[],s=[],a=false,p=true;for(let c of t.items??[])if(c.type==="string"&&typeof c.const=="string"){let m=i.stringLiteral({text:c.const});o.push(m),s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else if((c.type==="number"||c.type==="integer")&&typeof c.const=="number"){p=false;let m=i.ots.number(c.const);s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else if(c.type==="boolean"&&typeof c.const=="boolean"){p=false;let m=i.ots.boolean(c.const);s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else (c.type==="null"||c.const===null)&&(a=true);return s.length?(p&&o.length>0?n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.enum}),parameters:[i.arrayLiteralExpression({elements:o,multiLine:false})]}):s.length===1?n.expression=s[0]:n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:s,multiLine:s.length>3})]}),a&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.nullable}),parameters:[n.expression]})),n):Mi({plugin:e})},ex=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.never})}),r},tx=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.null})}),r},Pn=({isBigInt:e,value:t})=>{let r=i.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?i.callExpression({functionName:"BigInt",parameters:[r]}):r},rx=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={},o=t.type==="integer"&&t.format==="int64";if(typeof t.const=="number")return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.number(t.const)]}),n;n.expression=i.callExpression({functionName:o?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:r.placeholder,name:g.coerce}),name:g.bigint}):i.propertyAccessExpression({expression:r.placeholder,name:g.number})}),!o&&t.type==="integer"&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.int})}));let s=[];return t.exclusiveMinimum!==void 0?s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.gt}),parameters:[Pn({isBigInt:o,value:t.exclusiveMinimum})]})):t.minimum!==void 0&&s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.gte}),parameters:[Pn({isBigInt:o,value:t.minimum})]})),t.exclusiveMaximum!==void 0?s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.lt}),parameters:[Pn({isBigInt:o,value:t.exclusiveMaximum})]})):t.maximum!==void 0&&s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.lte}),parameters:[Pn({isBigInt:o,value:t.maximum})]})),s.length&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:g.check}),parameters:s})),n},nx=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o={},s=[],a=t.required??[];for(let p in t.properties){let c=t.properties[p],m=a.includes(p),l=vt({optional:!m,plugin:e,schema:c,state:r});l.hasCircularReference&&(o.hasCircularReference=true),oe.lastIndex=0;let f;oe.test(p)?f=p.startsWith("-")?S__default.default.factory.createStringLiteral(p):S__default.default.factory.createNumericLiteral(p):f=p,(p.match(/^[0-9]/)&&p.match(/\D+/g)||p.match(/\W/g))&&!p.startsWith("'")&&!p.endsWith("'")&&(f=`'${p}'`),l.hasCircularReference?s.push(i.getAccessorDeclaration({name:f,returnType:l.typeName?i.propertyAccessExpression({expression:n.placeholder,name:l.typeName}):void 0,statements:[i.returnStatement({expression:l.expression})]})):s.push(i.propertyAssignment({initializer:l.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let p=vt({plugin:e,schema:t.additionalProperties,state:r});return o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.string}),parameters:[]}),p.expression]}),p.hasCircularReference&&(o.hasCircularReference=true),o}return o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.object}),parameters:[S__default.default.factory.createObjectLiteralExpression(s,true)]}),o},ox=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n={};if(typeof t.const=="string")return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.string(t.const)]}),n;n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.string})});let o=[];if(e.config.dates.offset&&o.push({key:"offset",value:true}),e.config.dates.local&&o.push({key:"local",value:true}),t.format)switch(t.format){case "date":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:r.placeholder,name:g.iso}),name:g.date})});break;case "date-time":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:r.placeholder,name:g.iso}),name:g.datetime}),parameters:o.length>0?[i.objectExpression({obj:o})]:[]});break;case "email":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.email})});break;case "ipv4":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.ipv4})});break;case "ipv6":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.ipv6})});break;case "time":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:r.placeholder,name:g.iso}),name:g.time})});break;case "uri":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.url})});break;case "uuid":n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.uuid})});break}let s=[];return t.minLength===t.maxLength&&t.minLength!==void 0?s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.length}),parameters:[i.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.minLength}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.maxLength}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),s.length&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:g.check}),parameters:s})),n},sx=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o={};if(t.const&&Array.isArray(t.const)){let a=t.const.map(p=>i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[i.valueToExpression({value:p})]}));return o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:a})]}),o}let s=[];for(let a of t.items??[]){let p=vt({plugin:e,schema:a,state:r});s.push(p.expression),p.hasCircularReference&&(o.hasCircularReference=true);}return o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:s})]}),o},ix=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.undefined})}),r},Mi=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.unknown})}),r},ax=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod")),r={};return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.void})}),r},fl=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return Gh({plugin:e,schema:t,state:r});case "boolean":return Jh({plugin:e,schema:t});case "enum":return Yh({plugin:e,schema:t});case "integer":case "number":return rx({plugin:e,schema:t});case "never":return ex({plugin:e});case "null":return tx({plugin:e});case "object":return nx({plugin:e,schema:t,state:r});case "string":return ox({plugin:e,schema:t});case "tuple":return sx({plugin:e,schema:t,state:r});case "undefined":return ix({plugin:e});case "unknown":return Mi({plugin:e});case "void":return ax({plugin:e})}},vt=({optional:e,plugin:t,schema:r,state:n})=>{let o={},s=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let a=n.circularReferenceTracker.includes(r.$ref),p=n.currentReferenceTracker.includes(r.$ref);n.circularReferenceTracker.push(r.$ref),n.currentReferenceTracker.push(r.$ref);let c=t.api.getSelector("ref",r.$ref),m=t.getSymbol(c);if(a)m||(m=t.referenceSymbol(c)),p?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.lazy}),parameters:[i.arrowFunction({returnType:i.keywordTypeNode({keyword:"any"}),statements:[i.returnStatement({expression:i.identifier({text:m.placeholder})})]})]}):o.expression=i.identifier({text:m.placeholder}),o.hasCircularReference=r.circular;else {if(m)o.hasCircularReference=r.circular;else {let f=t.context.resolveIrRef(r.$ref);Ns({id:r.$ref,plugin:t,schema:f,state:n});}let l=t.referenceSymbol(c);o.expression=i.identifier({text:l.placeholder});}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=fl({plugin:t,schema:r,state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,t.config.metadata&&r.description&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.register}),parameters:[i.propertyAccessExpression({expression:s.placeholder,name:g.globalRegistry}),i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=J({schema:r}),r.items){let a=r.items.map(p=>vt({plugin:t,schema:p,state:n}));if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.intersection}),parameters:a.map(c=>c.expression)}):(o.expression=a[0].expression,a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.intersection}),parameters:[o.expression,c.hasCircularReference?i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:c.expression})]})]}):c.expression]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:a.map(p=>p.expression)})]});}else o=vt({plugin:t,schema:r,state:n});else {let a=fl({plugin:t,schema:{type:"unknown"},state:n});o.expression=a.expression;}if(o.expression&&(r.accessScope==="read"&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.readonly}),parameters:[o.expression]})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.optional}),parameters:[o.expression]}),o.typeName=g.ZodMiniOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=Pn({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g._default}),parameters:[o.expression,p]}));}return o},Ns=({id:e,plugin:t,schema:r,state:n})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...n,currentReferenceTracker:[e]},s=t.api.getSelector("ref",e),a=t.getSymbol(s);if(a&&!t.getSymbolValue(a))return;let p=vt({plugin:t,schema:r,state:o}),c=H(e);a=t.registerSymbol({exported:true,name:R({config:t.config.definitions,name:c}),selector:s});let m=t.config.definitions.types.infer.enabled?t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.definitions.types.infer,name:c}),selector:t.api.getSelector("type-infer-ref",e)}):void 0;ze({plugin:t,schema:r,symbol:a,typeInferSymbol:m,zodSchema:p});},ul=({plugin:e})=>{e.registerSymbol({external:Qr({plugin:e}),meta:{importKind:"namespace"},name:"z",selector:e.api.getSelector("import","zod")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{switch(t.type){case "operation":Ur({getZodSchema:r=>vt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":Ns({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":Ns({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":Ns({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Zr({getZodSchema:r=>vt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var px=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o=i.propertyAccessExpression({expression:n.placeholder,name:g.array}),s,a=false;if(!t.items)s=i.callExpression({functionName:o,parameters:[Li({plugin:e})]});else {t=J({schema:t});let p=t.items.map(c=>{let m=jt({plugin:e,schema:c,state:r});return m.hasCircularReference&&(a=true),m.expression});if(p.length===1)s=i.callExpression({functionName:o,parameters:p});else if(t.logicalOperator==="and"){let c=t.items[0],m;if(c.logicalOperator==="or"||c.type&&c.type!=="object")m=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.intersection}),parameters:p});else {m=p[0];for(let l=1;l<p.length;l++)m=i.callExpression({functionName:i.propertyAccessExpression({expression:m,name:g.and}),parameters:[p[l]]});}s=i.callExpression({functionName:o,parameters:[m]});}else s=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:p})]})]});}return t.minItems===t.maxItems&&t.minItems!==void 0?s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:g.length}),parameters:[i.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:g.min}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:g.max}),parameters:[i.valueToExpression({value:t.maxItems})]}))),{expression:s,hasCircularReference:a}},cx=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="boolean"?i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.boolean(t.const)]}):i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.boolean})})},mx=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n=[],o=[],s=false,a=true;for(let c of t.items??[])if(c.type==="string"&&typeof c.const=="string"){let m=i.stringLiteral({text:c.const});n.push(m),o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else if((c.type==="number"||c.type==="integer")&&typeof c.const=="number"){a=false;let m=i.ots.number(c.const);o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else if(c.type==="boolean"&&typeof c.const=="boolean"){a=false;let m=i.ots.boolean(c.const);o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[m]}));}else (c.type==="null"||c.const===null)&&(s=true);if(!o.length)return Li({plugin:e});let p;return a&&n.length>0?p=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.enum}),parameters:[i.arrayLiteralExpression({elements:n,multiLine:false})]}):o.length===1?p=o[0]:p=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(p=i.callExpression({functionName:i.propertyAccessExpression({expression:p,name:g.nullable})})),p},lx=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.never})})},fx=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.null})})},An=({isBigInt:e,value:t})=>{let r=i.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?i.callExpression({functionName:"BigInt",parameters:[r]}):r},ux=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod")),n=t.type==="integer"&&t.format==="int64";if(typeof t.const=="number")return i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.number(t.const)]});let o=i.callExpression({functionName:n?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:r.placeholder,name:g.coerce}),name:g.bigint}):i.propertyAccessExpression({expression:r.placeholder,name:g.number})});return !n&&t.type==="integer"&&(o=i.callExpression({functionName:i.propertyAccessExpression({expression:o,name:g.int})})),t.exclusiveMinimum!==void 0?o=i.callExpression({functionName:i.propertyAccessExpression({expression:o,name:g.gt}),parameters:[An({isBigInt:n,value:t.exclusiveMinimum})]}):t.minimum!==void 0&&(o=i.callExpression({functionName:i.propertyAccessExpression({expression:o,name:g.gte}),parameters:[An({isBigInt:n,value:t.minimum})]})),t.exclusiveMaximum!==void 0?o=i.callExpression({functionName:i.propertyAccessExpression({expression:o,name:g.lt}),parameters:[An({isBigInt:n,value:t.exclusiveMaximum})]}):t.maximum!==void 0&&(o=i.callExpression({functionName:i.propertyAccessExpression({expression:o,name:g.lte}),parameters:[An({isBigInt:n,value:t.maximum})]})),o},dx=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o=false,s=[],a=t.required??[];for(let c in t.properties){let m=t.properties[c],l=a.includes(c),f=jt({optional:!l,plugin:e,schema:m,state:r});f.hasCircularReference&&(o=true),oe.lastIndex=0;let u;oe.test(c)?u=c.startsWith("-")?S__default.default.factory.createStringLiteral(c):S__default.default.factory.createNumericLiteral(c):u=c,(c.match(/^[0-9]/)&&c.match(/\D+/g)||c.match(/\W/g))&&!c.startsWith("'")&&!c.endsWith("'")&&(u=`'${c}'`),s.push(i.propertyAssignment({initializer:f.expression,name:u}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let c=jt({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.record}),parameters:[c.expression]}),hasCircularReference:c.hasCircularReference}}return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.object}),parameters:[S__default.default.factory.createObjectLiteralExpression(s,true)]}),hasCircularReference:o}},yx=({plugin:e,schema:t})=>{let r=e.referenceSymbol(e.api.getSelector("import","zod"));if(typeof t.const=="string")return i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.literal}),parameters:[i.ots.string(t.const)]});let n=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.string})}),o=[];if(e.config.dates.offset&&o.push({key:"offset",value:true}),e.config.dates.local&&o.push({key:"local",value:true}),t.format)switch(t.format){case "date":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.date})});break;case "date-time":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.datetime}),parameters:o.length>0?[i.objectExpression({obj:o})]:[]});break;case "email":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.email})});break;case "ipv4":case "ipv6":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.ip})});break;case "time":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.time})});break;case "uri":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.url})});break;case "uuid":n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.length}),parameters:[i.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.min}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.max}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&(n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:g.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),n},gx=({plugin:e,schema:t,state:r})=>{let n=e.referenceSymbol(e.api.getSelector("import","zod")),o=false;if(t.const&&Array.isArray(t.const)){let p=t.const.map(m=>i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[i.valueToExpression({value:m})]}));return {expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:p})]}),hasCircularReference:o}}let s=[];for(let p of t.items??[]){let c=jt({plugin:e,schema:p,state:r});c.hasCircularReference&&(o=true),s.push(c.expression);}return {expression:i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:s})]}),hasCircularReference:o}},hx=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.undefined})})},Li=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.unknown})})},xx=({plugin:e})=>{let t=e.referenceSymbol(e.api.getSelector("import","zod"));return i.callExpression({functionName:i.propertyAccessExpression({expression:t.placeholder,name:g.void})})},dl=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return px({plugin:e,schema:t,state:r});case "boolean":return {expression:cx({plugin:e,schema:t})};case "enum":return {expression:mx({plugin:e,schema:t})};case "integer":case "number":return {expression:ux({plugin:e,schema:t})};case "never":return {expression:lx({plugin:e})};case "null":return {expression:fx({plugin:e})};case "object":return dx({plugin:e,schema:t,state:r});case "string":return {expression:yx({plugin:e,schema:t})};case "tuple":return gx({plugin:e,schema:t,state:r});case "undefined":return {expression:hx({plugin:e})};case "unknown":return {expression:Li({plugin:e})};case "void":return {expression:xx({plugin:e})}}},jt=({optional:e,plugin:t,schema:r,state:n})=>{let o={},s=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let a=n.circularReferenceTracker.includes(r.$ref);n.circularReferenceTracker.push(r.$ref),n.currentReferenceTracker.push(r.$ref);let p=t.api.getSelector("ref",r.$ref),c=t.getSymbol(p);if(a)c||(c=t.referenceSymbol(p)),o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:i.identifier({text:c.placeholder})})]})]}),o.hasCircularReference=r.circular;else {if(c)o.hasCircularReference=r.circular;else {let l=t.context.resolveIrRef(r.$ref);ws({id:r.$ref,plugin:t,schema:l,state:{...n,currentReferenceTracker:[r.$ref]}});}let m=t.referenceSymbol(p);o.expression=i.identifier({text:m.placeholder});}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=dl({plugin:t,schema:r,state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,o.typeName=a.anyType,t.config.metadata&&r.description&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.describe}),parameters:[i.stringLiteral({text:r.description})]}));}else if(r.items)if(r=J({schema:r}),r.items){let a=r.items.map(p=>{let c=jt({plugin:t,schema:p,state:n});return c.hasCircularReference&&(o.hasCircularReference=true),c.expression});if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.intersection}),parameters:a}):(o.expression=a[0],a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.and}),parameters:[c]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:a})]});}else o=jt({plugin:t,schema:r,state:n});else {let a=dl({plugin:t,schema:{type:"unknown"},state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,o.typeName=a.anyType;}if(o.expression&&(r.accessScope==="read"&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.readonly})})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.optional})})),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=An({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.default}),parameters:[p]}));}return o.hasCircularReference?o.typeName||(o.typeName="ZodTypeAny"):o.typeName&&(o.typeName=void 0),o},ws=({id:e,plugin:t,schema:r,state:n})=>{n||(n={circularReferenceTracker:[e],currentReferenceTracker:[e],hasCircularReference:false});let o=t.api.getSelector("ref",e),s=t.getSymbol(o);if(s)return;let a=jt({plugin:t,schema:r,state:n}),p=H(e);s=t.registerSymbol({exported:true,name:R({config:t.config.definitions,name:p}),selector:o});let c=t.config.definitions.types.infer.enabled?t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.definitions.types.infer,name:p}),selector:t.api.getSelector("type-infer-ref",e)}):void 0;ze({plugin:t,schema:r,symbol:s,typeInferSymbol:c,zodSchema:a});},yl=({plugin:e})=>{e.registerSymbol({external:Qr({plugin:e}),name:"z",selector:e.api.getSelector("import","zod")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{switch(t.type){case "operation":Ur({getZodSchema:r=>jt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":ws({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":ws({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":ws({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Zr({getZodSchema:r=>jt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var bx=({plugin:e,schema:t,state:r})=>{let n={},o=e.referenceSymbol(e.api.getSelector("import","zod")),s=i.propertyAccessExpression({expression:o.placeholder,name:g.array});if(!t.items)n.expression=i.callExpression({functionName:s,parameters:[Bi({plugin:e}).expression]});else {t=J({schema:t});let a=t.items.map(p=>{let c=Nt({plugin:e,schema:p,state:r});return c.hasCircularReference&&(n.hasCircularReference=true),c.expression});if(a.length===1)n.expression=i.callExpression({functionName:s,parameters:a});else if(t.logicalOperator==="and"){let p=t.items[0],c;if(p.logicalOperator==="or"||p.type&&p.type!=="object")c=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.intersection}),parameters:a});else {c=a[0];for(let m=1;m<a.length;m++)c=i.callExpression({functionName:i.propertyAccessExpression({expression:c,name:g.and}),parameters:[a[m]]});}n.expression=i.callExpression({functionName:s,parameters:[c]});}else n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:a})]})]});}return t.minItems===t.maxItems&&t.minItems!==void 0?n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:g.length}),parameters:[i.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:g.min}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:g.max}),parameters:[i.valueToExpression({value:t.maxItems})]}))),n},Sx=({plugin:e,schema:t})=>{let r={},n=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="boolean"?(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[i.ots.boolean(t.const)]}),r):(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.boolean})}),r)},Ox=({plugin:e,schema:t})=>{let r={},n=e.referenceSymbol(e.api.getSelector("import","zod")),o=[],s=[],a=false,p=true;for(let c of t.items??[])if(c.type==="string"&&typeof c.const=="string"){let m=i.stringLiteral({text:c.const});o.push(m),s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[m]}));}else if((c.type==="number"||c.type==="integer")&&typeof c.const=="number"){p=false;let m=i.ots.number(c.const);s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[m]}));}else if(c.type==="boolean"&&typeof c.const=="boolean"){p=false;let m=i.ots.boolean(c.const);s.push(i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[m]}));}else (c.type==="null"||c.const===null)&&(a=true);return s.length?(p&&o.length>0?r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.enum}),parameters:[i.arrayLiteralExpression({elements:o,multiLine:false})]}):s.length===1?r.expression=s[0]:r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:s,multiLine:s.length>3})]}),a&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.nullable}),parameters:[r.expression]})),r):Bi({plugin:e})},Rx=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.never})}),t},Tx=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.null})}),t},En=({isBigInt:e,value:t})=>{let r=i.valueToExpression({value:t});return e&&(typeof t=="bigint"||typeof t=="number"||typeof t=="string"||typeof t=="boolean")?i.callExpression({functionName:"BigInt",parameters:[r]}):r},Px=({plugin:e,schema:t})=>{let r={},n=t.type==="integer"&&t.format==="int64",o=e.referenceSymbol(e.api.getSelector("import","zod"));return typeof t.const=="number"?(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.literal}),parameters:[i.ots.number(t.const)]}),r):(r.expression=i.callExpression({functionName:n?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:o.placeholder,name:g.coerce}),name:g.bigint}):i.propertyAccessExpression({expression:o.placeholder,name:g.number})}),!n&&t.type==="integer"&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.int})})),t.exclusiveMinimum!==void 0?r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.gt}),parameters:[En({isBigInt:n,value:t.exclusiveMinimum})]}):t.minimum!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.gte}),parameters:[En({isBigInt:n,value:t.minimum})]})),t.exclusiveMaximum!==void 0?r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.lt}),parameters:[En({isBigInt:n,value:t.exclusiveMaximum})]}):t.maximum!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.lte}),parameters:[En({isBigInt:n,value:t.maximum})]})),r)},Ax=({plugin:e,schema:t,state:r})=>{let n={},o=[],s=t.required??[],a=e.referenceSymbol(e.api.getSelector("import","zod"));for(let p in t.properties){let c=t.properties[p],m=s.includes(p),l=Nt({optional:!m,plugin:e,schema:c,state:r});l.hasCircularReference&&(n.hasCircularReference=true),oe.lastIndex=0;let f;oe.test(p)?f=p.startsWith("-")?S__default.default.factory.createStringLiteral(p):S__default.default.factory.createNumericLiteral(p):f=p,(p.match(/^[0-9]/)&&p.match(/\D+/g)||p.match(/\W/g))&&!p.startsWith("'")&&!p.endsWith("'")&&(f=`'${p}'`),l.hasCircularReference?o.push(i.getAccessorDeclaration({name:f,returnType:l.typeName?i.propertyAccessExpression({expression:a.placeholder,name:l.typeName}):void 0,statements:[i.returnStatement({expression:l.expression})]})):o.push(i.propertyAssignment({initializer:l.expression,name:f}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let p=Nt({plugin:e,schema:t.additionalProperties,state:r});return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:g.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:g.string}),parameters:[]}),p.expression]}),p.hasCircularReference&&(n.hasCircularReference=true),n.hasCircularReference?{...n,typeName:"ZodType"}:n}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:a.placeholder,name:g.object}),parameters:[S__default.default.factory.createObjectLiteralExpression(o,true)]}),n.hasCircularReference?{...n,typeName:"ZodType"}:n},Ex=({plugin:e,schema:t})=>{let r={},n=e.referenceSymbol(e.api.getSelector("import","zod"));if(typeof t.const=="string")return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.literal}),parameters:[i.ots.string(t.const)]}),r;r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.string})});let o=[];if(e.config.dates.offset&&o.push({key:"offset",value:true}),e.config.dates.local&&o.push({key:"local",value:true}),t.format)switch(t.format){case "date":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:n.placeholder,name:g.iso}),name:g.date})});break;case "date-time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:n.placeholder,name:g.iso}),name:g.datetime}),parameters:o.length>0?[i.objectExpression({obj:o})]:[]});break;case "email":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.email})});break;case "ipv4":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.ipv4})});break;case "ipv6":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.ipv6})});break;case "time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:n.placeholder,name:g.iso}),name:g.time})});break;case "uri":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.url})});break;case "uuid":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.placeholder,name:g.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.length}),parameters:[i.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.min}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.max}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:g.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),r},Cx=({plugin:e,schema:t,state:r})=>{let n={},o=e.referenceSymbol(e.api.getSelector("import","zod"));if(t.const&&Array.isArray(t.const)){let a=t.const.map(p=>i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.literal}),parameters:[i.valueToExpression({value:p})]}));return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:a})]}),n}let s=[];for(let a of t.items??[]){let p=Nt({plugin:e,schema:a,state:r});s.push(p.expression),p.hasCircularReference&&(n.hasCircularReference=true);}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.placeholder,name:g.tuple}),parameters:[i.arrayLiteralExpression({elements:s})]}),n},kx=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.undefined})}),t},Bi=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.unknown})}),t},Ix=({plugin:e})=>{let t={},r=e.referenceSymbol(e.api.getSelector("import","zod"));return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.placeholder,name:g.void})}),t},gl=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return bx({plugin:e,schema:t,state:r});case "boolean":return Sx({plugin:e,schema:t});case "enum":return Ox({plugin:e,schema:t});case "integer":case "number":return Px({plugin:e,schema:t});case "never":return Rx({plugin:e});case "null":return Tx({plugin:e});case "object":return Ax({plugin:e,schema:t,state:r});case "string":return Ex({plugin:e,schema:t});case "tuple":return Cx({plugin:e,schema:t,state:r});case "undefined":return kx({plugin:e});case "unknown":return Bi({plugin:e});case "void":return Ix({plugin:e})}},Nt=({optional:e,plugin:t,schema:r,state:n})=>{let o={},s=t.referenceSymbol(t.api.getSelector("import","zod"));if(r.$ref){let a=n.circularReferenceTracker.includes(r.$ref),p=n.currentReferenceTracker.includes(r.$ref);n.circularReferenceTracker.push(r.$ref),n.currentReferenceTracker.push(r.$ref);let c=t.api.getSelector("ref",r.$ref),m=t.getSymbol(c);if(a)m||(m=t.referenceSymbol(c)),p?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.lazy}),parameters:[i.arrowFunction({returnType:i.keywordTypeNode({keyword:"any"}),statements:[i.returnStatement({expression:i.identifier({text:m.placeholder})})]})]}):o.expression=i.identifier({text:m.placeholder}),o.hasCircularReference=r.circular;else {if(m)o.hasCircularReference=r.circular;else {let f=t.context.resolveIrRef(r.$ref);qs({id:r.$ref,plugin:t,schema:f,state:n});}let l=t.referenceSymbol(c);o.expression=i.identifier({text:l.placeholder});}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=gl({plugin:t,schema:r,state:n});o.expression=a.expression,o.hasCircularReference=a.hasCircularReference,t.config.metadata&&r.description&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.register}),parameters:[i.propertyAccessExpression({expression:s.placeholder,name:g.globalRegistry}),i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=J({schema:r}),r.items){let a=r.items.map(p=>Nt({plugin:t,schema:p,state:n}));if(r.logicalOperator==="and"){let p=r.items[0];p.logicalOperator==="or"||p.type&&p.type!=="object"?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.intersection}),parameters:a.map(c=>c.expression)}):(o.expression=a[0].expression,a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.and}),parameters:[c.hasCircularReference?i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:c.expression})]})]}):c.expression]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.union}),parameters:[i.arrayLiteralExpression({elements:a.map(p=>p.expression)})]});}else o=Nt({plugin:t,schema:r,state:n});else {let a=gl({plugin:t,schema:{type:"unknown"},state:n});o.expression=a.expression;}if(o.expression&&(r.accessScope==="read"&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.readonly})})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:s.placeholder,name:g.optional}),parameters:[o.expression]}),o.typeName=g.ZodOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=En({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:g.default}),parameters:[p]}));}return o},qs=({id:e,plugin:t,schema:r,state:n})=>{let o={circularReferenceTracker:[e],hasCircularReference:false,...n,currentReferenceTracker:[e]},s=t.api.getSelector("ref",e),a=t.getSymbol(s);if(a&&!t.getSymbolValue(a))return;let p=Nt({plugin:t,schema:r,state:o}),c=H(e);a=t.registerSymbol({exported:true,name:R({config:t.config.definitions,name:c}),selector:s});let m=t.config.definitions.types.infer.enabled?t.registerSymbol({exported:true,meta:{kind:"type"},name:R({config:t.config.definitions.types.infer,name:c}),selector:t.api.getSelector("type-infer-ref",e)}):void 0;ze({plugin:t,schema:r,symbol:a,typeInferSymbol:m,zodSchema:p});},Vi=({plugin:e})=>{e.registerSymbol({external:Qr({plugin:e}),name:"z",selector:e.api.getSelector("import","zod")}),e.forEach("operation","parameter","requestBody","schema","webhook",t=>{switch(t.type){case "operation":Ur({getZodSchema:r=>Nt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break;case "parameter":qs({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case "requestBody":qs({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case "schema":qs({id:t.$ref,plugin:e,schema:t.schema});break;case "webhook":Zr({getZodSchema:r=>Nt({plugin:e,schema:r,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:t.operation,plugin:e});break}});};var hl=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return yl(e);case 4:return Vi(e);case "mini":return ul(e);default:return Vi(e)}};var $s={api:new js({name:"zod"}),config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:hl,name:"zod",resolveConfig:(e,t)=>{let n=t.package.getVersion("zod"),o=()=>n&&(n.major===4||n.major===3)?n.major:4,s=a=>{if(!a)return o();if(!n)return a;if((a===4||a===3||a==="mini")&&!t.package.satisfies(n,">=3.25.0 <5.0.0")){let p=o();return console.warn(`\u{1F50C} ${Z__default.default.yellow("Warning:")} Installed ${Z__default.default.cyan("zod")} ${Z__default.default.cyan(`v${n.version}`)} does not support compatibility version ${Z__default.default.yellow(String(a))}, using ${Z__default.default.yellow(String(p))}.`),p}return a};e.config.compatibilityVersion=s(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:Ge,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:{...Ge,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:Ge,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:{...Ge,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:Ge,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:{...Ge,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:Ge,value:c.infer})})},value:a.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"z{{name}}WebhookRequest",types:{...e.config.types,infer:{...e.config.types.infer,name:"{{name}}WebhookRequestZodType"}}},mappers:{...Ge,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:Ge,value:c.infer})})},value:a.types})})},value:e.config.webhooks});},tags:["validator"]};var Ms={"@angular/common":ko,"@hey-api/client-angular":No,"@hey-api/client-axios":qo,"@hey-api/client-fetch":Mo,"@hey-api/client-next":Lo,"@hey-api/client-nuxt":Bo,"@hey-api/client-ofetch":Ho,"@hey-api/schemas":Zo,"@hey-api/sdk":Go,"@hey-api/transformers":ts,"@hey-api/typescript":os,"@pinia/colada":ps,"@tanstack/angular-query-experimental":hs,"@tanstack/react-query":bs,"@tanstack/solid-query":Os,"@tanstack/svelte-query":Ts,"@tanstack/vue-query":As,fastify:Cs,"legacy/angular":_o,"legacy/axios":Wo,"legacy/fetch":Ko,"legacy/node":zo,"legacy/xhr":Qo,valibot:vs,zod:$s};var Hi=["@hey-api/typescript","@hey-api/sdk"],jx=({dependencies:e,userPlugins:t,userPluginsConfig:r})=>{let n=new Set,o=new Set,s={},a=p=>{if(n.has(p))throw new Error(`Circular reference detected at '${p}'`);if(o.has(p))return;n.add(p);let c=Ms[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 l={...c,...m,config:{...c?.config,...m?.config},dependencies:new Set([...c?.dependencies||[],...m?.dependencies||[]])};if(l.resolveConfig){let f={package:Qn(e),pluginByTag:(u,d={})=>{let{defaultPlugin:y,errorMessage:h}=d;for(let x of t){let b=Ms[x]||r[x];if(b&&b.tags?.includes(u)&&x!==p)return x}if(y){let x=Ms[y]||r[y];if(x&&x.tags?.includes(u)&&y!==p)return y}throw new Error(h||`missing plugin - no plugin with tag "${u}" found`)},valueToObject:Pe};l.resolveConfig(l,f);}for(let f of l.dependencies)a(f);n.delete(p),o.add(p),s[p]=l;};for(let p of t)a(p);return {pluginOrder:Array.from(o),plugins:s}},Nx=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"),xl=({dependencies:e,userConfig:t})=>{let r={},n=Hi;t.plugins&&(t.plugins=t.plugins.filter(s=>typeof s=="string"&&s||typeof s!="string"&&s.name),t.plugins.length===1&&Nx(t.plugins[0])?n=[...Hi,...t.plugins]:n=t.plugins);let o=n.map(s=>{if(typeof s=="string")return s;let a=s.name;return a&&(s.handler?r[a]=s:(r[a]={config:{...s}},delete r[a].config.name)),a}).filter(Boolean);return jx({dependencies:e,userPlugins:o,userPluginsConfig:r})};var $x=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),bl=async({logger:e,userConfigs:t})=>{let r=[],n={},o=e.timeEvent("load");for(let p of t){let c;if(p?.configFile){let d=p.configFile.split(".");c=d.slice(0,d.length-1).join(".");}let m=e.timeEvent("c12"),{config:l,configFile:f}=await c12.loadConfig({configFile:c,name:"openapi-ts"});m.timeEnd(),Object.keys(n).length||(n=Ta(Object.keys(l).length?f:void 0));let u=l instanceof Array?l.map(d=>Ws(d,p)):[Ws(l,p)];for(let d of u){let y=_s(d);if(d.output instanceof Array){let h=y.length,x=d.output.length;if(x>1)if(h!==x){console.warn(`\u2699\uFE0F ${Z__default.default.yellow("Warning:")} You provided ${Z__default.default.cyan(String(h))} ${Z__default.default.cyan(h===1?"input":"inputs")} and ${Z__default.default.yellow(String(x))} ${Z__default.default.yellow("outputs")}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let b of d.output)r.push({...d,input:y,output:b});}else d.output.forEach((b,k)=>{r.push({...d,input:y[k],output:b});});else r.push({...d,input:y,output:d.output[0]??""});}else r.push({...d,input:y});}}o.timeEnd();let s=[],a=e.timeEvent("build");for(let p of r){let{base:c,configFile:m="",dryRun:l=false,experimentalParser:f=true,exportCore:u=true,name:d,request:y,useOptions:h=true}=p,x=p.interactive!==void 0?p.interactive:$x(),b=Yr(p),k=_s(p),P=Oa(p),I=Aa(p),v=[];k.length||v.push(new Xe("missing input - which OpenAPI specification should we use to generate your output?")),P.path||v.push(new Xe("missing output - where should we generate your output?")),h||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"),P.path=L__default.default.resolve(process.cwd(),P.path);let w;try{w=xl({dependencies:n,userConfig:p});}catch(F){v.push(F),w={pluginOrder:[],plugins:{}};}let V=ga({...w,base:c,configFile:m,dryRun:l,experimentalParser:f,exportCore:false,input:k,interactive:x,logs:b,name:d,output:P,parser:I,request:y,useOptions:h});V.exportCore=W(V)?u:false;let M=s.length;if(b.level==="debug"){let F=Z__default.default.gray(`[Job ${M+1}] `);console.warn(`${F}${Z__default.default.cyan("config:")}`,V);}s.push({config:V,errors:v,jobIndex:M});}return a.timeEnd(),{dependencies:n,results:s}};var Ds=e=>{switch(e){case "legacy/angular":return "AngularHttpRequest";case "legacy/axios":return "AxiosHttpRequest";case "legacy/fetch":return "FetchHttpRequest";case "legacy/node":return "NodeHttpRequest";case "legacy/xhr":return "XHRHttpRequest";default:return ""}};var Sl=async(e,t,r,n)=>{let o=T(),s=E(o),a=n.client({$config:o,...r,httpRequest:Ds(s.name),models:dn(r.models),services:dn(r.services)});X(o)&&(Be(t),Se__default.default.writeFileSync(L__default.default.resolve(t,`${X(o)}.ts`),a));};var Ol=async(e,t,r)=>{let n=T();if(n.exportCore){let o=E(n),s={httpRequest:Ds(o.name),server:n.base!==void 0?n.base:t.server,version:t.version};if(Se__default.default.rmSync(L__default.default.resolve(e),{force:true,recursive:true}),Se__default.default.mkdirSync(L__default.default.resolve(e),{recursive:true}),await Se__default.default.writeFileSync(L__default.default.resolve(e,"OpenAPI.ts"),r.core.settings({$config:n,...s})),await Se__default.default.writeFileSync(L__default.default.resolve(e,"ApiError.ts"),r.core.apiError({$config:n,...s})),await Se__default.default.writeFileSync(L__default.default.resolve(e,"ApiRequestOptions.ts"),r.core.apiRequestOptions({$config:n,...s})),await Se__default.default.writeFileSync(L__default.default.resolve(e,"ApiResult.ts"),r.core.apiResult({$config:n,...s})),o.name!=="legacy/angular"&&await Se__default.default.writeFileSync(L__default.default.resolve(e,"CancelablePromise.ts"),r.core.cancelablePromise({$config:n,...s})),await Se__default.default.writeFileSync(L__default.default.resolve(e,"request.ts"),r.core.request({$config:n,...s})),X(n)&&(await Se__default.default.writeFileSync(L__default.default.resolve(e,"BaseHttpRequest.ts"),r.core.baseHttpRequest({$config:n,...s})),await Se__default.default.writeFileSync(L__default.default.resolve(e,`${s.httpRequest}.ts`),r.core.httpRequest({$config:n,...s}))),n.request){let a=L__default.default.resolve(process.cwd(),n.request);if(!await Se__default.default.existsSync(a))throw new Error(`Custom request file "${a}" does not exists`);await Se__default.default.copyFileSync(a,L__default.default.resolve(e,"request.ts"));}}};var Rl=({files:e})=>{let t=T();e.index=new De({dir:t.output.path,id:"index",name:"index.ts"}),X(t)&&e.index.add(i.exportNamedDeclaration({exports:X(t),module:`./${X(t)}`})),t.exportCore&&(e.index.add(i.exportNamedDeclaration({exports:"ApiError",module:"./core/ApiError"})),t.plugins["@hey-api/sdk"]?.config.response==="response"&&e.index.add(i.exportNamedDeclaration({exports:{asType:true,name:"ApiResult"},module:"./core/ApiResult"})),X(t)&&e.index.add(i.exportNamedDeclaration({exports:"BaseHttpRequest",module:"./core/BaseHttpRequest"})),E(t).name!=="legacy/angular"&&e.index.add(i.exportNamedDeclaration({exports:["CancelablePromise","CancelError"],module:"./core/CancelablePromise"})),e.index.add(i.exportNamedDeclaration({exports:["OpenAPI",{asType:true,name:"OpenAPIConfig"}],module:"./core/OpenAPI"}))),Object.keys(e).sort().forEach(r=>{let n=e[r];r==="index"||n.isEmpty()||n.exportFromIndex&&e.index.add(i.exportAllDeclaration({module:`./${n.nameWithoutExtension()}`}));});};var Tl=async({client:e,openApi:t,templates:r})=>{let n=T(),o=t;if(e){if(n.plugins["@hey-api/sdk"]?.config.include&&n.plugins["@hey-api/sdk"].config.asClass){let c=new RegExp(n.plugins["@hey-api/sdk"].config.include);e.services=e.services.filter(m=>c.test(m.name));}if(n.plugins["@hey-api/typescript"]?.config.include){let c=new RegExp(n.plugins["@hey-api/typescript"].config.include);e.models=e.models.filter(m=>c.test(m.name));}}let s=L__default.default.resolve(n.output.path);n.output.clean&&qn(s);let a=E(n);if(!W(n)&&"bundle"in a.config&&a.config.bundle){let c={importFileExtension:n.output.importFileExtension};vo({meta:c,outputPath:s,plugin:a});}await Sl(o,s,e,r),await Ol(L__default.default.resolve(n.output.path,"core"),e,r);let p={};for(let c of n.pluginOrder){let m=n.plugins[c],l=(m.output??"").split("/"),f=L__default.default.resolve(n.output.path,...l.slice(0,l.length-1));p[m.name]=new De({dir:f,id:`legacy-unused-${m.name}`,name:`${l[l.length-1]}.ts`}),m.handlerLegacy?.({client:e,files:p,openApi:o,plugin:m});}Rl({files:p}),Object.entries(p).forEach(([c,m])=>{n.dryRun||(c==="index"?m.write(`
|
|
45
45
|
`,n.output.tsConfig):m.write(`
|
|
46
46
|
|
|
47
47
|
`,n.output.tsConfig));});};var Al=async({context:e})=>{let t=L__default.default.resolve(e.config.output.path);e.config.output.clean&&qn(t);let r={importFileExtension:e.config.output.importFileExtension},n=E(e.config);"bundle"in n.config&&n.config.bundle&&(e.config._FRAGILE_CLIENT_BUNDLE_RENAMED=vo({meta:r,outputPath:t,plugin:n,project:e.gen}));for(let o of e.registerPlugins())await o.run();for(let o of e.gen.render(r)){let s=L__default.default.resolve(t,o.path),a=L__default.default.dirname(s);e.config.dryRun||(Se__default.default.mkdirSync(a,{recursive:true}),Se__default.default.writeFileSync(s,o.content,{encoding:"utf8"}));}};var Wx=e=>{let t=[];return e.forEach((r,n)=>{t.push([n,r]);}),t},Ls=(...e)=>{let t=new Headers;for(let r of e){if(!r)continue;let n=r instanceof Headers?Wx(r):Object.entries(r);for(let[o,s]of n)if(s===null)t.delete(o);else if(Array.isArray(s))for(let a of s)t.append(o,a);else s!==void 0&&t.set(o,typeof s=="object"?JSON.stringify(s):s);}return t};var Cl=async({fetchOptions:e,inputPath:t,timeout:r,watch:n})=>{let o=jsonSchemaRefParser.getResolvedInput({pathOrUrlOrSchema:t}),s,a,p;if(o.type==="url"){if(n.lastValue&&n.isHeadMethodSupported!==false){try{let c=await jsonSchemaRefParser.sendRequest({fetchOptions:{method:"HEAD",...e,headers:Ls(e?.headers,n.headers)},timeout:r,url:o.path});if(c.response.status>=300)return {error:"not-ok",response:c.response};p=c.response;}catch(c){return {error:"not-ok",response:new Response(c.message)}}if(!p.ok&&n.isHeadMethodSupported)return {error:"not-ok",response:p};if(n.isHeadMethodSupported===void 0&&(n.isHeadMethodSupported=p.ok),p.status===304)return {error:"not-modified",response:p};if(a===void 0){let c=p.headers.get("ETag");c&&(a=c!==n.headers.get("If-None-Match"),a&&n.headers.set("If-None-Match",c));}if(a===void 0){let c=p.headers.get("Last-Modified");c&&(a=c!==n.headers.get("If-Modified-Since"),a&&n.headers.set("If-Modified-Since",c));}if(a===false)return {error:"not-modified",response:p}}try{let c=await jsonSchemaRefParser.sendRequest({fetchOptions:{method:"GET",...e},timeout:r,url:o.path});if(c.response.status>=300)return {error:"not-ok",response:c.response};p=c.response;}catch(c){return {error:"not-ok",response:new Response(c.message)}}if(!p.ok)return {error:"not-ok",response:p};if(s=p.body?await p.arrayBuffer():new ArrayBuffer(0),a===void 0){let c=new TextDecoder().decode(s);a=c!==n.lastValue,n.lastValue=c;}}else n.lastValue?a=false:n.lastValue=o.type;return a===false?{error:"not-modified",response:p}:{arrayBuffer:s,resolvedInput:o}};var kl=({patchOptions:e,spec:t})=>{if(!e)return;let r=t;if("swagger"in r){if(e.version&&r.swagger&&(r.swagger=typeof e.version=="string"?e.version:e.version(r.swagger)),e.meta&&r.info&&e.meta(r.info),e.schemas&&r.definitions)for(let n in e.schemas){let o=r.definitions[n];if(!o||typeof o!="object")continue;let s=e.schemas[n];s(o);}if(e.operations&&r.paths)for(let n in e.operations){let[o,s]=n.split(" ");if(!o||!s)continue;let a=r.paths[s];if(!a)continue;let p=a[o.toLocaleLowerCase()]||a[o.toLocaleUpperCase()];if(!p||typeof p!="object")continue;let c=e.operations[n];c(p);}return}if(e.version&&r.openapi&&(r.openapi=typeof e.version=="string"?e.version:e.version(r.openapi)),e.meta&&r.info&&e.meta(r.info),r.components){if(e.schemas&&r.components.schemas)for(let n in e.schemas){let o=r.components.schemas[n];if(!o||typeof o!="object")continue;let s=e.schemas[n];s(o);}if(e.parameters&&r.components.parameters)for(let n in e.parameters){let o=r.components.parameters[n];if(!o||typeof o!="object")continue;let s=e.parameters[n];s(o);}if(e.requestBodies&&r.components.requestBodies)for(let n in e.requestBodies){let o=r.components.requestBodies[n];if(!o||typeof o!="object")continue;let s=e.requestBodies[n];s(o);}if(e.responses&&r.components.responses)for(let n in e.responses){let o=r.components.responses[n];if(!o||typeof o!="object")continue;let s=e.responses[n];s(o);}}if(e.operations&&r.paths)for(let n in e.operations){let[o,s]=n.split(" ");if(!o||!s)continue;let a=r.paths[s];if(!a)continue;let p=a[o.toLocaleLowerCase()]||a[o.toLocaleUpperCase()];if(!p||typeof p!="object")continue;let c=e.operations[n];c(p);}};var ra=Pu(hf()),bb={biome:{args:e=>["format","--write",e],command:"biome",name:"Biome (Format)"},prettier:{args:e=>["--ignore-unknown",e,"--write","--ignore-path","./.prettierignore"],command:"prettier",name:"Prettier"}},Sb={biome:{args:e=>["lint","--apply",e],command:"biome",name:"Biome (Lint)"},eslint:{args:e=>[e,"--fix"],command:"eslint",name:"ESLint"},oxlint:{args:e=>["--fix",e],command:"oxlint",name:"oxlint"}},xf=({config:e})=>{if(e.output.format){let t=bb[e.output.format];console.log(`\u2728 Running ${t.name}`),(0, ra.sync)(t.command,t.args(e.output.path));}if(e.output.lint){let t=Sb[e.output.lint];console.log(`\u2728 Running ${t.name}`),(0, ra.sync)(t.command,t.args(e.output.path));}};function bf(e,t){return {...e,config:t,models:e.models.map(r=>Ob(r)),services:Rb(e.operations).map(Tb),types:{}}}var Ob=e=>({...e,$refs:e.$refs.filter((t,r,n)=>de(t,r,n)),enum:e.enum.filter((t,r,n)=>n.findIndex(o=>o.value===t.value)===r),enums:e.enums.filter((t,r,n)=>n.findIndex(o=>o.name===t.name)===r),imports:e.imports.filter((t,r,n)=>de(t,r,n)&&t!==e.name).sort(Dr)}),Rb=e=>{let t=T(),r=new Map;return e.forEach(n=>{(n.tags?.length&&(t.plugins["@hey-api/sdk"]?.config.asClass||X(t))?n.tags.filter(de):["Default"]).forEach(s=>{let a={...n,service:Eb(s)},p=r.get(a.service)||Ab(a);p.$refs=[...p.$refs,...a.$refs],p.imports=[...p.imports,...a.imports],p.operations=[...p.operations,a],r.set(a.service,p);});}),Array.from(r.values())},Tb=e=>{let t={...e};return t.operations=Pb(t),t.operations.forEach(r=>{t.imports.push(...r.imports);}),t.imports=t.imports.filter(de).sort(Dr),t},Pb=e=>{let t=new Map;return e.operations.map(r=>{let n={...r};n.imports.push(...n.parameters.flatMap(p=>p.imports));let o=n.responses.filter(p=>p.responseTypes.includes("success"));n.imports.push(...o.flatMap(p=>p.imports));let s=n.name,a=t.get(s)||0;return a>0&&(n.name=`${s}${a}`),t.set(s,a+1),n})},Ab=e=>({$refs:[],imports:[],name:e.service,operations:[]}),Eb=e=>N({case:"PascalCase",value:_e(e)});var Ib=e=>{let t={...e,path:""};if(e.path&&(typeof e.path!="string"||e.registry!=="hey-api"))return t.path=e.path,t;let[r,n]=e.path.split("?"),s=(n||"").split("&").map(w=>w.split("=")),a=r||"";a.endsWith("/")&&(a=a.slice(0,a.length-1));let[,p]=a.split("://"),[c,m,l]=(p||"").split("/");t.organization=m||e.organization,t.project=l||e.project;let f=[],u="api_key";t.api_key=s.find(([w])=>w===u)?.[1]||e.api_key||process.env.HEY_API_TOKEN,t.api_key&&f.push(`${u}=${t.api_key}`);let d="branch";t.branch=s.find(([w])=>w===d)?.[1]||e.branch,t.branch&&f.push(`${d}=${t.branch}`);let y="commit_sha";t.commit_sha=s.find(([w])=>w===y)?.[1]||e.commit_sha,t.commit_sha&&f.push(`${y}=${t.commit_sha}`);let h="tags";t.tags=s.find(([w])=>w===h)?.[1]?.split(",")||e.tags,t.tags?.length&&f.push(`${h}=${t.tags.join(",")}`);let x="version";if(t.version=s.find(([w])=>w===x)?.[1]||e.version,t.version&&f.push(`${x}=${t.version}`),!t.organization)throw new Error("missing organization - from which Hey API Platform organization do you want to generate your output?");if(!t.project)throw new Error("missing project - from which Hey API Platform project do you want to generate your output?");let b=f.join("&"),k=c||"get.heyapi.dev",P=k.startsWith("localhost"),I=[P?"http":"https",k].join("://"),v=P?[I,"v1","get",t.organization,t.project].join("/"):[I,t.organization,t.project].join("/");return t.path=b?`${v}?${b}`:v,t},Sf=(e,t)=>{let r=[],n=Z__default.default.gray(`[Job ${t+1}] `),o=e.length,s=Z__default.default.cyan(`Generating from ${o} ${o===1?"input":"inputs"}:`);r.push(`${n}\u23F3 ${s}`),e.forEach((a,p)=>{let c=` [${p+1}] `,m=Z__default.default.cyan(c),l=" ".repeat(c.length);if(typeof a.path!="string"){r.push(`${n}${m}raw OpenAPI specification`);return}switch(a.registry){case "hey-api":{let f=[a.organization,a.project].filter(Boolean).join("/");r.push(`${n}${m}${f}`),a.branch&&r.push(`${n}${l}${Z__default.default.gray("branch:")} ${Z__default.default.green(a.branch)}`),a.commit_sha&&r.push(`${n}${l}${Z__default.default.gray("commit:")} ${Z__default.default.green(a.commit_sha)}`),a.tags?.length&&r.push(`${n}${l}${Z__default.default.gray("tags:")} ${Z__default.default.green(a.tags.join(", "))}`),a.version&&r.push(`${n}${l}${Z__default.default.gray("version:")} ${Z__default.default.green(a.version)}`),r.push(`${n}${l}${Z__default.default.gray("registry:")} ${Z__default.default.green("Hey API")}`);break}case "readme":{let f=[a.organization,a.project].filter(Boolean).join("/");f?r.push(`${n}${m}${f}`):r.push(`${n}${m}${a.path}`),a.uuid&&r.push(`${n}${l}${Z__default.default.gray("uuid:")} ${Z__default.default.green(a.uuid)}`),r.push(`${n}${l}${Z__default.default.gray("registry:")} ${Z__default.default.green("ReadMe")}`);break}case "scalar":{let f=[a.organization,a.project].filter(Boolean).join("/");r.push(`${n}${m}${f}`),r.push(`${n}${l}${Z__default.default.gray("registry:")} ${Z__default.default.green("Scalar")}`);break}default:r.push(`${n}${m}${a.path}`);break}});for(let a of r)console.log(a);},na=async({config:e,dependencies:t,jobIndex:r,logger:n,templates:o,watches:s})=>{let a=s||Array.from({length:e.input.length},()=>({headers:new Headers})),p=e.input.map(d=>Ib(d));e.logs.level!=="silent"&&!s&&Sf(p,r);let c=async(d,y)=>{let h=n.timeEvent("spec"),{arrayBuffer:x,error:b,resolvedInput:k,response:P}=await Cl({fetchOptions:d.fetch,inputPath:p[y].path,timeout:d.watch.timeout,watch:a[y]});if(h.timeEnd(),b&&!s)throw new Error(`Request failed with status ${P.status}: ${P.statusText}`);return {arrayBuffer:x,resolvedInput:k}},m=(await Promise.all(e.input.map((d,y)=>c(d,y)))).filter(d=>d.arrayBuffer||d.resolvedInput),l,f;if(m.length){let d=new jsonSchemaRefParser.$RefParser,y=m.length>1?await d.bundleMany({arrayBuffer:m.map(P=>P.arrayBuffer),pathOrUrlOrSchemas:[],resolvedInputs:m.map(P=>P.resolvedInput)}):await d.bundle({arrayBuffer:m[0].arrayBuffer,pathOrUrlOrSchema:void 0,resolvedInput:m[0].resolvedInput});e.logs.level!=="silent"&&s&&(console.clear(),Sf(p,r));let h=n.timeEvent("input.patch");kl({patchOptions:e.parser.patch,spec:y}),h.timeEnd();let x=n.timeEvent("parser");if(e.experimentalParser&&!W(e)&&!X(e)&&(f=Vc({config:e,dependencies:t,logger:n,spec:y})),!f){let P=Bc({openApi:y});l=bf(P,e);}x.timeEnd();let b=n.timeEvent("generator");f?await Al({context:f}):l&&await Tl({client:l,openApi:y,templates:o}),b.timeEnd();let k=n.timeEvent("postprocess");if(!e.dryRun&&(xf({config:e}),e.logs.level!=="silent")){let P=process.env.INIT_CWD?`./${L__default.default.relative(process.env.INIT_CWD,e.output.path)}`:e.output.path,I=Z__default.default.gray(`[Job ${r+1}] `);console.log(`${I}${Z__default.default.green("\u2705 Done!")} Your output is in ${Z__default.default.cyanBright(P)}`);}k.timeEnd();}let u=e.input.find((d,y)=>d.watch.enabled&&typeof p[y].path=="string");return u&&setTimeout(()=>{na({config:e,dependencies:t,jobIndex:r,logger:n,templates:o,watches:a});},u.watch.interval),f||l};var vb=`
|