@hey-api/openapi-ts 0.80.3 → 0.80.4
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-LPOHZ24X.js → chunk-SCWPHXYA.js} +13 -13
- package/dist/chunk-SCWPHXYA.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/internal.cjs +6 -6
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/{types.d-CCdoSF-L.d.cts → types.d-5Zt8gOQV.d.cts} +140 -0
- package/dist/{types.d-CCdoSF-L.d.ts → types.d-5Zt8gOQV.d.ts} +140 -0
- package/package.json +1 -1
- package/dist/chunk-LPOHZ24X.js.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -33,7 +33,7 @@ ${We__default.default.cyan("\u{1F4C4} Crash log saved to:")} ${We__default.defau
|
|
|
33
33
|
${JSON.stringify(n,null,2)}`);}return r};var uc=({operation:e,plugin:t})=>{if(!t.config.validator.request)return;let r=t.getPlugin(t.config.validator.request);if(!(!r||!r.api.createRequestValidator))return r.api.createRequestValidator({file:t.context.file({id:be}),operation:e,plugin:r})},dc=({operation:e,plugin:t})=>{if(!t.config.validator.response)return;let r=t.getPlugin(t.config.validator.response);if(!(!r||!r.api.createResponseValidator))return r.api.createResponseValidator({file:t.context.file({id:be}),operation:e,plugin:r})};var yc=({context:e,value:t})=>{let r=v({case:"PascalCase",value:He(t)});return Ht({config:e.config,name:r})},gy=({operation:e,plugin:t})=>t.config.methodNameBuilder?t.config.methodNameBuilder(e):!t.config.asClass&&e.id.match(ge)?`${e.id}_`:e.id,vs=({context:e,operation:t,plugin:r})=>{let n=new Map,s,o,a=[];if(r.config.classStructure==="auto"&&t.operationId&&(a=t.operationId.split(/[./]/).filter(Boolean),a.length>1)){let c=a.pop();o=v({case:"camelCase",value:He(c)}),s=a.pop();}let p=r.config.instance?[r.config.instance]:t.tags??["default"];for(let c of p){let m=yc({context:e,value:s||c});n.set(c,{className:m,methodName:o||gy({operation:t,plugin:r}),path:(s?[c,...a,s]:[c]).map(l=>yc({context:e,value:l}))});}return n},_o=({file:e,operation:t,plugin:r,throwOnError:n})=>{let o=E(r.context.config).name==="@hey-api/client-nuxt",a=r.getPlugin("@hey-api/typescript"),p=r.context.file({id:P}),c=e.import({asType:true,module:e.relativePathToFile({context:r.context,id:P}),name:p.getName(a.api.getId({operation:t,type:"data"}))}),m=X.Options.name;if(o){let l=e.import({asType:true,module:e.relativePathToFile({context:r.context,id:P}),name:p.getName(a.api.getId({operation:t,type:o?"response":"responses"}))});return `${m}<${Dr}, ${c.name||"unknown"}, ${l.name||"unknown"}, ${mt}>`}return n?`${m}<${c.name||"unknown"}, ${n}>`:c.name?`${m}<${c.name}>`:m},Vo=({file:e,isRequiredOptions:t,operation:r,plugin:n})=>{let s={argNames:[],fields:[],parameters:[]},o=n.getPlugin("@hey-api/typescript"),a={usedTypeIDs:new Set},c=E(n.context.config).name==="@hey-api/client-nuxt";if(n.config.params_EXPERIMENTAL==="experiment"){let m=n.context.file({id:P});if(r.parameters?.path)for(let l in r.parameters.path){let f=r.parameters.path[l],u=ve(f.name);s.argNames.push(u),s.fields.push({in:"path",key:u}),s.parameters.push({isRequired:f.required,name:u,type:o.api.schemaToType({onRef:y=>{e.import({asType:true,module:e.relativePathToFile({context:n.context,id:P}),name:m.getName(y)});},plugin:o,schema:f.schema,state:a})});}if(r.parameters?.query)for(let l in r.parameters.query){let f=r.parameters.query[l],u=ve(f.name);s.argNames.push(u),s.fields.push({in:"path",key:u}),s.parameters.push({isRequired:f.required,name:u,type:o.api.schemaToType({onRef:y=>{e.import({asType:true,module:e.relativePathToFile({context:n.context,id:P}),name:m.getName(y)});},plugin:o,schema:f.schema,state:a})});}if(r.body){let l="body";s.argNames.push(l),s.fields.push({in:"body"}),s.parameters.push({isRequired:r.body.required,name:l,type:o.api.schemaToType({onRef:f=>{e.import({asType:true,module:e.relativePathToFile({context:n.context,id:P}),name:m.getName(f)});},plugin:o,schema:r.body.schema,state:a})});}}return s.parameters.push({isRequired:t,name:"options",type:_o({file:e,operation:r,plugin:n,throwOnError:c?void 0:"ThrowOnError"})}),s},hy=e=>{if(!e)return;let t=e.split(";")[0]?.trim();if(t){if(t.startsWith("application/json")||t.endsWith("+json"))return "json";if(["application/","audio/","image/","video/"].some(r=>t.startsWith(r)))return "blob";if(t.startsWith("text/"))return "text"}},Wo=({isRequiredOptions:e,opParameters:t,operation:r,plugin:n})=>{let s=n.context.file({id:be}),o=s.nameWithoutExtension(),a=E(n.context.config),p=a.name==="@hey-api/client-nuxt",c=n.getPlugin("@hey-api/typescript"),m=n.context.file({id:P}),l=s.import({asType:true,module:s.relativePathToFile({context:n.context,id:P}),name:m.getName(c.api.getId({operation:r,type:p?"response":"responses"}))}),f=s.import({asType:true,module:s.relativePathToFile({context:n.context,id:P}),name:m.getName(c.api.getId({operation:r,type:p?"error":"errors"}))}),u=[];if(r.body)switch(r.body.type){case "form-data":{let H=s.import({module:re({config:n.context.config,sourceOutput:o}),name:"formDataBodySerializer"});u.push({spread:H.name});break}case "json":break;case "text":case "octet-stream":u.push({key:"bodySerializer",value:null});break;case "url-search-params":{let H=s.import({module:re({config:n.context.config,sourceOutput:o}),name:"urlSearchParamsBodySerializer"});u.push({spread:H.name});break}}for(let H in r.parameters?.query){let te=r.parameters.query[H];if((te.schema.type==="array"||te.schema.type==="tuple")&&(te.style!=="form"||!te.explode)){u.push({key:"querySerializer",value:[{key:"array",value:[{key:"explode",value:false},{key:"style",value:"form"}]}]});break}}let y=uc({operation:r,plugin:n});if(y&&u.push({key:"requestValidator",value:y}),n.config.transformer==="@hey-api/transformers"){let H=n.context.file({id:pn}).identifier({$ref:Is({id:r.id,type:"response"}),namespace:"value"});H.name&&(s.import({module:s.relativePathToFile({context:n.context,id:pn}),name:H.name}),u.push({key:"responseTransformer",value:H.name}));}if(a.name==="@hey-api/client-axios"){for(let H in r.responses)if(Ao({statusCode:H})==="2XX"){let te=r.responses[H],$e=hy(te?.mediaType);if($e){u.push({key:"responseType",value:$e});break}}}let g=dc({operation:r,plugin:n});g&&u.push({key:"responseValidator",value:g}),n.config.responseStyle==="data"&&u.push({key:"responseStyle",value:n.config.responseStyle});let x=fc({context:n.context,operation:r,plugin:n});x.length&&u.push({key:"security",value:i.arrayLiteralExpression({elements:x})}),u.push({key:"url",value:r.path}),u.push({spread:"options"});let R=[],S=t.argNames.length;if(S){let H=[],te=[];for(let ze of t.argNames)H.push(i.identifier({text:ze}));for(let ze of t.fields){let mr=[];"in"in ze&&(mr.push({key:"in",value:ze.in}),ze.key&&mr.push({key:"key",value:ze.key}),ze.map&&mr.push({key:"map",value:ze.map})),te.push(i.objectExpression({obj:mr}));}let $e=s.import({module:re({config:n.context.config,sourceOutput:o}),name:"buildClientParams"});R.push(i.constVariable({expression:i.callExpression({functionName:$e.name,parameters:[i.arrayLiteralExpression({elements:H}),i.arrayLiteralExpression({elements:te})]}),name:"params"})),u.push({spread:"params"});}if(r.body){let H=r.parameters?.header?.["content-type"];if(!!!H?.required){let $e=[{key:H?.name??"Content-Type",value:r.body.type==="form-data"?null:r.body.mediaType},{spread:i.propertyAccessExpression({expression:i.identifier({text:"options"}),isOptional:!e,name:"headers"})}];S&&$e.push({spread:i.propertyAccessExpression({expression:i.identifier({text:"params"}),name:"headers"})}),u.push({key:"headers",value:$e});}}let N=l.name||"unknown",w=f.name||"unknown",B=n.config.client?s.import({alias:"_heyApiClient",module:s.relativePathToFile({context:n.context,id:Qe}),name:"client"}):void 0,D=i.propertyAccessExpression({expression:i.identifier({text:"options"}),isOptional:!e,name:"client"}),j;n.config.instance?j=i.binaryExpression({left:D,operator:"??",right:i.propertyAccessExpression({expression:i.this(),name:"_client"})}):B?.name?j=i.binaryExpression({left:D,operator:"??",right:i.identifier({text:B.name})}):j=D;let z=[];return p?z.push(Dr,`${N} | ${mt}`,w,mt):z.push(N,w,"ThrowOnError"),n.config.responseStyle==="data"&&z.push(i.stringLiteral({text:n.config.responseStyle})),R.push(i.returnFunctionCall({args:[i.objectExpression({identifiers:["responseTransformer"],obj:u})],name:i.propertyAccessExpression({expression:j,name:i.identifier({text:r.method})}),types:z})),R};var pr=({meta:e,onImport:t,...r})=>{if(!e)return {created:false,name:""};let{created:n,name:s}=je({meta:e,...r});return s&&t(s),{created:n,name:s}},Oc=e=>`${e}ModelResponseTransformer`,cr=e=>`${v({case:"PascalCase",value:e})}Data`,Fr=e=>`${v({case:"PascalCase",value:e})}Error`,zo=e=>`${e}Transformer`,lt=e=>`${v({case:"PascalCase",value:e})}Response`,Ko=({importedType:e,throwOnError:t})=>{let r=X.OptionsLegacyParser.name;return t?`${r}<${e||"unknown"}, ${t}>`:e?`${r}<${e}>`:r},gc=(e,t)=>{let r=T(),{name:n}=je({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:cr}),s=ct(t.parameters);if(!_(r))return [{isRequired:s,name:"options",type:Ko({importedType:n,throwOnError:"ThrowOnError"})}];if(!t.parameters.length)return [];let o=a=>{if(a.default!==void 0)return JSON.stringify(a.default,null,4)};return r.useOptions?[{default:s?void 0:{},name:"data",type:n}]:t.parameters.map(a=>{let p=`${n}['${a.name}']`;return {default:a?.default,isRequired:(!a.isRequired&&!o(a)?"?":"")=="",name:a.name,type:p}})},hc=(e,t)=>{let r=T(),n=i.typeNode("void");if(t.responses.filter(a=>a.responseTypes.includes("success")).length){let{name:a}=je({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:lt});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},xc=e=>{let t=T();if(!_(t))return [e.deprecated&&"@deprecated",e.summary&&K(e.summary),e.description&&K(e.description)];let r=[];e.parameters.length&&(t.useOptions?r=["@param data The data for the request.",...e.parameters.map(o=>`@param data.${o.name} ${o.description?K(o.description):""}`)]:r=e.parameters.map(o=>`@param ${o.name} ${o.description?K(o.description):""}`));let n=e.responses.filter(o=>o.responseTypes.includes("success"));return [e.deprecated&&"@deprecated",e.summary&&K(e.summary),e.description&&K(e.description),...r,...n.map(o=>`@returns ${o.type} ${o.description?K(o.description):""}`),"@throws ApiError"]},xy=({client:e,onClientImport:t,onImport:r,operation:n})=>{let s=T(),o=lt(n.name),{name:a}=je({client:e,meta:{$ref:`transformers/${o}`,name:o},nameTransformer:zo});if(a&&r(a),!_(s)){let l=[{spread:"options"}],u=n.parameters.filter(y=>y.in==="body"||y.in==="formData").map(y=>y.mediaType||(y.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 y=u.prop,g=s.useOptions?`data.${u.name}`:u.name;return y===g?f[y]=y:Ae(y)===y?f[y]=g:f[`'${y}'`]=g,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"&&(s.useOptions?c.formData=`data.${n.parametersBody.name}`:c.formData=n.parametersBody.name),n.parametersBody.in==="body"&&(s.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})},Ne=({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(ge)?`${r}_`:r,bc=({client:e,onClientImport:t,onImport:r,operation:n})=>{let s=T(),o=xy({client:e,onClientImport:t,onImport:r,operation:n});if(!_(s)){let p=je({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:Fr}).name,m=n.responses.filter(l=>l.responseTypes.includes("success")).length?je({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:lt}).name:"void";return [i.returnFunctionCall({args:[o],name:`(options?.client ?? client).${n.method.toLocaleLowerCase()}`,types:p&&m?[m,p,"ThrowOnError"]:p?["unknown",p,"ThrowOnError"]:m?[m,"unknown","ThrowOnError"]:[]})]}return Q(s)?[i.returnFunctionCall({args:[o],name:"this.httpRequest.request"})]:E(s).name==="legacy/angular"?[i.returnFunctionCall({args:["OpenAPI","this.http",o],name:"__request"})]:[i.returnFunctionCall({args:["OpenAPI",o],name:"__request"})]},by=({client:e,onClientImport:t,onImport:r,onNode:n,service:s})=>{let o=T(),a=E(o),p=_(o);for(let u of s.operations)u.parameters.length&&pr({client:e,meta:{$ref:u.name,name:u.name},nameTransformer:cr,onImport:r}),p||pr({client:e,meta:{$ref:u.name,name:u.name},nameTransformer:Fr,onImport:r}),u.responses.filter(g=>g.responseTypes.includes("success")).length&&pr({client:e,meta:{$ref:u.name,name:u.name},nameTransformer:lt,onImport:r});let c={default:("throwOnError"in a.config?a.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"};if(!o.plugins["@hey-api/sdk"]?.config.asClass&&!Q(o)){for(let u of s.operations){let y={parameters:gc(e,u),returnType:p?hc(e,u):void 0,statements:bc({client:e,onClientImport:t,onImport:r,operation:u}),types:p?void 0:[c]},g=a.name==="legacy/angular"?i.anonymousFunction(y):i.arrowFunction(y),x=i.constVariable({comment:xc(u),exportConst:true,expression:g,name:Ne({config:o,handleIllegal:true,id:u.name,operation:u})});n(x);}return}let m=s.operations.map(u=>i.methodDeclaration({accessLevel:"public",comment:xc(u),isStatic:Q(o)===void 0&&a.name!=="legacy/angular",name:Ne({config:o,id:u.name,operation:u}),parameters:gc(e,u),returnType:p?hc(e,u):void 0,statements:bc({client:e,onClientImport:t,onImport:r,operation:u}),types:p?void 0:[c]}));if(!m.length)return;Q(o)?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,y)=>{y&&l.push(i.identifier({text:`
|
|
34
34
|
`})),l.push(u);});let f=i.classDeclaration({decorator:a.name==="legacy/angular"?{args:[{providedIn:"root"}],name:"Injectable"}:void 0,exportClass:true,name:Ht({config:o,name:s.name}),nodes:l});n(f);},Sc=({client:e,files:t,plugin:r})=>{let n=T(),s=_(n),o="sdk";if(t.sdk=new xe({dir:n.output.path,exportFromIndex:r.config.exportFromIndex,id:"sdk",name:`${o}.ts`}),!s)t.sdk.import({module:re({config:n,sourceOutput:o}),name:"createClient"}),t.sdk.import({module:re({config:n,sourceOutput:o}),name:"createConfig"}),t.sdk.import({...X.OptionsLegacyParser,module:re({config:n,sourceOutput:o})});else if(E(n).name==="legacy/angular"?(t.sdk.import({module:"@angular/core",name:"Injectable"}),Q(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"}),Q(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(!s){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)by({client:e,onClientImport:p=>{t.sdk.import({module:re({config:n,sourceOutput:o}),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 Rc=({clientOptions:e,plugin:t})=>{let r=t.context.file({id:be}),s=E(t.context.config).name==="@hey-api/client-nuxt",o=re({config:t.context.config,sourceOutput:r.nameWithoutExtension()}),a=r.import({asType:true,module:o,name:"TDataShape"}),p=r.import({asType:true,module:o,name:"Client"}),c=i.typeAliasDeclaration({exportType:true,name:"Options",type:i.typeIntersectionNode({types:[i.typeReferenceNode({typeArguments:s?[i.typeReferenceNode({typeName:"TComposable"}),i.typeReferenceNode({typeName:"TData"}),i.typeReferenceNode({typeName:Ho}),i.typeReferenceNode({typeName:mt})]:[i.typeReferenceNode({typeName:"TData"}),i.typeReferenceNode({typeName:"ThrowOnError"})],typeName:e.name}),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:!t.config.client,name:"client",type:i.typeReferenceNode({typeName:p.name})},{comment:["You can pass arbitrary values through the `meta` object. This can be","used to access values that aren't defined as part of the SDK function."],isRequired:false,name:"meta",type:i.typeReferenceNode({typeArguments:[i.keywordTypeNode({keyword:"string"}),i.keywordTypeNode({keyword:"unknown"})],typeName:"Record"})}],useLegacyResolution:false})]}),typeParameters:s?[i.typeParameterDeclaration({constraint:i.typeReferenceNode({typeName:"Composable"}),name:"TComposable"}),i.typeParameterDeclaration({constraint:i.typeReferenceNode({typeName:a.name}),defaultType:i.typeReferenceNode({typeName:a.name}),name:"TData"}),i.typeParameterDeclaration({defaultType:i.keywordTypeNode({keyword:"unknown"}),name:Ho}),i.typeParameterDeclaration({defaultType:i.keywordTypeNode({keyword:"undefined"}),name:mt})]:[i.typeParameterDeclaration({constraint:i.typeReferenceNode({typeName:a.name}),defaultType:i.typeReferenceNode({typeName:a.name}),name:"TData"}),i.typeParameterDeclaration({constraint:i.keywordTypeNode({keyword:"boolean"}),defaultType:i.keywordTypeNode({keyword:"boolean"}),name:"ThrowOnError"})]});r.add(c);};var Sy=({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"})})});return [i.propertyDeclaration({initializer:e.config.client?i.identifier({text:"_heyApiClient"}):void 0,modifier:"protected",name:"_client",type:b__default.default.factory.createTypeReferenceNode("Client")}),i.identifier({text:`
|
|
35
35
|
`}),i.constructorDeclaration({multiLine:true,parameters:[{isRequired:!e.config.client,name:"args",type:i.typeInterfaceNode({properties:[{isRequired:!e.config.client,name:"client",type:"Client"}],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]})]},Ry=({plugin:e})=>{let t=E(e.context.config),r=t.name==="@hey-api/client-nuxt",n=e.context.file({id:be}),s=new Map,o=new Set,a=e.config.instance?Sy({plugin:e}):[];e.forEach("operation",({operation:c})=>{let m=ar({context:e.context,operation:c}),l=e.getPlugin("@hey-api/typescript"),f=e.context.file({id:P}),u=n.import({asType:true,module:n.relativePathToFile({context:e.context,id:P}),name:r?f.getName(l.api.getId({operation:c,type:"response"})):void 0}),y=vs({context:e.context,operation:c,plugin:e});for(let g of y.values())g.path.forEach((x,R)=>{s.has(x)||s.set(x,{className:x,classes:new Set,methods:new Set,nodes:[],root:!R});let S=g.path[R-1];if(S){let z=s.get(S);z.classes.add(x),s.set(S,z);}if(!(g.path.length===R+1))return;let w=s.get(x);if(w.methods.has(g.methodName))return;let B=Vo({file:n,isRequiredOptions:m,operation:c,plugin:e}),D=Wo({isRequiredOptions:m,opParameters:B,operation:c,plugin:e}),j=i.methodDeclaration({accessLevel:"public",comment:It({operation:c}),isStatic:!e.config.instance,name:g.methodName,parameters:B.parameters,returnType:void 0,statements:D,types:r?[{extends:i.typeNode("Composable"),name:Dr},{default:u.name?i.typeReferenceNode({typeName:u.name}):i.typeNode("undefined"),extends:u.name?i.typeReferenceNode({typeName:u.name}):void 0,name:mt}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]});w.nodes.length?w.nodes.push(i.identifier({text:`
|
|
36
|
-
`}),j):w.nodes.push(j),w.methods.add(g.methodName),s.set(x,w);});});let p=c=>{if(o.has(c.className))return;if(c.classes.size)for(let l of c.classes){let f=s.get(l);p(f),c.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:f.className})}):i.identifier({text:f.className}),modifier:e.config.instance?void 0:"static",name:v({case:"camelCase",value:f.className})}));}let m=i.classDeclaration({exportClass:c.root,extendedClasses:e.config.instance?["_HeyApiClient"]:void 0,name:c.className,nodes:c.nodes});n.add(m),o.add(c.className);};if(a.length){let c=i.classDeclaration({exportClass:false,name:"_HeyApiClient",nodes:a});n.add(c);}for(let c of s.values())p(c);},Ty=({plugin:e})=>{let t=E(e.context.config),r=t.name==="@hey-api/client-nuxt",n=e.context.file({id:be});e.forEach("operation",({operation:s})=>{let o=ar({context:e.context,operation:s}),a=e.getPlugin("@hey-api/typescript"),p=e.context.file({id:P}),c=n.import({asType:true,module:n.relativePathToFile({context:e.context,id:P}),name:r?p.getName(a.api.getId({operation:s,type:"response"})):void 0}),m=Vo({file:n,isRequiredOptions:o,operation:s,plugin:e}),l=Wo({isRequiredOptions:o,opParameters:m,operation:s,plugin:e}),f=i.constVariable({comment:It({operation:s}),exportConst:true,expression:i.arrowFunction({parameters:m.parameters,returnType:void 0,statements:l,types:r?[{extends:i.typeNode("Composable"),name:Dr},{default:c.name?i.typeReferenceNode({typeName:c.name}):i.typeNode("undefined"),extends:c.name?i.typeReferenceNode({typeName:c.name}):void 0,name:mt}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]}),name:Ne({config:e.context.config,handleIllegal:true,id:s.id,operation:s})});n.add(f);});},Tc=({plugin:e})=>{let t=e.createFile({id:be,path:e.output}),r=re({config:e.context.config,sourceOutput:t.nameWithoutExtension()}),n=t.import({...X.Options,alias:"ClientOptions",module:r});E(e.context.config).name==="@hey-api/client-nuxt"&&t.import({asType:true,module:r,name:"Composable"}),Rc({clientOptions:n,plugin:e}),e.config.asClass?Ry({plugin:e}):Ty({plugin:e});};var Cs={config:{asClass:false,auth:true,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:Tc,handlerLegacy:Sc,name:"@hey-api/sdk",output:"sdk",resolveConfig:(e,t)=>{e.config.client?(typeof e.config.client=="boolean"&&(e.config.client=t.pluginByTag("client",{defaultPlugin:"@hey-api/client-fetch"})),e.dependencies.add(e.config.client)):e.config.client=false,e.config.transformer?(typeof e.config.transformer=="boolean"&&(e.config.transformer=t.pluginByTag("transformer")),e.dependencies.add(e.config.transformer)):e.config.transformer=false,typeof e.config.validator!="object"&&(e.config.validator={request:e.config.validator,response:e.config.validator}),e.config.validator.request?(typeof e.config.validator.request=="boolean"&&(e.config.validator.request=t.pluginByTag("validator")),e.dependencies.add(e.config.validator.request)):e.config.validator.request=false,e.config.validator.response?(typeof e.config.validator.response=="boolean"&&(e.config.validator.response=t.pluginByTag("validator")),e.dependencies.add(e.config.validator.response)):e.config.validator.response=false,e.config.instance?(typeof e.config.instance!="string"&&(e.config.instance="Sdk"),e.config.asClass=true):e.config.instance=false;}};var Ay="$OpenApiTs",ue={$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:""},Iy=({comments:e,leadingComment:t,meta:r,obj:n,onNode:s,...o})=>{if(!r)return;let{created:a,name:p}=je({create:true,meta:r,...o});if(a){let c=i.enumDeclaration({comments:e,leadingComment:t,name:p,obj:n});s(c);}},Et=({comment:e,meta:t,onCreated:r,onNode:n,type:s,...o})=>{if(!t)return {created:false,name:""};let a=je({create:true,meta:t,...o}),{created:p,name:c}=a;if(p){let m=i.typeAliasDeclaration({comment:e,exportType:true,name:c,type:s});n(m),r?.(c);}return a},Ey=e=>{let t=[];Pc(e),e.model.enums.forEach(r=>Cy({...e,model:r,onNode:n=>{t.push(n);}})),t.length&&e.onNode(i.namespaceDeclaration({name:e.model.name,statements:t}));},vy=({client:e,model:t,onNode:r})=>{let n=T(),s={},o={};t.enum.forEach(c=>{let{key:m,value:l}=as(c);s[m]=l;let f=c.customDescription||c.description;f&&(o[m]=[K(f)]);});let a=[t.description&&K(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"){Iy({client:e,comments:o,leadingComment:a,meta:t.meta,obj:s,onNode:r});return}Et({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(s).map(([u,y])=>({comments:o[u],key:u,value:y})),unescape:true}),f=i.constVariable({assertion:"const",comment:a,exportConst:true,expression:l,name:c});r(f);}},onNode:r,type:jp(t.enum)});},Cy=({model:e,onNode:t})=>{let r={},n={};e.enum.forEach(s=>{let{key:o,value:a}=as(s);r[o]=a;let p=s.customDescription||s.description;p&&(n[o]=[K(p)]);}),t(i.enumDeclaration({comments:n,leadingComment:[e.description&&K(e.description),e.deprecated&&"@deprecated"],name:e.meta?.name||e.name,obj:r}));},Pc=({client:e,model:t,onNode:r})=>{Et({client:e,comment:[t.description&&K(t.description),t.deprecated&&"@deprecated"],meta:t.meta,onNode:r,type:ke(t)});},ky=e=>{switch(e.model.export){case "all-of":case "any-of":case "one-of":case "interface":return Ey(e);case "enum":return vy(e);default:return Pc(e)}},jy=({client:e,onNode:t})=>{let r={},n=T();if(!n.plugins["@hey-api/sdk"]&&!n.plugins["@hey-api/typescript"]?.config.tree)return;let s=_(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,...ue,in:"body",name:"body",prop:"body"},u=p.parameters.filter(S=>S.in==="body");u.length||(u=p.parameters.filter(S=>S.in==="formData")),u.length===1?f={...ue,...u[0],in:"body",isRequired:u[0].isRequired,name:"body",prop:"body"}:u.length>1&&(f={...ue,in:"body",isRequired:u.some(S=>S.isRequired),mediaType:"multipart/form-data",name:"body",prop:"body",properties:u});let y={...ue,in:"header",isRequired:ct(p.parameters.filter(S=>S.in==="header")),mediaType:null,name:s?"header":"headers",prop:s?"header":"headers",properties:p.parameters.filter(S=>S.in==="header").sort(rn)},g={...ue,in:"path",isRequired:ct(p.parameters.filter(S=>S.in==="path")),mediaType:null,name:"path",prop:"path",properties:p.parameters.filter(S=>S.in==="path").sort(rn)},x={...ue,in:"query",isRequired:ct(p.parameters.filter(S=>S.in==="query")),mediaType:null,name:"query",prop:"query",properties:p.parameters.filter(S=>S.in==="query").sort(rn)},R=s?nn([...p.parameters]):[f,y,g,x].filter(S=>S.properties.length||S.$refs.length||S.mediaType);m.req=R,Et({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:cr,onNode:t,type:ke({...ue,properties:R})});}let l=p.responses.filter(f=>f.responseTypes.includes("success"));if(l.length>0){Et({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:lt,onNode:t,type:ke({...ue,export:"any-of",properties:l})});let f=p.responses.filter(u=>u.responseTypes.includes("error"));s||Et({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:Fr,onNode:t,type:ke(f.length?{...ue,export:"one-of",properties:f}:{...ue,base:"unknown"})});}}let o=Object.entries(r).map(([a,p])=>{let c=Object.entries(p).map(([l,f])=>{let u=l,y=[];if(f.req){let x=f.$ref,{name:R}=je({client:e,meta:{$ref:x,name:x},nameTransformer:cr}),S={...ue,base:R,export:"reference",isRequired:true,name:"req",properties:[],type:R};y=[...y,S];}if(f.res){let x=Object.entries(f.res).map(([S,N])=>({...ue,...N,isRequired:true,name:String(S)})),R={...ue,isRequired:true,name:"res",properties:x};y=[...y,R];}return {...ue,isRequired:true,name:u.toLocaleLowerCase(),properties:y}}).filter(Boolean);return {...ue,isRequired:true,name:`'${a}'`,properties:c}});n.plugins["@hey-api/typescript"]?.config.tree&&Et({client:e,meta:{$ref:"@hey-api/openapi-ts",name:Ay},onNode:t,type:ke({...ue,properties:o})});},Ac=({client:e,files:t,plugin:r})=>{let n=T();t.types=new xe({dir:n.output.path,exportFromIndex:r.config.exportFromIndex,id:"types",name:"types.ts"});let s=o=>{t.types?.add(o);};for(let o of e.models)ky({client:e,model:o,onNode:s});jy({client:e,onNode:s});};var Vt="data",Ny=e=>e.base==="unknown"&&e.export==="generic"&&e.type==="unknown",Ic=({client:e,model:t})=>t.$refs.map(n=>{let s=e.models.find(o=>o.meta?.$ref===n);if(!s)throw new Error(`Ref ${n} could not be found. Transformers cannot be generated without having access to all refs.`);return s}),Ec=e=>{let t=e.model.meta.name,{name:r}=Et({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:Oc,onCreated:s=>{let o=ks({...e,meta:{$ref:`transformers/${t}`,name:s},path:[Vt]});vc({...e,async:false,name:s,statements:o});},type:`(${Vt}: any) => ${t}`});return {created:!!e.client.types[r],name:r}},wy=e=>{let{model:t}=e,r=Ic(e);if(r.length===1){let{created:n,name:s}=Ec({...e,model:r[0]});return n?[i.transformArrayMutation({path:e.path,transformerName:s})]:[]}return sn(t)||t.link&&!Array.isArray(t.link)&&t.link.export==="any-of"&&t.link.properties.find(n=>sn(n))?[i.transformArrayMap({path:e.path,transformExpression:i.conditionalExpression({condition:i.identifier({text:"item"}),whenFalse:i.identifier({text:"item"}),whenTrue:i.transformNewDate({parameterName:"item"})})})]:[]},qy=e=>{let{model:t}=e,r=[...e.path,t.name];return t.type==="string"&&t.export!=="array"&&sn(t)?[i.transformDateMutation({path:r})]:ks({...e,model:t,path:r})},ks=e=>{let{model:t}=e;switch(t.export){case "array":return wy(e);case "interface":return t.properties.flatMap(r=>qy({...e,model:r}));case "reference":{if(t.$refs.length!==1)return [];let r=Ic(e),{created:n,name:s}=Ec({...e,model:r[0]});return n?t.in==="response"?[i.expressionToStatement({expression:i.callExpression({functionName:s,parameters:[Vt]})})]:i.transformFunctionMutation({path:e.path,transformerName:s}):[]}default:return []}},vc=({async:e,client:t,name:r,onNode:n,onRemoveNode:s,statements:o})=>{let a={created:false,name:r};if(!o.length)return qp({client:t,name:r}),s?.(),a;let p=i.arrowFunction({async:e,multiLine:true,parameters:[{name:Vt}],statements:[...o,i.returnVariable({expression:Vt})]}),c=i.constVariable({exportConst:true,expression:p,name:r,typeName:r});return n(c),{created:true,name:r}},Cc=({client:e,files:t})=>{let r=T(),n=o=>{t.types?.add(o);},s=()=>{t.types?.removeNode_LEGACY();};for(let o of e.services)for(let a of o.operations){let p=a.responses.filter(l=>l.responseTypes.includes("success"));if(!p.length)continue;let c=p.filter(l=>!Ny(l));if(!c.length)continue;if(c.length>1){r.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${$(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=lt(a.name);Et({client:e,meta:{$ref:`transformers/${m}`,name:m},nameTransformer:zo,onCreated:l=>{let f=p.length>1?p.flatMap(u=>{let y=ks({client:e,meta:{$ref:`transformers/${m}`,name:m},model:u,onNode:n,onRemoveNode:s,path:[Vt]});return y.length?[i.ifStatement({expression:i.safeAccessExpression(["data"]),thenStatement:i.block({statements:y})})]:[]}):ks({client:e,meta:{$ref:`transformers/${m}`,name:m},model:p[0],onNode:n,onRemoveNode:s,path:[Vt]});vc({async:true,client:e,name:l,onNode:n,onRemoveNode:s,statements:f});},onNode:n,type:`(${Vt}: any) => Promise<${m}>`});}};var js={config:{bigInt:true,dates:true,exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:lc,handlerLegacy:Cc,name:"@hey-api/transformers",output:"transformers",tags:["transformer"]};var jc=({context:e,name:t})=>(oe.lastIndex=0,oe.test(t)?t.startsWith("-")?b__default.default.factory.createStringLiteral(t):b__default.default.factory.createNumericLiteral(t):v({case:e.config.output.case,value:t}));var _e=({schema:e})=>{let t=[];return e.title&&t.push(K(e.title)),e.description&&t.push(K(e.description)),e.deprecated&&t.push("@deprecated"),t.length?t:void 0};var Ns=i.keywordTypeNode({keyword:"string"}),Dy=({server:e})=>{let t=et(e.url);return t.protocol&&t.host?i.literalTypeNode({literal:i.stringLiteral({text:e.url})}):i.templateLiteralType({value:[t.protocol||Ns,"://",t.host||Ns,t.port?`:${t.port}`:"",t.path||""]})},Nc=({nodeInfo:e,plugin:t,servers:r})=>{let n=t.context.file({id:P}),s=E(t.context.config),o=r.map(c=>Dy({server:c}));r.length?"strictBaseUrl"in s.config&&s.config.strictBaseUrl||o.push(i.typeIntersectionNode({types:[Ns,b__default.default.factory.createTypeLiteralNode([])]})):o.push(Ns);let a=i.typeInterfaceNode({properties:[{name:De(t.context.config),type:i.typeUnionNode({types:o})}],useLegacyResolution:false}),p=i.typeAliasDeclaration({exportType:e.exported,name:e.node,type:a});n.add(p);};var Uo=({parameters:e})=>{let t={type:"object"};if(e){let r={},n=[];for(let s in e){let o=e[s];r[o.name]=Y({detectFormat:false,schema:o.schema}),o.required&&n.push(o.name);}t.properties=r,n.length&&(t.required=n);}return t},Fy=({operation:e,plugin:t,state:r})=>{let n=t.context.file({id:P}),s={type:"object"},o=[];s.properties||(s.properties={}),e.body?(s.properties.body=e.body.schema,e.body.required&&o.push("body")):s.properties.body={type:"never"},e.parameters?.header&&(s.properties.headers=Uo({parameters:e.parameters.header}),s.properties.headers.required&&o.push("headers")),e.parameters?.path?(s.properties.path=Uo({parameters:e.parameters.path}),s.properties.path.required&&o.push("path")):s.properties.path={type:"never"},e.parameters?.query?(s.properties.query=Uo({parameters:e.parameters.query}),s.properties.query.required&&o.push("query")):s.properties.query={type:"never"},s.properties.url={const:e.path,type:"string"},o.push("url"),s.required=o;let a=M({config:t.config.requests,name:e.id}),p=n.updateNode(t.api.getId({operation:e,type:"data"}),{exported:true,name:a}),c=ye({onRef:void 0,plugin:t,schema:s,state:r}),m=i.typeAliasDeclaration({exportType:p.exported,name:p.node,type:c});n.add(m);},wc=({operation:e,plugin:t,state:r})=>{Fy({operation:e,plugin:t,state:r});let n=t.context.file({id:P}),{error:s,errors:o,response:a,responses:p}=rt(e);if(o){let c=M({config:t.config.errors,name:e.id}),m=n.updateNode(t.api.getId({operation:e,type:"errors"}),{exported:true,name:c}),l=ye({onRef:void 0,plugin:t,schema:o,state:r}),f=i.typeAliasDeclaration({exportType:m.exported,name:m.node,type:l});if(n.add(f),s){let u=M({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),y=n.updateNode(t.api.getId({operation:e,type:"error"}),{exported:true,name:u}),g=i.indexedAccessTypeNode({indexType:b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m.node),objectType:m.node}),x=i.typeAliasDeclaration({exportType:y.exported,name:y.node,type:g});n.add(x);}}if(p){let c=M({config:t.config.responses,name:e.id}),m=n.updateNode(t.api.getId({operation:e,type:"responses"}),{exported:true,name:c}),l=ye({onRef:void 0,plugin:t,schema:p,state:r}),f=i.typeAliasDeclaration({exportType:m.exported,name:m.node,type:l});if(n.add(f),a){let u=M({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),y=n.updateNode(t.api.getId({operation:e,type:"response"}),{exported:true,name:u}),g=i.indexedAccessTypeNode({indexType:b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m.node),objectType:m.node}),x=i.typeAliasDeclaration({exportType:y.exported,name:y.node,type:g});n.add(x);}}};var Ly=({plugin:e,schema:t})=>{let r=[];return {obj:(t.items??[]).map((s,o)=>{let a=typeof s.const;r.includes(a)||r.push(a);let p;return s.title?p=s.title:a==="number"||a==="string"?p=`${s.const}`:a==="boolean"?p=s.const?"true":"false":s.const===null?p="null":p=`${o}`,p&&(p=v({case:e.config.enums.case,stripLeadingSeparators:false,value:p}),oe.lastIndex=0,oe.test(p)&&e.config.enums.enabled&&e.config.enums.mode==="typescript"&&(p=`_${p}`)),{comments:_e({schema:s}),key:p,value:s.const}}),typeofItems:r}},By=({onRef:e,plugin:t,schema:r,state:n})=>{if(!r.items)return i.typeArrayNode(i.keywordTypeNode({keyword:"unknown"}));r=Y({detectFormat:false,schema:r});let s=[];for(let o of r.items){let a=ye({onRef:e,plugin:t,schema:o,state:n});s.push(a);}return s.length===1?i.typeArrayNode(s[0]):r.logicalOperator==="and"?i.typeArrayNode(i.typeIntersectionNode({types:s})):i.typeArrayNode(i.typeUnionNode({types:s}))},Hy=({schema:e})=>e.const!==void 0?i.literalTypeNode({literal:i.ots.boolean(e.const)}):i.keywordTypeNode({keyword:"boolean"}),_y=({onRef:e,plugin:t,schema:r,state:n})=>ye({onRef:e,plugin:t,schema:{...r,type:void 0},state:n}),Vy=({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"}),Wy=({onRef:e,plugin:t,schema:r,state:n})=>{let s,o,a=[],p=[],c=r.required??[],m=false;for(let l in r.properties){let f=r.properties[l],u=ye({onRef:e,plugin:t,schema:f,state:n}),y=c.includes(l);a.push({comment:_e({schema:f}),isReadOnly:f.accessScope==="read",isRequired:y,name:jc({context:t.context,name:l}),type:u}),p.push(f),y||(m=true);}return r.additionalProperties&&(r.additionalProperties.type!=="never"||!p.length)&&(r.additionalProperties.type==="never"?p=[r.additionalProperties]:p.unshift(r.additionalProperties),m&&p.push({type:"undefined"}),o={isRequired:!r.propertyNames,name:"key",type:ye({onRef:e,plugin:t,schema:p.length===1?p[0]:{items:p,logicalOperator:"or"},state:n})},r.propertyNames?.$ref&&(s=ye({onRef:e,plugin:t,schema:{$ref:r.propertyNames.$ref},state:n}))),i.typeInterfaceNode({indexKey:s,indexProperty:o,properties:a,useLegacyResolution:false})},zy=({plugin:e,schema:t,state:r})=>{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 n=String(t.example).split("_");n.pop();let s=n.join("_");r.usedTypeIDs.add(s);let o=ve(v({case:e.config.case,value:s+"_id"}));return i.typeReferenceNode({typeName:o})}}return i.keywordTypeNode({keyword:"string"})},Ky=({onRef:e,plugin:t,schema:r,state:n})=>{let s=[];if(r.const&&Array.isArray(r.const))s=r.const.map(o=>i.valueToExpression({value:o})??i.identifier({text:"unknown"}));else if(r.items)for(let o of r.items){let a=ye({onRef:e,plugin:t,schema:o,state:n});s.push(a);}return i.typeTupleNode({types:s})},$c=({onRef:e,plugin:t,schema:r,state:n})=>{let s=t.getPlugin("@hey-api/transformers");if(s?.config.typeTransformers)for(let o of s.config.typeTransformers){let a=t.context.file({id:P}),p=o({file:a,schema:r});if(p)return p}switch(r.type){case "array":return By({onRef:e,plugin:t,schema:r,state:n});case "boolean":return Hy({schema:r});case "enum":return _y({onRef:e,plugin:t,schema:r,state:n});case "integer":case "number":return Vy({plugin:t,schema:r});case "never":return i.keywordTypeNode({keyword:"never"});case "null":return i.literalTypeNode({literal:i.null()});case "object":return Wy({onRef:e,plugin:t,schema:r,state:n});case "string":return zy({plugin:t,schema:r,state:n});case "tuple":return Ky({onRef:e,plugin:t,schema:r,state:n});case "undefined":return i.keywordTypeNode({keyword:"undefined"});case "unknown":return i.keywordTypeNode({keyword:"unknown"});case "void":return i.keywordTypeNode({keyword:"void"})}},ye=({onRef:e,plugin:t,schema:r,state:n})=>{let s=t.context.file({id:P});if(r.$ref)return e&&e(t.api.getId({type:"ref",value:r.$ref})),s.getNode(t.api.getId({type:"ref",value:r.$ref})).node;if(r.type)return $c({onRef:e,plugin:t,schema:r,state:n});if(r.items){if(r=Y({detectFormat:false,schema:r}),r.items){let o=[];for(let a of r.items){let p=ye({onRef:e,plugin:t,schema:a,state:n});o.push(p);}return r.logicalOperator==="and"?i.typeIntersectionNode({types:o}):i.typeUnionNode({types:o})}return ye({onRef:e,plugin:t,schema:r,state:n})}return $c({onRef:e,plugin:t,schema:{type:"unknown"},state:n})},Uy=({id:e,plugin:t,schema:r,type:n})=>{let s=t.context.file({id:P}),o=s.getNode(t.api.getId({type:"ref",value:e}));if(r.type==="enum"&&t.config.enums.enabled){let p=Ly({plugin:t,schema:r});if(t.config.enums.mode==="javascript"){t.config.enums.constantsIgnoreNull&&p.typeofItems.includes("object")&&(p.obj=p.obj.filter(u=>u.value!==null));let c=i.constVariable({assertion:"const",comment:_e({schema:r}),exportConst:o.exported,expression:i.objectExpression({multiLine:true,obj:p.obj}),name:o.node});s.add(c);let m=i.typeOfExpression({text:o.node.typeName}),l=b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m),f=i.typeAliasDeclaration({comment:_e({schema:r}),exportType:o.exported,name:o.node,type:i.indexedAccessTypeNode({indexType:l,objectType:m})});s.add(f);return}else if(t.config.enums.mode==="typescript"&&!p.typeofItems.some(m=>m!=="number"&&m!=="string")){let m=i.enumDeclaration({leadingComment:_e({schema:r}),name:o.node,obj:p.obj});s.add(m);return}}let a=i.typeAliasDeclaration({comment:_e({schema:r}),exportType:o.exported,name:o.node,type:n});s.add(a);},Zo=({id:e,plugin:t,schema:r,state:n})=>{let s=t.context.file({id:P}),o=ye({onRef:void 0,plugin:t,schema:r,state:n}),a=M({config:t.config.definitions,name:V(e)});s.updateNode(t.api.getId({type:"ref",value:e}),{exported:true,name:a}),Uy({id:e,plugin:t,schema:r,type:o});},Mc=({plugin:e})=>{let t={usedTypeIDs:new Set},r=e.createFile({case:e.config.case,id:P,path:e.output}),n=M({config:{case:e.config.case},name:"ClientOptions"}),s=r.updateNode(e.api.getId({type:"ClientOptions"}),{exported:true,name:n}),o=[];if(e.forEach("operation","parameter","requestBody","schema","server",a=>{a.type==="operation"?wc({operation:a.operation,plugin:e,state:t}):a.type==="parameter"?Zo({id:a.$ref,plugin:e,schema:a.parameter.schema,state:t}):a.type==="requestBody"?Zo({id:a.$ref,plugin:e,schema:a.requestBody.schema,state:t}):a.type==="schema"?Zo({id:a.$ref,plugin:e,schema:a.schema,state:t}):a.type==="server"&&o.push(a.server);}),t.usedTypeIDs.size){let a=i.typeParameterDeclaration({constraint:i.keywordTypeNode({keyword:"string"}),name:"T"}),p=i.typeAliasDeclaration({exportType:true,name:"TypeID",type:i.templateLiteralType({value:[i.typeReferenceNode({typeName:"T"}),"_",i.keywordTypeNode({keyword:"string"})]}),typeParameters:[a]});r.add(p);for(let c of t.usedTypeIDs.values()){let m=ve(v({case:e.config.case,value:c+"_id"})),l=i.typeAliasDeclaration({exportType:true,name:m,type:i.typeReferenceNode({typeArguments:[i.literalTypeNode({literal:i.stringLiteral({text:c})})],typeName:"TypeID"})});r.add(l);}}Nc({nodeInfo:s,plugin:e,servers:o});};var Zy=e=>{switch(e.type){case "data":case "error":case "errors":case "response":case "responses":return `${e.operation.id}-${e.type}`;case "ref":return e.value;default:return e.type}},Dc={getId:Zy,schemaToType:e=>ye({onRef:void 0,...e})};var qs={api:Dc,config:{case:"PascalCase",exportFromIndex:true,style:"preserve",tree:false},handler:Mc,handlerLegacy:Ac,name:"@hey-api/typescript",output:"types",resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.definitions}),e.config.enums=t.valueToObject({defaultValue:{case:"SCREAMING_SNAKE_CASE",constantsIgnoreNull:false,enabled:!!e.config.enums,mode:"javascript"},mappers:{boolean:r=>({enabled:r}),string:r=>({mode:r})},value:e.config.enums}),e.config.errors=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",error:"{{name}}Error",name:"{{name}}Errors"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.errors}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}Data"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}Responses",response:"{{name}}Response"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.responses});}};var Wt=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),n=t.getPlugin("@hey-api/sdk");return _o({file:r,operation:e,plugin:n})},$s=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),n=t.getPlugin("@hey-api/typescript"),s=t.context.file({id:P}),a={asType:true,name:r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:s.getName(n.api.getId({operation:e,type:"error"}))}).name||""};if(a.name||(a=r.import({asType:true,module:t.name,name:"DefaultError"})),E(t.context.config).name==="@hey-api/client-axios"){let c=r.import({asType:true,module:"axios",name:"AxiosError"});a={...c,name:`${c.name}<${a.name}>`};}return a},Ms=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),n=t.getPlugin("@hey-api/typescript"),s=t.context.file({id:P});return r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:s.getName(n.api.getId({operation:e,type:"response"}))}).name||"unknown"};var Lc="createQueryKey",Fs="QueryKey",cn="TOptions",Fc=i.identifier({text:"infinite"}),Ds=i.identifier({text:"options"}),Ls=({plugin:e})=>{let t=e.context.file({id:e.name}),r=t.identifier({$ref:`#/tanstack-query-create-query-key/${Lc}`,case:e.config.case,create:true,namespace:"value"});if(r.name){let n=i.indexedAccessTypeNode({indexType:i.literalTypeNode({literal:i.ots.number(0)}),objectType:i.typeReferenceNode({typeArguments:[i.typeReferenceNode({typeName:cn})],typeName:Fs})}),s=De(e.context.config),o=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"id",type:i.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:i.typeReferenceNode({typeName:cn})},{isRequired:false,name:"infinite",type:i.typeReferenceNode({typeName:"boolean"})}],returnType:i.typeTupleNode({types:[n]}),statements:[i.constVariable({assertion:n,expression:i.objectExpression({multiLine:false,obj:[{key:"_id",value:i.identifier({text:"id"})},{key:s,value:i.identifier({text:`options?.${s} || (options?.client ?? _heyApiClient).getConfig().${s}`})}]}),name:"params",typeName:n}),i.ifStatement({expression:Fc,thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"_infinite"}),right:Fc})})]})}),i.ifStatement({expression:i.propertyAccessExpression({expression:Ds,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:Ds,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:Ds,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:Ds,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:X.Options.name})}),name:cn}]}),name:r.name});t.add(o);}},Xy=({id:e,isInfinite:t,plugin:r})=>{let s=r.context.file({id:r.name}).identifier({$ref:`#/tanstack-query-create-query-key/${Lc}`,case:r.config.case,namespace:"value"});return i.callExpression({functionName:s.name||"",parameters:[i.ots.string(e),"options",t?i.ots.boolean(true):void 0]})},Bs=({plugin:e})=>{let t=e.context.file({id:e.name}),r=[{name:"_id",type:i.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:i.keywordTypeNode({keyword:"boolean"})}],n=i.typeAliasDeclaration({exportType:true,name:Fs,type:i.typeTupleNode({types:[i.typeIntersectionNode({types:[i.typeReferenceNode({typeName:`Pick<${cn}, '${De(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),i.typeInterfaceNode({properties:r,useLegacyResolution:true})]})]}),typeParameters:[{extends:i.typeReferenceNode({typeName:i.identifier({text:X.Options.name})}),name:cn}]});t.add(n);},Hs=({isInfinite:e,operation:t,plugin:r,typeQueryKey:n})=>{let s=r.context.file({id:r.name}),o=Wt({operation:t,plugin:r}),a=e?s.identifier({$ref:`#/tanstack-query-infinite-query-key/${t.id}`,case:r.config.infiniteQueryKeys.case,create:true,nameTransformer:r.config.infiniteQueryKeys.name,namespace:"value"}):s.identifier({$ref:`#/tanstack-query-query-key/${t.id}`,case:r.config.queryKeys.case,create:true,nameTransformer:r.config.queryKeys.name,namespace:"value"});return i.constVariable({exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:Qn(t),name:"options",type:o}],returnType:e?n:void 0,statements:Xy({id:t.id,isInfinite:e,plugin:r})}),name:a.name||""})};var Hc="createInfiniteParams",Bc="infiniteQueryOptions",Jy=({plugin:e})=>{let t=e.context.file({id:e.name}),r=t.identifier({$ref:`#/tanstack-query-create-infinite-params/${Hc}`,case:e.config.case,create:true,namespace:"value"}),n=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:i.typeReferenceNode({typeName:`QueryKey<${X.Options.name}>`})},{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:b__default.default.factory.createTypeQueryNode(i.identifier({text:"page"}))})})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:`Pick<QueryKey<${X.Options.name}>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:"K"}]}),name:r.name||""});t.add(n);},_c=({operation:e,plugin:t,queryFn:r,state:n})=>{if(!t.config.infiniteQueryOptions||!["get","post"].includes(e.method))return n;let s=_a({context:t.context,operation:e});if(!s)return n;let o=t.context.file({id:t.name}),a=ar({context:t.context,operation:e});n.hasInfiniteQueries||(n.hasInfiniteQueries=true,n.hasCreateQueryKeyParamsFunction||(Bs({plugin:t}),Ls({plugin:t}),n.hasCreateQueryKeyParamsFunction=true),n.hasCreateInfiniteParamsFunction||(Jy({plugin:t}),n.hasCreateInfiniteParamsFunction=true),o.import({module:t.name,name:Bc}),n.typeInfiniteData=o.import({asType:true,module:t.name,name:"InfiniteData"})),n.hasUsedQueryFn=true;let p=Wt({operation:e,plugin:t}),c=$s({operation:e,plugin:t}),m=Ms({operation:e,plugin:t}),l=`${Fs}<${p}>`,f=`Pick<${l}[0], 'body' | 'headers' | 'path' | 'query'>`,u=t.getPlugin("@hey-api/typescript"),y={usedTypeIDs:new Set},g=u.api.schemaToType({plugin:u,schema:s.schema,state:y}),x=`${Xe({node:g,unescape:true})} | ${f}`,R=Hs({isInfinite:true,operation:e,plugin:t,typeQueryKey:l});o.add(R);let S=o.identifier({$ref:`#/tanstack-query-infinite-query-key/${e.id}`,case:t.config.infiniteQueryKeys.case,nameTransformer:t.config.infiniteQueryKeys.name,namespace:"value"}),N=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}]})]})}),w=o.identifier({$ref:`#/tanstack-query-create-infinite-params/${Hc}`,case:t.config.case,namespace:"value"}),B=[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:s.in,value:i.objectExpression({multiLine:true,obj:[{key:s.name,value:i.identifier({text:"pageParam"})}]})}]}),whenTrue:i.identifier({text:"pageParam"})}),name:"page",typeName:f}),i.constVariable({expression:i.callExpression({functionName:w.name||"",parameters:["queryKey","page"]}),name:"params"})];t.getPlugin("@hey-api/sdk")?.config.responseStyle==="data"?B.push(i.returnVariable({expression:N})):B.push(i.constVariable({destructure:true,expression:N,name:"data"}),i.returnVariable({expression:"data"}));let D=o.identifier({$ref:`#/tanstack-query-infinite-query-options/${e.id}`,case:t.config.infiniteQueryOptions.case,create:true,nameTransformer:t.config.infiniteQueryOptions.name,namespace:"value"}),j=i.constVariable({comment:t.config.comments?It({operation:e}):void 0,exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:a,name:"options",type:p}],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:B})},{key:"queryKey",value:i.callExpression({functionName:S.name||"",parameters:["options"]})}]})],name:Bc,types:[m,c.name||"unknown",`${typeof n.typeInfiniteData=="string"?n.typeInfiniteData:n.typeInfiniteData.name}<${m}>`,l,x]})]}),name:D.name||""});o.add(j);};var Vc="mutationOptions",Wc=({operation:e,plugin:t,queryFn:r,state:n})=>{if(!t.config.mutationOptions.enabled||!["delete","patch","post","put"].includes(e.method))return n;let s=t.name==="@tanstack/angular-query-experimental"||t.name==="@tanstack/svelte-query"||t.name==="@tanstack/solid-query"?"MutationOptions":"UseMutationOptions",o=t.context.file({id:t.name});n.hasMutations||(n.hasMutations=true,o.import({asType:true,module:t.name,name:s})),n.hasUsedQueryFn=true;let a=Wt({operation:e,plugin:t}),p=$s({operation:e,plugin:t}),c=Ms({operation:e,plugin:t}),m=`${s}<${c}, ${p.name}, ${a}>`,l=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"localOptions"},{key:"throwOnError",value:true}]})]})}),f=[];t.getPlugin("@hey-api/sdk")?.config.responseStyle==="data"?f.push(i.returnVariable({expression:l})):f.push(i.constVariable({destructure:true,expression:l,name:"data"}),i.returnVariable({expression:"data"}));let u=o.identifier({$ref:`#/tanstack-query-mutation-options/${e.id}`,case:t.config.mutationOptions.case,create:true,nameTransformer:t.config.mutationOptions.name,namespace:"value"}),y=i.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${a}>`}],returnType:m,statements:[i.constVariable({expression:i.objectExpression({obj:[{key:"mutationFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{name:"localOptions"}],statements:f})}]}),name:Vc,typeName:m}),i.returnVariable({expression:Vc})]}),g=i.constVariable({comment:t.config.comments?It({operation:e}):void 0,exportConst:true,expression:y,name:u.name||""});return o.add(g),n};var zc="queryOptions",Kc=({operation:e,plugin:t,queryFn:r,state:n})=>{if(!t.config.queryOptions||!["get","post"].includes(e.method))return n;let s=t.context.file({id:t.name}),o=ar({context:t.context,operation:e});n.hasQueries||(n.hasQueries=true,n.hasCreateQueryKeyParamsFunction||(Bs({plugin:t}),Ls({plugin:t}),n.hasCreateQueryKeyParamsFunction=true),s.import({module:t.name,name:zc})),n.hasUsedQueryFn=true;let a=Hs({isInfinite:false,operation:e,plugin:t});s.add(a);let p=Wt({operation:e,plugin:t}),c=s.identifier({$ref:`#/tanstack-query-query-key/${e.id}`,case:t.config.queryKeys.case,nameTransformer:t.config.queryKeys.name,namespace:"value"}),m=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:i.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),l=[];t.getPlugin("@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=s.identifier({$ref:`#/tanstack-query-query-options/${e.id}`,case:t.config.queryOptions.case,create:true,nameTransformer:t.config.queryOptions.name,namespace:"value"}),u=i.constVariable({comment:t.config.comments?It({operation:e}):void 0,exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:o,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:l})},{key:"queryKey",value:i.callExpression({functionName:c.name||"",parameters:["options"]})}]})],name:zc})]}),name:f.name||""});return s.add(u),n};var ft=({plugin:e})=>{let t=e.createFile({case:e.config.case,id:e.name,path:e.output}),r={hasCreateInfiniteParamsFunction:false,hasCreateQueryKeyParamsFunction:false,hasInfiniteQueries:false,hasMutations:false,hasQueries:false,hasUsedQueryFn:false,typeInfiniteData:void 0};t.import({...X.Options,module:t.relativePathToFile({context:e.context,id:be})}),e.forEach("operation",({operation:n})=>{r.hasUsedQueryFn=false;let s=e.getPlugin("@hey-api/sdk"),o=s?.config.asClass?vs({context:e.context,operation:n,plugin:s}):void 0,a=o?o.values().next().value:void 0,p=(a?[a.path[0],...a.path.slice(1).map(c=>v({case:"camelCase",value:c})),a.methodName].filter(Boolean):[Ne({config:e.context.config,handleIllegal:true,id:n.id,operation:n})]).join(".");Kc({operation:n,plugin:e,queryFn:p,state:r}),_c({operation:n,plugin:e,queryFn:p,state:r}),Wc({operation:n,plugin:e,queryFn:p,state:r}),r.hasUsedQueryFn&&t.import({module:t.relativePathToFile({context:e.context,id:be}),name:p.split(".")[0]});}),(r.hasQueries||r.hasInfiniteQueries)&&t.import({alias:"_heyApiClient",module:t.relativePathToFile({context:e.context,id:Qe}),name:"client"});};var Yy=e=>`${Ne({config:T(),id:e.name,operation:e})}InfiniteOptions`,eg=e=>`${Ne({config:T(),id:e.name,operation:e})}Mutation`,tg=({config:e,id:t,operation:r})=>`${Ne({config:e,id:t,operation:r})}Options`,_s=({config:e,id:t,isInfinite:r,operation:n})=>`${Ne({config:e,id:t,operation:n})}${r?"Infinite":""}QueryKey`,rg=e=>{switch(e.in){case "formData":return "body";case "header":return "headers";default:return e.in}},ng="createInfiniteParams",tm="createQueryKey",Uc="infiniteQueryOptions",Zc="mutationOptions",Xo="QueryKey",Qc="queryOptions",ln="TOptions",sg=({file:e})=>{let t=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:i.typeNode(`QueryKey<${X.OptionsLegacyParser.name}>`)},{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:b__default.default.factory.createAsExpression(b__default.default.factory.createAsExpression(i.identifier({text:"params"}),b__default.default.factory.createKeywordTypeNode(b__default.default.SyntaxKind.UnknownKeyword)),b__default.default.factory.createTypeQueryNode(i.identifier({text:"page"})))})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:`Pick<QueryKey<${X.OptionsLegacyParser.name}>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:"K"}]}),name:ng});e.add(t);},Xc=({file:e})=>{let t=i.indexedAccessTypeNode({indexType:i.typeNode(0),objectType:i.typeNode(Xo,[i.typeNode(ln)])}),r=i.identifier({text:"infinite"}),n=De(T()),s=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"id",type:i.typeNode("string")},{isRequired:false,name:"options",type:i.typeNode(ln)},{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:X.OptionsLegacyParser.name})}),name:ln}]}),name:tm});e.add(s);},Gc=({file:e})=>{let t=[{name:"_id",type:i.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:i.keywordTypeNode({keyword:"boolean"})}],r=i.typeAliasDeclaration({name:Xo,type:i.typeTupleNode({types:[i.typeIntersectionNode({types:[i.typeReferenceNode({typeName:`Pick<${ln}, '${De(T())}' | 'body' | 'headers' | 'path' | 'query'>`}),i.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:i.typeReferenceNode({typeName:i.identifier({text:X.OptionsLegacyParser.name})}),name:ln}]});e.add(r);},Qo=({client:e,file:t,operation:r,typesModulePath:n})=>{let{name:s}=pr({client:e,meta:r.parameters.length?{$ref:r.name,name:r.name}:void 0,nameTransformer:cr,onImport:a=>{t.import({asType:true,module:n,name:a});}});return {typeData:Ko({importedType:s})}},Jc=({client:e,file:t,operation:r,pluginName:n,typesModulePath:s})=>{let o=T(),{name:a}=pr({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Fr,onImport:m=>{t.import({asType:true,module:s,name:m});}}),p={asType:true,name:a};if(p.name||(p=t.import({asType:true,module:n,name:"DefaultError"})),E(o).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}},Yc=({client:e,file:t,operation:r,typesModulePath:n})=>{let{name:s}=pr({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:lt,onImport:a=>{t.import({asType:true,module:n,name:a});}});return {typeResponse:s||"void"}},em=({id:e,isInfinite:t})=>i.arrayLiteralExpression({elements:[i.callExpression({functionName:tm,parameters:[i.ots.string(e),"options",t?i.ots.boolean(true):void 0]})],multiLine:false}),ut=({client:e,files:t,plugin:r})=>{let n=T();if(_(n))throw new Error("TanStack Query plugin does not support legacy clients");let s=t[r.name];s.import({...X.OptionsLegacyParser,module:re({config:n,sourceOutput:r.output})});let o=lr({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,y=new Map;for(let g of e.services)for(let x of g.operations){let R=$(x);if(y.has(R))continue;y.set(R,true);let S=[n.plugins["@hey-api/sdk"]?.config.asClass&&Ht({config:n,name:g.name}),Ne({config:n,handleIllegal:!n.plugins["@hey-api/sdk"]?.config.asClass,id:x.name,operation:x})].filter(Boolean).join("."),N=false;if(r.config.queryOptions&&["GET","POST"].includes(x.method)){u||(u=true,m||(Gc({file:s}),Xc({file:s}),m=true),s.import({module:r.name,name:Qc})),N=true;let{typeData:w}=Qo({client:e,file:s,operation:x,typesModulePath:o}),B=ct(x.parameters),D=i.constVariable({exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:B,name:"options",type:w}],statements:em({id:x.name})}),name:_s({config:n,id:x.name,operation:x})});s.add(D);let j=i.constVariable({comment:[],exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:B,name:"options",type:w}],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:S,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:_s({config:n,id:x.name,operation:x}),parameters:["options"]})}]})],name:Qc})]}),name:tg({config:n,id:x.name,operation:x})});s.add(j);}if(r.config.infiniteQueryOptions&&["GET","POST"].includes(x.method)){let w,B=x.parameters.find(D=>{if(Te(n.parser.pagination).test(D.name))return w=D,true;if(D.in==="body"){if(D.export==="reference"){let z=D.$refs[0];return e.models.find(te=>te.meta?.$ref===z)?.properties.find(te=>{if(Te(n.parser.pagination).test(te.name))return w=te,true})}return D.properties.find(z=>{if(Te(n.parser.pagination).test(z.name))return w=z,true})}});if(B&&w){l||(l=true,m||(Gc({file:s}),Xc({file:s}),m=true),c||(sg({file:s}),c=true),s.import({module:r.name,name:Uc}),p=s.import({asType:true,module:r.name,name:"InfiniteData"})),N=true;let{typeData:D}=Qo({client:e,file:s,operation:x,typesModulePath:o}),{typeError:j}=Jc({client:e,file:s,operation:x,pluginName:r.name,typesModulePath:o}),{typeResponse:z}=Yc({client:e,file:s,operation:x,typesModulePath:o}),H=ct(x.parameters),te=`${Xo}<${D}>`,$e=`Pick<${te}[0], 'body' | 'headers' | 'path' | 'query'>`,ze=`${w.base} | ${$e}`,mr=i.constVariable({exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:H,name:"options",type:D}],returnType:te,statements:em({id:x.name,isInfinite:true})}),name:_s({config:n,id:x.name,isInfinite:true,operation:x})});s.add(mr);let df=i.constVariable({comment:[],exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:H,name:"options",type:D}],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:rg(B),value:i.objectExpression({multiLine:true,obj:[{key:w.name,value:i.identifier({text:"pageParam"})}]})}]}),whenTrue:i.identifier({text:"pageParam"})}),name:"page",typeName:$e}),i.constVariable({expression:i.callExpression({functionName:"createInfiniteParams",parameters:["queryKey","page"]}),name:"params"}),i.constVariable({destructure:true,expression:i.awaitExpression({expression:i.callExpression({functionName:S,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:_s({config:n,id:x.name,isInfinite:true,operation:x}),parameters:["options"]})}]})],name:Uc,types:[z,j.name,`${typeof p=="string"?p:p.name}<${z}>`,te,ze]})]}),name:Yy(x)});s.add(df);}}if(r.config.mutationOptions&&["DELETE","PATCH","POST","PUT"].includes(x.method)){f||(f=true,s.import({asType:true,module:r.name,name:a})),N=true;let{typeData:w}=Qo({client:e,file:s,operation:x,typesModulePath:o}),{typeError:B}=Jc({client:e,file:s,operation:x,pluginName:r.name,typesModulePath:o}),{typeResponse:D}=Yc({client:e,file:s,operation:x,typesModulePath:o}),j=i.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${w}>`}],statements:[i.constVariable({expression:i.objectExpression({obj:[{key:"mutationFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{name:"localOptions"}],statements:[i.constVariable({destructure:true,expression:i.awaitExpression({expression:i.callExpression({functionName:S,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"localOptions"},{key:"throwOnError",value:true}]})]})}),name:"data"}),i.returnVariable({expression:"data"})]})}]}),name:Zc,typeName:`${a}<${D}, ${B.name}, ${w}>`}),i.returnVariable({expression:Zc})]}),z=i.constVariable({comment:[],exportConst:true,expression:j,name:eg(x)});s.add(z);}(u||l)&&s.import({alias:"_heyApiClient",module:lr({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:r.output}),name:"client"}),N&&s.import({module:lr({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:r.output}),name:S.split(".")[0]});}};var Vs={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:ft,handlerLegacy:ut,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"},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"},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}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Ws={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:ft,handlerLegacy:ut,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"},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"},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}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var zs={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:ft,handlerLegacy:ut,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"},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"},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}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Ks={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:ft,handlerLegacy:ut,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"},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"},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}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Us={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:ft,handlerLegacy:ut,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"},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"},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}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var rm="fastify",mg=({operation:e,plugin:t})=>{let r=t.context.file({id:rm}),n=[],s=t.getPlugin("@hey-api/typescript"),o=t.context.file({id:P}),a=o.getName(s.api.getId({operation:e,type:"data"}));a&&(e.body&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:a}),n.push({isRequired:e.body.required,name:"Body",type:`${a}['body']`})),e.parameters&&(e.parameters.header&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:a}),n.push({isRequired:$t(e.parameters.header),name:"Headers",type:`${a}['headers']`})),e.parameters.path&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:a}),n.push({isRequired:$t(e.parameters.path),name:"Params",type:`${a}['path']`})),e.parameters.query&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:a}),n.push({isRequired:$t(e.parameters.query),name:"Querystring",type:`${a}['query']`}))));let{errors:p,responses:c}=rt(e),m,l=o.getName(s.api.getId({operation:e,type:"errors"}));if(l&&p&&p.properties){let x=Object.keys(p.properties);if(x.length){if(!x.includes("default"))r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:l}),m=i.typeReferenceNode({typeName:l});else if(x.length>1){r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:l});let S=i.typeReferenceNode({typeName:l}),N=i.literalTypeNode({literal:i.stringLiteral({text:"default"})});m=i.typeReferenceNode({typeArguments:[S,N],typeName:"Omit"});}}}let f,u=o.getName(s.api.getId({operation:e,type:"responses"}));if(u&&c&&c.properties){let x=Object.keys(c.properties);if(x.length){if(!x.includes("default"))r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:u}),f=i.typeReferenceNode({typeName:u});else if(x.length>1){r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:u});let S=i.typeReferenceNode({typeName:u}),N=i.literalTypeNode({literal:i.stringLiteral({text:"default"})});f=i.typeReferenceNode({typeArguments:[S,N],typeName:"Omit"});}}}let y=[m,f].filter(Boolean);return y.length&&n.push({name:"Reply",type:i.typeIntersectionNode({types:y})}),n.length?{name:e.id,type:i.typeNode("RouteHandler",[i.typeInterfaceNode({properties:n,useLegacyResolution:false})])}:void 0},nm=({plugin:e})=>{let t=e.createFile({id:rm,path:e.output}),r=[];e.forEach("operation",({operation:s})=>{let o=mg({operation:s,plugin:e});o&&r.push(o);});let n=t.identifier({$ref:"RouteHandlers",create:true,namespace:"type"});n.name&&(r.length&&t.import({asType:true,module:"fastify",name:"RouteHandler"}),t.add(i.typeAliasDeclaration({exportType:true,name:n.name,type:i.typeInterfaceNode({properties:r,useLegacyResolution:false})})));};var Zs={config:{exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:nm,name:"fastify",output:"fastify"};var h={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"})},v:i.identifier({text:"v"})},dt="valibot";var fg=({file:e,operation:t,plugin:r})=>{let{requests:n}=r.config,s=r.context.file({id:dt}).identifier({$ref:`#/valibot-response/${t.id}`,nameTransformer:typeof n=="object"?n.name:void 0,namespace:"value"});if(!s.name)return;e.import({module:e.relativePathToFile({context:r.context,id:dt}),name:s.name}),e.import({alias:h.v.text,module:"valibot",name:"*"});let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.async.parseAsync}),parameters:[i.identifier({text:s.name}),i.identifier({text:o})]})})})]})},ug=({file:e,operation:t,plugin:r})=>{let{responses:n}=r.config,s=r.context.file({id:dt}).identifier({$ref:`#/valibot-response/${t.id}`,nameTransformer:typeof n=="object"?n.name:void 0,namespace:"value"});if(!s.name)return;e.import({module:e.relativePathToFile({context:r.context,id:dt}),name:s.name}),e.import({alias:h.v.text,module:"valibot",name:"*"});let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.async.parseAsync}),parameters:[i.identifier({text:s.name}),i.identifier({text:o})]})})})]})},sm={createRequestValidator:fg,createResponseValidator:ug};var Qs={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}},Go=e=>e!==void 0&&e in Qs,om=e=>Go(e)&&Qs[e].needsBigInt,Lr=({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 im=({operation:e,plugin:t,state:r})=>{let n=t.context.file({id:dt});if(t.config.requests.enabled){let s=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let p={},c=[];for(let m in e.parameters.header){let l=e.parameters.header[m];p[l.name]=l.schema,l.required&&(c.push(l.name),s.add("headers"));}Object.keys(p).length&&(o.properties.headers={properties:p,required:c,type:"object"});}if(e.parameters.path){let p={},c=[];for(let m in e.parameters.path){let l=e.parameters.path[m];p[l.name]=l.schema,l.required&&(c.push(l.name),s.add("path"));}Object.keys(p).length&&(o.properties.path={properties:p,required:c,type:"object"});}if(e.parameters.query){let p={},c=[];for(let m in e.parameters.query){let l=e.parameters.query[m];p[l.name]=l.schema,l.required&&(c.push(l.name),s.add("query"));}Object.keys(p).length&&(o.properties.query={properties:p,required:c,type:"object"});}}e.body&&(o.properties.body=e.body.schema,e.body.required&&s.add("body")),o.required=[...s];let a=n.identifier({$ref:`#/valibot-data/${e.id}`,case:t.config.requests.case,create:true,nameTransformer:t.config.requests.name,namespace:"value"});Pe({$ref:`#/valibot-data/${e.id}`,identifier:a,plugin:t,schema:o,state:r});}if(t.config.responses.enabled&&e.responses){let{response:s}=rt(e);if(s){let o=n.identifier({$ref:`#/valibot-response/${e.id}`,case:t.config.responses.case,create:true,nameTransformer:t.config.responses.name,namespace:"value"});Pe({$ref:`#/valibot-response/${e.id}`,identifier:o,plugin:t,schema:s,state:r});}}};var Ve=e=>e.length===1?e[0]:i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.methods.pipe}),parameters:e}),dg=({plugin:e,schema:t,state:r})=>{let n=i.propertyAccessExpression({expression:h.v,name:h.schemas.array}),s=[];if(t.items){t=Y({schema:t});let o=t.items.map(a=>{let p=Pe({plugin:e,schema:a,state:r});return Ve(p)});if(o.length===1){let a=i.callExpression({functionName:n,parameters:o});s.push(a);}else {t.logicalOperator;let a=i.callExpression({functionName:n,parameters:[fn()]});s.push(a);}}else {let o=i.callExpression({functionName:n,parameters:[fn()]});s.push(o);}if(t.minItems===t.maxItems&&t.minItems!==void 0){let o=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.length}),parameters:[i.valueToExpression({value:t.minItems})]});s.push(o);}else {if(t.minItems!==void 0){let o=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.minLength}),parameters:[i.valueToExpression({value:t.minItems})]});s.push(o);}if(t.maxItems!==void 0){let o=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.maxLength}),parameters:[i.valueToExpression({value:t.maxItems})]});s.push(o);}}return Ve(s)},yg=({schema:e})=>typeof e.const=="boolean"?i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[i.ots.boolean(e.const)]}):i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.boolean})}),gg=({schema:e})=>{let t=[],r=false;for(let s of e.items??[])s.type==="string"&&typeof s.const=="string"?t.push(i.stringLiteral({text:s.const})):(s.type==="null"||s.const===null)&&(r=true);if(!t.length)return fn();let n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.picklist}),parameters:[i.arrayLiteralExpression({elements:t,multiLine:false})]});return r&&(n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.nullable}),parameters:[n]})),n},hg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.never})}),xg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.null})}),am=({schema:e})=>{let t=e.format,r=e.type==="integer",n=om(t),s=Go(t)?Qs[t]:null;if(e.const!==void 0&&e.const!==null){let a=e.const,p;if(typeof a=="number"&&!t)p=i.ots.number(a);else if(typeof a=="number"&&t)n?p=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(a.toString())]}):p=i.ots.number(a);else if(typeof a=="string"&&n){let c=a.endsWith("n")?a.slice(0,-1):a;p=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(c)]});}else if(typeof a=="bigint"){let c=a.toString(),m=c.endsWith("n")?c.slice(0,-1):c;p=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(m)]});}else p=i.valueToExpression({value:a});return i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[p]})}let o=[];if(n){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.union}),parameters:[i.arrayLiteralExpression({elements:[i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.number})}),i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.string})}),i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.bigInt})})],multiLine:false})]});o.push(a);let p=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.transform}),parameters:[i.arrowFunction({parameters:[{name:"x"}],statements:i.callExpression({functionName:"BigInt",parameters:[i.identifier({text:"x"})]})})]});o.push(p);}else {let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.number})});o.push(a);}if(!n&&r){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.integer})});o.push(a);}if(s){let a=s.min,p=s.max,c=s.minError,m=s.maxError,l=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.minValue}),parameters:[n?i.callExpression({functionName:"BigInt",parameters:[i.ots.string(a.toString())]}):i.ots.number(a),i.ots.string(c)]});o.push(l);let f=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.maxValue}),parameters:[n?i.callExpression({functionName:"BigInt",parameters:[i.ots.string(p.toString())]}):i.ots.number(p),i.ots.string(m)]});o.push(f);}if(e.exclusiveMinimum!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.gtValue}),parameters:[Lr({isBigInt:n,value:e.exclusiveMinimum})]});o.push(a);}else if(e.minimum!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.minValue}),parameters:[Lr({isBigInt:n,value:e.minimum})]});o.push(a);}if(e.exclusiveMaximum!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.ltValue}),parameters:[Lr({isBigInt:n,value:e.exclusiveMaximum})]});o.push(a);}else if(e.maximum!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.maxValue}),parameters:[Lr({isBigInt:n,value:e.maximum})]});o.push(a);}return Ve(o)},bg=({plugin:e,schema:t,state:r})=>{let n=[],s=t.required??[];for(let a in t.properties){let p=t.properties[a],c=s.includes(a),m=Pe({optional:!c,plugin:e,schema:p,state:r});oe.lastIndex=0;let l;oe.test(a)?l=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):l=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(l=`'${a}'`),n.push(i.propertyAssignment({initializer:Ve(m),name:l}));}if(t.additionalProperties&&t.additionalProperties.type==="object"&&!Object.keys(n).length){let a=Pe({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.string}),parameters:[]}),Ve(a)]})}}let o=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(n,true)]});return {anyType:h.types.GenericSchema.text,expression:o}},Og=({schema:e})=>{if(typeof e.const=="string")return i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[i.ots.string(e.const)]});let t=[],r=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.string})});if(t.push(r),e.format)switch(e.format){case "date":t.push(i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.isoDate})}));break;case "date-time":t.push(i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.isoTimestamp})}));break;case "ipv4":case "ipv6":t.push(i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.ip})}));break;case "uri":t.push(i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.url})}));break;case "email":case "time":case "uuid":t.push(i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:i.identifier({text:e.format})})}));break}if(e.minLength===e.maxLength&&e.minLength!==void 0){let n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.length}),parameters:[i.valueToExpression({value:e.minLength})]});t.push(n);}else {if(e.minLength!==void 0){let n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.minLength}),parameters:[i.valueToExpression({value:e.minLength})]});t.push(n);}if(e.maxLength!==void 0){let n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.maxLength}),parameters:[i.valueToExpression({value:e.maxLength})]});t.push(n);}}if(e.pattern){let n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.regex}),parameters:[i.regularExpressionLiteral({text:e.pattern})]});t.push(n);}return Ve(t)},Sg=({plugin:e,schema:t,state:r})=>{if(t.const&&Array.isArray(t.const)){let n=t.const.map(o=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[i.valueToExpression({value:o})]}));return i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.tuple}),parameters:[i.arrayLiteralExpression({elements:n})]})}if(t.items){let n=t.items.map(o=>{let a=Pe({plugin:e,schema:o,state:r});return Ve(a)});return i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.tuple}),parameters:[i.arrayLiteralExpression({elements:n})]})}return fn()},Rg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.undefined})}),fn=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.unknown})}),Tg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.void})}),pm=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:dg({plugin:e,schema:t,state:r})};case "boolean":return {expression:yg({schema:t})};case "enum":return {expression:gg({schema:t})};case "integer":case "number":return {expression:am({schema:t})};case "never":return {expression:hg()};case "null":return {expression:xg()};case "object":return bg({plugin:e,schema:t,state:r});case "string":return t.format==="int64"||t.format==="uint64"?{expression:am({schema:t})}:{expression:Og({schema:t})};case "tuple":return {expression:Sg({plugin:e,schema:t,state:r})};case "undefined":return {expression:Rg()};case "unknown":return {expression:fn()};case "void":return {expression:Tg()}}},Pe=({$ref:e,identifier:t,optional:r,plugin:n,schema:s,state:o})=>{let a=n.context.file({id:dt}),p,c=t,m=[];if(e&&(o.circularReferenceTracker.add(e),c||(c=a.identifier({$ref:e,case:o.nameCase,create:true,nameTransformer:o.nameTransformer,namespace:"value"}))),s.$ref){let l=o.circularReferenceTracker.has(s.$ref),f=a.identifier({$ref:s.$ref,case:o.nameCase,nameTransformer:o.nameTransformer,namespace:"value"});if(!f.name){let u=n.context.resolveIrRef(s.$ref),y=Pe({$ref:s.$ref,plugin:n,schema:u,state:o});m.push(...y),f=a.identifier({$ref:s.$ref,case:o.nameCase,nameTransformer:o.nameTransformer,namespace:"value"});}if(f.name){let u=i.identifier({text:f.name});if(l){let y=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:u})]})]});m.push(y),o.hasCircularReference=true;}else m.push(u);}}else if(s.type){let l=pm({plugin:n,schema:s,state:o});if(p=l.anyType,m.push(l.expression),n.config.metadata&&s.description){let f=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.metadata}),parameters:[i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:s.description})}]})]});m.push(f);}}else if(s.items)if(s=Y({schema:s}),s.items){let l=s.items.map(f=>{let u=Pe({plugin:n,schema:f,state:o});return Ve(u)});if(s.logicalOperator==="and"){let f=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.intersect}),parameters:[i.arrayLiteralExpression({elements:l})]});m.push(f);}else {let f=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.union}),parameters:[i.arrayLiteralExpression({elements:l})]});m.push(f);}}else {let l=Pe({plugin:n,schema:s,state:o});m.push(...l);}else {let l=pm({plugin:n,schema:{type:"unknown"},state:o});p=l.anyType,m.push(l.expression);}if(e&&o.circularReferenceTracker.delete(e),m.length&&s.accessScope==="read"){let l=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.readonly})});m.push(l);}if(m.length){let l;if(s.default!==void 0){let f=s.type==="integer"&&s.format==="int64";l=Lr({isBigInt:f,value:s.default}),l&&(m=[i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.optional}),parameters:[Ve(m),l]})]);}r&&!l&&(m=[i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.optional}),parameters:[Ve(m)]})]);}if(c&&c.name&&c.created){let l=i.constVariable({comment:n.config.comments?_e({schema:s}):void 0,exportConst:true,expression:Ve(m),name:c.name,typeName:o.hasCircularReference?i.propertyAccessExpression({expression:h.v,name:p||h.types.GenericSchema.text}):void 0});return a.add(l),[]}return m},cm=({plugin:e})=>{e.createFile({case:e.config.case,id:dt,path:e.output}).import({alias:h.v.text,module:"valibot",name:"*"}),e.forEach("operation","parameter","requestBody","schema",r=>{let n={circularReferenceTracker:new Set,hasCircularReference:false,nameCase:e.config.definitions.case,nameTransformer:e.config.definitions.name};r.type==="operation"?im({operation:r.operation,plugin:e,state:n}):r.type==="parameter"?Pe({$ref:r.$ref,plugin:e,schema:r.parameter.schema,state:n}):r.type==="requestBody"?Pe({$ref:r.$ref,plugin:e,schema:r.requestBody.schema,state:n}):r.type==="schema"&&Pe({$ref:r.$ref,plugin:e,schema:r.schema,state:n});});};var Xs={api:sm,config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:cm,name:"valibot",output:"valibot",resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}Data"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}Response"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.responses});},tags:["validator"]};var d={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"}),z:i.identifier({text:"z"})},G="zod";var Ag=({file:e,operation:t,plugin:r})=>{let s=r.context.file({id:G}).getName(r.api.getId({operation:t,type:"data"}));if(!s)return;e.import({module:e.relativePathToFile({context:r.context,id:G}),name:s});let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:i.identifier({text:s}),name:d.parseAsync}),parameters:[i.identifier({text:o})]})})})]})},Ig=({file:e,operation:t,plugin:r})=>{let s=r.context.file({id:G}).getName(r.api.getId({operation:t,type:"responses"}));if(!s)return;e.import({module:e.relativePathToFile({context:r.context,id:G}),name:s});let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:i.identifier({text:s}),name:d.parseAsync}),parameters:[i.identifier({text:o})]})})})]})},Eg=e=>{switch(e.type){case "data":case "responses":case "type-infer-data":case "type-infer-responses":return `${e.operation.id}-${e.type}`;case "ref":case "type-infer-ref":default:return `${e.type}-${e.value}`}},mm={createRequestValidator:Ag,createResponseValidator:Ig,getId:Eg};var vt=({plugin:e,schema:t,schemaId:r,typeInferId:n,zodSchema:s})=>{let o=e.context.file({id:G}),a=o.addNodeReference(r,{factory:c=>i.typeReferenceNode({typeName:c})}),p=i.constVariable({comment:e.config.comments?_e({schema:t}):void 0,exportConst:true,expression:s.expression,name:a,typeName:s.typeName?i.propertyAccessExpression({expression:d.z,name:s.typeName}):void 0});if(o.add(p),n){let c=o.addNodeReference(n,{factory:f=>i.typeReferenceNode({typeName:f})}),m=o.addNodeReference(r,{factory:f=>i.identifier({text:f})}),l=i.typeAliasDeclaration({exportType:true,name:c,type:i.typeReferenceNode({typeArguments:[i.typeOfExpression({text:m})],typeName:i.propertyAccessExpression({expression:d.z,name:d.infer})})});o.add(l);}};var Br=({plugin:e})=>{let t=e.package.getVersion("zod");if(t&&e.package.satisfies(t,"<4.0.0"))switch(e.config.compatibilityVersion){case 3:default:return "zod";case 4:return "zod/v4";case "mini":return "zod/v4-mini"}switch(e.config.compatibilityVersion){case 3:return "zod/v3";case 4:default:return "zod";case "mini":return "zod/mini"}};var Hr=({getZodSchema:e,operation:t,plugin:r})=>{let n=r.context.file({id:G});if(r.config.requests.enabled){let s=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(t.parameters){if(t.parameters.header){let m={},l=[];for(let f in t.parameters.header){let u=t.parameters.header[f];m[u.name]=u.schema,u.required&&(l.push(u.name),s.add("headers"));}Object.keys(m).length&&(o.properties.headers={properties:m,required:l,type:"object"});}if(t.parameters.path){let m={},l=[];for(let f in t.parameters.path){let u=t.parameters.path[f];m[u.name]=u.schema,u.required&&(l.push(u.name),s.add("path"));}Object.keys(m).length&&(o.properties.path={properties:m,required:l,type:"object"});}if(t.parameters.query){let m={},l=[];for(let f in t.parameters.query){let u=t.parameters.query[f];m[u.name]=u.schema,u.required&&(l.push(u.name),s.add("query"));}Object.keys(m).length&&(o.properties.query={properties:m,required:l,type:"object"});}}t.body&&(o.properties.body=t.body.schema,t.body.required&&s.add("body")),o.required=[...s];let a=e(o),p=r.api.getId({operation:t,type:"data"}),c=r.config.requests.types.infer.enabled?r.api.getId({operation:t,type:"type-infer-data"}):void 0;vt({plugin:r,schema:o,schemaId:p,typeInferId:c,zodSchema:a}),n.updateNodeReferences(p,M({config:r.config.requests,name:t.id})),c&&n.updateNodeReferences(c,M({config:r.config.requests.types.infer,name:t.id}));}if(r.config.responses.enabled&&t.responses){let{response:s}=rt(t);if(s){let o=e(s),a=r.api.getId({operation:t,type:"responses"}),p=r.config.responses.types.infer.enabled?r.api.getId({operation:t,type:"type-infer-responses"}):void 0;vt({plugin:r,schema:s,schemaId:a,typeInferId:p,zodSchema:o}),n.updateNodeReferences(a,M({config:r.config.responses,name:t.id})),p&&n.updateNodeReferences(p,M({config:r.config.responses.types.infer,name:t.id}));}}};var vg=({plugin:e,schema:t,state:r})=>{let n={},s=i.propertyAccessExpression({expression:d.z,name:d.array});if(!t.items)n.expression=i.callExpression({functionName:s,parameters:[ei().expression]});else {t=Y({schema:t});let a=t.items.map(p=>{let c=zt({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:d.z,name:d.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:a})]})]}));}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.length}),parameters:[i.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.minLength}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.maxLength}),parameters:[i.valueToExpression({value:t.maxItems})]}))),o.length&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:d.check}),parameters:o})),n},Cg=({schema:e})=>{let t={};return typeof e.const=="boolean"?(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.boolean(e.const)]}),t):(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.boolean})}),t)},kg=({schema:e})=>{let t={},r=[],n=false;for(let s of e.items??[])s.type==="string"&&typeof s.const=="string"?r.push(i.stringLiteral({text:s.const})):(s.type==="null"||s.const===null)&&(n=true);return r.length?(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.enum}),parameters:[i.arrayLiteralExpression({elements:r,multiLine:false})]}),n&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.nullable}),parameters:[t.expression]})),t):ei()},jg=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.never})}),t},Ng=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.null})}),t},un=({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},wg=({schema:e})=>{let t={},r=e.type==="integer"&&e.format==="int64";if(typeof e.const=="number")return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.number(e.const)]}),t;t.expression=i.callExpression({functionName:r?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.coerce}),name:d.bigint}):i.propertyAccessExpression({expression:d.z,name:d.number})}),!r&&e.type==="integer"&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.int})}));let n=[];return e.exclusiveMinimum!==void 0?n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.gt}),parameters:[un({isBigInt:r,value:e.exclusiveMinimum})]})):e.minimum!==void 0&&n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.gte}),parameters:[un({isBigInt:r,value:e.minimum})]})),e.exclusiveMaximum!==void 0?n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.lt}),parameters:[un({isBigInt:r,value:e.exclusiveMaximum})]})):e.maximum!==void 0&&n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.lte}),parameters:[un({isBigInt:r,value:e.maximum})]})),n.length&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.expression,name:d.check}),parameters:n})),t},qg=({plugin:e,schema:t,state:r})=>{let n={},s=[],o=t.required??[];for(let a in t.properties){let p=t.properties[a],c=o.includes(a),m=zt({optional:!c,plugin:e,schema:p,state:r});m.hasCircularReference&&(n.hasCircularReference=true),oe.lastIndex=0;let l;oe.test(a)?l=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):l=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(l=`'${a}'`),m.hasCircularReference?s.push(i.getAccessorDeclaration({name:l,returnType:m.typeName?i.propertyAccessExpression({expression:d.z,name:m.typeName}):void 0,statements:[i.returnStatement({expression:m.expression})]})):s.push(i.propertyAssignment({initializer:m.expression,name:l}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=zt({plugin:e,schema:t.additionalProperties,state:r});return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.string}),parameters:[]}),a.expression]}),a.hasCircularReference&&(n.hasCircularReference=true),n}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(s,true)]}),n},$g=({plugin:e,schema:t})=>{let r={};if(typeof t.const=="string")return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.string(t.const)]}),r;if(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.string})}),t.format)switch(t.format){case "date":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.date})});break;case "date-time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.datetime}),parameters:e.config.dates.offset?[i.objectExpression({obj:[{key:"offset",value:true}]})]:[]});break;case "email":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.email})});break;case "ipv4":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.ipv4})});break;case "ipv6":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.ipv6})});break;case "time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.time})});break;case "uri":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.url})});break;case "uuid":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.uuid})});break}let n=[];return t.minLength===t.maxLength&&t.minLength!==void 0?n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.length}),parameters:[i.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.minLength}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.maxLength}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),n.length&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:d.check}),parameters:n})),r},Mg=({plugin:e,schema:t,state:r})=>{let n={};if(t.const&&Array.isArray(t.const)){let o=t.const.map(a=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.valueToExpression({value:a})]}));return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:o})]}),n}let s=[];for(let o of t.items??[]){let a=zt({plugin:e,schema:o,state:r});s.push(a.expression),a.hasCircularReference&&(n.hasCircularReference=true);}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:s})]}),n},Dg=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.undefined})}),t},ei=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.unknown})}),t},Fg=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.void})}),t},lm=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return vg({plugin:e,schema:t,state:r});case "boolean":return Cg({schema:t});case "enum":return kg({schema:t});case "integer":case "number":return wg({schema:t});case "never":return jg();case "null":return Ng();case "object":return qg({plugin:e,schema:t,state:r});case "string":return $g({plugin:e,schema:t});case "tuple":return Mg({plugin:e,schema:t,state:r});case "undefined":return Dg();case "unknown":return ei();case "void":return Fg()}},zt=({optional:e,plugin:t,schema:r,state:n})=>{let s=t.context.file({id:G}),o={};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.getId({type:"ref",value:r.$ref});if(a){let m=s.addNodeReference(c,{factory:l=>i.identifier({text:l})});p?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.lazy}),parameters:[i.arrowFunction({returnType:i.keywordTypeNode({keyword:"any"}),statements:[i.returnStatement({expression:m})]})]}):o.expression=m,o.hasCircularReference=true;}else if(!s.getName(c)){let m=t.context.resolveIrRef(r.$ref);Gs({id:r.$ref,plugin:t,schema:m,state:n});}if(!a){let m=s.addNodeReference(c,{factory:l=>i.identifier({text:l})});o.expression=m;}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=lm({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:d.register}),parameters:[i.propertyAccessExpression({expression:d.z,name:d.globalRegistry}),i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=Y({schema:r}),r.items){let a=r.items.map(p=>zt({plugin:t,schema:p,state:n}).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:d.z,name:d.intersection}),parameters:a}):(o.expression=a[0],a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.intersection}),parameters:[o.expression,c]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:a})]});}else o=zt({plugin:t,schema:r,state:n});else {let a=lm({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:d.z,name:d.readonly}),parameters:[o.expression]})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.optional}),parameters:[o.expression]}),o.typeName=d.ZodMiniOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=un({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d._default}),parameters:[o.expression,p]}));}return o},Gs=({id:e,plugin:t,schema:r,state:n})=>{let s={circularReferenceTracker:[e],hasCircularReference:false,...n,currentReferenceTracker:[e]},o=t.context.file({id:G}),a=t.api.getId({type:"ref",value:e});if(o.getName(a))return;let p=zt({plugin:t,schema:r,state:s}),c=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;vt({plugin:t,schema:r,schemaId:a,typeInferId:c,zodSchema:p});let m=V(e);o.updateNodeReferences(a,M({config:t.config.definitions,name:m})),c&&o.updateNodeReferences(c,M({config:t.config.definitions.types.infer,name:m}));},fm=({plugin:e})=>{e.createFile({case:e.config.case,id:G,path:e.output}).import({alias:d.z.text,module:Br({plugin:e}),name:"*"}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Hr({getZodSchema:n=>zt({plugin:e,schema:n,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?Gs({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?Gs({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&Gs({id:r.$ref,plugin:e,schema:r.schema});});};var Lg=({plugin:e,schema:t,state:r})=>{let n=i.propertyAccessExpression({expression:d.z,name:d.array}),s;if(!t.items)s=i.callExpression({functionName:n,parameters:[ri()]});else {t=Y({schema:t});let o=t.items.map(a=>Kt({plugin:e,schema:a,state:r}).expression);o.length===1?s=i.callExpression({functionName:n,parameters:o}):(t.logicalOperator,s=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:o})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:d.length}),parameters:[i.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:d.min}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:d.max}),parameters:[i.valueToExpression({value:t.maxItems})]}))),s},Bg=({schema:e})=>typeof e.const=="boolean"?i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.boolean(e.const)]}):i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.boolean})}),Hg=({schema:e})=>{let t=[],r=false;for(let s of e.items??[])s.type==="string"&&typeof s.const=="string"?t.push(i.stringLiteral({text:s.const})):(s.type==="null"||s.const===null)&&(r=true);if(!t.length)return ri();let n=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.enum}),parameters:[i.arrayLiteralExpression({elements:t,multiLine:false})]});return r&&(n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:d.nullable})})),n},_g=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.never})}),Vg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.null})}),dn=({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},Wg=({schema:e})=>{let t=e.type==="integer"&&e.format==="int64";if(typeof e.const=="number")return i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.number(e.const)]});let r=i.callExpression({functionName:t?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.coerce}),name:d.bigint}):i.propertyAccessExpression({expression:d.z,name:d.number})});return !t&&e.type==="integer"&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.int})})),e.exclusiveMinimum!==void 0?r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.gt}),parameters:[dn({isBigInt:t,value:e.exclusiveMinimum})]}):e.minimum!==void 0&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.gte}),parameters:[dn({isBigInt:t,value:e.minimum})]})),e.exclusiveMaximum!==void 0?r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.lt}),parameters:[dn({isBigInt:t,value:e.exclusiveMaximum})]}):e.maximum!==void 0&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.lte}),parameters:[dn({isBigInt:t,value:e.maximum})]})),r},zg=({plugin:e,schema:t,state:r})=>{let n=[],s=t.required??[];for(let a in t.properties){let p=t.properties[a],c=s.includes(a),m=Kt({optional:!c,plugin:e,schema:p,state:r}).expression;oe.lastIndex=0;let l;oe.test(a)?l=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):l=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(l=`'${a}'`),n.push(i.propertyAssignment({initializer:m,name:l}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Kt({plugin:e,schema:t.additionalProperties,state:r}).expression;return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.record}),parameters:[a]})}}return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(n,true)]})}},Kg=({plugin:e,schema:t})=>{if(typeof t.const=="string")return i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.string(t.const)]});let r=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.string})});if(t.format)switch(t.format){case "date":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.date})});break;case "date-time":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.datetime}),parameters:e.config.dates.offset?[i.objectExpression({obj:[{key:"offset",value:true}]})]:[]});break;case "email":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.email})});break;case "ipv4":case "ipv6":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.ip})});break;case "time":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.time})});break;case "uri":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.url})});break;case "uuid":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.length}),parameters:[i.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.min}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.max}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),r},Ug=({plugin:e,schema:t,state:r})=>{if(t.const&&Array.isArray(t.const)){let o=t.const.map(p=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.valueToExpression({value:p})]}));return i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:o})]})}let n=[];for(let o of t.items??[])n.push(Kt({plugin:e,schema:o,state:r}).expression);return i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:n})]})},Zg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.undefined})}),ri=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.unknown})}),Qg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.void})}),um=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:Lg({plugin:e,schema:t,state:r})};case "boolean":return {expression:Bg({schema:t})};case "enum":return {expression:Hg({schema:t})};case "integer":case "number":return {expression:Wg({schema:t})};case "never":return {expression:_g()};case "null":return {expression:Vg()};case "object":return zg({plugin:e,schema:t,state:r});case "string":return {expression:Kg({plugin:e,schema:t})};case "tuple":return {expression:Ug({plugin:e,schema:t,state:r})};case "undefined":return {expression:Zg()};case "unknown":return {expression:ri()};case "void":return {expression:Qg()}}},Kt=({optional:e,plugin:t,schema:r,state:n})=>{let s=t.context.file({id:G}),o={};if(r.$ref){let a=n.circularReferenceTracker.includes(r.$ref);n.circularReferenceTracker.push(r.$ref),n.currentReferenceTracker.push(r.$ref);let p=t.api.getId({type:"ref",value:r.$ref});if(a){let c=s.addNodeReference(p,{factory:m=>i.identifier({text:m})});o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:c})]})]}),n.hasCircularReference=true;}else if(!s.getName(p)){let c=t.context.resolveIrRef(r.$ref);Js({id:r.$ref,plugin:t,schema:c,state:n});}if(!a){let c=s.addNodeReference(p,{factory:m=>i.identifier({text:m})});o.expression=c;}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=um({plugin:t,schema:r,state:n});o.expression=a.expression,o.typeName=a.anyType,t.config.metadata&&r.description&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.describe}),parameters:[i.stringLiteral({text:r.description})]}));}else if(r.items)if(r=Y({schema:r}),r.items){let a=r.items.map(p=>Kt({plugin:t,schema:p,state:n}).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:d.z,name:d.intersection}),parameters:a}):(o.expression=a[0],a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.and}),parameters:[c]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:a})]});}else o=Kt({plugin:t,schema:r,state:n});else {let a=um({plugin:t,schema:{type:"unknown"},state:n});o.expression=a.expression,o.typeName=a.anyType;}if(o.expression&&(r.accessScope==="read"&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.readonly})})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.optional})})),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=dn({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.default}),parameters:[p]}));}return n.hasCircularReference?o.typeName||(o.typeName="ZodTypeAny"):o.typeName=void 0,o},Js=({id:e,plugin:t,schema:r,state:n})=>{n||(n={circularReferenceTracker:[e],currentReferenceTracker:[e],hasCircularReference:false});let s=t.context.file({id:G}),o=t.api.getId({type:"ref",value:e});if(s.getName(o))return;let a=Kt({plugin:t,schema:r,state:n}),p=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;vt({plugin:t,schema:r,schemaId:o,typeInferId:p,zodSchema:a});let c=V(e);s.updateNodeReferences(o,M({config:t.config.definitions,name:c})),p&&s.updateNodeReferences(p,M({config:t.config.definitions.types.infer,name:c}));},dm=({plugin:e})=>{e.createFile({case:e.config.case,id:G,path:e.output}).import({module:Br({plugin:e}),name:d.z.text}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Hr({getZodSchema:n=>Kt({plugin:e,schema:n,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?Js({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?Js({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&Js({id:r.$ref,plugin:e,schema:r.schema});});};var Xg=({plugin:e,schema:t,state:r})=>{let n={},s=i.propertyAccessExpression({expression:d.z,name:d.array});if(!t.items)n.expression=i.callExpression({functionName:s,parameters:[si().expression]});else {t=Y({schema:t});let o=t.items.map(a=>{let p=Ut({plugin:e,schema:a,state:r});return p.hasCircularReference&&(n.hasCircularReference=true),p.expression});o.length===1?n.expression=i.callExpression({functionName:s,parameters:o}):(t.logicalOperator,n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:o})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:d.length}),parameters:[i.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:d.min}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:d.max}),parameters:[i.valueToExpression({value:t.maxItems})]}))),n},Gg=({schema:e})=>{let t={};return typeof e.const=="boolean"?(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.boolean(e.const)]}),t):(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.boolean})}),t)},Jg=({schema:e})=>{let t={},r=[],n=false;for(let s of e.items??[])s.type==="string"&&typeof s.const=="string"?r.push(i.stringLiteral({text:s.const})):(s.type==="null"||s.const===null)&&(n=true);return r.length?(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.enum}),parameters:[i.arrayLiteralExpression({elements:r,multiLine:false})]}),n&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.nullable}),parameters:[t.expression]})),t):si()},Yg=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.never})}),t},eh=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.null})}),t},yn=({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},th=({schema:e})=>{let t={},r=e.type==="integer"&&e.format==="int64";return typeof e.const=="number"?(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.number(e.const)]}),t):(t.expression=i.callExpression({functionName:r?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.coerce}),name:d.bigint}):i.propertyAccessExpression({expression:d.z,name:d.number})}),!r&&e.type==="integer"&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.int})})),e.exclusiveMinimum!==void 0?t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.expression,name:d.gt}),parameters:[yn({isBigInt:r,value:e.exclusiveMinimum})]}):e.minimum!==void 0&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.expression,name:d.gte}),parameters:[yn({isBigInt:r,value:e.minimum})]})),e.exclusiveMaximum!==void 0?t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.expression,name:d.lt}),parameters:[yn({isBigInt:r,value:e.exclusiveMaximum})]}):e.maximum!==void 0&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.expression,name:d.lte}),parameters:[yn({isBigInt:r,value:e.maximum})]})),t)},rh=({plugin:e,schema:t,state:r})=>{let n={},s=[],o=t.required??[];for(let a in t.properties){let p=t.properties[a],c=o.includes(a),m=Ut({optional:!c,plugin:e,schema:p,state:r});m.hasCircularReference&&(n.hasCircularReference=true),oe.lastIndex=0;let l;oe.test(a)?l=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):l=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(l=`'${a}'`),m.hasCircularReference?s.push(i.getAccessorDeclaration({name:l,returnType:m.typeName?i.propertyAccessExpression({expression:d.z,name:m.typeName}):void 0,statements:[i.returnStatement({expression:m.expression})]})):s.push(i.propertyAssignment({initializer:m.expression,name:l}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Ut({plugin:e,schema:t.additionalProperties,state:r});return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.string}),parameters:[]}),a.expression]}),a.hasCircularReference&&(n.hasCircularReference=true),n.hasCircularReference?{...n,typeName:"ZodType"}:n}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(s,true)]}),n.hasCircularReference?{...n,typeName:"ZodType"}:n},nh=({plugin:e,schema:t})=>{let r={};if(typeof t.const=="string")return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.string(t.const)]}),r;if(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.string})}),t.format)switch(t.format){case "date":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.date})});break;case "date-time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.datetime}),parameters:e.config.dates.offset?[i.objectExpression({obj:[{key:"offset",value:true}]})]:[]});break;case "email":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.email})});break;case "ipv4":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.ipv4})});break;case "ipv6":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.ipv6})});break;case "time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.time})});break;case "uri":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.url})});break;case "uuid":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:d.length}),parameters:[i.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:d.min}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:d.max}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:d.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),r},sh=({plugin:e,schema:t,state:r})=>{let n={};if(t.const&&Array.isArray(t.const)){let o=t.const.map(a=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.valueToExpression({value:a})]}));return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:o})]}),n}let s=[];for(let o of t.items??[]){let a=Ut({plugin:e,schema:o,state:r});s.push(a.expression),a.hasCircularReference&&(n.hasCircularReference=true);}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:s})]}),n},oh=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.undefined})}),t},si=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.unknown})}),t},ih=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.void})}),t},ym=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return Xg({plugin:e,schema:t,state:r});case "boolean":return Gg({schema:t});case "enum":return Jg({schema:t});case "integer":case "number":return th({schema:t});case "never":return Yg();case "null":return eh();case "object":return rh({plugin:e,schema:t,state:r});case "string":return nh({plugin:e,schema:t});case "tuple":return sh({plugin:e,schema:t,state:r});case "undefined":return oh();case "unknown":return si();case "void":return ih()}},Ut=({optional:e,plugin:t,schema:r,state:n})=>{let s=t.context.file({id:G}),o={};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.getId({type:"ref",value:r.$ref});if(a){let m=s.addNodeReference(c,{factory:l=>i.identifier({text:l})});p?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.lazy}),parameters:[i.arrowFunction({returnType:i.keywordTypeNode({keyword:"any"}),statements:[i.returnStatement({expression:m})]})]}):o.expression=m,o.hasCircularReference=true;}else if(!s.getName(c)){let m=t.context.resolveIrRef(r.$ref);Ys({id:r.$ref,plugin:t,schema:m,state:n});}if(!a){let m=s.addNodeReference(c,{factory:l=>i.identifier({text:l})});o.expression=m;}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=ym({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:d.register}),parameters:[i.propertyAccessExpression({expression:d.z,name:d.globalRegistry}),i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=Y({schema:r}),r.items){let a=r.items.map(p=>Ut({plugin:t,schema:p,state:n}).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:d.z,name:d.intersection}),parameters:a}):(o.expression=a[0],a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.and}),parameters:[c]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:a})]});}else o=Ut({plugin:t,schema:r,state:n});else {let a=ym({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:d.readonly})})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.optional}),parameters:[o.expression]}),o.typeName=d.ZodOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=yn({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.default}),parameters:[p]}));}return o},Ys=({id:e,plugin:t,schema:r,state:n})=>{let s={circularReferenceTracker:[e],hasCircularReference:false,...n,currentReferenceTracker:[e]},o=t.context.file({id:G}),a=t.api.getId({type:"ref",value:e});if(o.getName(a))return;let p=Ut({plugin:t,schema:r,state:s}),c=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;vt({plugin:t,schema:r,schemaId:a,typeInferId:c,zodSchema:p});let m=V(e);o.updateNodeReferences(a,M({config:t.config.definitions,name:m})),c&&o.updateNodeReferences(c,M({config:t.config.definitions.types.infer,name:m}));},oi=({plugin:e})=>{e.createFile({case:e.config.case,id:G,path:e.output}).import({module:Br({plugin:e}),name:d.z.text}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Hr({getZodSchema:n=>Ut({plugin:e,schema:n,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?Ys({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?Ys({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&Ys({id:r.$ref,plugin:e,schema:r.schema});});};var gm=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return dm(e);case 4:return oi(e);case "mini":return fm(e);default:return oi(e)}};var eo={api:mm,config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:gm,name:"zod",output:"zod",resolveConfig:(e,t)=>{let r="zod",n=t.package.getVersion(r),s=()=>n&&(n.major===4||n.major===3)?n.major:4,o=a=>{if(!a)return s();if(!n)return a;if((a===4||a===3||a==="mini")&&!t.package.satisfies(n,">=3.25.0 <5.0.0")){let p=s();return console.warn(`\u{1F50C} ${We__default.default.yellow("Warning:")} Installed ${We__default.default.cyan(r)} ${We__default.default.cyan(`v${n.version}`)} does not support compatibility version ${We__default.default.yellow(String(a))}, using ${We__default.default.yellow(String(p))}.`),p}return a};e.config.compatibilityVersion=o(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{offset:false},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:"PascalCase",enabled:false}},mappers:{object:(a,p)=>({...a,infer:t.valueToObject({defaultValue:{...p.infer,enabled:a.infer!==void 0?!!a.infer:p.infer.enabled},mappers:kt,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:{...kt,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:kt,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:{...kt,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:kt,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:{...kt,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:kt,value:c.infer})})},value:a.types})})},value:e.config.responses});},tags:["validator"]};var to={"@hey-api/client-axios":wn,"@hey-api/client-fetch":qn,"@hey-api/client-next":$n,"@hey-api/client-nuxt":Mn,"@hey-api/schemas":As,"@hey-api/sdk":Cs,"@hey-api/transformers":js,"@hey-api/typescript":qs,"@tanstack/angular-query-experimental":Vs,"@tanstack/react-query":Ws,"@tanstack/solid-query":zs,"@tanstack/svelte-query":Ks,"@tanstack/vue-query":Us,fastify:Zs,"legacy/angular":Dn,"legacy/axios":Fn,"legacy/fetch":Ln,"legacy/node":Bn,"legacy/xhr":Hn,valibot:Xs,zod:eo};var ii=["@hey-api/typescript","@hey-api/sdk"],ph=({dependencies:e,userPlugins:t,userPluginsConfig:r})=>{let n=new Set,s=new Set,o={},a=p=>{if(n.has(p))throw new Error(`Circular reference detected at '${p}'`);if(s.has(p))return;n.add(p);let c=to[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:zn(e),pluginByTag:(u,y={})=>{let{defaultPlugin:g,errorMessage:x}=y;for(let R of t){let S=to[R]||r[R];if(S&&S.tags?.includes(u)&&R!==p)return R}if(g){let R=to[g]||r[g];if(R&&R.tags?.includes(u)&&g!==p)return g}throw new Error(x||`missing plugin - no plugin with tag "${u}" found`)},valueToObject:Zt};l.resolveConfig(l,f);}for(let f of l.dependencies)a(f);n.delete(p),s.add(p),o[p]=l;};for(let p of t)a(p);return {pluginOrder:Array.from(s),plugins:o}},ch=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"),hm=({dependencies:e,userConfig:t})=>{let r={},n=ii;t.plugins&&(t.plugins=t.plugins.filter(o=>typeof o=="string"&&o||typeof o!="string"&&o.name),t.plugins.length===1&&ch(t.plugins[0])?n=[...ii,...t.plugins]:n=t.plugins);let s=n.map(o=>{if(typeof o=="string")return o;let a=o.name;return a&&(o.handler?r[a]=o:(r[a]={config:{...o}},delete r[a].config.name)),a}).filter(Boolean);return ph({dependencies:e,userPlugins:s,userPluginsConfig:r})};var xm=async e=>{let t;if(e?.configFile){let p=e.configFile.split(".");t=p.slice(0,p.length-1).join(".");}let{config:r,configFile:n}=await c12.loadConfig({configFile:t,name:"openapi-ts"}),s=qi(Object.keys(r).length?n:void 0),o=Array.isArray(e)?e:Array.isArray(r)?r.map(p=>co(p,e)):[co(r,e)],a=[];for(let p of o){let{base:c,configFile:m="",dryRun:l=false,experimentalParser:f=true,exportCore:u=true,interactive:y=false,name:g,request:x,useOptions:R=true}=p,S=[],N=Tn(p);N.level==="debug"&&console.warn("userConfig:",p);let w=ji(p),B=Ni(p),D=Mi(p);w.path||S.push(new Ze("missing input - which OpenAPI specification should we use to generate your output?")),B.path||S.push(new Ze("missing output - where should we generate your output?")),R||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"),B.path=J__default.default.resolve(process.cwd(),B.path);let j;try{j=hm({dependencies:s,userConfig:p});}catch(H){S.push(H),j={pluginOrder:[],plugins:{}};}let z=Ci({...j,base:c,configFile:m,dryRun:l,experimentalParser:f,exportCore:false,input:w,interactive:y,logs:N,name:g,output:B,parser:D,request:x,useOptions:R});z.exportCore=_(z)?u:false,N.level==="debug"&&console.warn("config:",z),a.push({config:z,errors:S});}return {dependencies:s,results:a}};var ro=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 bm=async(e,t,r,n)=>{let s=T(),o=E(s),a=n.client({$config:s,...r,httpRequest:ro(o.name),models:nn(r.models),services:nn(r.services)});Q(s)&&(Me(t),we__default.default.writeFileSync(J__default.default.resolve(t,`${Q(s)}.ts`),a));};var Om=async(e,t,r)=>{let n=T();if(n.exportCore){let s=E(n),o={httpRequest:ro(s.name),server:n.base!==void 0?n.base:t.server,version:t.version};if(we__default.default.rmSync(J__default.default.resolve(e),{force:true,recursive:true}),we__default.default.mkdirSync(J__default.default.resolve(e),{recursive:true}),await we__default.default.writeFileSync(J__default.default.resolve(e,"OpenAPI.ts"),r.core.settings({$config:n,...o})),await we__default.default.writeFileSync(J__default.default.resolve(e,"ApiError.ts"),r.core.apiError({$config:n,...o})),await we__default.default.writeFileSync(J__default.default.resolve(e,"ApiRequestOptions.ts"),r.core.apiRequestOptions({$config:n,...o})),await we__default.default.writeFileSync(J__default.default.resolve(e,"ApiResult.ts"),r.core.apiResult({$config:n,...o})),s.name!=="legacy/angular"&&await we__default.default.writeFileSync(J__default.default.resolve(e,"CancelablePromise.ts"),r.core.cancelablePromise({$config:n,...o})),await we__default.default.writeFileSync(J__default.default.resolve(e,"request.ts"),r.core.request({$config:n,...o})),Q(n)&&(await we__default.default.writeFileSync(J__default.default.resolve(e,"BaseHttpRequest.ts"),r.core.baseHttpRequest({$config:n,...o})),await we__default.default.writeFileSync(J__default.default.resolve(e,`${o.httpRequest}.ts`),r.core.httpRequest({$config:n,...o}))),n.request){let a=J__default.default.resolve(process.cwd(),n.request);if(!await we__default.default.existsSync(a))throw new Error(`Custom request file "${a}" does not exists`);await we__default.default.copyFileSync(a,J__default.default.resolve(e,"request.ts"));}}};var Sm=({files:e})=>{let t=T();e.index=new xe({dir:t.output.path,id:"index",name:"index.ts"}),Q(t)&&e.index.add(i.exportNamedDeclaration({exports:Q(t),module:`./${Q(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"})),Q(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 Rm=async({client:e,openApi:t,templates:r})=>{let n=T(),s=t;if(e){if(n.plugins["@hey-api/sdk"]?.config.include&&n.plugins["@hey-api/sdk"].config.asClass){let m=new RegExp(n.plugins["@hey-api/sdk"].config.include);e.services=e.services.filter(l=>m.test(l.name));}if(n.plugins["@hey-api/typescript"]?.config.include){let m=new RegExp(n.plugins["@hey-api/typescript"].config.include);e.models=e.models.filter(l=>m.test(l.name));}}let o=J__default.default.resolve(n.output.path);n.output.clean&&Rn(o);let a=On(bn(n.output.tsConfigPath)),p=E(n);!_(n)&&"bundle"in p.config&&p.config.bundle&&An({outputPath:o,plugin:p,tsConfig:a}),await bm(s,o,e,r),await Om(J__default.default.resolve(n.output.path,"core"),e,r);let c={};for(let m of n.pluginOrder){let l=n.plugins[m],f=(l.output??"").split("/"),u=J__default.default.resolve(n.output.path,...f.slice(0,f.length-1));c[l.name]=new xe({dir:u,id:`legacy-unused-${l.name}`,name:`${f[f.length-1]}.ts`}),l.handlerLegacy?.({client:e,files:c,openApi:s,plugin:l});}Sm({files:c}),Object.entries(c).forEach(([m,l])=>{n.dryRun||(m==="index"?l.write(`
|
|
36
|
+
`}),j):w.nodes.push(j),w.methods.add(g.methodName),s.set(x,w);});});let p=c=>{if(o.has(c.className))return;if(c.classes.size)for(let l of c.classes){let f=s.get(l);p(f),c.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:f.className})}):i.identifier({text:f.className}),modifier:e.config.instance?void 0:"static",name:v({case:"camelCase",value:f.className})}));}let m=i.classDeclaration({exportClass:c.root,extendedClasses:e.config.instance?["_HeyApiClient"]:void 0,name:c.className,nodes:c.nodes});n.add(m),o.add(c.className);};if(a.length){let c=i.classDeclaration({exportClass:false,name:"_HeyApiClient",nodes:a});n.add(c);}for(let c of s.values())p(c);},Ty=({plugin:e})=>{let t=E(e.context.config),r=t.name==="@hey-api/client-nuxt",n=e.context.file({id:be});e.forEach("operation",({operation:s})=>{let o=ar({context:e.context,operation:s}),a=e.getPlugin("@hey-api/typescript"),p=e.context.file({id:P}),c=n.import({asType:true,module:n.relativePathToFile({context:e.context,id:P}),name:r?p.getName(a.api.getId({operation:s,type:"response"})):void 0}),m=Vo({file:n,isRequiredOptions:o,operation:s,plugin:e}),l=Wo({isRequiredOptions:o,opParameters:m,operation:s,plugin:e}),f=i.constVariable({comment:It({operation:s}),exportConst:true,expression:i.arrowFunction({parameters:m.parameters,returnType:void 0,statements:l,types:r?[{extends:i.typeNode("Composable"),name:Dr},{default:c.name?i.typeReferenceNode({typeName:c.name}):i.typeNode("undefined"),extends:c.name?i.typeReferenceNode({typeName:c.name}):void 0,name:mt}]:[{default:("throwOnError"in t.config?t.config.throwOnError:false)??false,extends:"boolean",name:"ThrowOnError"}]}),name:Ne({config:e.context.config,handleIllegal:true,id:s.id,operation:s})});n.add(f);});},Tc=({plugin:e})=>{let t=e.createFile({id:be,path:e.output}),r=re({config:e.context.config,sourceOutput:t.nameWithoutExtension()}),n=t.import({...X.Options,alias:"ClientOptions",module:r});E(e.context.config).name==="@hey-api/client-nuxt"&&t.import({asType:true,module:r,name:"Composable"}),Rc({clientOptions:n,plugin:e}),e.config.asClass?Ry({plugin:e}):Ty({plugin:e});};var Cs={config:{asClass:false,auth:true,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:Tc,handlerLegacy:Sc,name:"@hey-api/sdk",output:"sdk",resolveConfig:(e,t)=>{e.config.client?(typeof e.config.client=="boolean"&&(e.config.client=t.pluginByTag("client",{defaultPlugin:"@hey-api/client-fetch"})),e.dependencies.add(e.config.client)):e.config.client=false,e.config.transformer?(typeof e.config.transformer=="boolean"&&(e.config.transformer=t.pluginByTag("transformer")),e.dependencies.add(e.config.transformer)):e.config.transformer=false,typeof e.config.validator!="object"&&(e.config.validator={request:e.config.validator,response:e.config.validator}),e.config.validator.request?(typeof e.config.validator.request=="boolean"&&(e.config.validator.request=t.pluginByTag("validator")),e.dependencies.add(e.config.validator.request)):e.config.validator.request=false,e.config.validator.response?(typeof e.config.validator.response=="boolean"&&(e.config.validator.response=t.pluginByTag("validator")),e.dependencies.add(e.config.validator.response)):e.config.validator.response=false,e.config.instance?(typeof e.config.instance!="string"&&(e.config.instance="Sdk"),e.config.asClass=true):e.config.instance=false;}};var Ay="$OpenApiTs",ue={$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:""},Iy=({comments:e,leadingComment:t,meta:r,obj:n,onNode:s,...o})=>{if(!r)return;let{created:a,name:p}=je({create:true,meta:r,...o});if(a){let c=i.enumDeclaration({comments:e,leadingComment:t,name:p,obj:n});s(c);}},Et=({comment:e,meta:t,onCreated:r,onNode:n,type:s,...o})=>{if(!t)return {created:false,name:""};let a=je({create:true,meta:t,...o}),{created:p,name:c}=a;if(p){let m=i.typeAliasDeclaration({comment:e,exportType:true,name:c,type:s});n(m),r?.(c);}return a},Ey=e=>{let t=[];Pc(e),e.model.enums.forEach(r=>Cy({...e,model:r,onNode:n=>{t.push(n);}})),t.length&&e.onNode(i.namespaceDeclaration({name:e.model.name,statements:t}));},vy=({client:e,model:t,onNode:r})=>{let n=T(),s={},o={};t.enum.forEach(c=>{let{key:m,value:l}=as(c);s[m]=l;let f=c.customDescription||c.description;f&&(o[m]=[K(f)]);});let a=[t.description&&K(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"){Iy({client:e,comments:o,leadingComment:a,meta:t.meta,obj:s,onNode:r});return}Et({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(s).map(([u,y])=>({comments:o[u],key:u,value:y})),unescape:true}),f=i.constVariable({assertion:"const",comment:a,exportConst:true,expression:l,name:c});r(f);}},onNode:r,type:jp(t.enum)});},Cy=({model:e,onNode:t})=>{let r={},n={};e.enum.forEach(s=>{let{key:o,value:a}=as(s);r[o]=a;let p=s.customDescription||s.description;p&&(n[o]=[K(p)]);}),t(i.enumDeclaration({comments:n,leadingComment:[e.description&&K(e.description),e.deprecated&&"@deprecated"],name:e.meta?.name||e.name,obj:r}));},Pc=({client:e,model:t,onNode:r})=>{Et({client:e,comment:[t.description&&K(t.description),t.deprecated&&"@deprecated"],meta:t.meta,onNode:r,type:ke(t)});},ky=e=>{switch(e.model.export){case "all-of":case "any-of":case "one-of":case "interface":return Ey(e);case "enum":return vy(e);default:return Pc(e)}},jy=({client:e,onNode:t})=>{let r={},n=T();if(!n.plugins["@hey-api/sdk"]&&!n.plugins["@hey-api/typescript"]?.config.tree)return;let s=_(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,...ue,in:"body",name:"body",prop:"body"},u=p.parameters.filter(S=>S.in==="body");u.length||(u=p.parameters.filter(S=>S.in==="formData")),u.length===1?f={...ue,...u[0],in:"body",isRequired:u[0].isRequired,name:"body",prop:"body"}:u.length>1&&(f={...ue,in:"body",isRequired:u.some(S=>S.isRequired),mediaType:"multipart/form-data",name:"body",prop:"body",properties:u});let y={...ue,in:"header",isRequired:ct(p.parameters.filter(S=>S.in==="header")),mediaType:null,name:s?"header":"headers",prop:s?"header":"headers",properties:p.parameters.filter(S=>S.in==="header").sort(rn)},g={...ue,in:"path",isRequired:ct(p.parameters.filter(S=>S.in==="path")),mediaType:null,name:"path",prop:"path",properties:p.parameters.filter(S=>S.in==="path").sort(rn)},x={...ue,in:"query",isRequired:ct(p.parameters.filter(S=>S.in==="query")),mediaType:null,name:"query",prop:"query",properties:p.parameters.filter(S=>S.in==="query").sort(rn)},R=s?nn([...p.parameters]):[f,y,g,x].filter(S=>S.properties.length||S.$refs.length||S.mediaType);m.req=R,Et({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:cr,onNode:t,type:ke({...ue,properties:R})});}let l=p.responses.filter(f=>f.responseTypes.includes("success"));if(l.length>0){Et({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:lt,onNode:t,type:ke({...ue,export:"any-of",properties:l})});let f=p.responses.filter(u=>u.responseTypes.includes("error"));s||Et({client:e,meta:{$ref:p.name,name:p.name},nameTransformer:Fr,onNode:t,type:ke(f.length?{...ue,export:"one-of",properties:f}:{...ue,base:"unknown"})});}}let o=Object.entries(r).map(([a,p])=>{let c=Object.entries(p).map(([l,f])=>{let u=l,y=[];if(f.req){let x=f.$ref,{name:R}=je({client:e,meta:{$ref:x,name:x},nameTransformer:cr}),S={...ue,base:R,export:"reference",isRequired:true,name:"req",properties:[],type:R};y=[...y,S];}if(f.res){let x=Object.entries(f.res).map(([S,N])=>({...ue,...N,isRequired:true,name:String(S)})),R={...ue,isRequired:true,name:"res",properties:x};y=[...y,R];}return {...ue,isRequired:true,name:u.toLocaleLowerCase(),properties:y}}).filter(Boolean);return {...ue,isRequired:true,name:`'${a}'`,properties:c}});n.plugins["@hey-api/typescript"]?.config.tree&&Et({client:e,meta:{$ref:"@hey-api/openapi-ts",name:Ay},onNode:t,type:ke({...ue,properties:o})});},Ac=({client:e,files:t,plugin:r})=>{let n=T();t.types=new xe({dir:n.output.path,exportFromIndex:r.config.exportFromIndex,id:"types",name:"types.ts"});let s=o=>{t.types?.add(o);};for(let o of e.models)ky({client:e,model:o,onNode:s});jy({client:e,onNode:s});};var Vt="data",Ny=e=>e.base==="unknown"&&e.export==="generic"&&e.type==="unknown",Ic=({client:e,model:t})=>t.$refs.map(n=>{let s=e.models.find(o=>o.meta?.$ref===n);if(!s)throw new Error(`Ref ${n} could not be found. Transformers cannot be generated without having access to all refs.`);return s}),Ec=e=>{let t=e.model.meta.name,{name:r}=Et({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:Oc,onCreated:s=>{let o=ks({...e,meta:{$ref:`transformers/${t}`,name:s},path:[Vt]});vc({...e,async:false,name:s,statements:o});},type:`(${Vt}: any) => ${t}`});return {created:!!e.client.types[r],name:r}},wy=e=>{let{model:t}=e,r=Ic(e);if(r.length===1){let{created:n,name:s}=Ec({...e,model:r[0]});return n?[i.transformArrayMutation({path:e.path,transformerName:s})]:[]}return sn(t)||t.link&&!Array.isArray(t.link)&&t.link.export==="any-of"&&t.link.properties.find(n=>sn(n))?[i.transformArrayMap({path:e.path,transformExpression:i.conditionalExpression({condition:i.identifier({text:"item"}),whenFalse:i.identifier({text:"item"}),whenTrue:i.transformNewDate({parameterName:"item"})})})]:[]},qy=e=>{let{model:t}=e,r=[...e.path,t.name];return t.type==="string"&&t.export!=="array"&&sn(t)?[i.transformDateMutation({path:r})]:ks({...e,model:t,path:r})},ks=e=>{let{model:t}=e;switch(t.export){case "array":return wy(e);case "interface":return t.properties.flatMap(r=>qy({...e,model:r}));case "reference":{if(t.$refs.length!==1)return [];let r=Ic(e),{created:n,name:s}=Ec({...e,model:r[0]});return n?t.in==="response"?[i.expressionToStatement({expression:i.callExpression({functionName:s,parameters:[Vt]})})]:i.transformFunctionMutation({path:e.path,transformerName:s}):[]}default:return []}},vc=({async:e,client:t,name:r,onNode:n,onRemoveNode:s,statements:o})=>{let a={created:false,name:r};if(!o.length)return qp({client:t,name:r}),s?.(),a;let p=i.arrowFunction({async:e,multiLine:true,parameters:[{name:Vt}],statements:[...o,i.returnVariable({expression:Vt})]}),c=i.constVariable({exportConst:true,expression:p,name:r,typeName:r});return n(c),{created:true,name:r}},Cc=({client:e,files:t})=>{let r=T(),n=o=>{t.types?.add(o);},s=()=>{t.types?.removeNode_LEGACY();};for(let o of e.services)for(let a of o.operations){let p=a.responses.filter(l=>l.responseTypes.includes("success"));if(!p.length)continue;let c=p.filter(l=>!Ny(l));if(!c.length)continue;if(c.length>1){r.logs.level==="debug"&&console.warn(`\u2757\uFE0F Transformers warning: route ${$(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=lt(a.name);Et({client:e,meta:{$ref:`transformers/${m}`,name:m},nameTransformer:zo,onCreated:l=>{let f=p.length>1?p.flatMap(u=>{let y=ks({client:e,meta:{$ref:`transformers/${m}`,name:m},model:u,onNode:n,onRemoveNode:s,path:[Vt]});return y.length?[i.ifStatement({expression:i.safeAccessExpression(["data"]),thenStatement:i.block({statements:y})})]:[]}):ks({client:e,meta:{$ref:`transformers/${m}`,name:m},model:p[0],onNode:n,onRemoveNode:s,path:[Vt]});vc({async:true,client:e,name:l,onNode:n,onRemoveNode:s,statements:f});},onNode:n,type:`(${Vt}: any) => Promise<${m}>`});}};var js={config:{bigInt:true,dates:true,exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:lc,handlerLegacy:Cc,name:"@hey-api/transformers",output:"transformers",tags:["transformer"]};var jc=({context:e,name:t})=>(oe.lastIndex=0,oe.test(t)?t.startsWith("-")?b__default.default.factory.createStringLiteral(t):b__default.default.factory.createNumericLiteral(t):v({case:e.config.output.case,value:t}));var _e=({schema:e})=>{let t=[];return e.title&&t.push(K(e.title)),e.description&&t.push(K(e.description)),e.deprecated&&t.push("@deprecated"),t.length?t:void 0};var Ns=i.keywordTypeNode({keyword:"string"}),Dy=({server:e})=>{let t=et(e.url);return t.protocol&&t.host?i.literalTypeNode({literal:i.stringLiteral({text:e.url})}):i.templateLiteralType({value:[t.protocol||Ns,"://",t.host||Ns,t.port?`:${t.port}`:"",t.path||""]})},Nc=({nodeInfo:e,plugin:t,servers:r})=>{let n=t.context.file({id:P}),s=E(t.context.config),o=r.map(c=>Dy({server:c}));r.length?"strictBaseUrl"in s.config&&s.config.strictBaseUrl||o.push(i.typeIntersectionNode({types:[Ns,b__default.default.factory.createTypeLiteralNode([])]})):o.push(Ns);let a=i.typeInterfaceNode({properties:[{name:De(t.context.config),type:i.typeUnionNode({types:o})}],useLegacyResolution:false}),p=i.typeAliasDeclaration({exportType:e.exported,name:e.node,type:a});n.add(p);};var Uo=({parameters:e})=>{let t={type:"object"};if(e){let r={},n=[];for(let s in e){let o=e[s];r[o.name]=Y({detectFormat:false,schema:o.schema}),o.required&&n.push(o.name);}t.properties=r,n.length&&(t.required=n);}return t},Fy=({operation:e,plugin:t,state:r})=>{let n=t.context.file({id:P}),s={type:"object"},o=[];s.properties||(s.properties={}),e.body?(s.properties.body=e.body.schema,e.body.required&&o.push("body")):s.properties.body={type:"never"},e.parameters?.header&&(s.properties.headers=Uo({parameters:e.parameters.header}),s.properties.headers.required&&o.push("headers")),e.parameters?.path?(s.properties.path=Uo({parameters:e.parameters.path}),s.properties.path.required&&o.push("path")):s.properties.path={type:"never"},e.parameters?.query?(s.properties.query=Uo({parameters:e.parameters.query}),s.properties.query.required&&o.push("query")):s.properties.query={type:"never"},s.properties.url={const:e.path,type:"string"},o.push("url"),s.required=o;let a=M({config:t.config.requests,name:e.id}),p=n.updateNode(t.api.getId({operation:e,type:"data"}),{exported:true,name:a}),c=ye({onRef:void 0,plugin:t,schema:s,state:r}),m=i.typeAliasDeclaration({exportType:p.exported,name:p.node,type:c});n.add(m);},wc=({operation:e,plugin:t,state:r})=>{Fy({operation:e,plugin:t,state:r});let n=t.context.file({id:P}),{error:s,errors:o,response:a,responses:p}=rt(e);if(o){let c=M({config:t.config.errors,name:e.id}),m=n.updateNode(t.api.getId({operation:e,type:"errors"}),{exported:true,name:c}),l=ye({onRef:void 0,plugin:t,schema:o,state:r}),f=i.typeAliasDeclaration({exportType:m.exported,name:m.node,type:l});if(n.add(f),s){let u=M({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),y=n.updateNode(t.api.getId({operation:e,type:"error"}),{exported:true,name:u}),g=i.indexedAccessTypeNode({indexType:b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m.node),objectType:m.node}),x=i.typeAliasDeclaration({exportType:y.exported,name:y.node,type:g});n.add(x);}}if(p){let c=M({config:t.config.responses,name:e.id}),m=n.updateNode(t.api.getId({operation:e,type:"responses"}),{exported:true,name:c}),l=ye({onRef:void 0,plugin:t,schema:p,state:r}),f=i.typeAliasDeclaration({exportType:m.exported,name:m.node,type:l});if(n.add(f),a){let u=M({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),y=n.updateNode(t.api.getId({operation:e,type:"response"}),{exported:true,name:u}),g=i.indexedAccessTypeNode({indexType:b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m.node),objectType:m.node}),x=i.typeAliasDeclaration({exportType:y.exported,name:y.node,type:g});n.add(x);}}};var Ly=({plugin:e,schema:t})=>{let r=[];return {obj:(t.items??[]).map((s,o)=>{let a=typeof s.const;r.includes(a)||r.push(a);let p;return s.title?p=s.title:a==="number"||a==="string"?p=`${s.const}`:a==="boolean"?p=s.const?"true":"false":s.const===null?p="null":p=`${o}`,p&&(p=v({case:e.config.enums.case,stripLeadingSeparators:false,value:p}),oe.lastIndex=0,oe.test(p)&&e.config.enums.enabled&&e.config.enums.mode==="typescript"&&(p=`_${p}`)),{comments:_e({schema:s}),key:p,value:s.const}}),typeofItems:r}},By=({onRef:e,plugin:t,schema:r,state:n})=>{if(!r.items)return i.typeArrayNode(i.keywordTypeNode({keyword:"unknown"}));r=Y({detectFormat:false,schema:r});let s=[];for(let o of r.items){let a=ye({onRef:e,plugin:t,schema:o,state:n});s.push(a);}return s.length===1?i.typeArrayNode(s[0]):r.logicalOperator==="and"?i.typeArrayNode(i.typeIntersectionNode({types:s})):i.typeArrayNode(i.typeUnionNode({types:s}))},Hy=({schema:e})=>e.const!==void 0?i.literalTypeNode({literal:i.ots.boolean(e.const)}):i.keywordTypeNode({keyword:"boolean"}),_y=({onRef:e,plugin:t,schema:r,state:n})=>ye({onRef:e,plugin:t,schema:{...r,type:void 0},state:n}),Vy=({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"}),Wy=({onRef:e,plugin:t,schema:r,state:n})=>{let s,o,a=[],p=[],c=r.required??[],m=false;for(let l in r.properties){let f=r.properties[l],u=ye({onRef:e,plugin:t,schema:f,state:n}),y=c.includes(l);a.push({comment:_e({schema:f}),isReadOnly:f.accessScope==="read",isRequired:y,name:jc({context:t.context,name:l}),type:u}),p.push(f),y||(m=true);}return r.additionalProperties&&(r.additionalProperties.type!=="never"||!p.length)&&(r.additionalProperties.type==="never"?p=[r.additionalProperties]:p.unshift(r.additionalProperties),m&&p.push({type:"undefined"}),o={isRequired:!r.propertyNames,name:"key",type:ye({onRef:e,plugin:t,schema:p.length===1?p[0]:{items:p,logicalOperator:"or"},state:n})},r.propertyNames?.$ref&&(s=ye({onRef:e,plugin:t,schema:{$ref:r.propertyNames.$ref},state:n}))),i.typeInterfaceNode({indexKey:s,indexProperty:o,properties:a,useLegacyResolution:false})},zy=({plugin:e,schema:t,state:r})=>{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 n=String(t.example).split("_");n.pop();let s=n.join("_");r.usedTypeIDs.add(s);let o=ve(v({case:e.config.case,value:s+"_id"}));return i.typeReferenceNode({typeName:o})}}return i.keywordTypeNode({keyword:"string"})},Ky=({onRef:e,plugin:t,schema:r,state:n})=>{let s=[];if(r.const&&Array.isArray(r.const))s=r.const.map(o=>i.valueToExpression({value:o})??i.identifier({text:"unknown"}));else if(r.items)for(let o of r.items){let a=ye({onRef:e,plugin:t,schema:o,state:n});s.push(a);}return i.typeTupleNode({types:s})},$c=({onRef:e,plugin:t,schema:r,state:n})=>{let s=t.getPlugin("@hey-api/transformers");if(s?.config.typeTransformers)for(let o of s.config.typeTransformers){let a=t.context.file({id:P}),p=o({file:a,schema:r});if(p)return p}switch(r.type){case "array":return By({onRef:e,plugin:t,schema:r,state:n});case "boolean":return Hy({schema:r});case "enum":return _y({onRef:e,plugin:t,schema:r,state:n});case "integer":case "number":return Vy({plugin:t,schema:r});case "never":return i.keywordTypeNode({keyword:"never"});case "null":return i.literalTypeNode({literal:i.null()});case "object":return Wy({onRef:e,plugin:t,schema:r,state:n});case "string":return zy({plugin:t,schema:r,state:n});case "tuple":return Ky({onRef:e,plugin:t,schema:r,state:n});case "undefined":return i.keywordTypeNode({keyword:"undefined"});case "unknown":return i.keywordTypeNode({keyword:"unknown"});case "void":return i.keywordTypeNode({keyword:"void"})}},ye=({onRef:e,plugin:t,schema:r,state:n})=>{let s=t.context.file({id:P});if(r.$ref)return e&&e(t.api.getId({type:"ref",value:r.$ref})),s.getNode(t.api.getId({type:"ref",value:r.$ref})).node;if(r.type)return $c({onRef:e,plugin:t,schema:r,state:n});if(r.items){if(r=Y({detectFormat:false,schema:r}),r.items){let o=[];for(let a of r.items){let p=ye({onRef:e,plugin:t,schema:a,state:n});o.push(p);}return r.logicalOperator==="and"?i.typeIntersectionNode({types:o}):i.typeUnionNode({types:o})}return ye({onRef:e,plugin:t,schema:r,state:n})}return $c({onRef:e,plugin:t,schema:{type:"unknown"},state:n})},Uy=({id:e,plugin:t,schema:r,type:n})=>{let s=t.context.file({id:P}),o=s.getNode(t.api.getId({type:"ref",value:e}));if(r.type==="enum"&&t.config.enums.enabled){let p=Ly({plugin:t,schema:r});if(t.config.enums.mode==="javascript"){t.config.enums.constantsIgnoreNull&&p.typeofItems.includes("object")&&(p.obj=p.obj.filter(u=>u.value!==null));let c=i.constVariable({assertion:"const",comment:_e({schema:r}),exportConst:o.exported,expression:i.objectExpression({multiLine:true,obj:p.obj}),name:o.node});s.add(c);let m=i.typeOfExpression({text:o.node.typeName}),l=b__default.default.factory.createTypeOperatorNode(b__default.default.SyntaxKind.KeyOfKeyword,m),f=i.typeAliasDeclaration({comment:_e({schema:r}),exportType:o.exported,name:o.node,type:i.indexedAccessTypeNode({indexType:l,objectType:m})});s.add(f);return}else if(t.config.enums.mode==="typescript"&&!p.typeofItems.some(m=>m!=="number"&&m!=="string")){let m=i.enumDeclaration({leadingComment:_e({schema:r}),name:o.node,obj:p.obj});s.add(m);return}}let a=i.typeAliasDeclaration({comment:_e({schema:r}),exportType:o.exported,name:o.node,type:n});s.add(a);},Zo=({id:e,plugin:t,schema:r,state:n})=>{let s=t.context.file({id:P}),o=ye({onRef:void 0,plugin:t,schema:r,state:n}),a=M({config:t.config.definitions,name:V(e)});s.updateNode(t.api.getId({type:"ref",value:e}),{exported:true,name:a}),Uy({id:e,plugin:t,schema:r,type:o});},Mc=({plugin:e})=>{let t={usedTypeIDs:new Set},r=e.createFile({case:e.config.case,id:P,path:e.output}),n=M({config:{case:e.config.case},name:"ClientOptions"}),s=r.updateNode(e.api.getId({type:"ClientOptions"}),{exported:true,name:n}),o=[];if(e.forEach("operation","parameter","requestBody","schema","server",a=>{a.type==="operation"?wc({operation:a.operation,plugin:e,state:t}):a.type==="parameter"?Zo({id:a.$ref,plugin:e,schema:a.parameter.schema,state:t}):a.type==="requestBody"?Zo({id:a.$ref,plugin:e,schema:a.requestBody.schema,state:t}):a.type==="schema"?Zo({id:a.$ref,plugin:e,schema:a.schema,state:t}):a.type==="server"&&o.push(a.server);}),t.usedTypeIDs.size){let a=i.typeParameterDeclaration({constraint:i.keywordTypeNode({keyword:"string"}),name:"T"}),p=i.typeAliasDeclaration({exportType:true,name:"TypeID",type:i.templateLiteralType({value:[i.typeReferenceNode({typeName:"T"}),"_",i.keywordTypeNode({keyword:"string"})]}),typeParameters:[a]});r.add(p);for(let c of t.usedTypeIDs.values()){let m=ve(v({case:e.config.case,value:c+"_id"})),l=i.typeAliasDeclaration({exportType:true,name:m,type:i.typeReferenceNode({typeArguments:[i.literalTypeNode({literal:i.stringLiteral({text:c})})],typeName:"TypeID"})});r.add(l);}}Nc({nodeInfo:s,plugin:e,servers:o});};var Zy=e=>{switch(e.type){case "data":case "error":case "errors":case "response":case "responses":return `${e.operation.id}-${e.type}`;case "ref":return e.value;default:return e.type}},Dc={getId:Zy,schemaToType:e=>ye({onRef:void 0,...e})};var qs={api:Dc,config:{case:"PascalCase",exportFromIndex:true,style:"preserve",tree:false},handler:Mc,handlerLegacy:Ac,name:"@hey-api/typescript",output:"types",resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.definitions}),e.config.enums=t.valueToObject({defaultValue:{case:"SCREAMING_SNAKE_CASE",constantsIgnoreNull:false,enabled:!!e.config.enums,mode:"javascript"},mappers:{boolean:r=>({enabled:r}),string:r=>({mode:r})},value:e.config.enums}),e.config.errors=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",error:"{{name}}Error",name:"{{name}}Errors"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.errors}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}Data"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"PascalCase",name:"{{name}}Responses",response:"{{name}}Response"},mappers:{function:r=>({name:r}),string:r=>({name:r})},value:e.config.responses});}};var Wt=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),n=t.getPlugin("@hey-api/sdk");return _o({file:r,operation:e,plugin:n})},$s=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),n=t.getPlugin("@hey-api/typescript"),s=t.context.file({id:P}),a={asType:true,name:r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:s.getName(n.api.getId({operation:e,type:"error"}))}).name||""};if(a.name||(a=r.import({asType:true,module:t.name,name:"DefaultError"})),E(t.context.config).name==="@hey-api/client-axios"){let c=r.import({asType:true,module:"axios",name:"AxiosError"});a={...c,name:`${c.name}<${a.name}>`};}return a},Ms=({operation:e,plugin:t})=>{let r=t.context.file({id:t.name}),n=t.getPlugin("@hey-api/typescript"),s=t.context.file({id:P});return r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:s.getName(n.api.getId({operation:e,type:"response"}))}).name||"unknown"};var Lc="createQueryKey",Fs="QueryKey",cn="TOptions",Fc=i.identifier({text:"infinite"}),Ds=i.identifier({text:"options"}),Ls=({plugin:e})=>{let t=e.context.file({id:e.name}),r=t.identifier({$ref:`#/tanstack-query-create-query-key/${Lc}`,case:e.config.case,create:true,namespace:"value"});if(r.name){let n=i.indexedAccessTypeNode({indexType:i.literalTypeNode({literal:i.ots.number(0)}),objectType:i.typeReferenceNode({typeArguments:[i.typeReferenceNode({typeName:cn})],typeName:Fs})}),s=De(e.context.config),o=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"id",type:i.typeReferenceNode({typeName:"string"})},{isRequired:false,name:"options",type:i.typeReferenceNode({typeName:cn})},{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:s,value:i.identifier({text:`options?.${s} || (options?.client ?? _heyApiClient).getConfig().${s}`})}]}),name:"params",typeName:n}),i.ifStatement({expression:Fc,thenStatement:i.block({statements:[i.expressionToStatement({expression:i.binaryExpression({left:i.propertyAccessExpression({expression:"params",name:"_infinite"}),right:Fc})})]})}),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:Ds,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:Ds,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:Ds,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:Ds,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:X.Options.name})}),name:cn}]}),name:r.name});t.add(o);}},Xy=({id:e,isInfinite:t,operation:r,plugin:n})=>{let o=n.context.file({id:n.name}).identifier({$ref:`#/tanstack-query-create-query-key/${Lc}`,case:n.config.case,namespace:"value"}),a=t?n.config.infiniteQueryKeys:n.config.queryKeys,p;return a.tags&&r.tags&&r.tags.length>0&&(p=i.arrayLiteralExpression({elements:r.tags.map(m=>i.stringLiteral({text:m}))})),i.callExpression({functionName:o.name||"",parameters:[i.ots.string(e),"options",t||p?i.ots.boolean(!!t):void 0,p||void 0]})},Bs=({plugin:e})=>{let t=e.context.file({id:e.name}),r=[{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>"})}],n=i.typeAliasDeclaration({exportType:true,name:Fs,type:i.typeTupleNode({types:[i.typeIntersectionNode({types:[i.typeReferenceNode({typeName:`Pick<${cn}, '${De(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),i.typeInterfaceNode({properties:r,useLegacyResolution:true})]})]}),typeParameters:[{extends:i.typeReferenceNode({typeName:i.identifier({text:X.Options.name})}),name:cn}]});t.add(n);},Hs=({isInfinite:e,operation:t,plugin:r,typeQueryKey:n})=>{let s=r.context.file({id:r.name}),o=Wt({operation:t,plugin:r}),a=e?s.identifier({$ref:`#/tanstack-query-infinite-query-key/${t.id}`,case:r.config.infiniteQueryKeys.case,create:true,nameTransformer:r.config.infiniteQueryKeys.name,namespace:"value"}):s.identifier({$ref:`#/tanstack-query-query-key/${t.id}`,case:r.config.queryKeys.case,create:true,nameTransformer:r.config.queryKeys.name,namespace:"value"});return i.constVariable({exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:Qn(t),name:"options",type:o}],returnType:e?n:void 0,statements:Xy({id:t.id,isInfinite:e,operation:t,plugin:r})}),name:a.name||""})};var Hc="createInfiniteParams",Bc="infiniteQueryOptions",Jy=({plugin:e})=>{let t=e.context.file({id:e.name}),r=t.identifier({$ref:`#/tanstack-query-create-infinite-params/${Hc}`,case:e.config.case,create:true,namespace:"value"}),n=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:i.typeReferenceNode({typeName:`QueryKey<${X.Options.name}>`})},{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:b__default.default.factory.createTypeQueryNode(i.identifier({text:"page"}))})})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:`Pick<QueryKey<${X.Options.name}>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:"K"}]}),name:r.name||""});t.add(n);},_c=({operation:e,plugin:t,queryFn:r,state:n})=>{if(!t.config.infiniteQueryOptions||!["get","post"].includes(e.method))return n;let s=_a({context:t.context,operation:e});if(!s)return n;let o=t.context.file({id:t.name}),a=ar({context:t.context,operation:e});n.hasInfiniteQueries||(n.hasInfiniteQueries=true,n.hasCreateQueryKeyParamsFunction||(Bs({plugin:t}),Ls({plugin:t}),n.hasCreateQueryKeyParamsFunction=true),n.hasCreateInfiniteParamsFunction||(Jy({plugin:t}),n.hasCreateInfiniteParamsFunction=true),o.import({module:t.name,name:Bc}),n.typeInfiniteData=o.import({asType:true,module:t.name,name:"InfiniteData"})),n.hasUsedQueryFn=true;let p=Wt({operation:e,plugin:t}),c=$s({operation:e,plugin:t}),m=Ms({operation:e,plugin:t}),l=`${Fs}<${p}>`,f=`Pick<${l}[0], 'body' | 'headers' | 'path' | 'query'>`,u=t.getPlugin("@hey-api/typescript"),y={usedTypeIDs:new Set},g=u.api.schemaToType({plugin:u,schema:s.schema,state:y}),x=`${Xe({node:g,unescape:true})} | ${f}`,R=Hs({isInfinite:true,operation:e,plugin:t,typeQueryKey:l});o.add(R);let S=o.identifier({$ref:`#/tanstack-query-infinite-query-key/${e.id}`,case:t.config.infiniteQueryKeys.case,nameTransformer:t.config.infiniteQueryKeys.name,namespace:"value"}),N=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}]})]})}),w=o.identifier({$ref:`#/tanstack-query-create-infinite-params/${Hc}`,case:t.config.case,namespace:"value"}),B=[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:s.in,value:i.objectExpression({multiLine:true,obj:[{key:s.name,value:i.identifier({text:"pageParam"})}]})}]}),whenTrue:i.identifier({text:"pageParam"})}),name:"page",typeName:f}),i.constVariable({expression:i.callExpression({functionName:w.name||"",parameters:["queryKey","page"]}),name:"params"})];t.getPlugin("@hey-api/sdk")?.config.responseStyle==="data"?B.push(i.returnVariable({expression:N})):B.push(i.constVariable({destructure:true,expression:N,name:"data"}),i.returnVariable({expression:"data"}));let D=o.identifier({$ref:`#/tanstack-query-infinite-query-options/${e.id}`,case:t.config.infiniteQueryOptions.case,create:true,nameTransformer:t.config.infiniteQueryOptions.name,namespace:"value"}),j=i.constVariable({comment:t.config.comments?It({operation:e}):void 0,exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:a,name:"options",type:p}],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:B})},{key:"queryKey",value:i.callExpression({functionName:S.name||"",parameters:["options"]})}]})],name:Bc,types:[m,c.name||"unknown",`${typeof n.typeInfiniteData=="string"?n.typeInfiniteData:n.typeInfiniteData.name}<${m}>`,l,x]})]}),name:D.name||""});o.add(j);};var Vc="mutationOptions",Wc=({operation:e,plugin:t,queryFn:r,state:n})=>{if(!t.config.mutationOptions.enabled||!["delete","patch","post","put"].includes(e.method))return n;let s=t.name==="@tanstack/angular-query-experimental"||t.name==="@tanstack/svelte-query"||t.name==="@tanstack/solid-query"?"MutationOptions":"UseMutationOptions",o=t.context.file({id:t.name});n.hasMutations||(n.hasMutations=true,o.import({asType:true,module:t.name,name:s})),n.hasUsedQueryFn=true;let a=Wt({operation:e,plugin:t}),p=$s({operation:e,plugin:t}),c=Ms({operation:e,plugin:t}),m=`${s}<${c}, ${p.name}, ${a}>`,l=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"localOptions"},{key:"throwOnError",value:true}]})]})}),f=[];t.getPlugin("@hey-api/sdk")?.config.responseStyle==="data"?f.push(i.returnVariable({expression:l})):f.push(i.constVariable({destructure:true,expression:l,name:"data"}),i.returnVariable({expression:"data"}));let u=o.identifier({$ref:`#/tanstack-query-mutation-options/${e.id}`,case:t.config.mutationOptions.case,create:true,nameTransformer:t.config.mutationOptions.name,namespace:"value"}),y=i.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${a}>`}],returnType:m,statements:[i.constVariable({expression:i.objectExpression({obj:[{key:"mutationFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{name:"localOptions"}],statements:f})}]}),name:Vc,typeName:m}),i.returnVariable({expression:Vc})]}),g=i.constVariable({comment:t.config.comments?It({operation:e}):void 0,exportConst:true,expression:y,name:u.name||""});return o.add(g),n};var zc="queryOptions",Kc=({operation:e,plugin:t,queryFn:r,state:n})=>{if(!t.config.queryOptions||!["get","post"].includes(e.method))return n;let s=t.context.file({id:t.name}),o=ar({context:t.context,operation:e});n.hasQueries||(n.hasQueries=true,n.hasCreateQueryKeyParamsFunction||(Bs({plugin:t}),Ls({plugin:t}),n.hasCreateQueryKeyParamsFunction=true),s.import({module:t.name,name:zc})),n.hasUsedQueryFn=true;let a=Hs({isInfinite:false,operation:e,plugin:t});s.add(a);let p=Wt({operation:e,plugin:t}),c=s.identifier({$ref:`#/tanstack-query-query-key/${e.id}`,case:t.config.queryKeys.case,nameTransformer:t.config.queryKeys.name,namespace:"value"}),m=i.awaitExpression({expression:i.callExpression({functionName:r,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"queryKey[0]"},{key:"signal",shorthand:true,value:i.identifier({text:"signal"})},{key:"throwOnError",value:true}]})]})}),l=[];t.getPlugin("@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=s.identifier({$ref:`#/tanstack-query-query-options/${e.id}`,case:t.config.queryOptions.case,create:true,nameTransformer:t.config.queryOptions.name,namespace:"value"}),u=i.constVariable({comment:t.config.comments?It({operation:e}):void 0,exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:o,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:l})},{key:"queryKey",value:i.callExpression({functionName:c.name||"",parameters:["options"]})}]})],name:zc})]}),name:f.name||""});return s.add(u),n};var ft=({plugin:e})=>{let t=e.createFile({case:e.config.case,id:e.name,path:e.output}),r={hasCreateInfiniteParamsFunction:false,hasCreateQueryKeyParamsFunction:false,hasInfiniteQueries:false,hasMutations:false,hasQueries:false,hasUsedQueryFn:false,typeInfiniteData:void 0};t.import({...X.Options,module:t.relativePathToFile({context:e.context,id:be})}),e.forEach("operation",({operation:n})=>{r.hasUsedQueryFn=false;let s=e.getPlugin("@hey-api/sdk"),o=s?.config.asClass?vs({context:e.context,operation:n,plugin:s}):void 0,a=o?o.values().next().value:void 0,p=(a?[a.path[0],...a.path.slice(1).map(c=>v({case:"camelCase",value:c})),a.methodName].filter(Boolean):[Ne({config:e.context.config,handleIllegal:true,id:n.id,operation:n})]).join(".");Kc({operation:n,plugin:e,queryFn:p,state:r}),_c({operation:n,plugin:e,queryFn:p,state:r}),Wc({operation:n,plugin:e,queryFn:p,state:r}),r.hasUsedQueryFn&&t.import({module:t.relativePathToFile({context:e.context,id:be}),name:p.split(".")[0]});}),(r.hasQueries||r.hasInfiniteQueries)&&t.import({alias:"_heyApiClient",module:t.relativePathToFile({context:e.context,id:Qe}),name:"client"});};var Yy=e=>`${Ne({config:T(),id:e.name,operation:e})}InfiniteOptions`,eg=e=>`${Ne({config:T(),id:e.name,operation:e})}Mutation`,tg=({config:e,id:t,operation:r})=>`${Ne({config:e,id:t,operation:r})}Options`,_s=({config:e,id:t,isInfinite:r,operation:n})=>`${Ne({config:e,id:t,operation:n})}${r?"Infinite":""}QueryKey`,rg=e=>{switch(e.in){case "formData":return "body";case "header":return "headers";default:return e.in}},ng="createInfiniteParams",tm="createQueryKey",Uc="infiniteQueryOptions",Zc="mutationOptions",Xo="QueryKey",Qc="queryOptions",ln="TOptions",sg=({file:e})=>{let t=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"queryKey",type:i.typeNode(`QueryKey<${X.OptionsLegacyParser.name}>`)},{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:b__default.default.factory.createAsExpression(b__default.default.factory.createAsExpression(i.identifier({text:"params"}),b__default.default.factory.createKeywordTypeNode(b__default.default.SyntaxKind.UnknownKeyword)),b__default.default.factory.createTypeQueryNode(i.identifier({text:"page"})))})],types:[{extends:i.typeReferenceNode({typeName:i.identifier({text:`Pick<QueryKey<${X.OptionsLegacyParser.name}>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:"K"}]}),name:ng});e.add(t);},Xc=({file:e})=>{let t=i.indexedAccessTypeNode({indexType:i.typeNode(0),objectType:i.typeNode(Xo,[i.typeNode(ln)])}),r=i.identifier({text:"infinite"}),n=De(T()),s=i.constVariable({expression:i.arrowFunction({multiLine:true,parameters:[{name:"id",type:i.typeNode("string")},{isRequired:false,name:"options",type:i.typeNode(ln)},{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:X.OptionsLegacyParser.name})}),name:ln}]}),name:tm});e.add(s);},Gc=({file:e})=>{let t=[{name:"_id",type:i.keywordTypeNode({keyword:"string"})},{isRequired:false,name:"_infinite",type:i.keywordTypeNode({keyword:"boolean"})}],r=i.typeAliasDeclaration({name:Xo,type:i.typeTupleNode({types:[i.typeIntersectionNode({types:[i.typeReferenceNode({typeName:`Pick<${ln}, '${De(T())}' | 'body' | 'headers' | 'path' | 'query'>`}),i.typeInterfaceNode({properties:t,useLegacyResolution:true})]})]}),typeParameters:[{extends:i.typeReferenceNode({typeName:i.identifier({text:X.OptionsLegacyParser.name})}),name:ln}]});e.add(r);},Qo=({client:e,file:t,operation:r,typesModulePath:n})=>{let{name:s}=pr({client:e,meta:r.parameters.length?{$ref:r.name,name:r.name}:void 0,nameTransformer:cr,onImport:a=>{t.import({asType:true,module:n,name:a});}});return {typeData:Ko({importedType:s})}},Jc=({client:e,file:t,operation:r,pluginName:n,typesModulePath:s})=>{let o=T(),{name:a}=pr({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Fr,onImport:m=>{t.import({asType:true,module:s,name:m});}}),p={asType:true,name:a};if(p.name||(p=t.import({asType:true,module:n,name:"DefaultError"})),E(o).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}},Yc=({client:e,file:t,operation:r,typesModulePath:n})=>{let{name:s}=pr({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:lt,onImport:a=>{t.import({asType:true,module:n,name:a});}});return {typeResponse:s||"void"}},em=({id:e,isInfinite:t})=>i.arrayLiteralExpression({elements:[i.callExpression({functionName:tm,parameters:[i.ots.string(e),"options",t?i.ots.boolean(true):void 0]})],multiLine:false}),ut=({client:e,files:t,plugin:r})=>{let n=T();if(_(n))throw new Error("TanStack Query plugin does not support legacy clients");let s=t[r.name];s.import({...X.OptionsLegacyParser,module:re({config:n,sourceOutput:r.output})});let o=lr({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,y=new Map;for(let g of e.services)for(let x of g.operations){let R=$(x);if(y.has(R))continue;y.set(R,true);let S=[n.plugins["@hey-api/sdk"]?.config.asClass&&Ht({config:n,name:g.name}),Ne({config:n,handleIllegal:!n.plugins["@hey-api/sdk"]?.config.asClass,id:x.name,operation:x})].filter(Boolean).join("."),N=false;if(r.config.queryOptions&&["GET","POST"].includes(x.method)){u||(u=true,m||(Gc({file:s}),Xc({file:s}),m=true),s.import({module:r.name,name:Qc})),N=true;let{typeData:w}=Qo({client:e,file:s,operation:x,typesModulePath:o}),B=ct(x.parameters),D=i.constVariable({exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:B,name:"options",type:w}],statements:em({id:x.name})}),name:_s({config:n,id:x.name,operation:x})});s.add(D);let j=i.constVariable({comment:[],exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:B,name:"options",type:w}],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:S,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:_s({config:n,id:x.name,operation:x}),parameters:["options"]})}]})],name:Qc})]}),name:tg({config:n,id:x.name,operation:x})});s.add(j);}if(r.config.infiniteQueryOptions&&["GET","POST"].includes(x.method)){let w,B=x.parameters.find(D=>{if(Te(n.parser.pagination).test(D.name))return w=D,true;if(D.in==="body"){if(D.export==="reference"){let z=D.$refs[0];return e.models.find(te=>te.meta?.$ref===z)?.properties.find(te=>{if(Te(n.parser.pagination).test(te.name))return w=te,true})}return D.properties.find(z=>{if(Te(n.parser.pagination).test(z.name))return w=z,true})}});if(B&&w){l||(l=true,m||(Gc({file:s}),Xc({file:s}),m=true),c||(sg({file:s}),c=true),s.import({module:r.name,name:Uc}),p=s.import({asType:true,module:r.name,name:"InfiniteData"})),N=true;let{typeData:D}=Qo({client:e,file:s,operation:x,typesModulePath:o}),{typeError:j}=Jc({client:e,file:s,operation:x,pluginName:r.name,typesModulePath:o}),{typeResponse:z}=Yc({client:e,file:s,operation:x,typesModulePath:o}),H=ct(x.parameters),te=`${Xo}<${D}>`,$e=`Pick<${te}[0], 'body' | 'headers' | 'path' | 'query'>`,ze=`${w.base} | ${$e}`,mr=i.constVariable({exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:H,name:"options",type:D}],returnType:te,statements:em({id:x.name,isInfinite:true})}),name:_s({config:n,id:x.name,isInfinite:true,operation:x})});s.add(mr);let df=i.constVariable({comment:[],exportConst:true,expression:i.arrowFunction({parameters:[{isRequired:H,name:"options",type:D}],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:rg(B),value:i.objectExpression({multiLine:true,obj:[{key:w.name,value:i.identifier({text:"pageParam"})}]})}]}),whenTrue:i.identifier({text:"pageParam"})}),name:"page",typeName:$e}),i.constVariable({expression:i.callExpression({functionName:"createInfiniteParams",parameters:["queryKey","page"]}),name:"params"}),i.constVariable({destructure:true,expression:i.awaitExpression({expression:i.callExpression({functionName:S,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:_s({config:n,id:x.name,isInfinite:true,operation:x}),parameters:["options"]})}]})],name:Uc,types:[z,j.name,`${typeof p=="string"?p:p.name}<${z}>`,te,ze]})]}),name:Yy(x)});s.add(df);}}if(r.config.mutationOptions&&["DELETE","PATCH","POST","PUT"].includes(x.method)){f||(f=true,s.import({asType:true,module:r.name,name:a})),N=true;let{typeData:w}=Qo({client:e,file:s,operation:x,typesModulePath:o}),{typeError:B}=Jc({client:e,file:s,operation:x,pluginName:r.name,typesModulePath:o}),{typeResponse:D}=Yc({client:e,file:s,operation:x,typesModulePath:o}),j=i.arrowFunction({parameters:[{isRequired:false,name:"options",type:`Partial<${w}>`}],statements:[i.constVariable({expression:i.objectExpression({obj:[{key:"mutationFn",value:i.arrowFunction({async:true,multiLine:true,parameters:[{name:"localOptions"}],statements:[i.constVariable({destructure:true,expression:i.awaitExpression({expression:i.callExpression({functionName:S,parameters:[i.objectExpression({multiLine:true,obj:[{spread:"options"},{spread:"localOptions"},{key:"throwOnError",value:true}]})]})}),name:"data"}),i.returnVariable({expression:"data"})]})}]}),name:Zc,typeName:`${a}<${D}, ${B.name}, ${w}>`}),i.returnVariable({expression:Zc})]}),z=i.constVariable({comment:[],exportConst:true,expression:j,name:eg(x)});s.add(z);}(u||l)&&s.import({alias:"_heyApiClient",module:lr({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:r.output}),name:"client"}),N&&s.import({module:lr({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:r.output}),name:S.split(".")[0]});}};var Vs={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:ft,handlerLegacy:ut,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,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Ws={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:ft,handlerLegacy:ut,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,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var zs={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:ft,handlerLegacy:ut,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,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Ks={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:ft,handlerLegacy:ut,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,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var Us={config:{case:"camelCase",comments:true,exportFromIndex:false},dependencies:["@hey-api/sdk","@hey-api/typescript"],handler:ft,handlerLegacy:ut,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,name:"{{name}}Options"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.queryOptions});}};var rm="fastify",mg=({operation:e,plugin:t})=>{let r=t.context.file({id:rm}),n=[],s=t.getPlugin("@hey-api/typescript"),o=t.context.file({id:P}),a=o.getName(s.api.getId({operation:e,type:"data"}));a&&(e.body&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:a}),n.push({isRequired:e.body.required,name:"Body",type:`${a}['body']`})),e.parameters&&(e.parameters.header&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:a}),n.push({isRequired:$t(e.parameters.header),name:"Headers",type:`${a}['headers']`})),e.parameters.path&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:a}),n.push({isRequired:$t(e.parameters.path),name:"Params",type:`${a}['path']`})),e.parameters.query&&(r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:a}),n.push({isRequired:$t(e.parameters.query),name:"Querystring",type:`${a}['query']`}))));let{errors:p,responses:c}=rt(e),m,l=o.getName(s.api.getId({operation:e,type:"errors"}));if(l&&p&&p.properties){let x=Object.keys(p.properties);if(x.length){if(!x.includes("default"))r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:l}),m=i.typeReferenceNode({typeName:l});else if(x.length>1){r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:l});let S=i.typeReferenceNode({typeName:l}),N=i.literalTypeNode({literal:i.stringLiteral({text:"default"})});m=i.typeReferenceNode({typeArguments:[S,N],typeName:"Omit"});}}}let f,u=o.getName(s.api.getId({operation:e,type:"responses"}));if(u&&c&&c.properties){let x=Object.keys(c.properties);if(x.length){if(!x.includes("default"))r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:u}),f=i.typeReferenceNode({typeName:u});else if(x.length>1){r.import({asType:true,module:r.relativePathToFile({context:t.context,id:P}),name:u});let S=i.typeReferenceNode({typeName:u}),N=i.literalTypeNode({literal:i.stringLiteral({text:"default"})});f=i.typeReferenceNode({typeArguments:[S,N],typeName:"Omit"});}}}let y=[m,f].filter(Boolean);return y.length&&n.push({name:"Reply",type:i.typeIntersectionNode({types:y})}),n.length?{name:e.id,type:i.typeNode("RouteHandler",[i.typeInterfaceNode({properties:n,useLegacyResolution:false})])}:void 0},nm=({plugin:e})=>{let t=e.createFile({id:rm,path:e.output}),r=[];e.forEach("operation",({operation:s})=>{let o=mg({operation:s,plugin:e});o&&r.push(o);});let n=t.identifier({$ref:"RouteHandlers",create:true,namespace:"type"});n.name&&(r.length&&t.import({asType:true,module:"fastify",name:"RouteHandler"}),t.add(i.typeAliasDeclaration({exportType:true,name:n.name,type:i.typeInterfaceNode({properties:r,useLegacyResolution:false})})));};var Zs={config:{exportFromIndex:false},dependencies:["@hey-api/typescript"],handler:nm,name:"fastify",output:"fastify"};var h={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"})},v:i.identifier({text:"v"})},dt="valibot";var fg=({file:e,operation:t,plugin:r})=>{let{requests:n}=r.config,s=r.context.file({id:dt}).identifier({$ref:`#/valibot-response/${t.id}`,nameTransformer:typeof n=="object"?n.name:void 0,namespace:"value"});if(!s.name)return;e.import({module:e.relativePathToFile({context:r.context,id:dt}),name:s.name}),e.import({alias:h.v.text,module:"valibot",name:"*"});let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.async.parseAsync}),parameters:[i.identifier({text:s.name}),i.identifier({text:o})]})})})]})},ug=({file:e,operation:t,plugin:r})=>{let{responses:n}=r.config,s=r.context.file({id:dt}).identifier({$ref:`#/valibot-response/${t.id}`,nameTransformer:typeof n=="object"?n.name:void 0,namespace:"value"});if(!s.name)return;e.import({module:e.relativePathToFile({context:r.context,id:dt}),name:s.name}),e.import({alias:h.v.text,module:"valibot",name:"*"});let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.async.parseAsync}),parameters:[i.identifier({text:s.name}),i.identifier({text:o})]})})})]})},sm={createRequestValidator:fg,createResponseValidator:ug};var Qs={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}},Go=e=>e!==void 0&&e in Qs,om=e=>Go(e)&&Qs[e].needsBigInt,Lr=({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 im=({operation:e,plugin:t,state:r})=>{let n=t.context.file({id:dt});if(t.config.requests.enabled){let s=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(e.parameters){if(e.parameters.header){let p={},c=[];for(let m in e.parameters.header){let l=e.parameters.header[m];p[l.name]=l.schema,l.required&&(c.push(l.name),s.add("headers"));}Object.keys(p).length&&(o.properties.headers={properties:p,required:c,type:"object"});}if(e.parameters.path){let p={},c=[];for(let m in e.parameters.path){let l=e.parameters.path[m];p[l.name]=l.schema,l.required&&(c.push(l.name),s.add("path"));}Object.keys(p).length&&(o.properties.path={properties:p,required:c,type:"object"});}if(e.parameters.query){let p={},c=[];for(let m in e.parameters.query){let l=e.parameters.query[m];p[l.name]=l.schema,l.required&&(c.push(l.name),s.add("query"));}Object.keys(p).length&&(o.properties.query={properties:p,required:c,type:"object"});}}e.body&&(o.properties.body=e.body.schema,e.body.required&&s.add("body")),o.required=[...s];let a=n.identifier({$ref:`#/valibot-data/${e.id}`,case:t.config.requests.case,create:true,nameTransformer:t.config.requests.name,namespace:"value"});Pe({$ref:`#/valibot-data/${e.id}`,identifier:a,plugin:t,schema:o,state:r});}if(t.config.responses.enabled&&e.responses){let{response:s}=rt(e);if(s){let o=n.identifier({$ref:`#/valibot-response/${e.id}`,case:t.config.responses.case,create:true,nameTransformer:t.config.responses.name,namespace:"value"});Pe({$ref:`#/valibot-response/${e.id}`,identifier:o,plugin:t,schema:s,state:r});}}};var Ve=e=>e.length===1?e[0]:i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.methods.pipe}),parameters:e}),dg=({plugin:e,schema:t,state:r})=>{let n=i.propertyAccessExpression({expression:h.v,name:h.schemas.array}),s=[];if(t.items){t=Y({schema:t});let o=t.items.map(a=>{let p=Pe({plugin:e,schema:a,state:r});return Ve(p)});if(o.length===1){let a=i.callExpression({functionName:n,parameters:o});s.push(a);}else {t.logicalOperator;let a=i.callExpression({functionName:n,parameters:[fn()]});s.push(a);}}else {let o=i.callExpression({functionName:n,parameters:[fn()]});s.push(o);}if(t.minItems===t.maxItems&&t.minItems!==void 0){let o=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.length}),parameters:[i.valueToExpression({value:t.minItems})]});s.push(o);}else {if(t.minItems!==void 0){let o=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.minLength}),parameters:[i.valueToExpression({value:t.minItems})]});s.push(o);}if(t.maxItems!==void 0){let o=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.maxLength}),parameters:[i.valueToExpression({value:t.maxItems})]});s.push(o);}}return Ve(s)},yg=({schema:e})=>typeof e.const=="boolean"?i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[i.ots.boolean(e.const)]}):i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.boolean})}),gg=({schema:e})=>{let t=[],r=false;for(let s of e.items??[])s.type==="string"&&typeof s.const=="string"?t.push(i.stringLiteral({text:s.const})):(s.type==="null"||s.const===null)&&(r=true);if(!t.length)return fn();let n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.picklist}),parameters:[i.arrayLiteralExpression({elements:t,multiLine:false})]});return r&&(n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.nullable}),parameters:[n]})),n},hg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.never})}),xg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.null})}),am=({schema:e})=>{let t=e.format,r=e.type==="integer",n=om(t),s=Go(t)?Qs[t]:null;if(e.const!==void 0&&e.const!==null){let a=e.const,p;if(typeof a=="number"&&!t)p=i.ots.number(a);else if(typeof a=="number"&&t)n?p=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(a.toString())]}):p=i.ots.number(a);else if(typeof a=="string"&&n){let c=a.endsWith("n")?a.slice(0,-1):a;p=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(c)]});}else if(typeof a=="bigint"){let c=a.toString(),m=c.endsWith("n")?c.slice(0,-1):c;p=i.callExpression({functionName:"BigInt",parameters:[i.ots.string(m)]});}else p=i.valueToExpression({value:a});return i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[p]})}let o=[];if(n){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.union}),parameters:[i.arrayLiteralExpression({elements:[i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.number})}),i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.string})}),i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.bigInt})})],multiLine:false})]});o.push(a);let p=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.transform}),parameters:[i.arrowFunction({parameters:[{name:"x"}],statements:i.callExpression({functionName:"BigInt",parameters:[i.identifier({text:"x"})]})})]});o.push(p);}else {let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.number})});o.push(a);}if(!n&&r){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.integer})});o.push(a);}if(s){let a=s.min,p=s.max,c=s.minError,m=s.maxError,l=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.minValue}),parameters:[n?i.callExpression({functionName:"BigInt",parameters:[i.ots.string(a.toString())]}):i.ots.number(a),i.ots.string(c)]});o.push(l);let f=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.maxValue}),parameters:[n?i.callExpression({functionName:"BigInt",parameters:[i.ots.string(p.toString())]}):i.ots.number(p),i.ots.string(m)]});o.push(f);}if(e.exclusiveMinimum!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.gtValue}),parameters:[Lr({isBigInt:n,value:e.exclusiveMinimum})]});o.push(a);}else if(e.minimum!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.minValue}),parameters:[Lr({isBigInt:n,value:e.minimum})]});o.push(a);}if(e.exclusiveMaximum!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.ltValue}),parameters:[Lr({isBigInt:n,value:e.exclusiveMaximum})]});o.push(a);}else if(e.maximum!==void 0){let a=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.maxValue}),parameters:[Lr({isBigInt:n,value:e.maximum})]});o.push(a);}return Ve(o)},bg=({plugin:e,schema:t,state:r})=>{let n=[],s=t.required??[];for(let a in t.properties){let p=t.properties[a],c=s.includes(a),m=Pe({optional:!c,plugin:e,schema:p,state:r});oe.lastIndex=0;let l;oe.test(a)?l=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):l=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(l=`'${a}'`),n.push(i.propertyAssignment({initializer:Ve(m),name:l}));}if(t.additionalProperties&&t.additionalProperties.type==="object"&&!Object.keys(n).length){let a=Pe({plugin:e,schema:t.additionalProperties,state:r});return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.string}),parameters:[]}),Ve(a)]})}}let o=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(n,true)]});return {anyType:h.types.GenericSchema.text,expression:o}},Og=({schema:e})=>{if(typeof e.const=="string")return i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[i.ots.string(e.const)]});let t=[],r=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.string})});if(t.push(r),e.format)switch(e.format){case "date":t.push(i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.isoDate})}));break;case "date-time":t.push(i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.isoTimestamp})}));break;case "ipv4":case "ipv6":t.push(i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.ip})}));break;case "uri":t.push(i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.url})}));break;case "email":case "time":case "uuid":t.push(i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:i.identifier({text:e.format})})}));break}if(e.minLength===e.maxLength&&e.minLength!==void 0){let n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.length}),parameters:[i.valueToExpression({value:e.minLength})]});t.push(n);}else {if(e.minLength!==void 0){let n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.minLength}),parameters:[i.valueToExpression({value:e.minLength})]});t.push(n);}if(e.maxLength!==void 0){let n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.maxLength}),parameters:[i.valueToExpression({value:e.maxLength})]});t.push(n);}}if(e.pattern){let n=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.regex}),parameters:[i.regularExpressionLiteral({text:e.pattern})]});t.push(n);}return Ve(t)},Sg=({plugin:e,schema:t,state:r})=>{if(t.const&&Array.isArray(t.const)){let n=t.const.map(o=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.literal}),parameters:[i.valueToExpression({value:o})]}));return i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.tuple}),parameters:[i.arrayLiteralExpression({elements:n})]})}if(t.items){let n=t.items.map(o=>{let a=Pe({plugin:e,schema:o,state:r});return Ve(a)});return i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.tuple}),parameters:[i.arrayLiteralExpression({elements:n})]})}return fn()},Rg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.undefined})}),fn=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.unknown})}),Tg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.void})}),pm=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:dg({plugin:e,schema:t,state:r})};case "boolean":return {expression:yg({schema:t})};case "enum":return {expression:gg({schema:t})};case "integer":case "number":return {expression:am({schema:t})};case "never":return {expression:hg()};case "null":return {expression:xg()};case "object":return bg({plugin:e,schema:t,state:r});case "string":return t.format==="int64"||t.format==="uint64"?{expression:am({schema:t})}:{expression:Og({schema:t})};case "tuple":return {expression:Sg({plugin:e,schema:t,state:r})};case "undefined":return {expression:Rg()};case "unknown":return {expression:fn()};case "void":return {expression:Tg()}}},Pe=({$ref:e,identifier:t,optional:r,plugin:n,schema:s,state:o})=>{let a=n.context.file({id:dt}),p,c=t,m=[];if(e&&(o.circularReferenceTracker.add(e),c||(c=a.identifier({$ref:e,case:o.nameCase,create:true,nameTransformer:o.nameTransformer,namespace:"value"}))),s.$ref){let l=o.circularReferenceTracker.has(s.$ref),f=a.identifier({$ref:s.$ref,case:o.nameCase,nameTransformer:o.nameTransformer,namespace:"value"});if(!f.name){let u=n.context.resolveIrRef(s.$ref),y=Pe({$ref:s.$ref,plugin:n,schema:u,state:o});m.push(...y),f=a.identifier({$ref:s.$ref,case:o.nameCase,nameTransformer:o.nameTransformer,namespace:"value"});}if(f.name){let u=i.identifier({text:f.name});if(l){let y=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:u})]})]});m.push(y),o.hasCircularReference=true;}else m.push(u);}}else if(s.type){let l=pm({plugin:n,schema:s,state:o});if(p=l.anyType,m.push(l.expression),n.config.metadata&&s.description){let f=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.metadata}),parameters:[i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:s.description})}]})]});m.push(f);}}else if(s.items)if(s=Y({schema:s}),s.items){let l=s.items.map(f=>{let u=Pe({plugin:n,schema:f,state:o});return Ve(u)});if(s.logicalOperator==="and"){let f=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.intersect}),parameters:[i.arrayLiteralExpression({elements:l})]});m.push(f);}else {let f=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.union}),parameters:[i.arrayLiteralExpression({elements:l})]});m.push(f);}}else {let l=Pe({plugin:n,schema:s,state:o});m.push(...l);}else {let l=pm({plugin:n,schema:{type:"unknown"},state:o});p=l.anyType,m.push(l.expression);}if(e&&o.circularReferenceTracker.delete(e),m.length&&s.accessScope==="read"){let l=i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.actions.readonly})});m.push(l);}if(m.length){let l;if(s.default!==void 0){let f=s.type==="integer"&&s.format==="int64";l=Lr({isBigInt:f,value:s.default}),l&&(m=[i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.optional}),parameters:[Ve(m),l]})]);}r&&!l&&(m=[i.callExpression({functionName:i.propertyAccessExpression({expression:h.v,name:h.schemas.optional}),parameters:[Ve(m)]})]);}if(c&&c.name&&c.created){let l=i.constVariable({comment:n.config.comments?_e({schema:s}):void 0,exportConst:true,expression:Ve(m),name:c.name,typeName:o.hasCircularReference?i.propertyAccessExpression({expression:h.v,name:p||h.types.GenericSchema.text}):void 0});return a.add(l),[]}return m},cm=({plugin:e})=>{e.createFile({case:e.config.case,id:dt,path:e.output}).import({alias:h.v.text,module:"valibot",name:"*"}),e.forEach("operation","parameter","requestBody","schema",r=>{let n={circularReferenceTracker:new Set,hasCircularReference:false,nameCase:e.config.definitions.case,nameTransformer:e.config.definitions.name};r.type==="operation"?im({operation:r.operation,plugin:e,state:n}):r.type==="parameter"?Pe({$ref:r.$ref,plugin:e,schema:r.parameter.schema,state:n}):r.type==="requestBody"?Pe({$ref:r.$ref,plugin:e,schema:r.requestBody.schema,state:n}):r.type==="schema"&&Pe({$ref:r.$ref,plugin:e,schema:r.schema,state:n});});};var Xs={api:sm,config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:cm,name:"valibot",output:"valibot",resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}Data"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??"camelCase",enabled:true,name:"v{{name}}Response"},mappers:{boolean:r=>({enabled:r}),function:r=>({name:r}),string:r=>({name:r})},value:e.config.responses});},tags:["validator"]};var d={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"}),z:i.identifier({text:"z"})},G="zod";var Ag=({file:e,operation:t,plugin:r})=>{let s=r.context.file({id:G}).getName(r.api.getId({operation:t,type:"data"}));if(!s)return;e.import({module:e.relativePathToFile({context:r.context,id:G}),name:s});let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:i.identifier({text:s}),name:d.parseAsync}),parameters:[i.identifier({text:o})]})})})]})},Ig=({file:e,operation:t,plugin:r})=>{let s=r.context.file({id:G}).getName(r.api.getId({operation:t,type:"responses"}));if(!s)return;e.import({module:e.relativePathToFile({context:r.context,id:G}),name:s});let o="data";return i.arrowFunction({async:true,parameters:[{name:o}],statements:[i.returnStatement({expression:i.awaitExpression({expression:i.callExpression({functionName:i.propertyAccessExpression({expression:i.identifier({text:s}),name:d.parseAsync}),parameters:[i.identifier({text:o})]})})})]})},Eg=e=>{switch(e.type){case "data":case "responses":case "type-infer-data":case "type-infer-responses":return `${e.operation.id}-${e.type}`;case "ref":case "type-infer-ref":default:return `${e.type}-${e.value}`}},mm={createRequestValidator:Ag,createResponseValidator:Ig,getId:Eg};var vt=({plugin:e,schema:t,schemaId:r,typeInferId:n,zodSchema:s})=>{let o=e.context.file({id:G}),a=o.addNodeReference(r,{factory:c=>i.typeReferenceNode({typeName:c})}),p=i.constVariable({comment:e.config.comments?_e({schema:t}):void 0,exportConst:true,expression:s.expression,name:a,typeName:s.typeName?i.propertyAccessExpression({expression:d.z,name:s.typeName}):void 0});if(o.add(p),n){let c=o.addNodeReference(n,{factory:f=>i.typeReferenceNode({typeName:f})}),m=o.addNodeReference(r,{factory:f=>i.identifier({text:f})}),l=i.typeAliasDeclaration({exportType:true,name:c,type:i.typeReferenceNode({typeArguments:[i.typeOfExpression({text:m})],typeName:i.propertyAccessExpression({expression:d.z,name:d.infer})})});o.add(l);}};var Br=({plugin:e})=>{let t=e.package.getVersion("zod");if(t&&e.package.satisfies(t,"<4.0.0"))switch(e.config.compatibilityVersion){case 3:default:return "zod";case 4:return "zod/v4";case "mini":return "zod/v4-mini"}switch(e.config.compatibilityVersion){case 3:return "zod/v3";case 4:default:return "zod";case "mini":return "zod/mini"}};var Hr=({getZodSchema:e,operation:t,plugin:r})=>{let n=r.context.file({id:G});if(r.config.requests.enabled){let s=new Set,o={properties:{body:{type:"never"},path:{type:"never"},query:{type:"never"}},type:"object"};if(t.parameters){if(t.parameters.header){let m={},l=[];for(let f in t.parameters.header){let u=t.parameters.header[f];m[u.name]=u.schema,u.required&&(l.push(u.name),s.add("headers"));}Object.keys(m).length&&(o.properties.headers={properties:m,required:l,type:"object"});}if(t.parameters.path){let m={},l=[];for(let f in t.parameters.path){let u=t.parameters.path[f];m[u.name]=u.schema,u.required&&(l.push(u.name),s.add("path"));}Object.keys(m).length&&(o.properties.path={properties:m,required:l,type:"object"});}if(t.parameters.query){let m={},l=[];for(let f in t.parameters.query){let u=t.parameters.query[f];m[u.name]=u.schema,u.required&&(l.push(u.name),s.add("query"));}Object.keys(m).length&&(o.properties.query={properties:m,required:l,type:"object"});}}t.body&&(o.properties.body=t.body.schema,t.body.required&&s.add("body")),o.required=[...s];let a=e(o),p=r.api.getId({operation:t,type:"data"}),c=r.config.requests.types.infer.enabled?r.api.getId({operation:t,type:"type-infer-data"}):void 0;vt({plugin:r,schema:o,schemaId:p,typeInferId:c,zodSchema:a}),n.updateNodeReferences(p,M({config:r.config.requests,name:t.id})),c&&n.updateNodeReferences(c,M({config:r.config.requests.types.infer,name:t.id}));}if(r.config.responses.enabled&&t.responses){let{response:s}=rt(t);if(s){let o=e(s),a=r.api.getId({operation:t,type:"responses"}),p=r.config.responses.types.infer.enabled?r.api.getId({operation:t,type:"type-infer-responses"}):void 0;vt({plugin:r,schema:s,schemaId:a,typeInferId:p,zodSchema:o}),n.updateNodeReferences(a,M({config:r.config.responses,name:t.id})),p&&n.updateNodeReferences(p,M({config:r.config.responses.types.infer,name:t.id}));}}};var vg=({plugin:e,schema:t,state:r})=>{let n={},s=i.propertyAccessExpression({expression:d.z,name:d.array});if(!t.items)n.expression=i.callExpression({functionName:s,parameters:[ei().expression]});else {t=Y({schema:t});let a=t.items.map(p=>{let c=zt({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:d.z,name:d.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:a})]})]}));}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.length}),parameters:[i.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.minLength}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&o.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.maxLength}),parameters:[i.valueToExpression({value:t.maxItems})]}))),o.length&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:d.check}),parameters:o})),n},Cg=({schema:e})=>{let t={};return typeof e.const=="boolean"?(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.boolean(e.const)]}),t):(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.boolean})}),t)},kg=({schema:e})=>{let t={},r=[],n=false;for(let s of e.items??[])s.type==="string"&&typeof s.const=="string"?r.push(i.stringLiteral({text:s.const})):(s.type==="null"||s.const===null)&&(n=true);return r.length?(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.enum}),parameters:[i.arrayLiteralExpression({elements:r,multiLine:false})]}),n&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.nullable}),parameters:[t.expression]})),t):ei()},jg=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.never})}),t},Ng=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.null})}),t},un=({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},wg=({schema:e})=>{let t={},r=e.type==="integer"&&e.format==="int64";if(typeof e.const=="number")return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.number(e.const)]}),t;t.expression=i.callExpression({functionName:r?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.coerce}),name:d.bigint}):i.propertyAccessExpression({expression:d.z,name:d.number})}),!r&&e.type==="integer"&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.int})}));let n=[];return e.exclusiveMinimum!==void 0?n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.gt}),parameters:[un({isBigInt:r,value:e.exclusiveMinimum})]})):e.minimum!==void 0&&n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.gte}),parameters:[un({isBigInt:r,value:e.minimum})]})),e.exclusiveMaximum!==void 0?n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.lt}),parameters:[un({isBigInt:r,value:e.exclusiveMaximum})]})):e.maximum!==void 0&&n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.lte}),parameters:[un({isBigInt:r,value:e.maximum})]})),n.length&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.expression,name:d.check}),parameters:n})),t},qg=({plugin:e,schema:t,state:r})=>{let n={},s=[],o=t.required??[];for(let a in t.properties){let p=t.properties[a],c=o.includes(a),m=zt({optional:!c,plugin:e,schema:p,state:r});m.hasCircularReference&&(n.hasCircularReference=true),oe.lastIndex=0;let l;oe.test(a)?l=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):l=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(l=`'${a}'`),m.hasCircularReference?s.push(i.getAccessorDeclaration({name:l,returnType:m.typeName?i.propertyAccessExpression({expression:d.z,name:m.typeName}):void 0,statements:[i.returnStatement({expression:m.expression})]})):s.push(i.propertyAssignment({initializer:m.expression,name:l}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=zt({plugin:e,schema:t.additionalProperties,state:r});return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.string}),parameters:[]}),a.expression]}),a.hasCircularReference&&(n.hasCircularReference=true),n}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(s,true)]}),n},$g=({plugin:e,schema:t})=>{let r={};if(typeof t.const=="string")return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.string(t.const)]}),r;if(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.string})}),t.format)switch(t.format){case "date":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.date})});break;case "date-time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.datetime}),parameters:e.config.dates.offset?[i.objectExpression({obj:[{key:"offset",value:true}]})]:[]});break;case "email":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.email})});break;case "ipv4":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.ipv4})});break;case "ipv6":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.ipv6})});break;case "time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.time})});break;case "uri":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.url})});break;case "uuid":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.uuid})});break}let n=[];return t.minLength===t.maxLength&&t.minLength!==void 0?n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.length}),parameters:[i.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.minLength}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.maxLength}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&n.push(i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),n.length&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:d.check}),parameters:n})),r},Mg=({plugin:e,schema:t,state:r})=>{let n={};if(t.const&&Array.isArray(t.const)){let o=t.const.map(a=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.valueToExpression({value:a})]}));return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:o})]}),n}let s=[];for(let o of t.items??[]){let a=zt({plugin:e,schema:o,state:r});s.push(a.expression),a.hasCircularReference&&(n.hasCircularReference=true);}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:s})]}),n},Dg=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.undefined})}),t},ei=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.unknown})}),t},Fg=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.void})}),t},lm=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return vg({plugin:e,schema:t,state:r});case "boolean":return Cg({schema:t});case "enum":return kg({schema:t});case "integer":case "number":return wg({schema:t});case "never":return jg();case "null":return Ng();case "object":return qg({plugin:e,schema:t,state:r});case "string":return $g({plugin:e,schema:t});case "tuple":return Mg({plugin:e,schema:t,state:r});case "undefined":return Dg();case "unknown":return ei();case "void":return Fg()}},zt=({optional:e,plugin:t,schema:r,state:n})=>{let s=t.context.file({id:G}),o={};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.getId({type:"ref",value:r.$ref});if(a){let m=s.addNodeReference(c,{factory:l=>i.identifier({text:l})});p?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.lazy}),parameters:[i.arrowFunction({returnType:i.keywordTypeNode({keyword:"any"}),statements:[i.returnStatement({expression:m})]})]}):o.expression=m,o.hasCircularReference=true;}else if(!s.getName(c)){let m=t.context.resolveIrRef(r.$ref);Gs({id:r.$ref,plugin:t,schema:m,state:n});}if(!a){let m=s.addNodeReference(c,{factory:l=>i.identifier({text:l})});o.expression=m;}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=lm({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:d.register}),parameters:[i.propertyAccessExpression({expression:d.z,name:d.globalRegistry}),i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=Y({schema:r}),r.items){let a=r.items.map(p=>zt({plugin:t,schema:p,state:n}).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:d.z,name:d.intersection}),parameters:a}):(o.expression=a[0],a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.intersection}),parameters:[o.expression,c]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:a})]});}else o=zt({plugin:t,schema:r,state:n});else {let a=lm({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:d.z,name:d.readonly}),parameters:[o.expression]})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.optional}),parameters:[o.expression]}),o.typeName=d.ZodMiniOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=un({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d._default}),parameters:[o.expression,p]}));}return o},Gs=({id:e,plugin:t,schema:r,state:n})=>{let s={circularReferenceTracker:[e],hasCircularReference:false,...n,currentReferenceTracker:[e]},o=t.context.file({id:G}),a=t.api.getId({type:"ref",value:e});if(o.getName(a))return;let p=zt({plugin:t,schema:r,state:s}),c=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;vt({plugin:t,schema:r,schemaId:a,typeInferId:c,zodSchema:p});let m=V(e);o.updateNodeReferences(a,M({config:t.config.definitions,name:m})),c&&o.updateNodeReferences(c,M({config:t.config.definitions.types.infer,name:m}));},fm=({plugin:e})=>{e.createFile({case:e.config.case,id:G,path:e.output}).import({alias:d.z.text,module:Br({plugin:e}),name:"*"}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Hr({getZodSchema:n=>zt({plugin:e,schema:n,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?Gs({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?Gs({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&Gs({id:r.$ref,plugin:e,schema:r.schema});});};var Lg=({plugin:e,schema:t,state:r})=>{let n=i.propertyAccessExpression({expression:d.z,name:d.array}),s;if(!t.items)s=i.callExpression({functionName:n,parameters:[ri()]});else {t=Y({schema:t});let o=t.items.map(a=>Kt({plugin:e,schema:a,state:r}).expression);o.length===1?s=i.callExpression({functionName:n,parameters:o}):(t.logicalOperator,s=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:o})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:d.length}),parameters:[i.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:d.min}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(s=i.callExpression({functionName:i.propertyAccessExpression({expression:s,name:d.max}),parameters:[i.valueToExpression({value:t.maxItems})]}))),s},Bg=({schema:e})=>typeof e.const=="boolean"?i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.boolean(e.const)]}):i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.boolean})}),Hg=({schema:e})=>{let t=[],r=false;for(let s of e.items??[])s.type==="string"&&typeof s.const=="string"?t.push(i.stringLiteral({text:s.const})):(s.type==="null"||s.const===null)&&(r=true);if(!t.length)return ri();let n=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.enum}),parameters:[i.arrayLiteralExpression({elements:t,multiLine:false})]});return r&&(n=i.callExpression({functionName:i.propertyAccessExpression({expression:n,name:d.nullable})})),n},_g=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.never})}),Vg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.null})}),dn=({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},Wg=({schema:e})=>{let t=e.type==="integer"&&e.format==="int64";if(typeof e.const=="number")return i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.number(e.const)]});let r=i.callExpression({functionName:t?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.coerce}),name:d.bigint}):i.propertyAccessExpression({expression:d.z,name:d.number})});return !t&&e.type==="integer"&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.int})})),e.exclusiveMinimum!==void 0?r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.gt}),parameters:[dn({isBigInt:t,value:e.exclusiveMinimum})]}):e.minimum!==void 0&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.gte}),parameters:[dn({isBigInt:t,value:e.minimum})]})),e.exclusiveMaximum!==void 0?r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.lt}),parameters:[dn({isBigInt:t,value:e.exclusiveMaximum})]}):e.maximum!==void 0&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.lte}),parameters:[dn({isBigInt:t,value:e.maximum})]})),r},zg=({plugin:e,schema:t,state:r})=>{let n=[],s=t.required??[];for(let a in t.properties){let p=t.properties[a],c=s.includes(a),m=Kt({optional:!c,plugin:e,schema:p,state:r}).expression;oe.lastIndex=0;let l;oe.test(a)?l=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):l=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(l=`'${a}'`),n.push(i.propertyAssignment({initializer:m,name:l}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Kt({plugin:e,schema:t.additionalProperties,state:r}).expression;return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.record}),parameters:[a]})}}return {anyType:"AnyZodObject",expression:i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(n,true)]})}},Kg=({plugin:e,schema:t})=>{if(typeof t.const=="string")return i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.string(t.const)]});let r=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.string})});if(t.format)switch(t.format){case "date":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.date})});break;case "date-time":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.datetime}),parameters:e.config.dates.offset?[i.objectExpression({obj:[{key:"offset",value:true}]})]:[]});break;case "email":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.email})});break;case "ipv4":case "ipv6":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.ip})});break;case "time":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.time})});break;case "uri":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.url})});break;case "uuid":r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.length}),parameters:[i.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.min}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.max}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=i.callExpression({functionName:i.propertyAccessExpression({expression:r,name:d.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),r},Ug=({plugin:e,schema:t,state:r})=>{if(t.const&&Array.isArray(t.const)){let o=t.const.map(p=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.valueToExpression({value:p})]}));return i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:o})]})}let n=[];for(let o of t.items??[])n.push(Kt({plugin:e,schema:o,state:r}).expression);return i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:n})]})},Zg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.undefined})}),ri=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.unknown})}),Qg=e=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.void})}),um=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return {expression:Lg({plugin:e,schema:t,state:r})};case "boolean":return {expression:Bg({schema:t})};case "enum":return {expression:Hg({schema:t})};case "integer":case "number":return {expression:Wg({schema:t})};case "never":return {expression:_g()};case "null":return {expression:Vg()};case "object":return zg({plugin:e,schema:t,state:r});case "string":return {expression:Kg({plugin:e,schema:t})};case "tuple":return {expression:Ug({plugin:e,schema:t,state:r})};case "undefined":return {expression:Zg()};case "unknown":return {expression:ri()};case "void":return {expression:Qg()}}},Kt=({optional:e,plugin:t,schema:r,state:n})=>{let s=t.context.file({id:G}),o={};if(r.$ref){let a=n.circularReferenceTracker.includes(r.$ref);n.circularReferenceTracker.push(r.$ref),n.currentReferenceTracker.push(r.$ref);let p=t.api.getId({type:"ref",value:r.$ref});if(a){let c=s.addNodeReference(p,{factory:m=>i.identifier({text:m})});o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.lazy}),parameters:[i.arrowFunction({statements:[i.returnStatement({expression:c})]})]}),n.hasCircularReference=true;}else if(!s.getName(p)){let c=t.context.resolveIrRef(r.$ref);Js({id:r.$ref,plugin:t,schema:c,state:n});}if(!a){let c=s.addNodeReference(p,{factory:m=>i.identifier({text:m})});o.expression=c;}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=um({plugin:t,schema:r,state:n});o.expression=a.expression,o.typeName=a.anyType,t.config.metadata&&r.description&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.describe}),parameters:[i.stringLiteral({text:r.description})]}));}else if(r.items)if(r=Y({schema:r}),r.items){let a=r.items.map(p=>Kt({plugin:t,schema:p,state:n}).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:d.z,name:d.intersection}),parameters:a}):(o.expression=a[0],a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.and}),parameters:[c]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:a})]});}else o=Kt({plugin:t,schema:r,state:n});else {let a=um({plugin:t,schema:{type:"unknown"},state:n});o.expression=a.expression,o.typeName=a.anyType;}if(o.expression&&(r.accessScope==="read"&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.readonly})})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.optional})})),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=dn({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.default}),parameters:[p]}));}return n.hasCircularReference?o.typeName||(o.typeName="ZodTypeAny"):o.typeName=void 0,o},Js=({id:e,plugin:t,schema:r,state:n})=>{n||(n={circularReferenceTracker:[e],currentReferenceTracker:[e],hasCircularReference:false});let s=t.context.file({id:G}),o=t.api.getId({type:"ref",value:e});if(s.getName(o))return;let a=Kt({plugin:t,schema:r,state:n}),p=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;vt({plugin:t,schema:r,schemaId:o,typeInferId:p,zodSchema:a});let c=V(e);s.updateNodeReferences(o,M({config:t.config.definitions,name:c})),p&&s.updateNodeReferences(p,M({config:t.config.definitions.types.infer,name:c}));},dm=({plugin:e})=>{e.createFile({case:e.config.case,id:G,path:e.output}).import({module:Br({plugin:e}),name:d.z.text}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Hr({getZodSchema:n=>Kt({plugin:e,schema:n,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?Js({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?Js({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&Js({id:r.$ref,plugin:e,schema:r.schema});});};var Xg=({plugin:e,schema:t,state:r})=>{let n={},s=i.propertyAccessExpression({expression:d.z,name:d.array});if(!t.items)n.expression=i.callExpression({functionName:s,parameters:[si().expression]});else {t=Y({schema:t});let o=t.items.map(a=>{let p=Ut({plugin:e,schema:a,state:r});return p.hasCircularReference&&(n.hasCircularReference=true),p.expression});o.length===1?n.expression=i.callExpression({functionName:s,parameters:o}):(t.logicalOperator,n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.array}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:o})]})]}));}return t.minItems===t.maxItems&&t.minItems!==void 0?n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:d.length}),parameters:[i.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:d.min}),parameters:[i.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:n.expression,name:d.max}),parameters:[i.valueToExpression({value:t.maxItems})]}))),n},Gg=({schema:e})=>{let t={};return typeof e.const=="boolean"?(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.boolean(e.const)]}),t):(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.boolean})}),t)},Jg=({schema:e})=>{let t={},r=[],n=false;for(let s of e.items??[])s.type==="string"&&typeof s.const=="string"?r.push(i.stringLiteral({text:s.const})):(s.type==="null"||s.const===null)&&(n=true);return r.length?(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.enum}),parameters:[i.arrayLiteralExpression({elements:r,multiLine:false})]}),n&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.nullable}),parameters:[t.expression]})),t):si()},Yg=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.never})}),t},eh=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.null})}),t},yn=({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},th=({schema:e})=>{let t={},r=e.type==="integer"&&e.format==="int64";return typeof e.const=="number"?(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.number(e.const)]}),t):(t.expression=i.callExpression({functionName:r?i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.coerce}),name:d.bigint}):i.propertyAccessExpression({expression:d.z,name:d.number})}),!r&&e.type==="integer"&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.int})})),e.exclusiveMinimum!==void 0?t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.expression,name:d.gt}),parameters:[yn({isBigInt:r,value:e.exclusiveMinimum})]}):e.minimum!==void 0&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.expression,name:d.gte}),parameters:[yn({isBigInt:r,value:e.minimum})]})),e.exclusiveMaximum!==void 0?t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.expression,name:d.lt}),parameters:[yn({isBigInt:r,value:e.exclusiveMaximum})]}):e.maximum!==void 0&&(t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:t.expression,name:d.lte}),parameters:[yn({isBigInt:r,value:e.maximum})]})),t)},rh=({plugin:e,schema:t,state:r})=>{let n={},s=[],o=t.required??[];for(let a in t.properties){let p=t.properties[a],c=o.includes(a),m=Ut({optional:!c,plugin:e,schema:p,state:r});m.hasCircularReference&&(n.hasCircularReference=true),oe.lastIndex=0;let l;oe.test(a)?l=a.startsWith("-")?b__default.default.factory.createStringLiteral(a):b__default.default.factory.createNumericLiteral(a):l=a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith("'")&&!a.endsWith("'")&&(l=`'${a}'`),m.hasCircularReference?s.push(i.getAccessorDeclaration({name:l,returnType:m.typeName?i.propertyAccessExpression({expression:d.z,name:m.typeName}):void 0,statements:[i.returnStatement({expression:m.expression})]})):s.push(i.propertyAssignment({initializer:m.expression,name:l}));}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Ut({plugin:e,schema:t.additionalProperties,state:r});return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.record}),parameters:[i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.string}),parameters:[]}),a.expression]}),a.hasCircularReference&&(n.hasCircularReference=true),n.hasCircularReference?{...n,typeName:"ZodType"}:n}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.object}),parameters:[b__default.default.factory.createObjectLiteralExpression(s,true)]}),n.hasCircularReference?{...n,typeName:"ZodType"}:n},nh=({plugin:e,schema:t})=>{let r={};if(typeof t.const=="string")return r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.ots.string(t.const)]}),r;if(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.string})}),t.format)switch(t.format){case "date":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.date})});break;case "date-time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.datetime}),parameters:e.config.dates.offset?[i.objectExpression({obj:[{key:"offset",value:true}]})]:[]});break;case "email":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.email})});break;case "ipv4":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.ipv4})});break;case "ipv6":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.ipv6})});break;case "time":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:i.propertyAccessExpression({expression:d.z,name:d.iso}),name:d.time})});break;case "uri":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.url})});break;case "uuid":r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:d.length}),parameters:[i.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:d.min}),parameters:[i.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:d.max}),parameters:[i.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:r.expression,name:d.regex}),parameters:[i.regularExpressionLiteral({text:t.pattern})]})),r},sh=({plugin:e,schema:t,state:r})=>{let n={};if(t.const&&Array.isArray(t.const)){let o=t.const.map(a=>i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.literal}),parameters:[i.valueToExpression({value:a})]}));return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:o})]}),n}let s=[];for(let o of t.items??[]){let a=Ut({plugin:e,schema:o,state:r});s.push(a.expression),a.hasCircularReference&&(n.hasCircularReference=true);}return n.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.tuple}),parameters:[i.arrayLiteralExpression({elements:s})]}),n},oh=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.undefined})}),t},si=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.unknown})}),t},ih=e=>{let t={};return t.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.void})}),t},ym=({plugin:e,schema:t,state:r})=>{switch(t.type){case "array":return Xg({plugin:e,schema:t,state:r});case "boolean":return Gg({schema:t});case "enum":return Jg({schema:t});case "integer":case "number":return th({schema:t});case "never":return Yg();case "null":return eh();case "object":return rh({plugin:e,schema:t,state:r});case "string":return nh({plugin:e,schema:t});case "tuple":return sh({plugin:e,schema:t,state:r});case "undefined":return oh();case "unknown":return si();case "void":return ih()}},Ut=({optional:e,plugin:t,schema:r,state:n})=>{let s=t.context.file({id:G}),o={};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.getId({type:"ref",value:r.$ref});if(a){let m=s.addNodeReference(c,{factory:l=>i.identifier({text:l})});p?o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.lazy}),parameters:[i.arrowFunction({returnType:i.keywordTypeNode({keyword:"any"}),statements:[i.returnStatement({expression:m})]})]}):o.expression=m,o.hasCircularReference=true;}else if(!s.getName(c)){let m=t.context.resolveIrRef(r.$ref);Ys({id:r.$ref,plugin:t,schema:m,state:n});}if(!a){let m=s.addNodeReference(c,{factory:l=>i.identifier({text:l})});o.expression=m;}n.circularReferenceTracker.pop(),n.currentReferenceTracker.pop();}else if(r.type){let a=ym({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:d.register}),parameters:[i.propertyAccessExpression({expression:d.z,name:d.globalRegistry}),i.objectExpression({obj:[{key:"description",value:i.stringLiteral({text:r.description})}]})]}));}else if(r.items)if(r=Y({schema:r}),r.items){let a=r.items.map(p=>Ut({plugin:t,schema:p,state:n}).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:d.z,name:d.intersection}),parameters:a}):(o.expression=a[0],a.slice(1).forEach(c=>{o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.and}),parameters:[c]});}));}else o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.union}),parameters:[i.arrayLiteralExpression({elements:a})]});}else o=Ut({plugin:t,schema:r,state:n});else {let a=ym({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:d.readonly})})),e&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:d.z,name:d.optional}),parameters:[o.expression]}),o.typeName=d.ZodOptional),r.default!==void 0)){let a=r.type==="integer"&&r.format==="int64",p=yn({isBigInt:a,value:r.default});p&&(o.expression=i.callExpression({functionName:i.propertyAccessExpression({expression:o.expression,name:d.default}),parameters:[p]}));}return o},Ys=({id:e,plugin:t,schema:r,state:n})=>{let s={circularReferenceTracker:[e],hasCircularReference:false,...n,currentReferenceTracker:[e]},o=t.context.file({id:G}),a=t.api.getId({type:"ref",value:e});if(o.getName(a))return;let p=Ut({plugin:t,schema:r,state:s}),c=t.config.definitions.types.infer.enabled?t.api.getId({type:"type-infer-ref",value:e}):void 0;vt({plugin:t,schema:r,schemaId:a,typeInferId:c,zodSchema:p});let m=V(e);o.updateNodeReferences(a,M({config:t.config.definitions,name:m})),c&&o.updateNodeReferences(c,M({config:t.config.definitions.types.infer,name:m}));},oi=({plugin:e})=>{e.createFile({case:e.config.case,id:G,path:e.output}).import({module:Br({plugin:e}),name:d.z.text}),e.forEach("operation","parameter","requestBody","schema",r=>{r.type==="operation"?Hr({getZodSchema:n=>Ut({plugin:e,schema:n,state:{circularReferenceTracker:[],currentReferenceTracker:[],hasCircularReference:false}}),operation:r.operation,plugin:e}):r.type==="parameter"?Ys({id:r.$ref,plugin:e,schema:r.parameter.schema}):r.type==="requestBody"?Ys({id:r.$ref,plugin:e,schema:r.requestBody.schema}):r.type==="schema"&&Ys({id:r.$ref,plugin:e,schema:r.schema});});};var gm=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return dm(e);case 4:return oi(e);case "mini":return fm(e);default:return oi(e)}};var eo={api:mm,config:{case:"camelCase",comments:true,exportFromIndex:false,metadata:false},handler:gm,name:"zod",output:"zod",resolveConfig:(e,t)=>{let r="zod",n=t.package.getVersion(r),s=()=>n&&(n.major===4||n.major===3)?n.major:4,o=a=>{if(!a)return s();if(!n)return a;if((a===4||a===3||a==="mini")&&!t.package.satisfies(n,">=3.25.0 <5.0.0")){let p=s();return console.warn(`\u{1F50C} ${We__default.default.yellow("Warning:")} Installed ${We__default.default.cyan(r)} ${We__default.default.cyan(`v${n.version}`)} does not support compatibility version ${We__default.default.yellow(String(a))}, using ${We__default.default.yellow(String(p))}.`),p}return a};e.config.compatibilityVersion=o(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{offset:false},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:"PascalCase",enabled:false}},mappers:{object:(a,p)=>({...a,infer:t.valueToObject({defaultValue:{...p.infer,enabled:a.infer!==void 0?!!a.infer:p.infer.enabled},mappers:kt,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:{...kt,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:kt,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:{...kt,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:kt,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:{...kt,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:kt,value:c.infer})})},value:a.types})})},value:e.config.responses});},tags:["validator"]};var to={"@hey-api/client-axios":wn,"@hey-api/client-fetch":qn,"@hey-api/client-next":$n,"@hey-api/client-nuxt":Mn,"@hey-api/schemas":As,"@hey-api/sdk":Cs,"@hey-api/transformers":js,"@hey-api/typescript":qs,"@tanstack/angular-query-experimental":Vs,"@tanstack/react-query":Ws,"@tanstack/solid-query":zs,"@tanstack/svelte-query":Ks,"@tanstack/vue-query":Us,fastify:Zs,"legacy/angular":Dn,"legacy/axios":Fn,"legacy/fetch":Ln,"legacy/node":Bn,"legacy/xhr":Hn,valibot:Xs,zod:eo};var ii=["@hey-api/typescript","@hey-api/sdk"],ph=({dependencies:e,userPlugins:t,userPluginsConfig:r})=>{let n=new Set,s=new Set,o={},a=p=>{if(n.has(p))throw new Error(`Circular reference detected at '${p}'`);if(s.has(p))return;n.add(p);let c=to[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:zn(e),pluginByTag:(u,y={})=>{let{defaultPlugin:g,errorMessage:x}=y;for(let R of t){let S=to[R]||r[R];if(S&&S.tags?.includes(u)&&R!==p)return R}if(g){let R=to[g]||r[g];if(R&&R.tags?.includes(u)&&g!==p)return g}throw new Error(x||`missing plugin - no plugin with tag "${u}" found`)},valueToObject:Zt};l.resolveConfig(l,f);}for(let f of l.dependencies)a(f);n.delete(p),s.add(p),o[p]=l;};for(let p of t)a(p);return {pluginOrder:Array.from(s),plugins:o}},ch=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"),hm=({dependencies:e,userConfig:t})=>{let r={},n=ii;t.plugins&&(t.plugins=t.plugins.filter(o=>typeof o=="string"&&o||typeof o!="string"&&o.name),t.plugins.length===1&&ch(t.plugins[0])?n=[...ii,...t.plugins]:n=t.plugins);let s=n.map(o=>{if(typeof o=="string")return o;let a=o.name;return a&&(o.handler?r[a]=o:(r[a]={config:{...o}},delete r[a].config.name)),a}).filter(Boolean);return ph({dependencies:e,userPlugins:s,userPluginsConfig:r})};var xm=async e=>{let t;if(e?.configFile){let p=e.configFile.split(".");t=p.slice(0,p.length-1).join(".");}let{config:r,configFile:n}=await c12.loadConfig({configFile:t,name:"openapi-ts"}),s=qi(Object.keys(r).length?n:void 0),o=Array.isArray(e)?e:Array.isArray(r)?r.map(p=>co(p,e)):[co(r,e)],a=[];for(let p of o){let{base:c,configFile:m="",dryRun:l=false,experimentalParser:f=true,exportCore:u=true,interactive:y=false,name:g,request:x,useOptions:R=true}=p,S=[],N=Tn(p);N.level==="debug"&&console.warn("userConfig:",p);let w=ji(p),B=Ni(p),D=Mi(p);w.path||S.push(new Ze("missing input - which OpenAPI specification should we use to generate your output?")),B.path||S.push(new Ze("missing output - where should we generate your output?")),R||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"),B.path=J__default.default.resolve(process.cwd(),B.path);let j;try{j=hm({dependencies:s,userConfig:p});}catch(H){S.push(H),j={pluginOrder:[],plugins:{}};}let z=Ci({...j,base:c,configFile:m,dryRun:l,experimentalParser:f,exportCore:false,input:w,interactive:y,logs:N,name:g,output:B,parser:D,request:x,useOptions:R});z.exportCore=_(z)?u:false,N.level==="debug"&&console.warn("config:",z),a.push({config:z,errors:S});}return {dependencies:s,results:a}};var ro=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 bm=async(e,t,r,n)=>{let s=T(),o=E(s),a=n.client({$config:s,...r,httpRequest:ro(o.name),models:nn(r.models),services:nn(r.services)});Q(s)&&(Me(t),we__default.default.writeFileSync(J__default.default.resolve(t,`${Q(s)}.ts`),a));};var Om=async(e,t,r)=>{let n=T();if(n.exportCore){let s=E(n),o={httpRequest:ro(s.name),server:n.base!==void 0?n.base:t.server,version:t.version};if(we__default.default.rmSync(J__default.default.resolve(e),{force:true,recursive:true}),we__default.default.mkdirSync(J__default.default.resolve(e),{recursive:true}),await we__default.default.writeFileSync(J__default.default.resolve(e,"OpenAPI.ts"),r.core.settings({$config:n,...o})),await we__default.default.writeFileSync(J__default.default.resolve(e,"ApiError.ts"),r.core.apiError({$config:n,...o})),await we__default.default.writeFileSync(J__default.default.resolve(e,"ApiRequestOptions.ts"),r.core.apiRequestOptions({$config:n,...o})),await we__default.default.writeFileSync(J__default.default.resolve(e,"ApiResult.ts"),r.core.apiResult({$config:n,...o})),s.name!=="legacy/angular"&&await we__default.default.writeFileSync(J__default.default.resolve(e,"CancelablePromise.ts"),r.core.cancelablePromise({$config:n,...o})),await we__default.default.writeFileSync(J__default.default.resolve(e,"request.ts"),r.core.request({$config:n,...o})),Q(n)&&(await we__default.default.writeFileSync(J__default.default.resolve(e,"BaseHttpRequest.ts"),r.core.baseHttpRequest({$config:n,...o})),await we__default.default.writeFileSync(J__default.default.resolve(e,`${o.httpRequest}.ts`),r.core.httpRequest({$config:n,...o}))),n.request){let a=J__default.default.resolve(process.cwd(),n.request);if(!await we__default.default.existsSync(a))throw new Error(`Custom request file "${a}" does not exists`);await we__default.default.copyFileSync(a,J__default.default.resolve(e,"request.ts"));}}};var Sm=({files:e})=>{let t=T();e.index=new xe({dir:t.output.path,id:"index",name:"index.ts"}),Q(t)&&e.index.add(i.exportNamedDeclaration({exports:Q(t),module:`./${Q(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"})),Q(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 Rm=async({client:e,openApi:t,templates:r})=>{let n=T(),s=t;if(e){if(n.plugins["@hey-api/sdk"]?.config.include&&n.plugins["@hey-api/sdk"].config.asClass){let m=new RegExp(n.plugins["@hey-api/sdk"].config.include);e.services=e.services.filter(l=>m.test(l.name));}if(n.plugins["@hey-api/typescript"]?.config.include){let m=new RegExp(n.plugins["@hey-api/typescript"].config.include);e.models=e.models.filter(l=>m.test(l.name));}}let o=J__default.default.resolve(n.output.path);n.output.clean&&Rn(o);let a=On(bn(n.output.tsConfigPath)),p=E(n);!_(n)&&"bundle"in p.config&&p.config.bundle&&An({outputPath:o,plugin:p,tsConfig:a}),await bm(s,o,e,r),await Om(J__default.default.resolve(n.output.path,"core"),e,r);let c={};for(let m of n.pluginOrder){let l=n.plugins[m],f=(l.output??"").split("/"),u=J__default.default.resolve(n.output.path,...f.slice(0,f.length-1));c[l.name]=new xe({dir:u,id:`legacy-unused-${l.name}`,name:`${f[f.length-1]}.ts`}),l.handlerLegacy?.({client:e,files:c,openApi:s,plugin:l});}Sm({files:c}),Object.entries(c).forEach(([m,l])=>{n.dryRun||(m==="index"?l.write(`
|
|
37
37
|
`,a):l.write(`
|
|
38
38
|
|
|
39
39
|
`,a));});};var Tm=async({context:e})=>{let t=J__default.default.resolve(e.config.output.path);e.config.output.clean&&Rn(t);let r=On(bn(e.config.output.tsConfigPath)),n=r?.options.moduleResolution===b__default.default.ModuleResolutionKind.NodeNext,s=E(e.config);"bundle"in s.config&&s.config.bundle&&An({outputPath:t,plugin:s,tsConfig:r});for(let o of e.registerPlugins())await o.run();if(!e.config.dryRun){let o=e.createFile({id:"_index",path:"index"});for(let a of Object.values(e.files))if(a.nameWithoutExtension()!==o.nameWithoutExtension()){if(!a.isEmpty()&&a.exportFromIndex&&e.config.output.indexFile){let c=o.relativePathToFile({context:e,id:a.id});n&&(c.startsWith("./")||c.startsWith("../"))&&(c==="./client"?c="./client/index.js":c=`${c}.js`),o.add(i.exportAllDeclaration({module:c}));}a.write(`
|