@hey-api/openapi-ts 0.86.7 → 0.86.8

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.
@@ -20,5 +20,5 @@ ${r}`,d.default.writeFileSync(e,r,`utf8`)},Tl=({meta:e,outputPath:t,plugin:n,pro
20
20
  `,t=null){if(this.isEmpty()){this.remove({force:!0});return}let n=this._path;if(typeof this._path==`string`){let e=this._path.split(f.default.sep);n=e.slice(0,e.length-1).join(f.default.sep)}ie(n),d.default.writeFileSync(this._path,this._toString(e,t))}};const hu=e=>{let t=e.match(/\.[0-9a-z]+$/i),n=t?t[0].slice(1):``;return{extension:n,name:e.slice(0,e.length-(n?n.length+1:0))}},gu=(e,t)=>{let n=x();if(Array.isArray(e))return e.map(e=>gu(e));if(typeof e!=`object`||!e)return e;let r={...e};return Object.entries(r).forEach(([e,i])=>{if(n.plugins[`@hey-api/schemas`]?.config.type===`form`&&[`description`,`x-enum-descriptions`,`x-enum-varnames`,`x-enumNames`,`title`].includes(e)&&t!==`properties`){delete r[e];return}e===`$ref`&&typeof i==`string`&&(r[e]=decodeURIComponent(i)),i&&typeof i==`object`&&(r[e]=gu(i,e))}),r},_u=(e,t)=>{let n=x(),r=br(e),i=n.plugins[`@hey-api/schemas`];return i?.config.nameBuilder?typeof i.config.nameBuilder==`function`?i.config.nameBuilder(r,t):i.config.nameBuilder.replace(`{{name}}`,r):`${r}Schema`},vu=({files:e,openApi:t,plugin:n})=>{e.schemas=new mu({dir:x().output.path,exportFromIndex:n.config.exportFromIndex,id:`schemas`,name:`schemas.ts`});let r=(t,n)=>{let r=gu(n),i=I.objectExpression({obj:r}),a=I.constVariable({assertion:`const`,exportConst:!0,expression:i,name:_u(t,n)});e.schemas.add(a)};`swagger`in t&&Object.entries(t.definitions??{}).forEach(([e,t])=>{r(e,t)}),`openapi`in t&&Object.entries(t.components?.schemas??{}).forEach(([e,t])=>{r(e,t)})},yu={api:new iu({name:`@hey-api/schemas`}),config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:pu,handlerLegacy:vu,name:`@hey-api/schemas`},bu=C(yu);var xu=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Su=({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`})})}),n=e.referenceSymbol(e.api.selector(`Client`)),r=b(e.context.config),i=r.api&&`selector`in r.api?e.getSymbol(r.api.selector(`client`)):void 0;return[I.propertyDeclaration({initializer:i?I.identifier({text:i.placeholder}):void 0,modifier:`protected`,name:`_client`,type:I.typeReferenceNode({typeName:n.placeholder})}),I.identifier({text:`
21
21
  `}),I.constructorDeclaration({multiLine:!0,parameters:[{isRequired:!e.config.client,name:`args`,type:I.typeInterfaceNode({properties:[{isRequired:!e.config.client,name:`client`,type:n.placeholder}],useLegacyResolution:!1})}],statements:[e.config.client?I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`args`}),isOptional:!0,name:`client`}),thenStatement:I.block({statements:[t]})}):t]})]},Cu=({plugin:e})=>{let t=b(e.context.config),n=t.name===`@hey-api/client-angular`,r=t.name===`@hey-api/client-nuxt`,i=new Map,a=new Set,o=e.config.instance?Su({plugin:e}):[];e.forEach(`operation`,({operation:a})=>{let o=$c({context:e.context,operation:a}),s=e.getPluginOrThrow(`@hey-api/typescript`),c=r?e.getSymbol(s.api.selector(`response`,a.id)):void 0,l=qc({context:e.context,operation:a,plugin:e});for(let s of l.values())s.path.forEach((l,u)=>{let d=e.referenceSymbol(e.api.selector(`class`,l));i.has(d.id)||i.set(d.id,{className:l,classes:new Set,id:d.id,methods:new Set,nodes:[],root:!u});let f=s.path[u-1];if(f){let t=e.referenceSymbol(e.api.selector(`class`,f));if(t.placeholder!==d.placeholder){let e=i.get(t.id);e.classes.add(d.id),i.set(t.id,e)}}if(s.path.length!==u+1)return;let p=i.get(d.id);if(p.methods.has(s.methodName))return;let m=Yc({isRequiredOptions:o,operation:a,plugin:e}),h=Zc({isRequiredOptions:o,opParameters:m,operation:a,plugin:e}),g=I.methodDeclaration({accessLevel:`public`,comment:Qc({operation:a}),isStatic:n?!1:!e.config.instance,name:s.methodName,parameters:m.parameters,returnType:void 0,statements:h,types:r?[{default:I.ots.string(`$fetch`),extends:I.typeNode(e.referenceSymbol(e.api.selector(`Composable`)).placeholder),name:Bc},{default:c?I.typeReferenceNode({typeName:c.placeholder}):I.typeNode(`undefined`),extends:c?I.typeReferenceNode({typeName:c.placeholder}):void 0,name:Vc}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]});p.nodes.length?p.nodes.push(I.identifier({text:`
22
22
  `}),g):p.nodes.push(g),p.methods.add(s.methodName),i.set(d.id,p)})},{order:`declarations`});let s=e.registerSymbol({exported:!1,meta:{path:[]},name:`_HeyApiClient`}),c=t=>{if(a.has(t.id))return;if(t.classes.size)for(let n of t.classes){let r=i.get(n);c(r),t.nodes.push(I.propertyDeclaration({initializer:e.config.instance?I.newExpression({argumentsArray:e.config.instance?[I.objectExpression({multiLine:!1,obj:[{key:`client`,value:I.propertyAccessExpression({expression:I.this(),name:`_client`})}]})]:[],expression:I.identifier({text:e.referenceSymbol(r.id).placeholder})}):I.identifier({text:e.referenceSymbol(r.id).placeholder}),modifier:e.config.instance?void 0:`static`,name:T({case:`camelCase`,value:r.className})}))}let r=e.registerSymbol({exported:!0,meta:{path:[]},name:t.className,selector:e.api.selector(`class`,t.className)}),o=I.classDeclaration({decorator:t.root&&n?{args:[{providedIn:`root`}],name:e.referenceSymbol(e.api.selector(`Injectable`)).placeholder}:void 0,exportClass:r.exported,extendedClasses:e.config.instance?[s.placeholder]:void 0,name:r.placeholder,nodes:t.nodes});e.setSymbolValue(r,o),a.add(r.id)};if(o.length){let t=I.classDeclaration({exportClass:s.exported,name:s.placeholder,nodes:o});e.setSymbolValue(s,t)}for(let e of i.values())c(e)},wu=({meta:e,onImport:t,...n})=>{if(!e)return{created:!1,name:``};let{created:r,name:i}=Vs({meta:e,...n});return i&&t(i),{created:r,name:i}},Tu=e=>`${e}ModelResponseTransformer`,Eu=e=>`${T({case:`PascalCase`,value:e})}Data`,Du=e=>`${T({case:`PascalCase`,value:e})}Error`,Ou=e=>`${e}Transformer`,ku=e=>`${T({case:`PascalCase`,value:e})}Response`,Au=({importedType:e,throwOnError:t})=>{let n=`OptionsLegacyParser`;return t?`${n}<${e||`unknown`}, ${t}>`:e?`${n}<${e}>`:n},ju=(e,t)=>{let n=x(),{name:r}=Vs({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Eu}),i=Gs(t.parameters);if(!S(n))return[{isRequired:i,name:`options`,type:Au({importedType:r,throwOnError:`ThrowOnError`})}];if(!t.parameters.length)return[];let a=e=>{if(e.default!==void 0)return JSON.stringify(e.default,null,4)};return n.useOptions?[{default:i?void 0:{},name:`data`,type:r}]:t.parameters.map(e=>{let t=`${r}['${e.name}']`;return{default:e?.default,isRequired:(!e.isRequired&&!a(e)?`?`:``)==``,name:e.name,type:t}})},Mu=(e,t)=>{let n=x(),r=I.typeNode(`void`);if(t.responses.filter(e=>e.responseTypes.includes(`success`)).length){let{name:n}=Vs({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:ku});r=I.typeUnionNode({types:[n]})}return n.useOptions&&n.plugins[`@hey-api/sdk`]?.config.response===`response`&&(r=I.typeNode(`ApiResult`,[r])),r=b(n).name===`legacy/angular`?I.typeNode(`Observable`,[r]):I.typeNode(`CancelablePromise`,[r]),r},Nu=e=>{let t=x();if(!S(t))return[e.deprecated&&`@deprecated`,e.summary&&j(e.summary),e.description&&j(e.description)];let n=[];e.parameters.length&&(n=t.useOptions?[`@param data The data for the request.`,...e.parameters.map(e=>`@param data.${e.name} ${e.description?j(e.description):``}`)]:e.parameters.map(e=>`@param ${e.name} ${e.description?j(e.description):``}`));let r=e.responses.filter(e=>e.responseTypes.includes(`success`));return[e.deprecated&&`@deprecated`,e.summary&&j(e.summary),e.description&&j(e.description),...n,...r.map(e=>`@returns ${e.type} ${e.description?j(e.description):``}`),`@throws ApiError`]},Pu=({client:e,onClientImport:t,onImport:n,operation:r})=>{let i=x(),a=ku(r.name),{name:o}=Vs({client:e,meta:{$ref:`transformers/${a}`,name:a},nameTransformer:Ou});if(o&&n(o),!S(i)){let e=[{spread:`options`}],n=r.parameters.filter(e=>e.in===`body`||e.in===`formData`).map(e=>e.mediaType||(e.in===`formData`?`multipart/form-data`:void 0)).filter(Boolean).filter(ds);return n.length===1&&(n[0]===`multipart/form-data`&&(e=[...e,{spread:`formDataBodySerializer`},{key:`headers`,value:[{key:`Content-Type`,value:null},{spread:`options?.headers`}]}],t?.(`formDataBodySerializer`)),n[0]===`application/x-www-form-urlencoded`&&(e=[...e,{spread:`urlSearchParamsBodySerializer`},{key:`headers`,value:[{key:`Content-Type`,value:n[0]},{spread:`options?.headers`}]}],t?.(`urlSearchParamsBodySerializer`))),e=[...e,{key:`url`,value:r.path}],o&&(e=[...e,{key:`responseTransformer`,value:o}]),I.objectExpression({identifiers:[`responseTransformer`],obj:e})}let s=e=>e.reduce((e,t)=>{let n=t.prop,r=i.useOptions?`data.${t.name}`:t.name;return n===r?e[n]=n:St(n)===n?e[n]=r:e[`'${n}'`]=r,e},{}),c={method:r.method,url:r.path};r.parametersPath.length&&(c.path=s(r.parametersPath)),r.parametersCookie.length&&(c.cookies=s(r.parametersCookie)),r.parametersHeader.length&&(c.headers=s(r.parametersHeader)),r.parametersQuery.length&&(c.query=s(r.parametersQuery)),r.parametersForm.length&&(c.formData=s(r.parametersForm)),r.parametersBody&&(r.parametersBody.in===`formData`&&(i.useOptions?c.formData=`data.${r.parametersBody.name}`:c.formData=r.parametersBody.name),r.parametersBody.in===`body`&&(i.useOptions?c.body=`data.${r.parametersBody.name}`:c.body=r.parametersBody.name)),r.parametersBody?.mediaType&&(c.mediaType=r.parametersBody?.mediaType),r.responseHeader&&(c.responseHeader=r.responseHeader),o&&(c.responseTransformer=o);let l=r.responses.filter(e=>e.responseTypes.includes(`error`));if(l.length>0){let e={};l.forEach(t=>{e[t.code]=t.description??``}),c.errors=e}return I.objectExpression({identifiers:[`body`,`cookies`,`formData`,`headers`,`path`,`query`,`responseTransformer`],obj:c,shorthand:!0})},Fu=({config:e,handleIllegal:t,id:n,operation:r})=>e.plugins[`@hey-api/sdk`]?.config.methodNameBuilder?e.plugins[`@hey-api/sdk`].config.methodNameBuilder(r):t&&n.match(gt)?`${n}_`:n,Iu=({client:e,onClientImport:t,onImport:n,operation:r})=>{let i=x(),a=Pu({client:e,onClientImport:t,onImport:n,operation:r});if(!S(i)){let t=Vs({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Du}).name,n=r.responses.filter(e=>e.responseTypes.includes(`success`)).length?Vs({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:ku}).name:`void`;return[I.returnFunctionCall({args:[a],name:`(options?.client ?? client).${r.method.toLocaleLowerCase()}`,types:t&&n?[n,t,`ThrowOnError`]:t?[`unknown`,t,`ThrowOnError`]:n?[n,`unknown`,`ThrowOnError`]:[]})]}return ve(i)?[I.returnFunctionCall({args:[a],name:`this.httpRequest.request`})]:b(i).name===`legacy/angular`?[I.returnFunctionCall({args:[`OpenAPI`,`this.http`,a],name:`__request`})]:[I.returnFunctionCall({args:[`OpenAPI`,a],name:`__request`})]},Lu=({client:e,onClientImport:t,onImport:n,onNode:r,service:i})=>{let a=x(),o=b(a),s=S(a);for(let t of i.operations)t.parameters.length&&wu({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Eu,onImport:n}),s||wu({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Du,onImport:n}),t.responses.filter(e=>e.responseTypes.includes(`success`)).length&&wu({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:ku,onImport:n});let c={default:(`throwOnError`in o.config?o.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`};if(!a.plugins[`@hey-api/sdk`]?.config.asClass&&!ve(a)){for(let l of i.operations){let i={parameters:ju(e,l),returnType:s?Mu(e,l):void 0,statements:Iu({client:e,onClientImport:t,onImport:n,operation:l}),types:s?void 0:[c]},u=o.name===`legacy/angular`?I.anonymousFunction(i):I.arrowFunction(i);r(I.constVariable({comment:Nu(l),exportConst:!0,expression:u,name:Fu({config:a,handleIllegal:!0,id:l.name,operation:l})}))}return}let l=i.operations.map(r=>I.methodDeclaration({accessLevel:`public`,comment:Nu(r),isStatic:ve(a)===void 0&&o.name!==`legacy/angular`,name:Fu({config:a,id:r.name,operation:r}),parameters:ju(e,r),returnType:s?Mu(e,r):void 0,statements:Iu({client:e,onClientImport:t,onImport:n,operation:r}),types:s?void 0:[c]}));if(!l.length)return;ve(a)?l=[I.constructorDeclaration({multiLine:!1,parameters:[{accessLevel:`public`,isReadOnly:!0,name:`httpRequest`,type:`BaseHttpRequest`}]}),...l]:o.name===`legacy/angular`&&(l=[I.constructorDeclaration({multiLine:!1,parameters:[{accessLevel:`public`,isReadOnly:!0,name:`http`,type:`HttpClient`}]}),...l]);let u=[];l.forEach((e,t)=>{t&&u.push(I.identifier({text:`
23
- `})),u.push(e)}),r(I.classDeclaration({decorator:o.name===`legacy/angular`?{args:[{providedIn:`root`}],name:`Injectable`}:void 0,exportClass:!0,name:as({config:a,name:i.name}),nodes:u}))},Ru=({client:e,files:t,plugin:n})=>{let r=x(),i=S(r);if(t.sdk=new mu({dir:r.output.path,exportFromIndex:n.config.exportFromIndex,id:`sdk`,name:`sdk.ts`}),!i)t.sdk.import({module:bl({config:r,sourceOutput:`sdk`}),name:`createClient`}),t.sdk.import({module:bl({config:r,sourceOutput:`sdk`}),name:`createConfig`}),t.sdk.import({asType:!0,module:bl({config:r,sourceOutput:`sdk`}),name:`OptionsLegacyParser`});else if(b(r).name===`legacy/angular`?(t.sdk.import({module:`@angular/core`,name:`Injectable`}),ve(r)||t.sdk.import({module:`@angular/common/http`,name:`HttpClient`}),t.sdk.import({asType:!0,module:`rxjs`,name:`Observable`})):t.sdk.import({asType:!0,module:`./core/CancelablePromise`,name:`CancelablePromise`}),r.plugins[`@hey-api/sdk`]?.config.response===`response`&&t.sdk.import({asType:!0,module:`./core/ApiResult`,name:`ApiResult`}),ve(r)){let e=b(r);t.sdk.import({asType:e.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(!i){let e=b(r),n=I.constVariable({exportConst:!0,expression:I.callExpression({functionName:`createClient`,parameters:[I.callExpression({functionName:`createConfig`,parameters:[`throwOnError`in e&&e.throwOnError?I.objectExpression({obj:[{key:`throwOnError`,value:!0}]}):void 0]})]}),name:`client`});t.sdk.add(n)}for(let n of e.services)Lu({client:e,onClientImport:e=>{t.sdk.import({module:bl({config:r,sourceOutput:`sdk`}),name:e})},onImport:e=>{t.sdk.import({asType:!e.endsWith(`Transformer`),module:`./${t.types.nameWithoutExtension()}`,name:e})},onNode:e=>{t.sdk.add(e)},service:n})},zu=({plugin:e})=>{let t=b(e.context.config),n=t.name===`@hey-api/client-nuxt`;e.forEach(`operation`,r=>{let{operation:i}=r,a=$c({context:e.context,operation:i}),o=e.getPluginOrThrow(`@hey-api/typescript`),s=n?e.getSymbol(o.api.selector(`response`,i.id)):void 0,c=Yc({isRequiredOptions:a,operation:i,plugin:e}),l=Zc({isRequiredOptions:a,opParameters:c,operation:i,plugin:e}),u=e.registerSymbol({meta:{path:r._path,tags:r.tags},name:Fu({config:e.context.config,handleIllegal:!0,id:i.id,operation:i}),selector:e.api.selector(`function`,i.id)}),d=I.constVariable({comment:Qc({operation:i}),exportConst:!0,expression:I.arrowFunction({parameters:c.parameters,returnType:void 0,statements:l,types:n?[{default:I.ots.string(`$fetch`),extends:I.typeNode(e.referenceSymbol(e.api.selector(`Composable`)).placeholder),name:Bc},{default:s?I.typeReferenceNode({typeName:s.placeholder}):I.typeNode(`undefined`),extends:s?I.typeReferenceNode({typeName:s.placeholder}):void 0,name:Vc}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]}),name:u.placeholder});e.setSymbolValue(u,d)},{order:`declarations`})},Bu=({plugin:e})=>{let t=xl(e.context.config),n=b(e.context.config).name===`@hey-api/client-nuxt`,r=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`TDataShape`}),i=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`Client`,selector:e.api.selector(`Client`)}),a=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`Options`}),o=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:`Options`,selector:e.api.selector(`Options`)}),s=I.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:I.typeIntersectionNode({types:[I.typeReferenceNode({typeArguments:n?[I.typeReferenceNode({typeName:`TComposable`}),I.typeReferenceNode({typeName:`TData`}),I.typeReferenceNode({typeName:Hc}),I.typeReferenceNode({typeName:Vc})]:[I.typeReferenceNode({typeName:`TData`}),I.typeReferenceNode({typeName:`ThrowOnError`})],typeName:a.placeholder}),I.typeInterfaceNode({properties:[{comment:["You can provide a client instance returned by `createClient()` instead of",`individual options. This might be also useful if you want to implement a`,`custom client.`],isRequired:!e.config.client,name:`client`,type:I.typeReferenceNode({typeName:i.placeholder})},{comment:["You can pass arbitrary values through the `meta` object. This can be",`used to access values that aren't defined as part of the SDK function.`],isRequired:!1,name:`meta`,type:I.typeReferenceNode({typeArguments:[I.keywordTypeNode({keyword:`string`}),I.keywordTypeNode({keyword:`unknown`})],typeName:`Record`})}],useLegacyResolution:!1})]}),typeParameters:n?[I.typeParameterDeclaration({constraint:I.typeReferenceNode({typeName:e.referenceSymbol(e.api.selector(`Composable`)).placeholder}),defaultType:I.typeNode(`'$fetch'`),name:`TComposable`}),I.typeParameterDeclaration({constraint:I.typeReferenceNode({typeName:r.placeholder}),defaultType:I.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),I.typeParameterDeclaration({defaultType:I.keywordTypeNode({keyword:`unknown`}),name:Hc}),I.typeParameterDeclaration({defaultType:I.keywordTypeNode({keyword:`undefined`}),name:Vc})]:[I.typeParameterDeclaration({constraint:I.typeReferenceNode({typeName:r.placeholder}),defaultType:I.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),I.typeParameterDeclaration({constraint:I.keywordTypeNode({keyword:`boolean`}),defaultType:I.keywordTypeNode({keyword:`boolean`}),name:`ThrowOnError`})]});e.setSymbolValue(o,s)},Vu=({plugin:e})=>{let t=xl(e.context.config);e.registerSymbol({external:t,name:`formDataBodySerializer`,selector:e.api.selector(`formDataBodySerializer`)}),e.registerSymbol({external:t,name:`urlSearchParamsBodySerializer`,selector:e.api.selector(`urlSearchParamsBodySerializer`)}),e.registerSymbol({external:t,name:`buildClientParams`,selector:e.api.selector(`buildClientParams`)});let n=b(e.context.config),r=n.name===`@hey-api/client-angular`;n.name===`@hey-api/client-nuxt`&&e.registerSymbol({external:t,meta:{kind:`type`},name:`Composable`,selector:e.api.selector(`Composable`)}),r&&e.config.asClass&&e.registerSymbol({external:`@angular/core`,name:`Injectable`,selector:e.api.selector(`Injectable`)}),Bu({plugin:e}),e.config.asClass?Cu({plugin:e}):zu({plugin:e})},Hu=e=>Vu(e),Uu={api:new xu({name:`@hey-api/sdk`}),config:{asClass:!1,auth:!0,classNameBuilder:`{{name}}`,classStructure:`auto`,client:!0,exportFromIndex:!0,instance:!1,operationId:!0,params_EXPERIMENTAL:`default`,response:`body`,responseStyle:`fields`,transformer:!1,validator:!1},dependencies:[`@hey-api/typescript`],handler:Hu,handlerLegacy:Ru,name:`@hey-api/sdk`,resolveConfig:(e,t)=>{e.config.client?(typeof e.config.client==`boolean`&&(e.config.client=t.pluginByTag(`client`,{defaultPlugin:`@hey-api/client-fetch`})),e.dependencies.add(e.config.client)):e.config.client=!1,e.config.transformer?(typeof e.config.transformer==`boolean`&&(e.config.transformer=t.pluginByTag(`transformer`)),e.dependencies.add(e.config.transformer)):e.config.transformer=!1,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=!1,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=!1,e.config.instance?(typeof e.config.instance!=`string`&&(e.config.instance=`Sdk`),e.config.asClass=!0):e.config.instance=!1,e.config.classNameBuilder===`{{name}}`&&e.config.client===`@hey-api/client-angular`&&(e.config.classNameBuilder=`{{name}}Service`)}},Wu=C(Uu);var Gu=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Ku=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:I.callExpression({functionName:`BigInt`,parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:e,name:`toString`})})]});if(n){if(typeof e==`string`)return[n];if(e)return[I.assignment({left:e,right:n})]}},qu=({dataExpression:e,schema:t})=>{if(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))return;let n=I.identifier({text:`Date`});if(typeof e==`string`)return[I.newExpression({argumentsArray:[I.identifier({text:e})],expression:n})];if(e)return[I.assignment({left:e,right:I.newExpression({argumentsArray:[e],expression:n})})]},Ju=`data`,Yu=e=>e.map(e=>m.default.isStatement(e)?e:I.expressionToStatement({expression:e})),Xu=({node:e})=>e.kind===m.default.SyntaxKind.ReturnStatement,Zu=({plugin:e,schema:t})=>{let n=I.identifier({text:Ju}),r=Qu({dataExpression:n,plugin:e,schema:t});return r.length&&!Xu({node:r[r.length-1]})&&r.push(I.returnStatement({expression:n})),r},Qu=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r=t.api.selector(`response-ref`,n.$ref);if(!t.getSymbol(r)){let e=t.registerSymbol({name:E({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:L(n.$ref)}),selector:r}),i=Zu({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(i.length){let n=I.constVariable({expression:I.arrowFunction({async:!1,multiLine:!0,parameters:[{name:Ju,type:I.keywordTypeNode({keyword:`any`})}],statements:Yu(i)}),name:e.placeholder});t.setSymbolValue(e,n)}}if(t.isSymbolRegistered(r)){let n=t.referenceSymbol(r),i=I.callExpression({functionName:n.placeholder,parameters:[e]});if(e)return typeof e==`string`&&e===`item`?[I.returnStatement({expression:i})]:[typeof e==`string`?i:I.assignment({left:e,right:i})]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?Qu({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=Yu(r);return i.some(e=>Xu({node:e}))||i.push(I.returnStatement({expression:I.identifier({text:`item`})})),[I.assignment({left:e,right:I.callExpression({functionName:I.propertyAccessExpression({expression:e,name:`map`}),parameters:[I.arrowFunction({multiLine:!0,parameters:[{name:`item`,type:`any`}],statements:i})]})})]}if(n.type===`object`){let r=[],i=n.required??[];for(let a in n.properties){let o=n.properties[a],s=I.propertyAccessExpression({expression:e||Ju,name:a}),c=Qu({dataExpression:s,plugin:t,schema:o});if(!c.length)continue;let l=!o.items?.find(e=>e.type===`null`);i.includes(a)&&l?r=r.concat(c):r.push(I.ifStatement({expression:s,thenStatement:I.block({statements:Yu(c)})}))}return r}if(n.items){if(n.items.length===1)return Qu({dataExpression:`item`,plugin:t,schema:n.items[0]});let r=[];if(n.logicalOperator===`and`||n.items.length===2&&n.items.find(e=>e.type===`null`||e.type===`void`)){for(let i of n.items){let n=Qu({dataExpression:e||`item`,plugin:t,schema:i});if(n.length)if(e)r=r.concat(n);else{let e=I.identifier({text:`item`});r.push(I.ifStatement({expression:e,thenStatement:I.block({statements:Yu(n)})}),I.returnStatement({expression:e}))}}return r}n.type!==`enum`&&((n.items??[]).every(e=>[`boolean`,`integer`,`null`,`number`,`string`].includes(e.type))||console.warn(`❗️ Transformers warning: schema ${JSON.stringify(n)} is too complex and won't be currently processed. This will likely produce an incomplete transformer which is not what you want. Please open an issue if you'd like this improved https://github.com/hey-api/openapi-ts/issues`))}for(let r of t.config.transformers){let i=r({config:t.config,dataExpression:e,schema:n});if(i)return i}return[]},$u=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=ut(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${k(t)} has ${n.items.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);return}let r=e.getPluginOrThrow(`@hey-api/typescript`),i=e.getSymbol(r.api.selector(`response`,t.id));if(!i)return;let a=Zu({plugin:e,schema:n});if(!a.length)return;let o=e.registerSymbol({exported:!0,name:E({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id}),selector:e.api.selector(`response`,t.id)}),s=I.constVariable({exportConst:o.exported,expression:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:Ju,type:I.keywordTypeNode({keyword:`any`})}],returnType:I.typeReferenceNode({typeArguments:[I.typeReferenceNode({typeName:i.placeholder})],typeName:`Promise`}),statements:Yu(a)}),name:o.placeholder});e.setSymbolValue(o,s)},{order:`declarations`})},ed=`$OpenApiTs`,K={$refs:[],base:``,description:null,enum:[],enums:[],export:`interface`,imports:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:``,properties:[],template:null,type:``},td=({comments:e,leadingComment:t,meta:n,obj:r,onNode:i,...a})=>{if(!n)return;let{created:o,name:s}=Vs({create:!0,meta:n,...a});if(o){let n=x().plugins[`@hey-api/typescript`];i(I.enumDeclaration({asConst:typeof n?.config.enums==`object`&&n.config.enums.mode===`typescript-const`,comments:e,leadingComment:t,name:s,obj:r}))}},nd=({comment:e,meta:t,onCreated:n,onNode:r,type:i,...a})=>{if(!t)return{created:!1,name:``};let o=Vs({create:!0,meta:t,...a}),{created:s,name:c}=o;return s&&(r(I.typeAliasDeclaration({comment:e,exportType:!0,name:c,type:i})),n?.(c)),o},rd=e=>{let t=[];od(e),e.model.enums.forEach(n=>ad({...e,model:n,onNode:e=>{t.push(e)}})),t.length&&e.onNode(I.namespaceDeclaration({name:e.model.name,statements:t}))},id=({client:e,model:t,onNode:n})=>{let r=x(),i={},a={};t.enum.forEach(e=>{let{key:t,value:n}=Os(e);i[t]=n;let r=e.customDescription||e.description;r&&(a[t]=[j(r)])});let o=[t.description&&j(t.description),t.deprecated&&`@deprecated`],s=r.plugins[`@hey-api/typescript`];if(s?.config&&typeof s.config.enums==`object`&&s.config.enums.enabled&&(s.config.enums.mode===`typescript`||s.config.enums.mode===`typescript-const`)){td({asConst:s.config.enums.mode===`typescript-const`,client:e,comments:a,leadingComment:o,meta:t.meta,obj:i,onNode:n});return}nd({client:e,comment:o,meta:t.meta,onCreated:e=>{let t=r.plugins[`@hey-api/typescript`];if(t?.config&&typeof t.config.enums==`object`&&t.config.enums.enabled&&t.config.enums.mode===`javascript`){let t=I.objectExpression({multiLine:!0,obj:Object.entries(i).map(([e,t])=>({comments:a[e],key:e,value:t})),unescape:!0});n(I.constVariable({assertion:`const`,comment:o,exportConst:!0,expression:t,name:e}))}},onNode:n,type:Es(t.enum)})},ad=({model:e,onNode:t})=>{let n={},r={};e.enum.forEach(e=>{let{key:t,value:i}=Os(e);n[t]=i;let a=e.customDescription||e.description;a&&(r[t]=[j(a)])});let i=x().plugins[`@hey-api/typescript`];t(I.enumDeclaration({asConst:typeof i?.config.enums==`object`&&i.config.enums.mode===`typescript-const`,comments:r,leadingComment:[e.description&&j(e.description),e.deprecated&&`@deprecated`],name:e.meta?.name||e.name,obj:n}))},od=({client:e,model:t,onNode:n})=>{nd({client:e,comment:[t.description&&j(t.description),t.deprecated&&`@deprecated`],meta:t.meta,onNode:n,type:Bs(t)})},sd=e=>{switch(e.model.export){case`all-of`:case`any-of`:case`one-of`:case`interface`:return rd(e);case`enum`:return id(e);default:return od(e)}},cd=({client:e,onNode:t})=>{let n={},r=x();if(!r.plugins[`@hey-api/sdk`]&&!r.plugins[`@hey-api/typescript`]?.config.tree)return;let i=S(r);for(let r of e.services)for(let a of r.operations){if(!a.parameters.length&&!a.responses.length)continue;n[a.path]||(n[a.path]={});let r=n[a.path];r[a.method]||(r[a.method]={});let o=r[a.method];if(o.$ref=a.name,a.responses.length>0){if(o.res||={},Array.isArray(o.res))continue;a.responses.forEach(e=>{o.res[e.code]=e})}if(a.parameters.length>0){let n={mediaType:null,...K,in:`body`,name:`body`,prop:`body`},r=a.parameters.filter(e=>e.in===`body`);r.length||(r=a.parameters.filter(e=>e.in===`formData`)),r.length===1?n={...K,...r[0],in:`body`,isRequired:r[0].isRequired,name:`body`,prop:`body`}:r.length>1&&(n={...K,in:`body`,isRequired:r.some(e=>e.isRequired),mediaType:`multipart/form-data`,name:`body`,prop:`body`,properties:r});let s={...K,in:`header`,isRequired:Gs(a.parameters.filter(e=>e.in===`header`)),mediaType:null,name:i?`header`:`headers`,prop:i?`header`:`headers`,properties:a.parameters.filter(e=>e.in===`header`).sort(Cs)},c={...K,in:`path`,isRequired:Gs(a.parameters.filter(e=>e.in===`path`)),mediaType:null,name:`path`,prop:`path`,properties:a.parameters.filter(e=>e.in===`path`).sort(Cs)},l={...K,in:`query`,isRequired:Gs(a.parameters.filter(e=>e.in===`query`)),mediaType:null,name:`query`,prop:`query`,properties:a.parameters.filter(e=>e.in===`query`).sort(Cs)},u=i?ws([...a.parameters]):[n,s,c,l].filter(e=>e.properties.length||e.$refs.length||e.mediaType);o.req=u,nd({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:Eu,onNode:t,type:Bs({...K,isRequired:!0,properties:u})})}let s=a.responses.filter(e=>e.responseTypes.includes(`success`));if(s.length>0){nd({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:ku,onNode:t,type:Bs({...K,export:`any-of`,isRequired:!0,properties:s})});let n=a.responses.filter(e=>e.responseTypes.includes(`error`));i||nd({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:Du,onNode:t,type:Bs(n.length?{...K,export:`one-of`,isRequired:!0,properties:n}:{...K,base:`unknown`,isRequired:!0,type:`unknown`})})}}let a=Object.entries(n).map(([t,n])=>{let r=Object.entries(n).map(([t,n])=>{let r=t,i=[];if(n.req){let t=n.$ref,{name:r}=Vs({client:e,meta:{$ref:t,name:t},nameTransformer:Eu}),a={...K,base:r,export:`reference`,isRequired:!0,name:`req`,properties:[],type:r};i=[...i,a]}if(n.res){let e=Object.entries(n.res).map(([e,t])=>({...K,...t,isRequired:!0,name:String(e)})),t={...K,isRequired:!0,name:`res`,properties:e};i=[...i,t]}return{...K,isRequired:!0,name:r.toLocaleLowerCase(),properties:i}}).filter(Boolean);return{...K,isRequired:!0,name:`'${t}'`,properties:r}});r.plugins[`@hey-api/typescript`]?.config.tree&&nd({client:e,meta:{$ref:`@hey-api/openapi-ts`,name:`$OpenApiTs`},onNode:t,type:Bs({...K,properties:a})})},ld=({client:e,files:t,plugin:n})=>{t.types=new mu({dir:x().output.path,exportFromIndex:n.config.exportFromIndex,id:`types`,name:`types.ts`});let r=e=>{t.types?.add(e)};for(let t of e.models)sd({client:e,model:t,onNode:r});cd({client:e,onNode:r})},ud=`data`,dd=e=>e.base===`unknown`&&e.export===`generic`&&e.type===`unknown`,fd=({client:e,model:t})=>t.$refs.map(t=>{let n=e.models.find(e=>e.meta?.$ref===t);if(!n)throw Error(`Ref ${t} could not be found. Transformers cannot be generated without having access to all refs.`);return n}),pd=e=>{let t=e.model.meta.name,{name:n}=nd({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:Tu,onCreated:n=>{let r=gd({...e,meta:{$ref:`transformers/${t}`,name:n},path:[ud]});_d({...e,async:!1,name:n,statements:r})},type:`(${ud}: any) => ${t}`});return{created:!!e.client.types[n],name:n}},md=e=>{let{model:t}=e,n=fd(e);if(n.length===1){let{created:t,name:r}=pd({...e,model:n[0]});return t?[I.transformArrayMutation({path:e.path,transformerName:r})]:[]}return Ms(t)||t.link&&!Array.isArray(t.link)&&t.link.export===`any-of`&&t.link.properties.find(e=>Ms(e))?[I.transformArrayMap({path:e.path,transformExpression:I.conditionalExpression({condition:I.identifier({text:`item`}),whenFalse:I.identifier({text:`item`}),whenTrue:I.transformNewDate({parameterName:`item`})})})]:[]},hd=e=>{let{model:t}=e,n=[...e.path,t.name];return t.type===`string`&&t.export!==`array`&&Ms(t)?[I.transformDateMutation({path:n})]:gd({...e,model:t,path:n})},gd=e=>{let{model:t}=e;switch(t.export){case`array`:return md(e);case`interface`:return t.properties.flatMap(t=>hd({...e,model:t}));case`reference`:{if(t.$refs.length!==1)return[];let n=fd(e),{created:r,name:i}=pd({...e,model:n[0]});return r?t.in===`response`?[I.expressionToStatement({expression:I.callExpression({functionName:i,parameters:[ud]})})]:I.transformFunctionMutation({path:e.path,transformerName:i}):[]}default:return[]}},_d=({async:e,client:t,name:n,onNode:r,onRemoveNode:i,statements:a})=>{let o={created:!1,name:n};if(!a.length)return Hs({client:t,name:n}),i?.(),o;let s=I.arrowFunction({async:e,multiLine:!0,parameters:[{name:ud}],statements:[...a,I.returnVariable({expression:ud})]});return r(I.constVariable({exportConst:!0,expression:s,name:n,typeName:n})),{created:!0,name:n}},vd=({client:e,files:t})=>{let n=x(),r=e=>{t.types?.add(e)},i=()=>{t.types?.removeNode_LEGACY()};for(let t of e.services)for(let a of t.operations){let t=a.responses.filter(e=>e.responseTypes.includes(`success`));if(!t.length)continue;let o=t.filter(e=>!dd(e));if(!o.length)continue;if(o.length>1){n.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${k(a)} has ${o.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 s=ku(a.name);nd({client:e,meta:{$ref:`transformers/${s}`,name:s},nameTransformer:Ou,onCreated:n=>{_d({async:!0,client:e,name:n,onNode:r,onRemoveNode:i,statements:t.length>1?t.flatMap(t=>{let n=gd({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t,onNode:r,onRemoveNode:i,path:[ud]});return n.length?[I.ifStatement({expression:I.safeAccessExpression([`data`]),thenStatement:I.block({statements:n})})]:[]}):gd({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t[0],onNode:r,onRemoveNode:i,path:[ud]})})},onNode:r,type:`(${ud}: any) => Promise<${s}>`})}},yd={api:new Gu({name:`@hey-api/transformers`}),config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:$u,handlerLegacy:vd,name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,qu]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,Ku])},tags:[`transformer`]},bd=C(yd),q=e=>({value:e}),J=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=q(e[n]));return t},xd=I.keywordTypeNode({keyword:`string`}),Sd=({server:e})=>{let t=ya(e.url);return t.protocol&&t.host?I.literalTypeNode({literal:I.stringLiteral({text:e.url})}):I.templateLiteralType({value:[t.protocol||xd,`://`,t.host||xd,t.port?`:${t.port}`:``,t.path||``]})},Cd=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=b(e.context.config),i=t.map(e=>Sd({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(I.typeIntersectionNode({types:[xd,m.default.factory.createTypeLiteralNode([])]})):i.push(xd);let a=I.typeInterfaceNode({properties:[{name:he(e.context.config),type:I.typeUnionNode({types:i})}],useLegacyResolution:!1}),o=I.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:a});e.setSymbolValue(n,o)},wd=({schema:e})=>{let t=[];return e.title&&t.push(j(e.title)),e.description&&(t.length&&t.push(``),t.push(j(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Td=({plugin:e,schema:t})=>{let n=[];return{obj:(t.items??[]).map((t,r)=>{let i=typeof t.const;n.includes(i)||n.push(i);let a;return a=t.title?t.title:i===`number`||i===`string`?`${t.const}`:i===`boolean`?t.const?`true`:`false`:t.const===null?`null`:`${r}`,a&&(a=T({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),A.lastIndex=0,A.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{comments:wd({schema:t}),key:a,value:t.const}}),typeofItems:n}},Ed=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=Td({plugin:e,schema:t});if(e.config.enums.mode===`javascript`){e.config.enums.constantsIgnoreNull&&r.typeofItems.includes(`object`)&&(r.obj=r.obj.filter(e=>e.value!==null));let i=I.constVariable({assertion:`const`,comment:wd({schema:t}),exportConst:!0,expression:I.objectExpression({multiLine:!0,obj:r.obj}),name:n.placeholder}),a=I.typeOfExpression({text:n.placeholder}),o=I.typeAliasDeclaration({comment:wd({schema:t}),exportType:!0,name:n.placeholder,type:I.indexedAccessTypeNode({indexType:I.typeOperatorNode({operator:`keyof`,type:a}),objectType:a})});e.setSymbolValue(n,[i,o]);return}else if((e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&!r.typeofItems.some(e=>e!==`number`&&e!==`string`)){let i=I.enumDeclaration({asConst:e.config.enums.mode===`typescript-const`,leadingComment:wd({schema:t}),name:n.placeholder,obj:r.obj});e.setSymbolValue(n,i);return}}let i=I.typeAliasDeclaration({comment:wd({schema:t}),exportType:n.exported,name:n.placeholder,type:r});e.setSymbolValue(n,i)},Dd=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=D({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},Od=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];r.properties||={},e.body?(r.properties.body=e.body.schema,e.body.required&&i.push(`body`)):r.properties.body={type:`never`},e.parameters?.header&&(r.properties.headers=Dd({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=Dd({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=Dd({parameters:e.parameters.query}),r.properties.query.required&&i.push(`query`)):r.properties.query={type:`never`},r.properties.url={const:e.path,type:`string`},i.push(`url`),r.required=i;let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.requests,name:e.id}),selector:t.api.selector(`data`,e.id)}),o=Y({plugin:t,schema:r,state:n}),s=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s)},kd=({operation:e,plugin:t,state:n})=>{Od({operation:e,plugin:t,state:n});let{error:r,errors:i,response:a,responses:o}=ut(e);if(i){let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.errors,name:e.id}),selector:t.api.selector(`errors`,e.id)}),o=Y({plugin:t,schema:i,state:n}),s=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});if(t.setSymbolValue(a,s),r){let r=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),selector:t.api.selector(`error`,e.id)}),i=I.indexedAccessTypeNode({indexType:I.typeOperatorNode({operator:`keyof`,type:I.typeReferenceNode({typeName:a.placeholder})}),objectType:I.typeReferenceNode({typeName:a.placeholder})}),o=I.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});t.setSymbolValue(r,o)}}if(o){let r=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.responses,name:e.id}),selector:t.api.selector(`responses`,e.id)}),i=Y({plugin:t,schema:o,state:n}),s=I.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});if(t.setSymbolValue(r,s),a){let i=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),selector:t.api.selector(`response`,e.id)}),a=I.indexedAccessTypeNode({indexType:I.typeOperatorNode({operator:`keyof`,type:I.typeReferenceNode({typeName:r.placeholder})}),objectType:I.typeReferenceNode({typeName:r.placeholder})}),o=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});t.setSymbolValue(i,o)}}},Ad=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];if(r.properties||={},e.body){let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id}),selector:t.api.selector(`webhook-payload`,e.id)}),o=Y({plugin:t,schema:e.body.schema,state:n}),s=I.typeAliasDeclaration({comment:wd({schema:e.body.schema}),exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s),t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:a.name,placeholder:a.placeholder,selector:t.api.selector(`ref`,a.placeholder)}),r.properties.body={$ref:a.placeholder},i.push(`body`)}else r.properties.body={type:`never`};r.properties.key={const:e.path,type:`string`},i.push(`key`),r.properties.path={type:`never`},r.properties.query={type:`never`},r.required=i;let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.webhooks,name:e.id}),selector:t.api.selector(`webhook-request`,e.id)}),o=Y({plugin:t,schema:r,state:n}),s=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});return t.setSymbolValue(a,s),a.placeholder},jd=({operation:e,plugin:t,state:n})=>Ad({operation:e,plugin:t,state:n}),Md=({plugin:e,symbolWebhooks:t,webhookNames:n})=>{if(!n.length)return;let r=I.typeUnionNode({types:n.map(e=>I.typeReferenceNode({typeName:e}))}),i=I.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:r});e.setSymbolValue(t,i)},Nd=({plugin:e,schema:t,state:n})=>{if(!t.items)return I.typeArrayNode(I.keywordTypeNode({keyword:e.config.topType}));t=D({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=Y({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});r.push(a)}),r.length===1?I.typeArrayNode(r[0]):t.logicalOperator===`and`?I.typeArrayNode(I.typeIntersectionNode({types:r})):I.typeArrayNode(I.typeUnionNode({types:r}))},Pd=({schema:e})=>e.const===void 0?I.keywordTypeNode({keyword:`boolean`}):I.literalTypeNode({literal:I.ots.boolean(e.const)}),Fd=({plugin:e,schema:t,state:n})=>Y({plugin:e,schema:{...t,type:void 0},state:n}),Id=e=>I.keywordTypeNode({keyword:`never`}),Ld=e=>I.literalTypeNode({literal:I.null()}),Rd=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?I.typeReferenceNode({typeName:`bigint`}):I.keywordTypeNode({keyword:`number`}):I.literalTypeNode({literal:I.ots.number(t.const)}),zd=({context:e,name:t})=>(A.lastIndex=0,A.test(t)?t.startsWith(`-`)?m.default.factory.createStringLiteral(t):m.default.factory.createNumericLiteral(t):T({case:e.config.output.case,value:t})),Bd=({plugin:e,schema:t,state:n})=>{let r,i,a=[],o=[],s=t.required??[],c=!1;for(let r in t.properties){let i=t.properties[r],l=Y({plugin:e,schema:i,state:{...n,path:q([...n.path.value,`properties`,r])}}),u=s.includes(r);a.push({comment:wd({schema:i}),isReadOnly:i.accessScope===`read`,isRequired:u,name:zd({context:e.context,name:r}),type:l}),o.push(i),u||(c=!0)}if(t.patternProperties)for(let e in t.patternProperties){let n=t.patternProperties[e];o.unshift(n)}let l=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,u=t.additionalProperties,d=u!==!1&&u?u:void 0;if(l||d&&(d.type!==`never`||!o.length)){let a=d;a&&a.type!==`never`?o.unshift(a):!l&&!o.length&&a&&a.type===`never`&&(o=[a]),c&&o.push({type:`undefined`}),i={isRequired:!t.propertyNames,name:`key`,type:o.length===1?Y({plugin:e,schema:o[0],state:n}):Y({plugin:e,schema:{items:o,logicalOperator:`or`},state:n})},t.propertyNames?.$ref&&(r=Y({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n}))}return I.typeInterfaceNode({indexKey:r,indexProperty:i,properties:a,useLegacyResolution:!1})},Vd=({plugin:e,schema:t})=>{if(t.const!==void 0)return I.literalTypeNode({literal:I.stringLiteral({text:t.const})});if(t.format){if(t.format===`binary`)return I.typeUnionNode({types:[I.typeReferenceNode({typeName:`Blob`}),I.typeReferenceNode({typeName:`File`})]});if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return I.typeReferenceNode({typeName:`Date`});if(t.format===`typeid`&&typeof t.example==`string`){let n=String(t.example).split(`_`);n.pop();let r=n.join(`_`),i=e.api.selector(`TypeID`,r);if(!e.getSymbol(i)){let t=e.api.selector(`TypeID`);if(!e.getSymbol(t)){let n=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:`TypeID`,selector:t}),r=I.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:I.templateLiteralType({value:[I.typeReferenceNode({typeName:`T`}),`_`,I.keywordTypeNode({keyword:`string`})]}),typeParameters:[I.typeParameterDeclaration({constraint:I.keywordTypeNode({keyword:`string`}),name:`T`})]});e.setSymbolValue(n,r)}let n=e.referenceSymbol(t),a=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:T({case:e.config.case,value:`${r}_id`}),selector:i}),o=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:I.typeReferenceNode({typeArguments:[I.literalTypeNode({literal:I.stringLiteral({text:r})})],typeName:n.placeholder})});e.setSymbolValue(a,o)}let a=e.referenceSymbol(i);return I.typeReferenceNode({typeName:a.placeholder})}}return I.keywordTypeNode({keyword:`string`})},Hd=({plugin:e,schema:t,state:n})=>{let r=[];return t.const&&Array.isArray(t.const)?r=t.const.map(t=>I.valueToExpression({value:t})??I.identifier({text:e.config.topType})):t.items&&t.items.forEach((t,i)=>{let a=Y({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});r.push(a)}),I.typeTupleNode({types:r})},Ud=e=>I.keywordTypeNode({keyword:`undefined`}),Wd=({plugin:e})=>I.keywordTypeNode({keyword:e.config.topType}),Gd=e=>I.keywordTypeNode({keyword:`void`}),Kd=({schema:e,...t})=>{let n=t.plugin.getPlugin(`@hey-api/transformers`);if(n?.config.typeTransformers)for(let t of n.config.typeTransformers){let n=t({schema:e});if(n)return n}switch(e.type){case`array`:return Nd({...t,schema:e});case`boolean`:return Pd({...t,schema:e});case`enum`:return Fd({...t,schema:e});case`integer`:case`number`:return Rd({...t,schema:e});case`never`:return Id({...t,schema:e});case`null`:return Ld({...t,schema:e});case`object`:return Bd({...t,schema:e});case`string`:return Vd({...t,schema:e});case`tuple`:return Hd({...t,schema:e});case`undefined`:return Ud({...t,schema:e});case`unknown`:return Wd({...t,schema:e});case`void`:return Gd({...t,schema:e})}},Y=({plugin:e,schema:t,state:n})=>{if(t.$ref){let n=e.referenceSymbol(e.api.selector(`ref`,t.$ref));return I.typeReferenceNode({typeName:n.placeholder})}if(t.type)return Kd({plugin:e,schema:t,state:n});if(t.items){if(t=D({detectFormat:!1,schema:t}),t.items){let r=[];for(let i of t.items){let t=Y({plugin:e,schema:i,state:n});r.push(t)}return t.logicalOperator===`and`?I.typeIntersectionNode({types:r}):I.typeUnionNode({types:r})}return Y({plugin:e,schema:t,state:n})}return Kd({plugin:e,schema:{type:`unknown`},state:n})},qd=({plugin:e,schema:t,state:n})=>{let r=Y({plugin:e,schema:t,state:n}),i=t.type===`enum`&&e.config.enums.enabled,a=mr(n.path.value);Ed({plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{kind:i?void 0:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:L(a)}),selector:e.api.selector(`ref`,a)}),type:r})},Jd=({plugin:e})=>{let t=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:E({config:{case:e.config.case},name:`ClientOptions`}),selector:e.api.selector(`ClientOptions`)}),n=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:E({config:{case:e.config.case},name:`Webhooks`}),selector:e.api.selector(`Webhooks`)}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=J({path:t._path,tags:t.tags});switch(t.type){case`operation`:kd({operation:t.operation,plugin:e,state:n});break;case`parameter`:qd({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:qd({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:qd({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(jd({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),Cd({plugin:e,servers:r,symbolClientOptions:t}),Md({plugin:e,symbolWebhooks:n,webhookNames:i})};var Yd=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}schemaToType(e){return Y(e)}};const Xd=e=>Jd(e),Zd={api:new Yd({name:`@hey-api/typescript`}),config:{case:`PascalCase`,exportFromIndex:!0,style:`preserve`,topType:`unknown`,tree:!1},handler:Xd,handlerLegacy:ld,name:`@hey-api/typescript`,resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.definitions}),e.config.enums=t.valueToObject({defaultValue:{case:`SCREAMING_SNAKE_CASE`,constantsIgnoreNull:!1,enabled:!!e.config.enums,mode:`javascript`},mappers:{boolean:e=>({enabled:e}),string:e=>({mode:e})},value:e.config.enums}),e.config.errors=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,error:`{{name}}Error`,name:`{{name}}Errors`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.errors}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}Data`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}Responses`,response:`{{name}}Response`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}WebhookRequest`,payload:`{{name}}WebhookPayload`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.webhooks})}},Qd=C(Zd);var $d=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const ef=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return I.valueToExpression({value:i})},tf=({operation:e,plugin:t})=>Jc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),nf=({operation:e,plugin:t})=>{let n=b(t.context.config),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`error`,e.id))?.placeholder;return i||=`Error`,n.name===`@hey-api/client-axios`&&(i=`${t.referenceSymbol(t.api.selector(`AxiosError`)).placeholder}<${i}>`),i},rf=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},af=({plugin:e,typeData:t})=>{let n=b(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},of=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`UseMutationOptions`)),i=tf({operation:e,plugin:t}),a=nf({operation:e,plugin:t}),o=rf({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=af({plugin:t,typeData:i}),l=s?`${r.placeholder}<${o}, ${c}, ${a}>`:`${r.placeholder}<${o}, ${i}, ${a}>`,u=`fnOptions`,d=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:u},{key:`throwOnError`,value:!0}]})]})}),f=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?f.push(I.returnVariable({expression:d})):f.push(I.constVariable({destructure:!0,expression:d,name:`data`}),I.returnVariable({expression:`data`}));let p=[{key:`mutation`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[s?{name:u,type:`Partial<${c}>`}:{name:u}],statements:f})}],m=ef(t,e,`mutationOptions`);m&&p.push({key:`meta`,value:m});let h=t.registerSymbol({exported:!0,name:E({config:t.config.mutationOptions,name:e.id})}),g=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:h.exported,expression:I.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${c}>`}],returnType:l,statements:[I.returnStatement({expression:I.objectExpression({obj:p})})]}),name:h.placeholder});t.setSymbolValue(h,g)},sf=`TOptions`,cf=I.identifier({text:`options`}),lf=({plugin:e})=>{let t=e.registerSymbol({name:E({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=e.referenceSymbol(e.api.selector(`_JSONValue`)),i=I.indexedAccessTypeNode({indexType:I.literalTypeNode({literal:I.ots.number(0)}),objectType:I.typeReferenceNode({typeArguments:[I.typeReferenceNode({typeName:sf})],typeName:n.placeholder})}),a=he(e.context.config),o=e.getPluginOrThrow(`@hey-api/sdk`),s=e.referenceSymbol(o.api.selector(`Options`)),c=b(e.context.config),l=c.api&&`selector`in c.api?e.getSymbol(c.api.selector(`client`)):void 0,u=xl(e.context.config),d=e.registerSymbol({external:u,name:`serializeQueryKeyValue`}),f=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:I.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:I.typeReferenceNode({typeName:sf})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:I.typeTupleNode({types:[i]}),statements:[I.constVariable({assertion:i,expression:I.objectExpression({multiLine:!1,obj:[{key:`_id`,value:I.identifier({text:`id`})},{key:a,value:I.identifier({text:`options?.${a} || (options?.client ?? ${l?.placeholder}).getConfig().${a}`})}]}),name:`params`,typeName:i}),I.ifStatement({expression:I.identifier({text:`tags`}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`tags`}),right:I.asExpression({expression:I.asExpression({expression:I.identifier({text:`tags`}),type:I.keywordTypeNode({keyword:`unknown`})}),type:I.typeReferenceNode({typeName:r.placeholder})})})})]})}),I.ifStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:cf,isOptional:!0,name:I.identifier({text:`body`})}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.constVariable({expression:I.callExpression({functionName:d.placeholder,parameters:[I.propertyAccessExpression({expression:`options`,name:`body`})]}),name:`normalizedBody`}),I.ifStatement({expression:I.binaryExpression({left:I.identifier({text:`normalizedBody`}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`body`}),right:I.identifier({text:`normalizedBody`})})})]})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:cf,isOptional:!0,name:I.identifier({text:`path`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`path`}),right:I.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),I.ifStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:cf,isOptional:!0,name:I.identifier({text:`query`})}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.constVariable({expression:I.callExpression({functionName:d.placeholder,parameters:[I.propertyAccessExpression({expression:`options`,name:`query`})]}),name:`normalizedQuery`}),I.ifStatement({expression:I.binaryExpression({left:I.identifier({text:`normalizedQuery`}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`query`}),right:I.identifier({text:`normalizedQuery`})})})]})})]})}),I.returnStatement({expression:I.arrayLiteralExpression({elements:[I.identifier({text:`params`})]})})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:s.placeholder})}),name:sf}]}),name:t.placeholder});e.setSymbolValue(t,f)},uf=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;r.tags&&t.tags&&t.tags.length>0&&(i=I.arrayLiteralExpression({elements:t.tags.map(e=>I.stringLiteral({text:e}))}));let a=n.referenceSymbol(n.api.selector(`createQueryKey`));return I.callExpression({functionName:a.placeholder,parameters:[I.ots.string(e),`options`,i]})},df=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`_JSONValue`)),n=[{name:`_id`,type:I.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:he(e.context.config),type:I.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`body`,type:I.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`query`,type:I.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:t.placeholder})}],r=e.getPluginOrThrow(`@hey-api/sdk`),i=e.referenceSymbol(r.api.selector(`Options`)),a=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`QueryKey`,selector:e.api.selector(`QueryKey`)}),o=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:I.typeTupleNode({types:[I.typeIntersectionNode({types:[I.typeReferenceNode({typeName:`Pick<${sf}, 'path'>`}),I.typeInterfaceNode({properties:n,useLegacyResolution:!0})]})]}),typeParameters:[{extends:I.typeReferenceNode({typeName:I.identifier({text:i.placeholder})}),name:sf}]});e.setSymbolValue(a,o)},ff=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=af({plugin:t,typeData:tf({operation:e,plugin:t})});return I.constVariable({exportConst:n.exported,expression:I.arrowFunction({parameters:[{isRequired:st(e),name:`options`,type:r}],statements:uf({id:e.id,operation:e,plugin:t})}),name:n.placeholder})},pf=`options`,mf=`context`,hf=({operation:e,plugin:t,queryFn:n})=>{if(el({operation:e}))return;let r=$c({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(df({plugin:t}),lf({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:E({config:t.config.queryKeys,name:e.id})}),r=ff({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=I.callExpression({functionName:n.placeholder,parameters:[pf]})}else{let n=t.referenceSymbol(t.api.selector(`createQueryKey`)),r;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(r=I.arrayLiteralExpression({elements:e.tags.map(e=>I.stringLiteral({text:e}))})),i=I.callExpression({functionName:n.placeholder,parameters:[I.ots.string(e.id),pf,r]})}let{strippedTypeData:a}=af({plugin:t,typeData:tf({operation:e,plugin:t})}),o=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:pf},{spread:mf},{key:`throwOnError`,value:!0}]})]})}),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(I.returnVariable({expression:o})):s.push(I.constVariable({destructure:!0,expression:o,name:`data`}),I.returnVariable({expression:`data`}));let c=[{key:`key`,value:i},{key:`query`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:mf}],statements:s})}],l=ef(t,e,`queryOptions`);l&&c.push({key:`meta`,value:l});let u=t.registerSymbol({exported:!0,name:E({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),d=t.registerSymbol({external:t.name,name:`defineQueryOptions`,selector:t.api.selector(`defineQueryOptions`)}),f=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:u.exported,expression:I.callExpression({functionName:d.placeholder,parameters:[I.arrowFunction({parameters:[{isRequired:r,name:pf,type:a}],statements:I.objectExpression({obj:c})})]}),name:u.placeholder});t.setSymbolValue(u,f)},gf=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:`type`},name:`UseMutationOptions`,selector:e.api.selector(`UseMutationOptions`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`UseQueryOptions`,selector:e.api.selector(`UseQueryOptions`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`_JSONValue`,selector:e.api.selector(`_JSONValue`)}),e.registerSymbol({external:`axios`,meta:{kind:`type`},name:`AxiosError`,selector:e.api.selector(`AxiosError`)});let t=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let r=t.config.asClass?qc({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(t.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>T({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(t.api.selector(`function`,n.id)).placeholder;e.hooks.operation.isQuery(n)&&e.config.queryOptions.enabled&&hf({operation:n,plugin:e,queryFn:a}),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&of({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},_f={api:new $d({name:`@pinia/colada`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:gf,name:`@pinia/colada`,resolveConfig:(e,t)=>{e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Query`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},vf=C(_f),yf=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return I.valueToExpression({value:i})},bf=({operation:e,plugin:t})=>Jc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),xf=({operation:e,plugin:t})=>{let n=b(t.context.config),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`error`,e.id))?.placeholder;return i||=t.referenceSymbol(t.api.selector(`DefaultError`)).placeholder,n.name===`@hey-api/client-axios`&&(i=`${t.referenceSymbol(t.api.selector(`AxiosError`)).placeholder}<${i}>`),i},Sf=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},Cf=`TOptions`,wf=I.identifier({text:`infinite`}),Tf=I.identifier({text:`options`}),Ef=({plugin:e})=>{let t=e.registerSymbol({name:E({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=I.indexedAccessTypeNode({indexType:I.literalTypeNode({literal:I.ots.number(0)}),objectType:I.typeReferenceNode({typeArguments:[I.typeReferenceNode({typeName:Cf})],typeName:n.placeholder})}),i=he(e.context.config),a=b(e.context.config),o=a.api&&`selector`in a.api?e.getSymbol(a.api.selector(`client`)):void 0,s=e.getPluginOrThrow(`@hey-api/sdk`),c=e.referenceSymbol(s.api.selector(`Options`)),l=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:I.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:I.typeReferenceNode({typeName:Cf})},{isRequired:!1,name:`infinite`,type:I.typeReferenceNode({typeName:`boolean`})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:I.typeTupleNode({types:[r]}),statements:[I.constVariable({assertion:r,expression:I.objectExpression({multiLine:!1,obj:[{key:`_id`,value:I.identifier({text:`id`})},{key:i,value:I.identifier({text:`options?.${i} || (options?.client ?? ${o?.placeholder}).getConfig().${i}`})}]}),name:`params`,typeName:r}),I.ifStatement({expression:wf,thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:wf})})]})}),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:Tf,isOptional:!0,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:Tf,isOptional:!0,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:Tf,isOptional:!0,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:Tf,isOptional:!0,name:I.identifier({text:`query`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`query`}),right:I.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),I.returnStatement({expression:I.arrayLiteralExpression({elements:[I.identifier({text:`params`})]})})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:c.placeholder})}),name:Cf}]}),name:t.placeholder});e.setSymbolValue(t,l)},Df=({id:e,isInfinite:t,operation:n,plugin:r})=>{let i=t?r.config.infiniteQueryKeys:r.config.queryKeys,a;i.tags&&n.tags&&n.tags.length>0&&(a=I.arrayLiteralExpression({elements:n.tags.map(e=>I.stringLiteral({text:e}))}));let o=r.referenceSymbol(r.api.selector(`createQueryKey`));return I.callExpression({functionName:o.placeholder,parameters:[I.ots.string(e),`options`,t||a?I.ots.boolean(!!t):void 0,a]})},Of=({plugin:e})=>{let t=[{name:`_id`,type:I.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:I.keywordTypeNode({keyword:`boolean`})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],n=e.getPluginOrThrow(`@hey-api/sdk`),r=e.referenceSymbol(n.api.selector(`Options`)),i=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`QueryKey`,selector:e.api.selector(`QueryKey`)}),a=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:I.typeTupleNode({types:[I.typeIntersectionNode({types:[I.typeReferenceNode({typeName:`Pick<${Cf}, '${he(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),I.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:I.typeReferenceNode({typeName:I.identifier({text:r.placeholder})}),name:Cf}]});e.setSymbolValue(i,a)},kf=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=bf({operation:t,plugin:n});return I.constVariable({exportConst:r.exported,expression:I.arrowFunction({parameters:[{isRequired:st(t),name:`options`,type:a}],returnType:e?i:void 0,statements:Df({id:t.id,isInfinite:e,operation:t,plugin:n})}),name:r.placeholder})},Af=({plugin:e})=>{let t=e.registerSymbol({name:E({config:{case:e.config.case},name:`createInfiniteParams`}),selector:e.api.selector(`createInfiniteParams`)}),n=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:I.typeReferenceNode({typeName:`QueryKey<Options>`})},{name:`page`,type:I.typeReferenceNode({typeName:`K`})}],statements:[I.constVariable({expression:I.objectExpression({obj:[{spread:I.propertyAccessExpression({expression:`queryKey`,name:0})}]}),name:`params`}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`body`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`body`}),right:I.objectExpression({multiLine:!0,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:!0,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:!0,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:!0,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:m.default.factory.createTypeQueryNode(I.identifier({text:`page`}))})})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:t.placeholder});e.setSymbolValue(t,n)},jf=({operation:e,plugin:t,queryFn:n})=>{let r=ct({context:t.context,operation:e});if(!r)return;let i=$c({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Of({plugin:t}),Ef({plugin:t})),t.getSymbol(t.api.selector(`createInfiniteParams`))||Af({plugin:t});let a=t.referenceSymbol(t.api.selector(`infiniteQueryOptions`)),o=t.referenceSymbol(t.api.selector(`InfiniteData`)),s=bf({operation:e,plugin:t}),c=xf({operation:e,plugin:t}),l=Sf({operation:e,plugin:t}),u=`${t.referenceSymbol(t.api.selector(`QueryKey`)).placeholder}<${s}>`,d=`Pick<${u}[0], 'body' | 'headers' | 'path' | 'query'>`,f=t.getPluginOrThrow(`@hey-api/typescript`),p=`${Ot({node:f.api.schemaToType({plugin:f,schema:r.schema,state:{path:{value:[]}}}),unescape:!0})} | ${d}`,m=t.registerSymbol({exported:!0,name:E({config:t.config.infiniteQueryKeys,name:e.id})}),h=kf({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.setSymbolValue(m,h);let g=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),_=t.referenceSymbol(t.api.selector(`createInfiniteParams`)),v=[I.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:I.conditionalExpression({condition:I.binaryExpression({left:I.typeOfExpression({text:`pageParam`}),operator:`===`,right:I.ots.string(`object`)}),whenFalse:I.objectExpression({multiLine:!0,obj:[{key:r.in,value:I.objectExpression({multiLine:!0,obj:[{key:r.name,value:I.identifier({text:`pageParam`})}]})}]}),whenTrue:I.identifier({text:`pageParam`})}),name:`page`,typeName:d}),I.constVariable({expression:I.callExpression({functionName:_.placeholder,parameters:[`queryKey`,`page`]}),name:`params`})];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?v.push(I.returnVariable({expression:g})):v.push(I.constVariable({destructure:!0,expression:g,name:`data`}),I.returnVariable({expression:`data`}));let y=[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:v})},{key:`queryKey`,value:I.callExpression({functionName:m.placeholder,parameters:[`options`]})}],ee=yf(t,e,`infiniteQueryOptions`);ee&&y.push({key:`meta`,value:ee});let te=t.registerSymbol({exported:!0,name:E({config:t.config.infiniteQueryOptions,name:e.id})}),ne=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:te.exported,expression:I.arrowFunction({parameters:[{isRequired:i,name:`options`,type:s}],statements:[I.returnFunctionCall({args:[I.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:y})],name:a.placeholder,types:[l,c||`unknown`,`${o.placeholder}<${l}>`,u,p]})]}),name:te.placeholder});t.setSymbolValue(te,ne)},Mf=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`MutationOptions`)),i=bf({operation:e,plugin:t}),a=xf({operation:e,plugin:t}),o=Sf({operation:e,plugin:t}),s=`${r.placeholder}<${o}, ${a}, ${i}>`,c=`fnOptions`,l=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),u=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?u.push(I.returnVariable({expression:l})):u.push(I.constVariable({destructure:!0,expression:l,name:`data`}),I.returnVariable({expression:`data`}));let d=[{key:`mutationFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:u})}],f=yf(t,e,`mutationOptions`);f&&d.push({key:`meta`,value:f});let p=`mutationOptions`,m=I.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${i}>`}],returnType:s,statements:[I.constVariable({expression:I.objectExpression({obj:d}),name:p,typeName:s}),I.returnVariable({expression:p})]}),h=t.registerSymbol({exported:!0,name:E({config:t.config.mutationOptions,name:e.id})}),g=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:h.exported,expression:m,name:h.placeholder});t.setSymbolValue(h,g)},Nf=`options`,Pf=({operation:e,plugin:t,queryFn:n})=>{if(el({operation:e}))return;let r=$c({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Of({plugin:t}),Ef({plugin:t}));let i=t.referenceSymbol(t.api.selector(`queryOptions`)),a=t.registerSymbol({exported:!0,name:E({config:t.config.queryKeys,name:e.id})}),o=kf({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=bf({operation:e,plugin:t}),c=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:Nf},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),l=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?l.push(I.returnVariable({expression:c})):l.push(I.constVariable({destructure:!0,expression:c,name:`data`}),I.returnVariable({expression:`data`}));let u=[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:l})},{key:`queryKey`,value:I.callExpression({functionName:a.placeholder,parameters:[Nf]})}],d=yf(t,e,`queryOptions`);d&&u.push({key:`meta`,value:d});let f=t.registerSymbol({exported:t.config.queryOptions.exported,name:E({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),p=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:f.exported,expression:I.arrowFunction({parameters:[{isRequired:r,name:Nf,type:s}],statements:[I.returnFunctionCall({args:[I.objectExpression({obj:u})],name:i.placeholder})]}),name:f.placeholder});t.setSymbolValue(f,p)},Ff=`options`,If=({operation:e,plugin:t})=>{if(el({operation:e})||!(`useQuery`in t.config))return;let n=t.registerSymbol({exported:!0,name:E({config:t.config.useQuery,name:e.id})}),r=t.referenceSymbol(t.api.selector(`useQuery`)),i=$c({context:t.context,operation:e}),a=bf({operation:e,plugin:t}),o=t.referenceSymbol(t.api.selector(`queryOptionsFn`,e.id)),s=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:n.exported,expression:I.arrowFunction({parameters:[{isRequired:i,name:Ff,type:a}],statements:[I.returnStatement({expression:I.callExpression({functionName:r.placeholder,parameters:[I.callExpression({functionName:o.placeholder,parameters:[Ff]})]})})]}),name:n.placeholder});t.setSymbolValue(n,s)},Lf=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:`type`},name:`DefaultError`,selector:e.api.selector(`DefaultError`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`InfiniteData`,selector:e.api.selector(`InfiniteData`)});let t=e.name===`@tanstack/angular-query-experimental`||e.name===`@tanstack/svelte-query`||e.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`;e.registerSymbol({external:e.name,meta:{kind:`type`},name:t,selector:e.api.selector(`MutationOptions`)}),e.registerSymbol({external:e.name,name:`infiniteQueryOptions`,selector:e.api.selector(`infiniteQueryOptions`)}),e.registerSymbol({external:e.name,name:`queryOptions`,selector:e.api.selector(`queryOptions`)}),e.registerSymbol({external:e.name,name:`useQuery`,selector:e.api.selector(`useQuery`)}),e.registerSymbol({external:`axios`,meta:{kind:`type`},name:`AxiosError`,selector:e.api.selector(`AxiosError`)});let n=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:t})=>{let r=n.config.asClass?qc({context:e.context,operation:t,plugin:n}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(n.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>T({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(n.api.selector(`function`,t.id)).placeholder;e.hooks.operation.isQuery(t)&&(e.config.queryOptions.enabled&&Pf({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&jf({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&If({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&Mf({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},Rf=e=>`${Fu({config:x(),id:e.name,operation:e})}InfiniteOptions`,zf=e=>`${Fu({config:x(),id:e.name,operation:e})}Mutation`,Bf=({config:e,id:t,operation:n})=>`${Fu({config:e,id:t,operation:n})}Options`,Vf=({config:e,id:t,isInfinite:n,operation:r})=>`${Fu({config:e,id:t,operation:r})}${n?`Infinite`:``}QueryKey`,Hf=e=>{switch(e.in){case`formData`:return`body`;case`header`:return`headers`;default:return e.in}},Uf=`createInfiniteParams`,Wf=`createQueryKey`,Gf=`infiniteQueryOptions`,Kf=`mutationOptions`,qf=`QueryKey`,Jf=`queryOptions`,Yf=`TOptions`,Xf=({file:e})=>{let t=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:I.typeNode(`QueryKey<OptionsLegacyParser>`)},{name:`page`,type:I.typeNode(`K`)}],statements:[I.constVariable({expression:I.identifier({text:`queryKey[0]`}),name:`params`}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`body`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`body`}),right:I.objectExpression({multiLine:!0,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:!0,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:!0,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:!0,obj:[{spread:`queryKey[0].query`},{spread:`page.query`}]})})})]})}),I.returnVariable({expression:m.default.factory.createAsExpression(m.default.factory.createAsExpression(I.identifier({text:`params`}),m.default.factory.createKeywordTypeNode(m.default.SyntaxKind.UnknownKeyword)),m.default.factory.createTypeQueryNode(I.identifier({text:`page`})))})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`Pick<QueryKey<OptionsLegacyParser>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:`createInfiniteParams`});e.add(t)},Zf=({file:e})=>{let t=I.indexedAccessTypeNode({indexType:I.typeNode(0),objectType:I.typeNode(qf,[I.typeNode(Yf)])}),n=I.identifier({text:`infinite`}),r=he(x()),i=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:I.typeNode(`string`)},{isRequired:!1,name:`options`,type:I.typeNode(Yf)},{isRequired:!1,name:`infinite`,type:I.typeNode(`boolean`)}],returnType:t,statements:[I.constVariable({assertion:t,expression:I.objectExpression({multiLine:!1,obj:[{key:`_id`,value:I.identifier({text:`id`})},{key:r,value:I.identifier({text:`options?.${r} || (options?.client ?? _heyApiClient).getConfig().${r}`})}]}),name:`params`,typeName:t}),I.ifStatement({expression:n,thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:n})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`options`}),isOptional:!0,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:!0,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:!0,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:!0,name:I.identifier({text:`query`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`query`}),right:I.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),I.returnVariable({expression:`params`})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`OptionsLegacyParser`})}),name:Yf}]}),name:Wf});e.add(i)},Qf=({file:e})=>{let t=[{name:`_id`,type:I.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:I.keywordTypeNode({keyword:`boolean`})}],n=I.typeAliasDeclaration({name:qf,type:I.typeTupleNode({types:[I.typeIntersectionNode({types:[I.typeReferenceNode({typeName:`Pick<${Yf}, '${he(x())}' | 'body' | 'headers' | 'path' | 'query'>`}),I.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`OptionsLegacyParser`})}),name:Yf}]});e.add(n)},$f=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=wu({client:e,meta:n.parameters.length?{$ref:n.name,name:n.name}:void 0,nameTransformer:Eu,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeData:Au({importedType:i})}},ep=({client:e,file:t,operation:n,pluginName:r,typesModulePath:i})=>{let a=x(),{name:o}=wu({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:Du,onImport:e=>{t.import({asType:!0,module:i,name:e})}}),s={asType:!0,name:o};if(s.name||(s=t.import({asType:!0,module:r,name:`DefaultError`})),b(a).name===`@hey-api/client-axios`){let e=t.import({asType:!0,module:`axios`,name:`AxiosError`});s={...e,name:`${e.name}<${s.name}>`}}return{typeError:s}},tp=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=wu({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:ku,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeResponse:i||`void`}},np=({id:e,isInfinite:t})=>I.arrayLiteralExpression({elements:[I.callExpression({functionName:Wf,parameters:[I.ots.string(e),`options`,t?I.ots.boolean(!0):void 0]})],multiLine:!1}),rp=({client:e,files:t,plugin:n})=>{let r=x();if(S(r))throw Error(`TanStack Query plugin does not support legacy clients`);let i=t[n.name];i.import({asType:!0,module:bl({config:r,sourceOutput:n.output}),name:`OptionsLegacyParser`});let a=oe({moduleOutput:t.types.nameWithoutExtension(),sourceOutput:n.output}),o=n.name===`@tanstack/angular-query-experimental`||n.name===`@tanstack/svelte-query`||n.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`,s,c=!1,l=!1,u=!1,d=!1,f=!1,p=new Map;for(let m of e.services)for(let h of m.operations){let g=k(h);if(p.has(g))continue;p.set(g,!0);let _=[r.plugins[`@hey-api/sdk`]?.config.asClass&&as({config:r,name:m.name}),Fu({config:r,handleIllegal:!r.plugins[`@hey-api/sdk`]?.config.asClass,id:h.name,operation:h})].filter(Boolean).join(`.`),v=!1;if(n.config.queryOptions.enabled&&[`GET`,`POST`].includes(h.method)){f||(f=!0,l||=(Qf({file:i}),Zf({file:i}),!0),i.import({module:n.name,name:Jf})),v=!0;let{typeData:t}=$f({client:e,file:i,operation:h,typesModulePath:a}),o=Gs(h.parameters),s=I.constVariable({exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:np({id:h.name})}),name:Vf({config:r,id:h.name,operation:h})});i.add(s);let c=I.constVariable({comment:[],exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:[I.returnFunctionCall({args:[I.objectExpression({obj:[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:[I.constVariable({destructure:!0,expression:I.awaitExpression({expression:I.callExpression({functionName:_,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),I.returnVariable({expression:`data`})]})},{key:`queryKey`,value:I.callExpression({functionName:Vf({config:r,id:h.name,operation:h}),parameters:[`options`]})}]})],name:Jf})]}),name:Bf({config:r,id:h.name,operation:h})});i.add(c)}if(n.config.infiniteQueryOptions&&[`GET`,`POST`].includes(h.method)){let t,o=h.parameters.find(n=>{if(Hi(r.parser.pagination).test(n.name))return t=n,!0;if(n.in===`body`){if(n.export===`reference`){let i=n.$refs[0];return e.models.find(e=>e.meta?.$ref===i)?.properties.find(e=>{if(Hi(r.parser.pagination).test(e.name))return t=e,!0})}return n.properties.find(e=>{if(Hi(r.parser.pagination).test(e.name))return t=e,!0})}});if(o&&t){u||(u=!0,l||=(Qf({file:i}),Zf({file:i}),!0),c||=(Xf({file:i}),!0),i.import({module:n.name,name:Gf}),s=i.import({asType:!0,module:n.name,name:`InfiniteData`})),v=!0;let{typeData:d}=$f({client:e,file:i,operation:h,typesModulePath:a}),{typeError:f}=ep({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:p}=tp({client:e,file:i,operation:h,typesModulePath:a}),m=Gs(h.parameters),g=`${qf}<${d}>`,y=`Pick<${g}[0], 'body' | 'headers' | 'path' | 'query'>`,ee=`${t.base} | ${y}`,te=I.constVariable({exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],returnType:g,statements:np({id:h.name,isInfinite:!0})}),name:Vf({config:r,id:h.name,isInfinite:!0,operation:h})});i.add(te);let ne=I.constVariable({comment:[],exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],statements:[I.returnFunctionCall({args:[I.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:[I.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:I.conditionalExpression({condition:I.binaryExpression({left:I.typeOfExpression({text:`pageParam`}),operator:`===`,right:I.ots.string(`object`)}),whenFalse:I.objectExpression({multiLine:!0,obj:[{key:Hf(o),value:I.objectExpression({multiLine:!0,obj:[{key:t.name,value:I.identifier({text:`pageParam`})}]})}]}),whenTrue:I.identifier({text:`pageParam`})}),name:`page`,typeName:y}),I.constVariable({expression:I.callExpression({functionName:`createInfiniteParams`,parameters:[`queryKey`,`page`]}),name:`params`}),I.constVariable({destructure:!0,expression:I.awaitExpression({expression:I.callExpression({functionName:_,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),I.returnVariable({expression:`data`})]})},{key:`queryKey`,value:I.callExpression({functionName:Vf({config:r,id:h.name,isInfinite:!0,operation:h}),parameters:[`options`]})}]})],name:Gf,types:[p,f.name,`${typeof s==`string`?s:s.name}<${p}>`,g,ee]})]}),name:Rf(h)});i.add(ne)}}if(n.config.mutationOptions&&[`DELETE`,`PATCH`,`POST`,`PUT`].includes(h.method)){d||(d=!0,i.import({asType:!0,module:n.name,name:o})),v=!0;let{typeData:t}=$f({client:e,file:i,operation:h,typesModulePath:a}),{typeError:r}=ep({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:s}=tp({client:e,file:i,operation:h,typesModulePath:a}),c=`fnOptions`,l=I.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${t}>`}],statements:[I.constVariable({expression:I.objectExpression({obj:[{key:`mutationFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:[I.constVariable({destructure:!0,expression:I.awaitExpression({expression:I.callExpression({functionName:_,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),I.returnVariable({expression:`data`})]})}]}),name:Kf,typeName:`${o}<${s}, ${r.name}, ${t}>`}),I.returnVariable({expression:Kf})]}),u=I.constVariable({comment:[],exportConst:!0,expression:l,name:zf(h)});i.add(u)}(f||u)&&i.import({alias:`_heyApiClient`,module:oe({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:n.output}),name:`client`}),v&&i.import({module:oe({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:n.output}),name:_.split(`.`)[0]})}};var ip=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const ap={api:new ip({name:`@tanstack/angular-query-experimental`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,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:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},op=C(ap);var sp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const cp={api:new sp({name:`@tanstack/react-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/react-query`,output:`@tanstack/react-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions}),e.config.useQuery=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!1,name:`use{{name}}Query`},mappers:{boolean:e=>({enabled:e}),function:e=>({enabled:!0,name:e}),object:e=>({enabled:!0,...e}),string:e=>({enabled:!0,name:e})},value:e.config.useQuery}),e.config.useQuery.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=!0,e.config.queryOptions.exported=!1))}},lp=C(cp);var up=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const dp={api:new up({name:`@tanstack/solid-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/solid-query`,output:`@tanstack/solid-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},fp=C(dp);var pp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const mp={api:new pp({name:`@tanstack/svelte-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/svelte-query`,output:`@tanstack/svelte-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},hp=C(mp);var gp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const _p={api:new gp({name:`@tanstack/vue-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/vue-query`,output:`@tanstack/vue-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},vp=C(_p),yp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[I.identifier({text:r})]})})})]})},bp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[I.identifier({text:r})]})})})]})};var xp=class{constructor(e){this.meta=e}createRequestValidator(e){return yp(e)}createResponseValidator(e){return bp(e)}selector(...e){return[this.meta.name,...e]}};const Sp={keywords:{false:I.identifier({text:`false`}),true:I.identifier({text:`true`})},number:{Infinity:I.identifier({text:`Infinity`}),NaN:I.identifier({text:`NaN`}),NegativeInfinity:I.identifier({text:`NegativeInfinity`}),epoch:I.identifier({text:`epoch`}),integer:I.identifier({text:`integer`}),safe:I.identifier({text:`safe`})},primitives:{bigint:I.identifier({text:`bigint`}),boolean:I.identifier({text:`boolean`}),keywords:I.identifier({text:`keywords`}),null:`null`,number:I.identifier({text:`number`}),string:`string`,symbol:I.identifier({text:`symbol`}),undefined:I.identifier({text:`undefined`}),unit:I.identifier({text:`unit`})},string:{NFC:I.identifier({text:`NFC`}),NFD:I.identifier({text:`NFD`}),NFKC:I.identifier({text:`NFKC`}),NFKD:I.identifier({text:`NFKD`}),alpha:I.identifier({text:`alpha`}),alphanumeric:I.identifier({text:`alphanumeric`}),base64:I.identifier({text:`base64`}),capitalize:I.identifier({text:`capitalize`}),creditCard:I.identifier({text:`creditCard`}),date:`date`,digits:I.identifier({text:`digits`}),email:`email`,epoch:I.identifier({text:`epoch`}),hex:I.identifier({text:`hex`}),integer:I.identifier({text:`integer`}),ip:`ip`,iso:`iso`,json:I.identifier({text:`json`}),lower:I.identifier({text:`lower`}),normalize:I.identifier({text:`normalize`}),numeric:I.identifier({text:`numeric`}),parse:I.identifier({text:`parse`}),preformatted:I.identifier({text:`preformatted`}),regex:I.identifier({text:`regex`}),semver:I.identifier({text:`semver`}),trim:I.identifier({text:`trim`}),upper:I.identifier({text:`upper`}),url:`url`,uuid:`uuid`,v1:`v1`,v2:`v2`,v3:`v3`,v4:`v4`,v5:`v5`,v6:`v6`,v7:`v7`,v8:`v8`},type:{$:I.identifier({text:`$`}),allows:I.identifier({text:`allows`}),and:I.identifier({text:`and`}),array:I.identifier({text:`array`}),as:I.identifier({text:`as`}),assert:I.identifier({text:`assert`}),brand:I.identifier({text:`brand`}),configure:I.identifier({text:`configure`}),default:I.identifier({text:`default`}),describe:I.identifier({text:`describe`}),description:I.identifier({text:`description`}),equals:I.identifier({text:`equals`}),exclude:I.identifier({text:`exclude`}),expression:I.identifier({text:`expression`}),extends:I.identifier({text:`extends`}),extract:I.identifier({text:`extract`}),filter:I.identifier({text:`filter`}),from:I.identifier({text:`from`}),ifEquals:I.identifier({text:`ifEquals`}),ifExtends:I.identifier({text:`ifExtends`}),infer:I.identifier({text:`infer`}),inferIn:I.identifier({text:`inferIn`}),intersect:I.identifier({text:`intersect`}),json:I.identifier({text:`json`}),meta:I.identifier({text:`meta`}),narrow:I.identifier({text:`narrow`}),onDeepUndeclaredKey:I.identifier({text:`onDeepUndeclaredKey`}),onUndeclaredKey:I.identifier({text:`onUndeclaredKey`}),optional:I.identifier({text:`optional`}),or:I.identifier({text:`or`}),overlaps:I.identifier({text:`overlaps`}),pipe:I.identifier({text:`pipe`}),select:I.identifier({text:`select`}),to:I.identifier({text:`to`}),toJsonSchema:I.identifier({text:`toJsonSchema`})}},Cp=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`arktype.type`)),o=I.constVariable({comment:t.config.comments?wd({schema:n}):void 0,exportConst:r.exported,expression:I.callExpression({functionName:a.placeholder,parameters:[e.def?I.stringLiteral({text:e.def}):e.expression]}),name:r.placeholder});if(t.setSymbolValue(r,o),i){let e=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:m.default.factory.createTypeQueryNode(m.default.factory.createQualifiedName(m.default.factory.createIdentifier(r.placeholder),Sp.type.infer))});t.setSymbolValue(i,e)}},wp=e=>{let t={};return t.def=Sp.primitives.null,t},Tp=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=a.includes(o),l=Op({optional:!c,plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,o])}});l.hasLazyExpression&&(r.hasLazyExpression=!0);let u=c?o:`${o}?`;u.endsWith(`?`)?u=m.default.factory.createComputedPropertyName(I.stringLiteral({text:u})):((u.match(/^[0-9]/)&&u.match(/\D+/g)||u.match(/\W/g))&&!u.startsWith(`'`)&&!u.endsWith(`'`)&&(u=`'${u}'`),A.lastIndex=0,u=A.test(u)?u.startsWith(`-`)?I.stringLiteral({text:o}):m.default.factory.createNumericLiteral(o):o),i.push(I.propertyAssignment({initializer:l.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Op({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:`TODO`,name:`record`}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:`TODO`,name:`string`}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r}return r.expression=m.default.factory.createObjectLiteralExpression(i,!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r},Ep=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=Sp.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${Sp.string.date}.${Sp.string.iso}`;break;case`email`:n=`${n}.${Sp.string.email}`;break;case`ipv4`:n=`${n}.${Sp.string.ip}.${Sp.string.v4}`;break;case`ipv6`:n=`${n}.${Sp.string.ip}.${Sp.string.v6}`;break;case`uri`:n=`${n}.${Sp.string.url}`;break;case`uuid`:n=`${n}.${Sp.string.uuid}`;break}return e.minLength===e.maxLength&&e.minLength!==void 0?n=`${e.minLength} <= ${n} <= ${e.maxLength}`:e.maxLength===void 0?e.minLength!==void 0&&(n=`${n} >= ${e.minLength}`):(n=`${n} <= ${e.maxLength}`,e.minLength!==void 0&&(n=`${e.minLength} <= ${n}`)),e.pattern&&(n=`/${e.pattern}/`),t.def=n,t},Dp=({schema:e,...t})=>{switch(e.type){case`null`:return wp({...t,schema:e});case`object`:return Tp({...t,schema:e});case`string`:return Ep({...t,schema:e})}let n=t.plugin.referenceSymbol(t.plugin.api.selector(`external`,`arktype.type`));return{def:``,expression:m.default.factory.createCallExpression(m.default.factory.createIdentifier(n.placeholder),void 0,[m.default.factory.createObjectLiteralExpression([m.default.factory.createPropertyAssignment(`name`,m.default.factory.createStringLiteral(`string`)),m.default.factory.createPropertyAssignment(`platform`,m.default.factory.createStringLiteral(`'android' | 'ios'`)),m.default.factory.createPropertyAssignment(m.default.factory.createComputedPropertyName(m.default.factory.createStringLiteral(`versions?`)),m.default.factory.createStringLiteral(`(number | string)[]`))],!0)]),hasLazyExpression:!1}},Op=({plugin:e,schema:t,state:n})=>{let r={};if(t.$ref){let i=e.api.selector(`ref`,t.$ref),a=e.referenceSymbol(i);e.isSymbolRegistered(i)?r.expression=I.identifier({text:a.placeholder}):(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:`TODO`,name:`TODO`}),parameters:[I.arrowFunction({returnType:I.keywordTypeNode({keyword:`any`}),statements:[I.returnStatement({expression:I.identifier({text:a.placeholder})})]})]}),r.hasLazyExpression=!0,n.hasLazyExpression.value=!0)}else if(t.type){let i=Dp({plugin:e,schema:t,state:n});r.def=i.def,r.expression=i.expression,r.hasLazyExpression=i.hasLazyExpression,e.config.metadata&&t.description}else if(t.items)t=D({schema:t}),t.items||(r=Op({plugin:e,schema:t,state:n}));else{let t=Dp({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=Dp({plugin:e,schema:{type:`unknown`},state:n}).expression,r},kp=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=Op({plugin:e,schema:t,state:n}),a=L(r);Cp({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},Ap=({plugin:e})=>{e.registerSymbol({external:`arktype`,name:`type`,selector:e.api.selector(`external`,`arktype.type`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:kp({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:kp({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:kp({plugin:e,schema:t.schema,state:n});break}})},jp=e=>Ap(e),Mp={api:new xp({name:`arktype`}),config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:jp,name:`arktype`,resolveConfig:(e,t)=>{e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Data`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Response`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequest`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},Np=C(Mp);var Pp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Fp=({operation:e,plugin:t})=>{let n=[],r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`data`,e.id));i&&(e.body&&n.push({isRequired:e.body.required,name:`Body`,type:`${i.placeholder}['body']`}),e.parameters&&(e.parameters.header&&n.push({isRequired:it(e.parameters.header),name:`Headers`,type:`${i.placeholder}['headers']`}),e.parameters.path&&n.push({isRequired:it(e.parameters.path),name:`Params`,type:`${i.placeholder}['path']`}),e.parameters.query&&n.push({isRequired:it(e.parameters.query),name:`Querystring`,type:`${i.placeholder}['query']`})));let{errors:a,responses:o}=ut(e),s,c=t.getSymbol(r.api.selector(`errors`,e.id));if(c&&a&&a.properties){let e=Object.keys(a.properties);if(e.length){if(!e.includes(`default`))s=I.typeReferenceNode({typeName:c.placeholder});else if(e.length>1){let e=I.typeReferenceNode({typeName:c.placeholder}),t=I.literalTypeNode({literal:I.stringLiteral({text:`default`})});s=I.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let l,u=t.getSymbol(r.api.selector(`responses`,e.id));if(u&&o&&o.properties){let e=Object.keys(o.properties);if(e.length){if(!e.includes(`default`))l=I.typeReferenceNode({typeName:u.placeholder});else if(e.length>1){let e=I.typeReferenceNode({typeName:u.placeholder}),t=I.literalTypeNode({literal:I.stringLiteral({text:`default`})});l=I.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let d=[s,l].filter(Boolean);if(d.length&&n.push({name:`Reply`,type:I.typeIntersectionNode({types:d})}),!n.length)return;let f=t.referenceSymbol(t.api.selector(`RouteHandler`));return{name:e.id,type:I.typeReferenceNode({typeArguments:[I.typeInterfaceNode({properties:n,useLegacyResolution:!1})],typeName:f.placeholder})}},Ip=({plugin:e})=>{e.registerSymbol({external:`fastify`,meta:{kind:`type`},name:`RouteHandler`,selector:e.api.selector(`RouteHandler`)});let t=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`RouteHandlers`}),n=[];e.forEach(`operation`,({operation:t})=>{let r=Fp({operation:t,plugin:e});r&&n.push(r)},{order:`declarations`});let r=I.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:I.typeInterfaceNode({properties:n,useLegacyResolution:!1})});e.setSymbolValue(t,r)},Lp={api:new Pp({name:`fastify`}),config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:Ip,name:`fastify`},Rp=C(Lp),X={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`})},storages:{},types:{GenericSchema:I.identifier({text:`GenericSchema`})},utils:{}},zp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),i=`data`;return I.arrowFunction({async:!0,parameters:[{name:i}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:X.async.parseAsync}),parameters:[I.identifier({text:n.placeholder}),I.identifier({text:i})]})})})]})},Bp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),i=`data`;return I.arrowFunction({async:!0,parameters:[{name:i}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:X.async.parseAsync}),parameters:[I.identifier({text:n.placeholder}),I.identifier({text:i})]})})})]})};var Vp=class{constructor(e){this.meta=e}createRequestValidator(e){return zp(e)}createResponseValidator(e){return Bp(e)}selector(...e){return[this.meta.name,...e]}};const Z=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let n=t.referenceSymbol(t.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.methods.pipe}),parameters:e})},Hp=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),o=I.constVariable({comment:t.config.comments?wd({schema:n}):void 0,exportConst:i.exported,expression:Z({pipes:e.pipes,plugin:t}),name:i.placeholder,typeName:r.hasLazyExpression.value?I.propertyAccessExpression({expression:a.placeholder,name:e.typeName||X.types.GenericSchema.text}):void 0});t.setSymbolValue(i,o)},Up={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:!1},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:!1},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:!0},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:!1},uint16:{max:65535,maxError:`Invalid value: Expected uint16 to be <= 2^16-1`,min:0,minError:`Invalid value: Expected uint16 to be >= 0`,needsBigInt:!1},uint32:{max:4294967295,maxError:`Invalid value: Expected uint32 to be <= 2^32-1`,min:0,minError:`Invalid value: Expected uint32 to be >= 0`,needsBigInt:!1},uint64:{max:`18446744073709551615`,maxError:`Invalid value: Expected uint64 to be <= 2^64-1`,min:`0`,minError:`Invalid value: Expected uint64 to be >= 0`,needsBigInt:!0},uint8:{max:255,maxError:`Invalid value: Expected uint8 to be <= 2^8-1`,min:0,minError:`Invalid value: Expected uint8 to be >= 0`,needsBigInt:!1}},Wp=e=>e!==void 0&&e in Up,Gp=e=>Wp(e)&&Up[e].needsBigInt,Kp=({isBigInt:e,value:t})=>{let n=I.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?I.callExpression({functionName:`BigInt`,parameters:[n]}):n},qp=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Hp({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.requests,name:t.id}),selector:n.api.selector(`data`,t.id)})})}if(n.config.responses.enabled&&t.responses){let{response:i}=ut(t);if(i){let a=[...r.path.value,`responses`];Hp({ast:e(i,a),plugin:n,schema:i,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:a,tags:r.tags?.value},name:E({config:n.config.responses,name:t.id}),selector:n.api.selector(`responses`,t.id)})})}}},Jp=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Hp({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.webhooks,name:t.id}),selector:n.api.selector(`webhook-request`,t.id)})})}},Yp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.unknown})})},Xp=({plugin:e,schema:t,state:n})=>{let r={pipes:[]},i=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),a=I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.array});if(t.items){t=D({schema:t});let i=t.items.map((t,i)=>{let a=cm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Z({pipes:a.pipes,plugin:e})});if(i.length===1){let e=I.callExpression({functionName:a,parameters:i});r.pipes.push(e)}else{t.logicalOperator;let i=I.callExpression({functionName:a,parameters:[Yp({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(i)}}else{let t=I.callExpression({functionName:a,parameters:[Yp({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.actions.length}),parameters:[I.valueToExpression({value:t.minItems})]});r.pipes.push(e)}else{if(t.minItems!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.actions.minLength}),parameters:[I.valueToExpression({value:t.minItems})]});r.pipes.push(e)}if(t.maxItems!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.actions.maxLength}),parameters:[I.valueToExpression({value:t.maxItems})]});r.pipes.push(e)}}return r},Zp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return typeof t.const==`boolean`?I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.literal}),parameters:[I.ots.boolean(t.const)]}):I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.boolean})})},Qp=({plugin:e,schema:t,state:n})=>{let r=[],i=!1;for(let e of t.items??[])e.type===`string`&&typeof e.const==`string`?r.push(I.stringLiteral({text:e.const})):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return Yp({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),o=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.picklist}),parameters:[I.arrayLiteralExpression({elements:r,multiLine:!1})]});return i&&(o=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.nullable}),parameters:[o]})),o},$p=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.never})})},em=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.null})})},tm=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=Gp(n),a=Wp(n)?Up[n]:null,o=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.const!==void 0&&t.const!==null){let e=t.const,r;if(typeof e==`number`&&!n)r=I.ots.number(e);else if(typeof e==`number`&&n)r=i?I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(e.toString())]}):I.ots.number(e);else if(typeof e==`string`&&i){let t=e.endsWith(`n`)?e.slice(0,-1):e;r=I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(t)]})}else if(typeof e==`bigint`){let t=e.toString(),n=t.endsWith(`n`)?t.slice(0,-1):t;r=I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(n)]})}else r=I.valueToExpression({value:e});return I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.literal}),parameters:[r]})}let s=[];if(i){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.union}),parameters:[I.arrayLiteralExpression({elements:[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.number})}),I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.string})}),I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.bigInt})})],multiLine:!1})]});s.push(e);let t=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.transform}),parameters:[I.arrowFunction({parameters:[{name:`x`}],statements:I.callExpression({functionName:`BigInt`,parameters:[I.identifier({text:`x`})]})})]});s.push(t)}else{let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.number})});s.push(e)}if(!i&&r){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.integer})});s.push(e)}if(a){let e=a.min,t=a.max,n=a.minError,r=a.maxError,c=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.minValue}),parameters:[i?I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(e.toString())]}):I.ots.number(e),I.ots.string(n)]});s.push(c);let l=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.maxValue}),parameters:[i?I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(t.toString())]}):I.ots.number(t),I.ots.string(r)]});s.push(l)}if(t.exclusiveMinimum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.gtValue}),parameters:[Kp({isBigInt:i,value:t.exclusiveMinimum})]});s.push(e)}else if(t.minimum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.minValue}),parameters:[Kp({isBigInt:i,value:t.minimum})]});s.push(e)}if(t.exclusiveMaximum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.ltValue}),parameters:[Kp({isBigInt:i,value:t.exclusiveMaximum})]});s.push(e)}else if(t.maximum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.maxValue}),parameters:[Kp({isBigInt:i,value:t.maximum})]});s.push(e)}return Z({pipes:s,plugin:e})},nm=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=cm({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),A.lastIndex=0;let l;l=A.test(o)?o.startsWith(`-`)?m.default.factory.createStringLiteral(o):m.default.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(l=`'${o}'`),i.push(I.propertyAssignment({initializer:Z({pipes:c.pipes,plugin:e}),name:l}))}let o=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.additionalProperties&&t.additionalProperties.type===`object`&&!Object.keys(i).length){let i=cm({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return i.hasLazyExpression&&(r.hasLazyExpression=!0),r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.record}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.string}),parameters:[]}),Z({pipes:i.pipes,plugin:e})]})],r}return r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.object}),parameters:[m.default.factory.createObjectLiteralExpression(i,!0)]})],r},rm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(typeof t.const==`string`)return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.literal}),parameters:[I.ots.string(t.const)]});let r=[],i=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.string})});if(r.push(i),t.format)switch(t.format){case`date`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoDate})}));break;case`date-time`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoTimestamp})}));break;case`ipv4`:case`ipv6`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.ip})}));break;case`uri`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.url})}));break;case`email`:case`time`:case`uuid`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:I.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.length}),parameters:[I.valueToExpression({value:t.minLength})]});r.push(e)}else{if(t.minLength!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.minLength}),parameters:[I.valueToExpression({value:t.minLength})]});r.push(e)}if(t.maxLength!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.maxLength}),parameters:[I.valueToExpression({value:t.maxLength})]});r.push(e)}}if(t.pattern){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]});r.push(e)}return Z({pipes:r,plugin:e})},im=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.literal}),parameters:[I.valueToExpression({value:e})]}));return r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]})],r}if(t.items){let a=t.items.map((t,i)=>{let a=cm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Z({pipes:a.pipes,plugin:e})});return r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]})],r}return{pipes:[Yp({plugin:e,schema:{type:`unknown`},state:n})]}},am=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.undefined})})},om=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.void})})},sm=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:Z({pipes:Xp({...t,schema:e}).pipes,plugin:t.plugin})};case`boolean`:return{expression:Zp({...t,schema:e})};case`enum`:return{expression:Qp({...t,schema:e})};case`integer`:case`number`:return{expression:tm({...t,schema:e})};case`never`:return{expression:$p({...t,schema:e})};case`null`:return{expression:em({...t,schema:e})};case`object`:return{expression:Z({pipes:nm({...t,schema:e}).pipes,plugin:t.plugin})};case`string`:return e.format===`int64`||e.format===`uint64`?{expression:tm({...t,schema:e})}:{expression:rm({...t,schema:e})};case`tuple`:return{expression:Z({pipes:im({...t,schema:e}).pipes,plugin:t.plugin})};case`undefined`:return{expression:am({...t,schema:e})};case`unknown`:return{expression:Yp({...t,schema:e})};case`void`:return{expression:om({...t,schema:e})}}},cm=({optional:e,plugin:t,schema:n,state:r})=>{let i={pipes:[]},a=t.referenceSymbol(t.api.selector(`external`,`valibot.v`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);if(t.isSymbolRegistered(e)){let e=I.identifier({text:o.placeholder});i.pipes.push(e)}else{let e=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]});i.pipes.push(e),r.hasLazyExpression.value=!0}}else if(n.type){let e=sm({plugin:t,schema:n,state:r});if(i.typeName=e.anyType,i.pipes.push(e.expression),t.config.metadata&&n.description){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.actions.metadata}),parameters:[I.objectExpression({obj:[{key:`description`,value:I.stringLiteral({text:n.description})}]})]});i.pipes.push(e)}}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>Z({pipes:cm({plugin:t,schema:e,state:{...r,path:q([...r.path.value,`items`,n])}}).pipes,plugin:t}));if(n.logicalOperator===`and`){let t=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.intersect}),parameters:[I.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}else{let t=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.union}),parameters:[I.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}}else{let e=cm({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=sm({plugin:t,schema:{type:`unknown`},state:r});i.typeName=e.anyType,i.pipes.push(e.expression)}if(i.pipes.length){if(n.accessScope===`read`){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.actions.readonly})});i.pipes.push(e)}let r;n.default!==void 0&&(r=Kp({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default}),r&&(i.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.optional}),parameters:[Z({pipes:i.pipes,plugin:t}),r]})])),e&&!r&&(i.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.optional}),parameters:[Z({pipes:i.pipes,plugin:t})]})])}return i},lm=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=cm({plugin:e,schema:t,state:n}),a=L(r);Hp({ast:i,plugin:e,schema:t,state:n,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)})})},um=({plugin:e})=>{e.registerSymbol({external:`valibot`,meta:{importKind:`namespace`},name:`v`,selector:e.api.selector(`external`,`valibot.v`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:qp({getAst:(n,r)=>cm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:lm({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:lm({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:lm({plugin:e,schema:t.schema,state:n});break;case`webhook`:Jp({getAst:(n,r)=>cm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},dm=e=>um(e),fm={api:new Vp({name:`valibot`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:dm,name:`valibot`,resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Data`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Response`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}WebhookRequest`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.webhooks})},tags:[`validator`]},pm=C(fm),Q={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`})},mm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},hm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},gm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},_m=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},vm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},ym=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})};var bm=class{constructor(e){this.meta=e}createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return gm(e);case`mini`:return mm(e);case 4:default:return vm(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return _m(e);case`mini`:return hm(e);case 4:default:return ym(e)}}selector(...e){return[this.meta.name,...e]}};const xm=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`zod.z`)),o=I.constVariable({comment:t.config.comments?wd({schema:n}):void 0,exportConst:r.exported,expression:e.expression,name:r.placeholder,typeName:e.typeName?I.propertyAccessExpression({expression:a.placeholder,name:e.typeName}):void 0});if(t.setSymbolValue(r,o),i){let e=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:I.typeReferenceNode({typeArguments:[I.typeOfExpression({text:r.placeholder})],typeName:I.propertyAccessExpression({expression:a.placeholder,name:Q.infer})})});t.setSymbolValue(i,e)}},Sm=({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`}},$=({isBigInt:e,value:t})=>{let n=I.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?I.callExpression({functionName:`BigInt`,parameters:[n]}):n},Cm=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],xm({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.requests,name:t.id}),selector:n.api.selector(`data`,t.id)}),typeInferSymbol:n.config.requests.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:r.path.value,tags:r.tags?.value},name:E({config:n.config.requests.types.infer,name:t.id}),selector:n.api.selector(`type-infer-data`,t.id)}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=ut(t);if(i){let a=[...r.path.value,`responses`];xm({ast:e(i,a),plugin:n,schema:i,symbol:n.registerSymbol({exported:!0,meta:{path:a,tags:r.tags?.value},name:E({config:n.config.responses,name:t.id}),selector:n.api.selector(`responses`,t.id)}),typeInferSymbol:n.config.responses.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:a,tags:r.tags?.value},name:E({config:n.config.responses.types.infer,name:t.id}),selector:n.api.selector(`type-infer-responses`,t.id)}):void 0})}}},wm=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],xm({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.webhooks,name:t.id}),selector:n.api.selector(`webhook-request`,t.id)}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:r.path.value,tags:r.tags?.value},name:E({config:n.config.webhooks.types.infer,name:t.id}),selector:n.api.selector(`type-infer-webhook-request`,t.id)}):void 0})}},Tm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})}),n},Em=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=I.propertyAccessExpression({expression:r.placeholder,name:Q.array});if(!t.items)i.expression=I.callExpression({functionName:a,parameters:[Tm({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=D({schema:t});let o=t.items.map((t,r)=>{let a=Rm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});return a.hasLazyExpression&&(i.hasLazyExpression=!0),a.expression});if(o.length===1)i.expression=I.callExpression({functionName:a,parameters:o});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:[n,o[e]]})}i.expression=I.callExpression({functionName:a,parameters:[n]})}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o})]})]})}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.length}),parameters:[I.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.minLength}),parameters:[I.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.maxLength}),parameters:[I.valueToExpression({value:t.maxItems})]}))),o.length&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.check}),parameters:o})),i},Dm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};return typeof t.const==`boolean`?(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.boolean(t.const)]}),r):(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})}),r)},Om=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=I.stringLiteral({text:e.const});a.push(t),o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=I.ots.number(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.ots.boolean(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[I.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?i.expression=o[0]:i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.nullable}),parameters:[i.expression]})),i):Tm({plugin:e,schema:{type:`unknown`},state:n})},km=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.never})}),n},Am=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.null})}),n},jm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={},i=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.number(t.const)]}),r;r.expression=I.callExpression({functionName:i?I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):I.propertyAccessExpression({expression:n.placeholder,name:Q.number})}),!i&&t.type===`integer`&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.int})}));let a=[];return t.exclusiveMinimum===void 0?t.minimum!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.gte}),parameters:[$({isBigInt:i,value:t.minimum})]})):a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.gt}),parameters:[$({isBigInt:i,value:t.exclusiveMinimum})]})),t.exclusiveMaximum===void 0?t.maximum!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.lte}),parameters:[$({isBigInt:i,value:t.maximum})]})):a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.lt}),parameters:[$({isBigInt:i,value:t.exclusiveMaximum})]})),a.length&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Mm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=Rm({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i.hasLazyExpression=!0),A.lastIndex=0;let l;l=A.test(r)?r.startsWith(`-`)?m.default.factory.createStringLiteral(r):m.default.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(l=`'${r}'`),c.hasLazyExpression?a.push(I.getAccessorDeclaration({name:l,statements:[I.returnStatement({expression:c.expression})]})):a.push(I.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Rm({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.string}),parameters:[]}),a.expression]}),a.hasLazyExpression&&(i.hasLazyExpression=!0),i}return i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[m.default.factory.createObjectLiteralExpression(a,!0)]}),i},Nm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};if(typeof t.const==`string`)return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.string(t.const)]}),r;r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.string})});let i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[I.objectExpression({obj:i})]:[]});break;case`email`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.email})});break;case`ipv4`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.ipv4})});break;case`ipv6`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.ipv6})});break;case`time`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.url})});break;case`uuid`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.uuid})});break}let a=[];return t.minLength===t.maxLength&&t.minLength!==void 0?a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.length}),parameters:[I.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.minLength}),parameters:[I.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.maxLength}),parameters:[I.valueToExpression({value:t.maxLength})]}))),t.pattern&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]})),a.length&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Pm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={};if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.valueToExpression({value:e})]}));return i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]}),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=Rm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]}),i},Fm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})}),n},Im=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.void})}),n},Lm=({schema:e,...t})=>{switch(e.type){case`array`:return Em({...t,schema:e});case`boolean`:return Dm({...t,schema:e});case`enum`:return Om({...t,schema:e});case`integer`:case`number`:return jm({...t,schema:e});case`never`:return km({...t,schema:e});case`null`:return Am({...t,schema:e});case`object`:return Mm({...t,schema:e});case`string`:return Nm({...t,schema:e});case`tuple`:return Pm({...t,schema:e});case`undefined`:return Fm({...t,schema:e});case`unknown`:return Tm({...t,schema:e});case`void`:return Im({...t,schema:e})}},Rm=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I.identifier({text:o.placeholder}):(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({returnType:I.keywordTypeNode({keyword:`any`}),statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=Lm({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[I.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),I.objectExpression({obj:[{key:`description`,value:I.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>Rm({plugin:t,schema:e,state:{...r,path:q([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:[i.expression,e.hasLazyExpression?I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=Rm({plugin:t,schema:n,state:r});else i.expression=Lm({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.readonly}),parameters:[i.expression]})),e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.optional}),parameters:[i.expression]}),i.typeName=Q.ZodMiniOptional),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q._default}),parameters:[i.expression,e]}))}return i},zm=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=Rm({plugin:e,schema:t,state:n}),a=L(r);xm({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},Bm=({plugin:e})=>{e.registerSymbol({external:Sm({plugin:e}),meta:{importKind:`namespace`},name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Cm({getAst:(n,r)=>Rm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:zm({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:zm({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:zm({plugin:e,schema:t.schema,state:n});break;case`webhook`:wm({getAst:(n,r)=>Rm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Vm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})})},Hm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=I.propertyAccessExpression({expression:r.placeholder,name:Q.array}),a,o=!1;if(!t.items)a=I.callExpression({functionName:i,parameters:[Vm({plugin:e,schema:{type:`unknown`},state:n})]});else{t=D({schema:t});let s=t.items.map((t,r)=>{let i=eh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});return i.hasLazyExpression&&(o=!0),i.expression});if(s.length===1)a=I.callExpression({functionName:i,parameters:s});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:s});else{n=s[0];for(let e=1;e<s.length;e++)n=I.callExpression({functionName:I.propertyAccessExpression({expression:n,name:Q.and}),parameters:[s[e]]})}a=I.callExpression({functionName:i,parameters:[n]})}else a=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:s})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?a=I.callExpression({functionName:I.propertyAccessExpression({expression:a,name:Q.length}),parameters:[I.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(a=I.callExpression({functionName:I.propertyAccessExpression({expression:a,name:Q.min}),parameters:[I.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(a=I.callExpression({functionName:I.propertyAccessExpression({expression:a,name:Q.max}),parameters:[I.valueToExpression({value:t.maxItems})]}))),{expression:a,hasLazyExpression:o}},Um=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.boolean(t.const)]}):I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})})},Wm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=[],a=[],o=!1,s=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=I.stringLiteral({text:e.const});i.push(t),a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){s=!1;let t=I.ots.number(e.const);a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=I.ots.boolean(e.const);a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return Vm({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[I.arrayLiteralExpression({elements:i,multiLine:!1})]}):a.length===1?a[0]:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:a,multiLine:a.length>3})]}),o&&(c=I.callExpression({functionName:I.propertyAccessExpression({expression:c,name:Q.nullable})})),c},Gm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.never})})},Km=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.null})})},qm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.number(t.const)]});let i=I.callExpression({functionName:r?I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):I.propertyAccessExpression({expression:n.placeholder,name:Q.number})});return!r&&t.type===`integer`&&(i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),i},Jm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1,a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=eh({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i=!0),A.lastIndex=0;let l;l=A.test(r)?r.startsWith(`-`)?m.default.factory.createStringLiteral(r):m.default.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(l=`'${r}'`),a.push(I.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=eh({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return{anyType:`AnyZodObject`,expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[i.expression]}),hasLazyExpression:i.hasLazyExpression}}return{anyType:`AnyZodObject`,expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[m.default.factory.createObjectLiteralExpression(a,!0)]}),hasLazyExpression:i}},Ym=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.string(t.const)]});let r=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.string})}),i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.date})});break;case`date-time`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.datetime}),parameters:i.length>0?[I.objectExpression({obj:i})]:[]});break;case`email`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.email})});break;case`ipv4`:case`ipv6`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.ip})});break;case`time`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.time})});break;case`uri`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.url})});break;case`uuid`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.length}),parameters:[I.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.min}),parameters:[I.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.max}),parameters:[I.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]})),r},Xm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1;if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.valueToExpression({value:e})]}));return{expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]}),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=eh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]}),hasLazyExpression:i}},Zm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})})},Qm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.void})})},$m=({schema:e,...t})=>{switch(e.type){case`array`:return Hm({...t,schema:e});case`boolean`:return{expression:Um({...t,schema:e})};case`enum`:return{expression:Wm({...t,schema:e})};case`integer`:case`number`:return{expression:qm({...t,schema:e})};case`never`:return{expression:Gm({...t,schema:e})};case`null`:return{expression:Km({...t,schema:e})};case`object`:return Jm({...t,schema:e});case`string`:return{expression:Ym({...t,schema:e})};case`tuple`:return Xm({...t,schema:e});case`undefined`:return{expression:Zm({...t,schema:e})};case`unknown`:return{expression:Vm({...t,schema:e})};case`void`:return{expression:Qm({...t,schema:e})}}},eh=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I.identifier({text:o.placeholder}):(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=$m({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.describe}),parameters:[I.stringLiteral({text:n.description})]}))}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>eh({plugin:t,schema:e,state:{...r,path:q([...r.path.value,`items`,n])}}).expression);if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e}):(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e]})}))}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:e})]})}else i=eh({plugin:t,schema:n,state:r});else{let e=$m({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}if(i.expression&&(n.accessScope===`read`&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.optional})})),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return r.hasLazyExpression.value?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},th=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=eh({plugin:e,schema:t,state:n}),a=L(r);xm({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},nh=({plugin:e})=>{e.registerSymbol({external:Sm({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Cm({getAst:(n,r)=>eh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:th({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:th({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:th({plugin:e,schema:t.schema,state:n});break;case`webhook`:wm({getAst:(n,r)=>eh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},rh=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.unknown})}),t},ih=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),a=I.propertyAccessExpression({expression:i.placeholder,name:Q.array});if(!t.items)r.expression=I.callExpression({functionName:a,parameters:[rh({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=D({schema:t});let o=t.items.map((t,i)=>{let a=gh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),a.expression});if(o.length===1)r.expression=I.callExpression({functionName:a,parameters:o});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=I.callExpression({functionName:I.propertyAccessExpression({expression:n,name:Q.and}),parameters:[o[e]]})}r.expression=I.callExpression({functionName:a,parameters:[n]})}else r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.array}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.length}),parameters:[I.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.min}),parameters:[I.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.max}),parameters:[I.valueToExpression({value:t.maxItems})]}))),r},ah=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.ots.boolean(t.const)]}),n):(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.boolean})}),n)},oh=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=I.stringLiteral({text:e.const});a.push(t),o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=I.ots.number(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.ots.boolean(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.enum}),parameters:[I.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?r.expression=o[0]:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.nullable}),parameters:[r.expression]})),r):rh({plugin:e,schema:{type:`unknown`},state:n})},sh=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.never})}),t},ch=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.null})}),t},lh=({plugin:e,schema:t})=>{let n={},r=t.type===`integer`&&t.format===`int64`,i=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`number`?(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[I.ots.number(t.const)]}),n):(n.expression=I.callExpression({functionName:r?I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:i.placeholder,name:Q.coerce}),name:Q.bigint}):I.propertyAccessExpression({expression:i.placeholder,name:Q.number})}),!r&&t.type===`integer`&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),n)},uh=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[],o=e.referenceSymbol(e.api.selector(`external`,`zod.z`));for(let o in t.properties){let s=t.properties[o],c=gh({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),A.lastIndex=0;let l;l=A.test(o)?o.startsWith(`-`)?m.default.factory.createStringLiteral(o):m.default.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(l=`'${o}'`),c.hasLazyExpression?i.push(I.getAccessorDeclaration({name:l,statements:[I.returnStatement({expression:c.expression})]})):i.push(I.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=gh({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:Q.record}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:Q.string}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`ZodType`}:r}return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:Q.object}),parameters:[m.default.factory.createObjectLiteralExpression(i,!0)]}),r.hasLazyExpression?{...r,typeName:`ZodType`}:r},dh=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.ots.string(t.const)]}),n;n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.string})});let i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[I.objectExpression({obj:i})]:[]});break;case`email`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.email})});break;case`ipv4`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.ipv4})});break;case`ipv6`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.ipv6})});break;case`time`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.url})});break;case`uuid`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.length}),parameters:[I.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.min}),parameters:[I.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.max}),parameters:[I.valueToExpression({value:t.maxLength})]}))),t.pattern&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]})),n},fh=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[I.valueToExpression({value:e})]}));return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]}),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=gh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]}),r},ph=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.undefined})}),t},mh=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.void})}),t},hh=({schema:e,...t})=>{switch(e.type){case`array`:return ih({...t,schema:e});case`boolean`:return ah({...t,schema:e});case`enum`:return oh({...t,schema:e});case`integer`:case`number`:return lh({...t,schema:e});case`never`:return sh({...t,schema:e});case`null`:return ch({...t,schema:e});case`object`:return uh({...t,schema:e});case`string`:return dh({...t,schema:e});case`tuple`:return fh({...t,schema:e});case`undefined`:return ph({...t,schema:e});case`unknown`:return rh({...t,schema:e});case`void`:return mh({...t,schema:e})}},gh=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I.identifier({text:o.placeholder}):(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({returnType:I.keywordTypeNode({keyword:`any`}),statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=hh({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[I.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),I.objectExpression({obj:[{key:`description`,value:I.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>gh({plugin:t,schema:e,state:{...r,path:q([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e.hasLazyExpression?I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=gh({plugin:t,schema:n,state:r});else i.expression=hh({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.optional}),parameters:[i.expression]}),i.typeName=Q.ZodOptional),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return i},_h=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=gh({plugin:e,schema:t,state:n}),a=L(r);xm({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},vh=({plugin:e})=>{e.registerSymbol({external:Sm({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Cm({getAst:(n,r)=>gh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:_h({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:_h({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:_h({plugin:e,schema:t.schema,state:n});break;case`webhook`:wm({getAst:(n,r)=>gh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},yh=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return nh(e);case`mini`:return Bm(e);case 4:default:return vh(e)}},bh={api:new bm({name:`zod`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:yh,name:`zod`,resolveConfig:(e,t)=>{let n=t.package.getVersion(`zod`),r=()=>n&&(n.major===4||n.major===3)?n.major:4,i=e=>{if(!e)return r();if(!n)return e;if((e===4||e===3||e===`mini`)&&!t.package.satisfies(n,`>=3.25.0 <5.0.0`)){let t=r();return console.warn(`🔌 ${u.default.yellow(`Warning:`)} Installed ${u.default.cyan(`zod`)} ${u.default.cyan(`v${n.version}`)} does not support compatibility version ${u.default.yellow(String(e))}, using ${u.default.yellow(String(t))}.`),t}return e};e.config.compatibilityVersion=i(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{local:!1,offset:!1},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}DataZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ResponseZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequestZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},xh=C(bh),Sh={"@angular/common":ml,"@hey-api/client-angular":jl,"@hey-api/client-axios":Pl,"@hey-api/client-fetch":Ll,"@hey-api/client-next":Bl,"@hey-api/client-nuxt":Ul,"@hey-api/client-ofetch":Kl,"@hey-api/schemas":yu,"@hey-api/sdk":Uu,"@hey-api/transformers":yd,"@hey-api/typescript":Zd,"@pinia/colada":_f,"@tanstack/angular-query-experimental":ap,"@tanstack/react-query":cp,"@tanstack/solid-query":dp,"@tanstack/svelte-query":mp,"@tanstack/vue-query":_p,arktype:Mp,fastify:Lp,"legacy/angular":Jl,"legacy/axios":Xl,"legacy/fetch":Ql,"legacy/node":eu,"legacy/xhr":nu,valibot:fm,zod:bh},Ch=[`@hey-api/typescript`,`@hey-api/sdk`],wh=({dependencies:e,userPlugins:t,userPluginsConfig:n})=>{let r=new Set,i=new Set,a={},o=s=>{if(r.has(s))throw Error(`Circular reference detected at '${s}'`);if(i.has(s))return;r.add(s);let c=Sh[s],l=n[s];if(!c&&!l)throw Error(`unknown plugin dependency "${s}" - do you need to register a custom plugin with this name?`);let u={...c,...l,config:{...c?.config,...l?.config},dependencies:new Set([...c?.dependencies||[],...l?.dependencies||[]])};if(u.resolveConfig){let r={package:ft(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=Sh[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=Sh[i]||n[i];if(t&&t.tags?.includes(e)&&i!==s)return i}throw Error(a||`missing plugin - no plugin with tag "${e}" found`)},valueToObject:Ue};u.resolveConfig(u,r)}for(let e of u.dependencies)o(e);r.delete(s),i.add(s),a[s]=u};for(let e of t)o(e);return{pluginOrder:Array.from(i),plugins:a}},Th=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`),Eh=({dependencies:e,userConfig:t})=>{let n={},r=Ch;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&Th(t.plugins[0])?[...Ch,...t.plugins]:t.plugins),wh({dependencies:e,userPlugins:r.map(e=>{if(typeof e==`string`)return e;let t=e.name;return t&&(e.handler?n[t]=e:(n[t]={config:{...e}},delete n[t].config.name)),t}).filter(Boolean),userPluginsConfig:n})},Dh=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),Oh=async({logger:e,userConfigs:t})=>{let n=[],r={},i=e.timeEvent(`load`);for(let i of t){let t;if(i?.configFile){let e=i.configFile.split(`.`);t=e.slice(0,e.length-1).join(`.`)}let a=e.timeEvent(`c12`),{loadConfig:o}=await import(`c12`),{config:s,configFile:c}=await o({configFile:t,name:`openapi-ts`});a.timeEnd(),Object.keys(r).length||(r=Ge(Object.keys(s).length?c:void 0));let l=s instanceof Array?s.map(e=>Be(e,i)):[Be(s,i)];for(let e of l){let t=Le(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${u.default.yellow(`Warning:`)} You provided ${u.default.cyan(String(r))} ${u.default.cyan(r===1?`input`:`inputs`)} and ${u.default.yellow(String(i))} ${u.default.yellow(`outputs`)}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let r of e.output)n.push({...e,input:t,output:r})}else e.output.forEach((r,i)=>{n.push({...e,input:t[i],output:r})});else n.push({...e,input:t,output:e.output[0]??``})}else n.push({...e,input:t})}}i.timeEnd();let a=[],o=e.timeEvent(`build`);for(let e of n){let{base:t,configFile:n=``,dryRun:i=!1,experimentalParser:o=!0,exportCore:s=!0,name:c,request:l,useOptions:d=!0}=e,p=e.interactive===void 0?Dh():e.interactive,m=Re(e),h=Le(e),g=We(e),_=qe(e),v=[];h.length||v.push(new se(`missing input - which OpenAPI specification should we use to generate your output?`)),g.path||v.push(new se(`missing output - where should we generate your output?`)),!d&&m.level!==`silent`&&console.warn(`❗️ 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`),g.path=f.default.resolve(process.cwd(),g.path);let y;try{y=Eh({dependencies:r,userConfig:e})}catch(e){v.push(e),y={pluginOrder:[],plugins:{}}}let ee=_e({...y,base:t,configFile:n,dryRun:i,experimentalParser:o,exportCore:!1,input:h,interactive:p,logs:m,name:c,output:g,parser:_,request:l,useOptions:d});ee.exportCore=S(ee)?s:!1;let te=a.length;if(m.level===`debug`){let e=u.default.gray(`[Job ${te+1}] `);console.warn(`${e}${u.default.cyan(`config:`)}`,ee)}a.push({config:ee,errors:v,jobIndex:te})}return o.timeEnd(),{dependencies:r,results:a}},kh=Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`}),Ah=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},jh=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},Mh=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Nh=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(jh(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Ah(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Ph({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Ph=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},Fh=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=Mh(r),s=Object.entries(i).map(([t,i])=>Ph({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Ih=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=Nh({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=Fh({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=Ph({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},Lh=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Rh=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?Lh(n):Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t},zh=Ih({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),Bh=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=(0,_.getResolvedInput)({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await(0,_.sendRequest)({fetchOptions:{method:`HEAD`,...e,headers:Rh(e?.headers,r.headers)},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok&&r.isHeadMethodSupported)return{error:`not-ok`,response:s};if(r.isHeadMethodSupported===void 0&&(r.isHeadMethodSupported=s.ok),s.status===304)return{error:`not-modified`,response:s};if(o===void 0){let e=s.headers.get(`ETag`);e&&(o=e!==r.headers.get(`If-None-Match`),o&&r.headers.set(`If-None-Match`,e))}if(o===void 0){let e=s.headers.get(`Last-Modified`);e&&(o=e!==r.headers.get(`If-Modified-Since`),o&&r.headers.set(`If-Modified-Since`,e))}if(o===!1)return{error:`not-modified`,response:s}}try{let t=await(0,_.sendRequest)({fetchOptions:{method:`GET`,...e},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok)return{error:`not-ok`,response:s};if(a=s.body?await s.arrayBuffer():new ArrayBuffer(0),o===void 0){let e=new TextDecoder().decode(a);o=e!==r.lastValue,r.lastValue=e}}else r.lastValue?o=!1:r.lastValue=i.type;return o===!1?{error:`not-modified`,response:s}:{arrayBuffer:a,resolvedInput:i}};Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`F`,{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,`I`,{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,`L`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,`P`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`R`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return Xn}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return kl}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return _l}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return Ss}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return ws}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return xr}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return hi}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return mu}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return Ic}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return as}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Oh}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Tl}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return ds}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Ch}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return gl}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Bh}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return Lc}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return T}});
24
- //# sourceMappingURL=getSpec-dCAz_woE.cjs.map
23
+ `})),u.push(e)}),r(I.classDeclaration({decorator:o.name===`legacy/angular`?{args:[{providedIn:`root`}],name:`Injectable`}:void 0,exportClass:!0,name:as({config:a,name:i.name}),nodes:u}))},Ru=({client:e,files:t,plugin:n})=>{let r=x(),i=S(r);if(t.sdk=new mu({dir:r.output.path,exportFromIndex:n.config.exportFromIndex,id:`sdk`,name:`sdk.ts`}),!i)t.sdk.import({module:bl({config:r,sourceOutput:`sdk`}),name:`createClient`}),t.sdk.import({module:bl({config:r,sourceOutput:`sdk`}),name:`createConfig`}),t.sdk.import({asType:!0,module:bl({config:r,sourceOutput:`sdk`}),name:`OptionsLegacyParser`});else if(b(r).name===`legacy/angular`?(t.sdk.import({module:`@angular/core`,name:`Injectable`}),ve(r)||t.sdk.import({module:`@angular/common/http`,name:`HttpClient`}),t.sdk.import({asType:!0,module:`rxjs`,name:`Observable`})):t.sdk.import({asType:!0,module:`./core/CancelablePromise`,name:`CancelablePromise`}),r.plugins[`@hey-api/sdk`]?.config.response===`response`&&t.sdk.import({asType:!0,module:`./core/ApiResult`,name:`ApiResult`}),ve(r)){let e=b(r);t.sdk.import({asType:e.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(!i){let e=b(r),n=I.constVariable({exportConst:!0,expression:I.callExpression({functionName:`createClient`,parameters:[I.callExpression({functionName:`createConfig`,parameters:[`throwOnError`in e&&e.throwOnError?I.objectExpression({obj:[{key:`throwOnError`,value:!0}]}):void 0]})]}),name:`client`});t.sdk.add(n)}for(let n of e.services)Lu({client:e,onClientImport:e=>{t.sdk.import({module:bl({config:r,sourceOutput:`sdk`}),name:e})},onImport:e=>{t.sdk.import({asType:!e.endsWith(`Transformer`),module:`./${t.types.nameWithoutExtension()}`,name:e})},onNode:e=>{t.sdk.add(e)},service:n})},zu=({plugin:e})=>{let t=b(e.context.config),n=t.name===`@hey-api/client-nuxt`;e.forEach(`operation`,r=>{let{operation:i}=r,a=$c({context:e.context,operation:i}),o=e.getPluginOrThrow(`@hey-api/typescript`),s=n?e.getSymbol(o.api.selector(`response`,i.id)):void 0,c=Yc({isRequiredOptions:a,operation:i,plugin:e}),l=Zc({isRequiredOptions:a,opParameters:c,operation:i,plugin:e}),u=e.registerSymbol({meta:{path:r._path,tags:r.tags},name:Fu({config:e.context.config,handleIllegal:!0,id:i.id,operation:i}),selector:e.api.selector(`function`,i.id)}),d=I.constVariable({comment:Qc({operation:i}),exportConst:!0,expression:I.arrowFunction({parameters:c.parameters,returnType:void 0,statements:l,types:n?[{default:I.ots.string(`$fetch`),extends:I.typeNode(e.referenceSymbol(e.api.selector(`Composable`)).placeholder),name:Bc},{default:s?I.typeReferenceNode({typeName:s.placeholder}):I.typeNode(`undefined`),extends:s?I.typeReferenceNode({typeName:s.placeholder}):void 0,name:Vc}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]}),name:u.placeholder});e.setSymbolValue(u,d)},{order:`declarations`})},Bu=({plugin:e})=>{let t=xl(e.context.config),n=b(e.context.config).name===`@hey-api/client-nuxt`,r=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`TDataShape`}),i=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`Client`,selector:e.api.selector(`Client`)}),a=e.registerSymbol({external:t,meta:{kind:`type`,path:[]},name:`Options`}),o=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:`Options`,selector:e.api.selector(`Options`)}),s=I.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:I.typeIntersectionNode({types:[I.typeReferenceNode({typeArguments:n?[I.typeReferenceNode({typeName:`TComposable`}),I.typeReferenceNode({typeName:`TData`}),I.typeReferenceNode({typeName:Hc}),I.typeReferenceNode({typeName:Vc})]:[I.typeReferenceNode({typeName:`TData`}),I.typeReferenceNode({typeName:`ThrowOnError`})],typeName:a.placeholder}),I.typeInterfaceNode({properties:[{comment:["You can provide a client instance returned by `createClient()` instead of",`individual options. This might be also useful if you want to implement a`,`custom client.`],isRequired:!e.config.client,name:`client`,type:I.typeReferenceNode({typeName:i.placeholder})},{comment:["You can pass arbitrary values through the `meta` object. This can be",`used to access values that aren't defined as part of the SDK function.`],isRequired:!1,name:`meta`,type:I.typeReferenceNode({typeArguments:[I.keywordTypeNode({keyword:`string`}),I.keywordTypeNode({keyword:`unknown`})],typeName:`Record`})}],useLegacyResolution:!1})]}),typeParameters:n?[I.typeParameterDeclaration({constraint:I.typeReferenceNode({typeName:e.referenceSymbol(e.api.selector(`Composable`)).placeholder}),defaultType:I.typeNode(`'$fetch'`),name:`TComposable`}),I.typeParameterDeclaration({constraint:I.typeReferenceNode({typeName:r.placeholder}),defaultType:I.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),I.typeParameterDeclaration({defaultType:I.keywordTypeNode({keyword:`unknown`}),name:Hc}),I.typeParameterDeclaration({defaultType:I.keywordTypeNode({keyword:`undefined`}),name:Vc})]:[I.typeParameterDeclaration({constraint:I.typeReferenceNode({typeName:r.placeholder}),defaultType:I.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),I.typeParameterDeclaration({constraint:I.keywordTypeNode({keyword:`boolean`}),defaultType:I.keywordTypeNode({keyword:`boolean`}),name:`ThrowOnError`})]});e.setSymbolValue(o,s)},Vu=({plugin:e})=>{let t=xl(e.context.config);e.registerSymbol({external:t,name:`formDataBodySerializer`,selector:e.api.selector(`formDataBodySerializer`)}),e.registerSymbol({external:t,name:`urlSearchParamsBodySerializer`,selector:e.api.selector(`urlSearchParamsBodySerializer`)}),e.registerSymbol({external:t,name:`buildClientParams`,selector:e.api.selector(`buildClientParams`)});let n=b(e.context.config),r=n.name===`@hey-api/client-angular`;n.name===`@hey-api/client-nuxt`&&e.registerSymbol({external:t,meta:{kind:`type`},name:`Composable`,selector:e.api.selector(`Composable`)}),r&&e.config.asClass&&e.registerSymbol({external:`@angular/core`,name:`Injectable`,selector:e.api.selector(`Injectable`)}),Bu({plugin:e}),e.config.asClass?Cu({plugin:e}):zu({plugin:e})},Hu=e=>Vu(e),Uu={api:new xu({name:`@hey-api/sdk`}),config:{asClass:!1,auth:!0,classNameBuilder:`{{name}}`,classStructure:`auto`,client:!0,exportFromIndex:!0,instance:!1,operationId:!0,params_EXPERIMENTAL:`default`,response:`body`,responseStyle:`fields`,transformer:!1,validator:!1},dependencies:[`@hey-api/typescript`],handler:Hu,handlerLegacy:Ru,name:`@hey-api/sdk`,resolveConfig:(e,t)=>{e.config.client?(typeof e.config.client==`boolean`&&(e.config.client=t.pluginByTag(`client`,{defaultPlugin:`@hey-api/client-fetch`})),e.dependencies.add(e.config.client)):e.config.client=!1,e.config.transformer?(typeof e.config.transformer==`boolean`&&(e.config.transformer=t.pluginByTag(`transformer`)),e.dependencies.add(e.config.transformer)):e.config.transformer=!1,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=!1,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=!1,e.config.instance?(typeof e.config.instance!=`string`&&(e.config.instance=`Sdk`),e.config.asClass=!0):e.config.instance=!1,e.config.classNameBuilder===`{{name}}`&&e.config.client===`@hey-api/client-angular`&&(e.config.classNameBuilder=`{{name}}Service`)}},Wu=C(Uu);var Gu=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Ku=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:I.callExpression({functionName:`BigInt`,parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:e,name:`toString`})})]});if(n){if(typeof e==`string`)return[n];if(e)return[I.assignment({left:e,right:n})]}},qu=({dataExpression:e,schema:t})=>{if(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))return;let n=I.identifier({text:`Date`});if(typeof e==`string`)return[I.newExpression({argumentsArray:[I.identifier({text:e})],expression:n})];if(e)return[I.assignment({left:e,right:I.newExpression({argumentsArray:[e],expression:n})})]},Ju=`data`,Yu=e=>e.map(e=>m.default.isStatement(e)?e:I.expressionToStatement({expression:e})),Xu=({node:e})=>e.kind===m.default.SyntaxKind.ReturnStatement,Zu=({plugin:e,schema:t})=>{let n=I.identifier({text:Ju}),r=Qu({dataExpression:n,plugin:e,schema:t});return r.length&&!Xu({node:r[r.length-1]})&&r.push(I.returnStatement({expression:n})),r},Qu=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r=t.api.selector(`response-ref`,n.$ref);if(!t.getSymbol(r)){let e=t.registerSymbol({name:E({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:L(n.$ref)}),selector:r}),i=Zu({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(i.length){let n=I.constVariable({expression:I.arrowFunction({async:!1,multiLine:!0,parameters:[{name:Ju,type:I.keywordTypeNode({keyword:`any`})}],statements:Yu(i)}),name:e.placeholder});t.setSymbolValue(e,n)}}if(t.isSymbolRegistered(r)){let n=t.referenceSymbol(r),i=I.callExpression({functionName:n.placeholder,parameters:[e]});if(e)return typeof e==`string`&&e===`item`?[I.returnStatement({expression:i})]:[typeof e==`string`?i:I.assignment({left:e,right:i})]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?Qu({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=Yu(r);return i.some(e=>Xu({node:e}))||i.push(I.returnStatement({expression:I.identifier({text:`item`})})),[I.assignment({left:e,right:I.callExpression({functionName:I.propertyAccessExpression({expression:e,name:`map`}),parameters:[I.arrowFunction({multiLine:!0,parameters:[{name:`item`,type:`any`}],statements:i})]})})]}if(n.type===`object`){let r=[],i=n.required??[];for(let a in n.properties){let o=n.properties[a],s=I.propertyAccessExpression({expression:e||Ju,name:a}),c=Qu({dataExpression:s,plugin:t,schema:o});if(!c.length)continue;let l=!o.items?.find(e=>e.type===`null`);i.includes(a)&&l?r=r.concat(c):r.push(I.ifStatement({expression:s,thenStatement:I.block({statements:Yu(c)})}))}return r}if(n.items){if(n.items.length===1)return Qu({dataExpression:`item`,plugin:t,schema:n.items[0]});let r=[];if(n.logicalOperator===`and`||n.items.length===2&&n.items.find(e=>e.type===`null`||e.type===`void`)){for(let i of n.items){let n=Qu({dataExpression:e||`item`,plugin:t,schema:i});if(n.length)if(e)r=r.concat(n);else{let e=I.identifier({text:`item`});r.push(I.ifStatement({expression:e,thenStatement:I.block({statements:Yu(n)})}),I.returnStatement({expression:e}))}}return r}n.type!==`enum`&&((n.items??[]).every(e=>[`boolean`,`integer`,`null`,`number`,`string`].includes(e.type))||console.warn(`❗️ Transformers warning: schema ${JSON.stringify(n)} is too complex and won't be currently processed. This will likely produce an incomplete transformer which is not what you want. Please open an issue if you'd like this improved https://github.com/hey-api/openapi-ts/issues`))}for(let r of t.config.transformers){let i=r({config:t.config,dataExpression:e,schema:n});if(i)return i}return[]},$u=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=ut(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${k(t)} has ${n.items.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);return}let r=e.getPluginOrThrow(`@hey-api/typescript`),i=e.getSymbol(r.api.selector(`response`,t.id));if(!i)return;let a=Zu({plugin:e,schema:n});if(!a.length)return;let o=e.registerSymbol({exported:!0,name:E({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id}),selector:e.api.selector(`response`,t.id)}),s=I.constVariable({exportConst:o.exported,expression:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:Ju,type:I.keywordTypeNode({keyword:`any`})}],returnType:I.typeReferenceNode({typeArguments:[I.typeReferenceNode({typeName:i.placeholder})],typeName:`Promise`}),statements:Yu(a)}),name:o.placeholder});e.setSymbolValue(o,s)},{order:`declarations`})},ed=`$OpenApiTs`,K={$refs:[],base:``,description:null,enum:[],enums:[],export:`interface`,imports:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:``,properties:[],template:null,type:``},td=({comments:e,leadingComment:t,meta:n,obj:r,onNode:i,...a})=>{if(!n)return;let{created:o,name:s}=Vs({create:!0,meta:n,...a});if(o){let n=x().plugins[`@hey-api/typescript`];i(I.enumDeclaration({asConst:typeof n?.config.enums==`object`&&n.config.enums.mode===`typescript-const`,comments:e,leadingComment:t,name:s,obj:r}))}},nd=({comment:e,meta:t,onCreated:n,onNode:r,type:i,...a})=>{if(!t)return{created:!1,name:``};let o=Vs({create:!0,meta:t,...a}),{created:s,name:c}=o;return s&&(r(I.typeAliasDeclaration({comment:e,exportType:!0,name:c,type:i})),n?.(c)),o},rd=e=>{let t=[];od(e),e.model.enums.forEach(n=>ad({...e,model:n,onNode:e=>{t.push(e)}})),t.length&&e.onNode(I.namespaceDeclaration({name:e.model.name,statements:t}))},id=({client:e,model:t,onNode:n})=>{let r=x(),i={},a={};t.enum.forEach(e=>{let{key:t,value:n}=Os(e);i[t]=n;let r=e.customDescription||e.description;r&&(a[t]=[j(r)])});let o=[t.description&&j(t.description),t.deprecated&&`@deprecated`],s=r.plugins[`@hey-api/typescript`];if(s?.config&&typeof s.config.enums==`object`&&s.config.enums.enabled&&(s.config.enums.mode===`typescript`||s.config.enums.mode===`typescript-const`)){td({asConst:s.config.enums.mode===`typescript-const`,client:e,comments:a,leadingComment:o,meta:t.meta,obj:i,onNode:n});return}nd({client:e,comment:o,meta:t.meta,onCreated:e=>{let t=r.plugins[`@hey-api/typescript`];if(t?.config&&typeof t.config.enums==`object`&&t.config.enums.enabled&&t.config.enums.mode===`javascript`){let t=I.objectExpression({multiLine:!0,obj:Object.entries(i).map(([e,t])=>({comments:a[e],key:e,value:t})),unescape:!0});n(I.constVariable({assertion:`const`,comment:o,exportConst:!0,expression:t,name:e}))}},onNode:n,type:Es(t.enum)})},ad=({model:e,onNode:t})=>{let n={},r={};e.enum.forEach(e=>{let{key:t,value:i}=Os(e);n[t]=i;let a=e.customDescription||e.description;a&&(r[t]=[j(a)])});let i=x().plugins[`@hey-api/typescript`];t(I.enumDeclaration({asConst:typeof i?.config.enums==`object`&&i.config.enums.mode===`typescript-const`,comments:r,leadingComment:[e.description&&j(e.description),e.deprecated&&`@deprecated`],name:e.meta?.name||e.name,obj:n}))},od=({client:e,model:t,onNode:n})=>{nd({client:e,comment:[t.description&&j(t.description),t.deprecated&&`@deprecated`],meta:t.meta,onNode:n,type:Bs(t)})},sd=e=>{switch(e.model.export){case`all-of`:case`any-of`:case`one-of`:case`interface`:return rd(e);case`enum`:return id(e);default:return od(e)}},cd=({client:e,onNode:t})=>{let n={},r=x();if(!r.plugins[`@hey-api/sdk`]&&!r.plugins[`@hey-api/typescript`]?.config.tree)return;let i=S(r);for(let r of e.services)for(let a of r.operations){if(!a.parameters.length&&!a.responses.length)continue;n[a.path]||(n[a.path]={});let r=n[a.path];r[a.method]||(r[a.method]={});let o=r[a.method];if(o.$ref=a.name,a.responses.length>0){if(o.res||={},Array.isArray(o.res))continue;a.responses.forEach(e=>{o.res[e.code]=e})}if(a.parameters.length>0){let n={mediaType:null,...K,in:`body`,name:`body`,prop:`body`},r=a.parameters.filter(e=>e.in===`body`);r.length||(r=a.parameters.filter(e=>e.in===`formData`)),r.length===1?n={...K,...r[0],in:`body`,isRequired:r[0].isRequired,name:`body`,prop:`body`}:r.length>1&&(n={...K,in:`body`,isRequired:r.some(e=>e.isRequired),mediaType:`multipart/form-data`,name:`body`,prop:`body`,properties:r});let s={...K,in:`header`,isRequired:Gs(a.parameters.filter(e=>e.in===`header`)),mediaType:null,name:i?`header`:`headers`,prop:i?`header`:`headers`,properties:a.parameters.filter(e=>e.in===`header`).sort(Cs)},c={...K,in:`path`,isRequired:Gs(a.parameters.filter(e=>e.in===`path`)),mediaType:null,name:`path`,prop:`path`,properties:a.parameters.filter(e=>e.in===`path`).sort(Cs)},l={...K,in:`query`,isRequired:Gs(a.parameters.filter(e=>e.in===`query`)),mediaType:null,name:`query`,prop:`query`,properties:a.parameters.filter(e=>e.in===`query`).sort(Cs)},u=i?ws([...a.parameters]):[n,s,c,l].filter(e=>e.properties.length||e.$refs.length||e.mediaType);o.req=u,nd({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:Eu,onNode:t,type:Bs({...K,isRequired:!0,properties:u})})}let s=a.responses.filter(e=>e.responseTypes.includes(`success`));if(s.length>0){nd({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:ku,onNode:t,type:Bs({...K,export:`any-of`,isRequired:!0,properties:s})});let n=a.responses.filter(e=>e.responseTypes.includes(`error`));i||nd({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:Du,onNode:t,type:Bs(n.length?{...K,export:`one-of`,isRequired:!0,properties:n}:{...K,base:`unknown`,isRequired:!0,type:`unknown`})})}}let a=Object.entries(n).map(([t,n])=>{let r=Object.entries(n).map(([t,n])=>{let r=t,i=[];if(n.req){let t=n.$ref,{name:r}=Vs({client:e,meta:{$ref:t,name:t},nameTransformer:Eu}),a={...K,base:r,export:`reference`,isRequired:!0,name:`req`,properties:[],type:r};i=[...i,a]}if(n.res){let e=Object.entries(n.res).map(([e,t])=>({...K,...t,isRequired:!0,name:String(e)})),t={...K,isRequired:!0,name:`res`,properties:e};i=[...i,t]}return{...K,isRequired:!0,name:r.toLocaleLowerCase(),properties:i}}).filter(Boolean);return{...K,isRequired:!0,name:`'${t}'`,properties:r}});r.plugins[`@hey-api/typescript`]?.config.tree&&nd({client:e,meta:{$ref:`@hey-api/openapi-ts`,name:`$OpenApiTs`},onNode:t,type:Bs({...K,properties:a})})},ld=({client:e,files:t,plugin:n})=>{t.types=new mu({dir:x().output.path,exportFromIndex:n.config.exportFromIndex,id:`types`,name:`types.ts`});let r=e=>{t.types?.add(e)};for(let t of e.models)sd({client:e,model:t,onNode:r});cd({client:e,onNode:r})},ud=`data`,dd=e=>e.base===`unknown`&&e.export===`generic`&&e.type===`unknown`,fd=({client:e,model:t})=>t.$refs.map(t=>{let n=e.models.find(e=>e.meta?.$ref===t);if(!n)throw Error(`Ref ${t} could not be found. Transformers cannot be generated without having access to all refs.`);return n}),pd=e=>{let t=e.model.meta.name,{name:n}=nd({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:Tu,onCreated:n=>{let r=gd({...e,meta:{$ref:`transformers/${t}`,name:n},path:[ud]});_d({...e,async:!1,name:n,statements:r})},type:`(${ud}: any) => ${t}`});return{created:!!e.client.types[n],name:n}},md=e=>{let{model:t}=e,n=fd(e);if(n.length===1){let{created:t,name:r}=pd({...e,model:n[0]});return t?[I.transformArrayMutation({path:e.path,transformerName:r})]:[]}return Ms(t)||t.link&&!Array.isArray(t.link)&&t.link.export===`any-of`&&t.link.properties.find(e=>Ms(e))?[I.transformArrayMap({path:e.path,transformExpression:I.conditionalExpression({condition:I.identifier({text:`item`}),whenFalse:I.identifier({text:`item`}),whenTrue:I.transformNewDate({parameterName:`item`})})})]:[]},hd=e=>{let{model:t}=e,n=[...e.path,t.name];return t.type===`string`&&t.export!==`array`&&Ms(t)?[I.transformDateMutation({path:n})]:gd({...e,model:t,path:n})},gd=e=>{let{model:t}=e;switch(t.export){case`array`:return md(e);case`interface`:return t.properties.flatMap(t=>hd({...e,model:t}));case`reference`:{if(t.$refs.length!==1)return[];let n=fd(e),{created:r,name:i}=pd({...e,model:n[0]});return r?t.in===`response`?[I.expressionToStatement({expression:I.callExpression({functionName:i,parameters:[ud]})})]:I.transformFunctionMutation({path:e.path,transformerName:i}):[]}default:return[]}},_d=({async:e,client:t,name:n,onNode:r,onRemoveNode:i,statements:a})=>{let o={created:!1,name:n};if(!a.length)return Hs({client:t,name:n}),i?.(),o;let s=I.arrowFunction({async:e,multiLine:!0,parameters:[{name:ud}],statements:[...a,I.returnVariable({expression:ud})]});return r(I.constVariable({exportConst:!0,expression:s,name:n,typeName:n})),{created:!0,name:n}},vd=({client:e,files:t})=>{let n=x(),r=e=>{t.types?.add(e)},i=()=>{t.types?.removeNode_LEGACY()};for(let t of e.services)for(let a of t.operations){let t=a.responses.filter(e=>e.responseTypes.includes(`success`));if(!t.length)continue;let o=t.filter(e=>!dd(e));if(!o.length)continue;if(o.length>1){n.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${k(a)} has ${o.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 s=ku(a.name);nd({client:e,meta:{$ref:`transformers/${s}`,name:s},nameTransformer:Ou,onCreated:n=>{_d({async:!0,client:e,name:n,onNode:r,onRemoveNode:i,statements:t.length>1?t.flatMap(t=>{let n=gd({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t,onNode:r,onRemoveNode:i,path:[ud]});return n.length?[I.ifStatement({expression:I.safeAccessExpression([`data`]),thenStatement:I.block({statements:n})})]:[]}):gd({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t[0],onNode:r,onRemoveNode:i,path:[ud]})})},onNode:r,type:`(${ud}: any) => Promise<${s}>`})}},yd={api:new Gu({name:`@hey-api/transformers`}),config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:$u,handlerLegacy:vd,name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,qu]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,Ku])},tags:[`transformer`]},bd=C(yd),q=e=>({value:e}),J=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=q(e[n]));return t},xd=I.keywordTypeNode({keyword:`string`}),Sd=({server:e})=>{let t=ya(e.url);return t.protocol&&t.host?I.literalTypeNode({literal:I.stringLiteral({text:e.url})}):I.templateLiteralType({value:[t.protocol||xd,`://`,t.host||xd,t.port?`:${t.port}`:``,t.path||``]})},Cd=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=b(e.context.config),i=t.map(e=>Sd({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(I.typeIntersectionNode({types:[xd,m.default.factory.createTypeLiteralNode([])]})):i.push(xd);let a=I.typeInterfaceNode({properties:[{name:he(e.context.config),type:I.typeUnionNode({types:i})}],useLegacyResolution:!1}),o=I.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:a});e.setSymbolValue(n,o)},wd=({schema:e})=>{let t=[];return e.title&&t.push(j(e.title)),e.description&&(t.length&&t.push(``),t.push(j(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Td=({plugin:e,schema:t})=>{let n=[];return{obj:(t.items??[]).map((t,r)=>{let i=typeof t.const;n.includes(i)||n.push(i);let a;return a=t.title?t.title:i===`number`||i===`string`?`${t.const}`:i===`boolean`?t.const?`true`:`false`:t.const===null?`null`:`${r}`,a&&(a=T({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),A.lastIndex=0,A.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{comments:wd({schema:t}),key:a,value:t.const}}),typeofItems:n}},Ed=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=Td({plugin:e,schema:t});if(e.config.enums.mode===`javascript`){e.config.enums.constantsIgnoreNull&&r.typeofItems.includes(`object`)&&(r.obj=r.obj.filter(e=>e.value!==null));let i=I.constVariable({assertion:`const`,comment:wd({schema:t}),exportConst:!0,expression:I.objectExpression({multiLine:!0,obj:r.obj}),name:n.placeholder}),a=I.typeOfExpression({text:n.placeholder}),o=I.typeAliasDeclaration({comment:wd({schema:t}),exportType:!0,name:n.placeholder,type:I.indexedAccessTypeNode({indexType:I.typeOperatorNode({operator:`keyof`,type:a}),objectType:a})});e.setSymbolValue(n,[i,o]);return}else if((e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&!r.typeofItems.some(e=>e!==`number`&&e!==`string`)){let i=I.enumDeclaration({asConst:e.config.enums.mode===`typescript-const`,leadingComment:wd({schema:t}),name:n.placeholder,obj:r.obj});e.setSymbolValue(n,i);return}}let i=I.typeAliasDeclaration({comment:wd({schema:t}),exportType:n.exported,name:n.placeholder,type:r});e.setSymbolValue(n,i)},Dd=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=D({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},Od=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];r.properties||={},e.body?(r.properties.body=e.body.schema,e.body.required&&i.push(`body`)):r.properties.body={type:`never`},e.parameters?.header&&(r.properties.headers=Dd({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=Dd({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=Dd({parameters:e.parameters.query}),r.properties.query.required&&i.push(`query`)):r.properties.query={type:`never`},r.properties.url={const:e.path,type:`string`},i.push(`url`),r.required=i;let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.requests,name:e.id}),selector:t.api.selector(`data`,e.id)}),o=Y({plugin:t,schema:r,state:n}),s=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s)},kd=({operation:e,plugin:t,state:n})=>{Od({operation:e,plugin:t,state:n});let{error:r,errors:i,response:a,responses:o}=ut(e);if(i){let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.errors,name:e.id}),selector:t.api.selector(`errors`,e.id)}),o=Y({plugin:t,schema:i,state:n}),s=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});if(t.setSymbolValue(a,s),r){let r=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),selector:t.api.selector(`error`,e.id)}),i=I.indexedAccessTypeNode({indexType:I.typeOperatorNode({operator:`keyof`,type:I.typeReferenceNode({typeName:a.placeholder})}),objectType:I.typeReferenceNode({typeName:a.placeholder})}),o=I.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});t.setSymbolValue(r,o)}}if(o){let r=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.responses,name:e.id}),selector:t.api.selector(`responses`,e.id)}),i=Y({plugin:t,schema:o,state:n}),s=I.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});if(t.setSymbolValue(r,s),a){let i=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),selector:t.api.selector(`response`,e.id)}),a=I.indexedAccessTypeNode({indexType:I.typeOperatorNode({operator:`keyof`,type:I.typeReferenceNode({typeName:r.placeholder})}),objectType:I.typeReferenceNode({typeName:r.placeholder})}),o=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});t.setSymbolValue(i,o)}}},Ad=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];if(r.properties||={},e.body){let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id}),selector:t.api.selector(`webhook-payload`,e.id)}),o=Y({plugin:t,schema:e.body.schema,state:n}),s=I.typeAliasDeclaration({comment:wd({schema:e.body.schema}),exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s),t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:a.name,placeholder:a.placeholder,selector:t.api.selector(`ref`,a.placeholder)}),r.properties.body={$ref:a.placeholder},i.push(`body`)}else r.properties.body={type:`never`};r.properties.key={const:e.path,type:`string`},i.push(`key`),r.properties.path={type:`never`},r.properties.query={type:`never`},r.required=i;let a=t.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:t.config.webhooks,name:e.id}),selector:t.api.selector(`webhook-request`,e.id)}),o=Y({plugin:t,schema:r,state:n}),s=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});return t.setSymbolValue(a,s),a.placeholder},jd=({operation:e,plugin:t,state:n})=>Ad({operation:e,plugin:t,state:n}),Md=({plugin:e,symbolWebhooks:t,webhookNames:n})=>{if(!n.length)return;let r=I.typeUnionNode({types:n.map(e=>I.typeReferenceNode({typeName:e}))}),i=I.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:r});e.setSymbolValue(t,i)},Nd=({plugin:e,schema:t,state:n})=>{if(!t.items)return I.typeArrayNode(I.keywordTypeNode({keyword:e.config.topType}));t=D({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=Y({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});r.push(a)}),r.length===1?I.typeArrayNode(r[0]):t.logicalOperator===`and`?I.typeArrayNode(I.typeIntersectionNode({types:r})):I.typeArrayNode(I.typeUnionNode({types:r}))},Pd=({schema:e})=>e.const===void 0?I.keywordTypeNode({keyword:`boolean`}):I.literalTypeNode({literal:I.ots.boolean(e.const)}),Fd=({plugin:e,schema:t,state:n})=>Y({plugin:e,schema:{...t,type:void 0},state:n}),Id=e=>I.keywordTypeNode({keyword:`never`}),Ld=e=>I.literalTypeNode({literal:I.null()}),Rd=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?I.typeReferenceNode({typeName:`bigint`}):I.keywordTypeNode({keyword:`number`}):I.literalTypeNode({literal:I.ots.number(t.const)}),zd=({context:e,name:t})=>(A.lastIndex=0,A.test(t)?t.startsWith(`-`)?m.default.factory.createStringLiteral(t):m.default.factory.createNumericLiteral(t):T({case:e.config.output.case,value:t})),Bd=({plugin:e,schema:t,state:n})=>{let r,i,a=[],o=[],s=t.required??[],c=!1;for(let r in t.properties){let i=t.properties[r],l=Y({plugin:e,schema:i,state:{...n,path:q([...n.path.value,`properties`,r])}}),u=s.includes(r);a.push({comment:wd({schema:i}),isReadOnly:i.accessScope===`read`,isRequired:u,name:zd({context:e.context,name:r}),type:l}),o.push(i),u||(c=!0)}if(t.patternProperties)for(let e in t.patternProperties){let n=t.patternProperties[e];o.unshift(n)}let l=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,u=t.additionalProperties,d=u!==!1&&u?u:void 0;if(l||d&&(d.type!==`never`||!o.length)){let a=d;a&&a.type!==`never`?o.unshift(a):!l&&!o.length&&a&&a.type===`never`&&(o=[a]),c&&o.push({type:`undefined`}),i={isRequired:!t.propertyNames,name:`key`,type:o.length===1?Y({plugin:e,schema:o[0],state:n}):Y({plugin:e,schema:{items:o,logicalOperator:`or`},state:n})},t.propertyNames?.$ref&&(r=Y({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n}))}return I.typeInterfaceNode({indexKey:r,indexProperty:i,properties:a,useLegacyResolution:!1})},Vd=({plugin:e,schema:t})=>{if(t.const!==void 0)return I.literalTypeNode({literal:I.stringLiteral({text:t.const})});if(t.format){if(t.format===`binary`)return I.typeUnionNode({types:[I.typeReferenceNode({typeName:`Blob`}),I.typeReferenceNode({typeName:`File`})]});if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return I.typeReferenceNode({typeName:`Date`});if(t.format===`typeid`&&typeof t.example==`string`){let n=String(t.example).split(`_`);n.pop();let r=n.join(`_`),i=e.api.selector(`TypeID`,r);if(!e.getSymbol(i)){let t=e.api.selector(`TypeID`);if(!e.getSymbol(t)){let n=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:`TypeID`,selector:t}),r=I.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:I.templateLiteralType({value:[I.typeReferenceNode({typeName:`T`}),`_`,I.keywordTypeNode({keyword:`string`})]}),typeParameters:[I.typeParameterDeclaration({constraint:I.keywordTypeNode({keyword:`string`}),name:`T`})]});e.setSymbolValue(n,r)}let n=e.referenceSymbol(t),a=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:T({case:e.config.case,value:`${r}_id`}),selector:i}),o=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:I.typeReferenceNode({typeArguments:[I.literalTypeNode({literal:I.stringLiteral({text:r})})],typeName:n.placeholder})});e.setSymbolValue(a,o)}let a=e.referenceSymbol(i);return I.typeReferenceNode({typeName:a.placeholder})}}return I.keywordTypeNode({keyword:`string`})},Hd=({plugin:e,schema:t,state:n})=>{let r=[];return t.const&&Array.isArray(t.const)?r=t.const.map(t=>I.valueToExpression({value:t})??I.identifier({text:e.config.topType})):t.items&&t.items.forEach((t,i)=>{let a=Y({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});r.push(a)}),I.typeTupleNode({types:r})},Ud=e=>I.keywordTypeNode({keyword:`undefined`}),Wd=({plugin:e})=>I.keywordTypeNode({keyword:e.config.topType}),Gd=e=>I.keywordTypeNode({keyword:`void`}),Kd=({schema:e,...t})=>{let n=t.plugin.getPlugin(`@hey-api/transformers`);if(n?.config.typeTransformers)for(let t of n.config.typeTransformers){let n=t({schema:e});if(n)return n}switch(e.type){case`array`:return Nd({...t,schema:e});case`boolean`:return Pd({...t,schema:e});case`enum`:return Fd({...t,schema:e});case`integer`:case`number`:return Rd({...t,schema:e});case`never`:return Id({...t,schema:e});case`null`:return Ld({...t,schema:e});case`object`:return Bd({...t,schema:e});case`string`:return Vd({...t,schema:e});case`tuple`:return Hd({...t,schema:e});case`undefined`:return Ud({...t,schema:e});case`unknown`:return Wd({...t,schema:e});case`void`:return Gd({...t,schema:e})}},Y=({plugin:e,schema:t,state:n})=>{if(t.$ref){let n=e.referenceSymbol(e.api.selector(`ref`,t.$ref));return I.typeReferenceNode({typeName:n.placeholder})}if(t.type)return Kd({plugin:e,schema:t,state:n});if(t.items){if(t=D({detectFormat:!1,schema:t}),t.items){let r=[];for(let i of t.items){let t=Y({plugin:e,schema:i,state:n});r.push(t)}return t.logicalOperator===`and`?I.typeIntersectionNode({types:r}):I.typeUnionNode({types:r})}return Y({plugin:e,schema:t,state:n})}return Kd({plugin:e,schema:{type:`unknown`},state:n})},qd=({plugin:e,schema:t,state:n})=>{let r=Y({plugin:e,schema:t,state:n}),i=t.type===`enum`&&e.config.enums.enabled,a=mr(n.path.value);Ed({plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{kind:i?void 0:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:L(a)}),selector:e.api.selector(`ref`,a)}),type:r})},Jd=({plugin:e})=>{let t=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:E({config:{case:e.config.case},name:`ClientOptions`}),selector:e.api.selector(`ClientOptions`)}),n=e.registerSymbol({exported:!0,meta:{kind:`type`,path:[]},name:E({config:{case:e.config.case},name:`Webhooks`}),selector:e.api.selector(`Webhooks`)}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=J({path:t._path,tags:t.tags});switch(t.type){case`operation`:kd({operation:t.operation,plugin:e,state:n});break;case`parameter`:qd({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:qd({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:qd({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(jd({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),Cd({plugin:e,servers:r,symbolClientOptions:t}),Md({plugin:e,symbolWebhooks:n,webhookNames:i})};var Yd=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}schemaToType(e){return Y(e)}};const Xd=e=>Jd(e),Zd={api:new Yd({name:`@hey-api/typescript`}),config:{case:`PascalCase`,exportFromIndex:!0,style:`preserve`,topType:`unknown`,tree:!1},handler:Xd,handlerLegacy:ld,name:`@hey-api/typescript`,resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.definitions}),e.config.enums=t.valueToObject({defaultValue:{case:`SCREAMING_SNAKE_CASE`,constantsIgnoreNull:!1,enabled:!!e.config.enums,mode:`javascript`},mappers:{boolean:e=>({enabled:e}),string:e=>({mode:e})},value:e.config.enums}),e.config.errors=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,error:`{{name}}Error`,name:`{{name}}Errors`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.errors}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}Data`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}Responses`,response:`{{name}}Response`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,name:`{{name}}WebhookRequest`,payload:`{{name}}WebhookPayload`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.config.webhooks})}},Qd=C(Zd);var $d=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const ef=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return I.valueToExpression({value:i})},tf=({operation:e,plugin:t})=>Jc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),nf=({operation:e,plugin:t})=>{let n=b(t.context.config),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`error`,e.id))?.placeholder;return i||=`Error`,n.name===`@hey-api/client-axios`&&(i=`${t.referenceSymbol(t.api.selector(`AxiosError`)).placeholder}<${i}>`),i},rf=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},af=({plugin:e,typeData:t})=>{let n=b(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},of=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`UseMutationOptions`)),i=tf({operation:e,plugin:t}),a=nf({operation:e,plugin:t}),o=rf({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=af({plugin:t,typeData:i}),l=s?`${r.placeholder}<${o}, ${c}, ${a}>`:`${r.placeholder}<${o}, ${i}, ${a}>`,u=`fnOptions`,d=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:u},{key:`throwOnError`,value:!0}]})]})}),f=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?f.push(I.returnVariable({expression:d})):f.push(I.constVariable({destructure:!0,expression:d,name:`data`}),I.returnVariable({expression:`data`}));let p=[{key:`mutation`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[s?{name:u,type:`Partial<${c}>`}:{name:u}],statements:f})}],m=ef(t,e,`mutationOptions`);m&&p.push({key:`meta`,value:m});let h=t.registerSymbol({exported:!0,name:E({config:t.config.mutationOptions,name:e.id})}),g=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:h.exported,expression:I.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${c}>`}],returnType:l,statements:[I.returnStatement({expression:I.objectExpression({obj:p})})]}),name:h.placeholder});t.setSymbolValue(h,g)},sf=`TOptions`,cf=I.identifier({text:`options`}),lf=({plugin:e})=>{let t=e.registerSymbol({name:E({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=e.referenceSymbol(e.api.selector(`_JSONValue`)),i=I.indexedAccessTypeNode({indexType:I.literalTypeNode({literal:I.ots.number(0)}),objectType:I.typeReferenceNode({typeArguments:[I.typeReferenceNode({typeName:sf})],typeName:n.placeholder})}),a=he(e.context.config),o=e.getPluginOrThrow(`@hey-api/sdk`),s=e.referenceSymbol(o.api.selector(`Options`)),c=b(e.context.config),l=c.api&&`selector`in c.api?e.getSymbol(c.api.selector(`client`)):void 0,u=xl(e.context.config),d=e.registerSymbol({external:u,name:`serializeQueryKeyValue`}),f=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:I.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:I.typeReferenceNode({typeName:sf})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:I.typeTupleNode({types:[i]}),statements:[I.constVariable({assertion:i,expression:I.objectExpression({multiLine:!1,obj:[{key:`_id`,value:I.identifier({text:`id`})},{key:a,value:I.identifier({text:`options?.${a} || (options?.client ?? ${l?.placeholder}).getConfig().${a}`})}]}),name:`params`,typeName:i}),I.ifStatement({expression:I.identifier({text:`tags`}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`tags`}),right:I.asExpression({expression:I.asExpression({expression:I.identifier({text:`tags`}),type:I.keywordTypeNode({keyword:`unknown`})}),type:I.typeReferenceNode({typeName:r.placeholder})})})})]})}),I.ifStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:cf,isOptional:!0,name:I.identifier({text:`body`})}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.constVariable({expression:I.callExpression({functionName:d.placeholder,parameters:[I.propertyAccessExpression({expression:`options`,name:`body`})]}),name:`normalizedBody`}),I.ifStatement({expression:I.binaryExpression({left:I.identifier({text:`normalizedBody`}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`body`}),right:I.identifier({text:`normalizedBody`})})})]})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:cf,isOptional:!0,name:I.identifier({text:`path`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`path`}),right:I.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),I.ifStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:cf,isOptional:!0,name:I.identifier({text:`query`})}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.constVariable({expression:I.callExpression({functionName:d.placeholder,parameters:[I.propertyAccessExpression({expression:`options`,name:`query`})]}),name:`normalizedQuery`}),I.ifStatement({expression:I.binaryExpression({left:I.identifier({text:`normalizedQuery`}),operator:`!==`,right:`undefined`}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`query`}),right:I.identifier({text:`normalizedQuery`})})})]})})]})}),I.returnStatement({expression:I.arrayLiteralExpression({elements:[I.identifier({text:`params`})]})})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:s.placeholder})}),name:sf}]}),name:t.placeholder});e.setSymbolValue(t,f)},uf=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;r.tags&&t.tags&&t.tags.length>0&&(i=I.arrayLiteralExpression({elements:t.tags.map(e=>I.stringLiteral({text:e}))}));let a=n.referenceSymbol(n.api.selector(`createQueryKey`));return I.callExpression({functionName:a.placeholder,parameters:[I.ots.string(e),`options`,i]})},df=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`_JSONValue`)),n=[{name:`_id`,type:I.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:he(e.context.config),type:I.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`body`,type:I.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`query`,type:I.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:t.placeholder})}],r=e.getPluginOrThrow(`@hey-api/sdk`),i=e.referenceSymbol(r.api.selector(`Options`)),a=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`QueryKey`,selector:e.api.selector(`QueryKey`)}),o=I.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:I.typeTupleNode({types:[I.typeIntersectionNode({types:[I.typeReferenceNode({typeName:`Pick<${sf}, 'path'>`}),I.typeInterfaceNode({properties:n,useLegacyResolution:!0})]})]}),typeParameters:[{extends:I.typeReferenceNode({typeName:I.identifier({text:i.placeholder})}),name:sf}]});e.setSymbolValue(a,o)},ff=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=af({plugin:t,typeData:tf({operation:e,plugin:t})});return I.constVariable({exportConst:n.exported,expression:I.arrowFunction({parameters:[{isRequired:st(e),name:`options`,type:r}],statements:uf({id:e.id,operation:e,plugin:t})}),name:n.placeholder})},pf=`options`,mf=`context`,hf=({operation:e,plugin:t,queryFn:n})=>{if(el({operation:e}))return;let r=$c({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(df({plugin:t}),lf({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:E({config:t.config.queryKeys,name:e.id})}),r=ff({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=I.callExpression({functionName:n.placeholder,parameters:[pf]})}else{let n=t.referenceSymbol(t.api.selector(`createQueryKey`)),r;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(r=I.arrayLiteralExpression({elements:e.tags.map(e=>I.stringLiteral({text:e}))})),i=I.callExpression({functionName:n.placeholder,parameters:[I.ots.string(e.id),pf,r]})}let{strippedTypeData:a}=af({plugin:t,typeData:tf({operation:e,plugin:t})}),o=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:pf},{spread:mf},{key:`throwOnError`,value:!0}]})]})}),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(I.returnVariable({expression:o})):s.push(I.constVariable({destructure:!0,expression:o,name:`data`}),I.returnVariable({expression:`data`}));let c=[{key:`key`,value:i},{key:`query`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:mf}],statements:s})}],l=ef(t,e,`queryOptions`);l&&c.push({key:`meta`,value:l});let u=t.registerSymbol({exported:!0,name:E({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),d=t.registerSymbol({external:t.name,name:`defineQueryOptions`,selector:t.api.selector(`defineQueryOptions`)}),f=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:u.exported,expression:I.callExpression({functionName:d.placeholder,parameters:[I.arrowFunction({parameters:[{isRequired:r,name:pf,type:a}],statements:I.objectExpression({obj:c})})]}),name:u.placeholder});t.setSymbolValue(u,f)},gf=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:`type`},name:`UseMutationOptions`,selector:e.api.selector(`UseMutationOptions`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`UseQueryOptions`,selector:e.api.selector(`UseQueryOptions`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`_JSONValue`,selector:e.api.selector(`_JSONValue`)}),e.registerSymbol({external:`axios`,meta:{kind:`type`},name:`AxiosError`,selector:e.api.selector(`AxiosError`)});let t=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let r=t.config.asClass?qc({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(t.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>T({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(t.api.selector(`function`,n.id)).placeholder;e.hooks.operation.isQuery(n)&&e.config.queryOptions.enabled&&hf({operation:n,plugin:e,queryFn:a}),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&of({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},_f={api:new $d({name:`@pinia/colada`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:gf,name:`@pinia/colada`,resolveConfig:(e,t)=>{e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Query`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},vf=C(_f),yf=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return I.valueToExpression({value:i})},bf=({operation:e,plugin:t})=>Jc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),xf=({operation:e,plugin:t})=>{let n=b(t.context.config),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`error`,e.id))?.placeholder;return i||=t.referenceSymbol(t.api.selector(`DefaultError`)).placeholder,n.name===`@hey-api/client-axios`&&(i=`${t.referenceSymbol(t.api.selector(`AxiosError`)).placeholder}<${i}>`),i},Sf=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},Cf=`TOptions`,wf=I.identifier({text:`infinite`}),Tf=I.identifier({text:`options`}),Ef=({plugin:e})=>{let t=e.registerSymbol({name:E({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=I.indexedAccessTypeNode({indexType:I.literalTypeNode({literal:I.ots.number(0)}),objectType:I.typeReferenceNode({typeArguments:[I.typeReferenceNode({typeName:Cf})],typeName:n.placeholder})}),i=he(e.context.config),a=b(e.context.config),o=a.api&&`selector`in a.api?e.getSymbol(a.api.selector(`client`)):void 0,s=e.getPluginOrThrow(`@hey-api/sdk`),c=e.referenceSymbol(s.api.selector(`Options`)),l=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:I.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:I.typeReferenceNode({typeName:Cf})},{isRequired:!1,name:`infinite`,type:I.typeReferenceNode({typeName:`boolean`})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:I.typeTupleNode({types:[r]}),statements:[I.constVariable({assertion:r,expression:I.objectExpression({multiLine:!1,obj:[{key:`_id`,value:I.identifier({text:`id`})},{key:i,value:I.identifier({text:`options?.${i} || (options?.client ?? ${o?.placeholder}).getConfig().${i}`})}]}),name:`params`,typeName:r}),I.ifStatement({expression:wf,thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:wf})})]})}),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:Tf,isOptional:!0,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:Tf,isOptional:!0,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:Tf,isOptional:!0,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:Tf,isOptional:!0,name:I.identifier({text:`query`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`query`}),right:I.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),I.returnStatement({expression:I.arrayLiteralExpression({elements:[I.identifier({text:`params`})]})})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:c.placeholder})}),name:Cf}]}),name:t.placeholder});e.setSymbolValue(t,l)},Df=({id:e,isInfinite:t,operation:n,plugin:r})=>{let i=t?r.config.infiniteQueryKeys:r.config.queryKeys,a;i.tags&&n.tags&&n.tags.length>0&&(a=I.arrayLiteralExpression({elements:n.tags.map(e=>I.stringLiteral({text:e}))}));let o=r.referenceSymbol(r.api.selector(`createQueryKey`));return I.callExpression({functionName:o.placeholder,parameters:[I.ots.string(e),`options`,t||a?I.ots.boolean(!!t):void 0,a]})},Of=({plugin:e})=>{let t=[{name:`_id`,type:I.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:I.keywordTypeNode({keyword:`boolean`})},{isRequired:!1,name:`tags`,type:I.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],n=e.getPluginOrThrow(`@hey-api/sdk`),r=e.referenceSymbol(n.api.selector(`Options`)),i=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`QueryKey`,selector:e.api.selector(`QueryKey`)}),a=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:I.typeTupleNode({types:[I.typeIntersectionNode({types:[I.typeReferenceNode({typeName:`Pick<${Cf}, '${he(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),I.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:I.typeReferenceNode({typeName:I.identifier({text:r.placeholder})}),name:Cf}]});e.setSymbolValue(i,a)},kf=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=bf({operation:t,plugin:n});return I.constVariable({exportConst:r.exported,expression:I.arrowFunction({parameters:[{isRequired:st(t),name:`options`,type:a}],returnType:e?i:void 0,statements:Df({id:t.id,isInfinite:e,operation:t,plugin:n})}),name:r.placeholder})},Af=({plugin:e})=>{let t=e.registerSymbol({name:E({config:{case:e.config.case},name:`createInfiniteParams`}),selector:e.api.selector(`createInfiniteParams`)}),n=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:I.typeReferenceNode({typeName:`QueryKey<Options>`})},{name:`page`,type:I.typeReferenceNode({typeName:`K`})}],statements:[I.constVariable({expression:I.objectExpression({obj:[{spread:I.propertyAccessExpression({expression:`queryKey`,name:0})}]}),name:`params`}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`body`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`body`}),right:I.objectExpression({multiLine:!0,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:!0,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:!0,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:!0,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:m.default.factory.createTypeQueryNode(I.identifier({text:`page`}))})})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:t.placeholder});e.setSymbolValue(t,n)},jf=({operation:e,plugin:t,queryFn:n})=>{let r=ct({context:t.context,operation:e});if(!r)return;let i=$c({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Of({plugin:t}),Ef({plugin:t})),t.getSymbol(t.api.selector(`createInfiniteParams`))||Af({plugin:t});let a=t.referenceSymbol(t.api.selector(`infiniteQueryOptions`)),o=t.referenceSymbol(t.api.selector(`InfiniteData`)),s=bf({operation:e,plugin:t}),c=xf({operation:e,plugin:t}),l=Sf({operation:e,plugin:t}),u=`${t.referenceSymbol(t.api.selector(`QueryKey`)).placeholder}<${s}>`,d=`Pick<${u}[0], 'body' | 'headers' | 'path' | 'query'>`,f=t.getPluginOrThrow(`@hey-api/typescript`),p=`${Ot({node:f.api.schemaToType({plugin:f,schema:r.schema,state:{path:{value:[]}}}),unescape:!0})} | ${d}`,m=t.registerSymbol({exported:!0,name:E({config:t.config.infiniteQueryKeys,name:e.id})}),h=kf({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.setSymbolValue(m,h);let g=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),_=t.referenceSymbol(t.api.selector(`createInfiniteParams`)),v=[I.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:I.conditionalExpression({condition:I.binaryExpression({left:I.typeOfExpression({text:`pageParam`}),operator:`===`,right:I.ots.string(`object`)}),whenFalse:I.objectExpression({multiLine:!0,obj:[{key:r.in,value:I.objectExpression({multiLine:!0,obj:[{key:r.name,value:I.identifier({text:`pageParam`})}]})}]}),whenTrue:I.identifier({text:`pageParam`})}),name:`page`,typeName:d}),I.constVariable({expression:I.callExpression({functionName:_.placeholder,parameters:[`queryKey`,`page`]}),name:`params`})];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?v.push(I.returnVariable({expression:g})):v.push(I.constVariable({destructure:!0,expression:g,name:`data`}),I.returnVariable({expression:`data`}));let y=[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:v})},{key:`queryKey`,value:I.callExpression({functionName:m.placeholder,parameters:[`options`]})}],ee=yf(t,e,`infiniteQueryOptions`);ee&&y.push({key:`meta`,value:ee});let te=t.registerSymbol({exported:!0,name:E({config:t.config.infiniteQueryOptions,name:e.id})}),ne=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:te.exported,expression:I.arrowFunction({parameters:[{isRequired:i,name:`options`,type:s}],statements:[I.returnFunctionCall({args:[I.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:y})],name:a.placeholder,types:[l,c||`unknown`,`${o.placeholder}<${l}>`,u,p]})]}),name:te.placeholder});t.setSymbolValue(te,ne)},Mf=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`MutationOptions`)),i=bf({operation:e,plugin:t}),a=xf({operation:e,plugin:t}),o=Sf({operation:e,plugin:t}),s=`${r.placeholder}<${o}, ${a}, ${i}>`,c=`fnOptions`,l=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),u=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?u.push(I.returnVariable({expression:l})):u.push(I.constVariable({destructure:!0,expression:l,name:`data`}),I.returnVariable({expression:`data`}));let d=[{key:`mutationFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:u})}],f=yf(t,e,`mutationOptions`);f&&d.push({key:`meta`,value:f});let p=`mutationOptions`,m=I.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${i}>`}],returnType:s,statements:[I.constVariable({expression:I.objectExpression({obj:d}),name:p,typeName:s}),I.returnVariable({expression:p})]}),h=t.registerSymbol({exported:!0,name:E({config:t.config.mutationOptions,name:e.id})}),g=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:h.exported,expression:m,name:h.placeholder});t.setSymbolValue(h,g)},Nf=`options`,Pf=({operation:e,plugin:t,queryFn:n})=>{if(el({operation:e}))return;let r=$c({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Of({plugin:t}),Ef({plugin:t}));let i=t.referenceSymbol(t.api.selector(`queryOptions`)),a=t.registerSymbol({exported:!0,name:E({config:t.config.queryKeys,name:e.id})}),o=kf({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=bf({operation:e,plugin:t}),c=I.awaitExpression({expression:I.callExpression({functionName:n,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:Nf},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),l=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?l.push(I.returnVariable({expression:c})):l.push(I.constVariable({destructure:!0,expression:c,name:`data`}),I.returnVariable({expression:`data`}));let u=[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:l})},{key:`queryKey`,value:I.callExpression({functionName:a.placeholder,parameters:[Nf]})}],d=yf(t,e,`queryOptions`);d&&u.push({key:`meta`,value:d});let f=t.registerSymbol({exported:t.config.queryOptions.exported,name:E({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),p=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:f.exported,expression:I.arrowFunction({parameters:[{isRequired:r,name:Nf,type:s}],statements:[I.returnFunctionCall({args:[I.objectExpression({obj:u})],name:i.placeholder})]}),name:f.placeholder});t.setSymbolValue(f,p)},Ff=`options`,If=({operation:e,plugin:t})=>{if(el({operation:e})||!(`useQuery`in t.config))return;let n=t.registerSymbol({exported:!0,name:E({config:t.config.useQuery,name:e.id})}),r=t.referenceSymbol(t.api.selector(`useQuery`)),i=$c({context:t.context,operation:e}),a=bf({operation:e,plugin:t}),o=t.referenceSymbol(t.api.selector(`queryOptionsFn`,e.id)),s=I.constVariable({comment:t.config.comments?Qc({operation:e}):void 0,exportConst:n.exported,expression:I.arrowFunction({parameters:[{isRequired:i,name:Ff,type:a}],statements:[I.returnStatement({expression:I.callExpression({functionName:r.placeholder,parameters:[I.callExpression({functionName:o.placeholder,parameters:[Ff]})]})})]}),name:n.placeholder});t.setSymbolValue(n,s)},Lf=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{kind:`type`},name:`DefaultError`,selector:e.api.selector(`DefaultError`)}),e.registerSymbol({external:e.name,meta:{kind:`type`},name:`InfiniteData`,selector:e.api.selector(`InfiniteData`)});let t=e.name===`@tanstack/angular-query-experimental`||e.name===`@tanstack/svelte-query`||e.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`;e.registerSymbol({external:e.name,meta:{kind:`type`},name:t,selector:e.api.selector(`MutationOptions`)}),e.registerSymbol({external:e.name,name:`infiniteQueryOptions`,selector:e.api.selector(`infiniteQueryOptions`)}),e.registerSymbol({external:e.name,name:`queryOptions`,selector:e.api.selector(`queryOptions`)}),e.registerSymbol({external:e.name,name:`useQuery`,selector:e.api.selector(`useQuery`)}),e.registerSymbol({external:`axios`,meta:{kind:`type`},name:`AxiosError`,selector:e.api.selector(`AxiosError`)});let n=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:t})=>{let r=n.config.asClass?qc({context:e.context,operation:t,plugin:n}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(n.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>T({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(n.api.selector(`function`,t.id)).placeholder;e.hooks.operation.isQuery(t)&&(e.config.queryOptions.enabled&&Pf({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&jf({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&If({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&Mf({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},Rf=e=>`${Fu({config:x(),id:e.name,operation:e})}InfiniteOptions`,zf=e=>`${Fu({config:x(),id:e.name,operation:e})}Mutation`,Bf=({config:e,id:t,operation:n})=>`${Fu({config:e,id:t,operation:n})}Options`,Vf=({config:e,id:t,isInfinite:n,operation:r})=>`${Fu({config:e,id:t,operation:r})}${n?`Infinite`:``}QueryKey`,Hf=e=>{switch(e.in){case`formData`:return`body`;case`header`:return`headers`;default:return e.in}},Uf=`createInfiniteParams`,Wf=`createQueryKey`,Gf=`infiniteQueryOptions`,Kf=`mutationOptions`,qf=`QueryKey`,Jf=`queryOptions`,Yf=`TOptions`,Xf=({file:e})=>{let t=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:I.typeNode(`QueryKey<OptionsLegacyParser>`)},{name:`page`,type:I.typeNode(`K`)}],statements:[I.constVariable({expression:I.identifier({text:`queryKey[0]`}),name:`params`}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`page`}),name:I.identifier({text:`body`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`body`}),right:I.objectExpression({multiLine:!0,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:!0,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:!0,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:!0,obj:[{spread:`queryKey[0].query`},{spread:`page.query`}]})})})]})}),I.returnVariable({expression:m.default.factory.createAsExpression(m.default.factory.createAsExpression(I.identifier({text:`params`}),m.default.factory.createKeywordTypeNode(m.default.SyntaxKind.UnknownKeyword)),m.default.factory.createTypeQueryNode(I.identifier({text:`page`})))})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`Pick<QueryKey<OptionsLegacyParser>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:`createInfiniteParams`});e.add(t)},Zf=({file:e})=>{let t=I.indexedAccessTypeNode({indexType:I.typeNode(0),objectType:I.typeNode(qf,[I.typeNode(Yf)])}),n=I.identifier({text:`infinite`}),r=he(x()),i=I.constVariable({expression:I.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:I.typeNode(`string`)},{isRequired:!1,name:`options`,type:I.typeNode(Yf)},{isRequired:!1,name:`infinite`,type:I.typeNode(`boolean`)}],returnType:t,statements:[I.constVariable({assertion:t,expression:I.objectExpression({multiLine:!1,obj:[{key:`_id`,value:I.identifier({text:`id`})},{key:r,value:I.identifier({text:`options?.${r} || (options?.client ?? _heyApiClient).getConfig().${r}`})}]}),name:`params`,typeName:t}),I.ifStatement({expression:n,thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:n})})]})}),I.ifStatement({expression:I.propertyAccessExpression({expression:I.identifier({text:`options`}),isOptional:!0,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:!0,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:!0,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:!0,name:I.identifier({text:`query`})}),thenStatement:I.block({statements:[I.expressionToStatement({expression:I.binaryExpression({left:I.propertyAccessExpression({expression:`params`,name:`query`}),right:I.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),I.returnVariable({expression:`params`})],types:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`OptionsLegacyParser`})}),name:Yf}]}),name:Wf});e.add(i)},Qf=({file:e})=>{let t=[{name:`_id`,type:I.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:I.keywordTypeNode({keyword:`boolean`})}],n=I.typeAliasDeclaration({name:qf,type:I.typeTupleNode({types:[I.typeIntersectionNode({types:[I.typeReferenceNode({typeName:`Pick<${Yf}, '${he(x())}' | 'body' | 'headers' | 'path' | 'query'>`}),I.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:I.typeReferenceNode({typeName:I.identifier({text:`OptionsLegacyParser`})}),name:Yf}]});e.add(n)},$f=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=wu({client:e,meta:n.parameters.length?{$ref:n.name,name:n.name}:void 0,nameTransformer:Eu,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeData:Au({importedType:i})}},ep=({client:e,file:t,operation:n,pluginName:r,typesModulePath:i})=>{let a=x(),{name:o}=wu({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:Du,onImport:e=>{t.import({asType:!0,module:i,name:e})}}),s={asType:!0,name:o};if(s.name||(s=t.import({asType:!0,module:r,name:`DefaultError`})),b(a).name===`@hey-api/client-axios`){let e=t.import({asType:!0,module:`axios`,name:`AxiosError`});s={...e,name:`${e.name}<${s.name}>`}}return{typeError:s}},tp=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=wu({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:ku,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeResponse:i||`void`}},np=({id:e,isInfinite:t})=>I.arrayLiteralExpression({elements:[I.callExpression({functionName:Wf,parameters:[I.ots.string(e),`options`,t?I.ots.boolean(!0):void 0]})],multiLine:!1}),rp=({client:e,files:t,plugin:n})=>{let r=x();if(S(r))throw Error(`TanStack Query plugin does not support legacy clients`);let i=t[n.name];i.import({asType:!0,module:bl({config:r,sourceOutput:n.output}),name:`OptionsLegacyParser`});let a=oe({moduleOutput:t.types.nameWithoutExtension(),sourceOutput:n.output}),o=n.name===`@tanstack/angular-query-experimental`||n.name===`@tanstack/svelte-query`||n.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`,s,c=!1,l=!1,u=!1,d=!1,f=!1,p=new Map;for(let m of e.services)for(let h of m.operations){let g=k(h);if(p.has(g))continue;p.set(g,!0);let _=[r.plugins[`@hey-api/sdk`]?.config.asClass&&as({config:r,name:m.name}),Fu({config:r,handleIllegal:!r.plugins[`@hey-api/sdk`]?.config.asClass,id:h.name,operation:h})].filter(Boolean).join(`.`),v=!1;if(n.config.queryOptions.enabled&&[`GET`,`POST`].includes(h.method)){f||(f=!0,l||=(Qf({file:i}),Zf({file:i}),!0),i.import({module:n.name,name:Jf})),v=!0;let{typeData:t}=$f({client:e,file:i,operation:h,typesModulePath:a}),o=Gs(h.parameters),s=I.constVariable({exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:np({id:h.name})}),name:Vf({config:r,id:h.name,operation:h})});i.add(s);let c=I.constVariable({comment:[],exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:[I.returnFunctionCall({args:[I.objectExpression({obj:[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:[I.constVariable({destructure:!0,expression:I.awaitExpression({expression:I.callExpression({functionName:_,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),I.returnVariable({expression:`data`})]})},{key:`queryKey`,value:I.callExpression({functionName:Vf({config:r,id:h.name,operation:h}),parameters:[`options`]})}]})],name:Jf})]}),name:Bf({config:r,id:h.name,operation:h})});i.add(c)}if(n.config.infiniteQueryOptions&&[`GET`,`POST`].includes(h.method)){let t,o=h.parameters.find(n=>{if(Hi(r.parser.pagination).test(n.name))return t=n,!0;if(n.in===`body`){if(n.export===`reference`){let i=n.$refs[0];return e.models.find(e=>e.meta?.$ref===i)?.properties.find(e=>{if(Hi(r.parser.pagination).test(e.name))return t=e,!0})}return n.properties.find(e=>{if(Hi(r.parser.pagination).test(e.name))return t=e,!0})}});if(o&&t){u||(u=!0,l||=(Qf({file:i}),Zf({file:i}),!0),c||=(Xf({file:i}),!0),i.import({module:n.name,name:Gf}),s=i.import({asType:!0,module:n.name,name:`InfiniteData`})),v=!0;let{typeData:d}=$f({client:e,file:i,operation:h,typesModulePath:a}),{typeError:f}=ep({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:p}=tp({client:e,file:i,operation:h,typesModulePath:a}),m=Gs(h.parameters),g=`${qf}<${d}>`,y=`Pick<${g}[0], 'body' | 'headers' | 'path' | 'query'>`,ee=`${t.base} | ${y}`,te=I.constVariable({exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],returnType:g,statements:np({id:h.name,isInfinite:!0})}),name:Vf({config:r,id:h.name,isInfinite:!0,operation:h})});i.add(te);let ne=I.constVariable({comment:[],exportConst:!0,expression:I.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],statements:[I.returnFunctionCall({args:[I.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:[{key:`queryFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:[I.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:I.conditionalExpression({condition:I.binaryExpression({left:I.typeOfExpression({text:`pageParam`}),operator:`===`,right:I.ots.string(`object`)}),whenFalse:I.objectExpression({multiLine:!0,obj:[{key:Hf(o),value:I.objectExpression({multiLine:!0,obj:[{key:t.name,value:I.identifier({text:`pageParam`})}]})}]}),whenTrue:I.identifier({text:`pageParam`})}),name:`page`,typeName:y}),I.constVariable({expression:I.callExpression({functionName:`createInfiniteParams`,parameters:[`queryKey`,`page`]}),name:`params`}),I.constVariable({destructure:!0,expression:I.awaitExpression({expression:I.callExpression({functionName:_,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:I.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),I.returnVariable({expression:`data`})]})},{key:`queryKey`,value:I.callExpression({functionName:Vf({config:r,id:h.name,isInfinite:!0,operation:h}),parameters:[`options`]})}]})],name:Gf,types:[p,f.name,`${typeof s==`string`?s:s.name}<${p}>`,g,ee]})]}),name:Rf(h)});i.add(ne)}}if(n.config.mutationOptions&&[`DELETE`,`PATCH`,`POST`,`PUT`].includes(h.method)){d||(d=!0,i.import({asType:!0,module:n.name,name:o})),v=!0;let{typeData:t}=$f({client:e,file:i,operation:h,typesModulePath:a}),{typeError:r}=ep({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:s}=tp({client:e,file:i,operation:h,typesModulePath:a}),c=`fnOptions`,l=I.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${t}>`}],statements:[I.constVariable({expression:I.objectExpression({obj:[{key:`mutationFn`,value:I.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:[I.constVariable({destructure:!0,expression:I.awaitExpression({expression:I.callExpression({functionName:_,parameters:[I.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),I.returnVariable({expression:`data`})]})}]}),name:Kf,typeName:`${o}<${s}, ${r.name}, ${t}>`}),I.returnVariable({expression:Kf})]}),u=I.constVariable({comment:[],exportConst:!0,expression:l,name:zf(h)});i.add(u)}(f||u)&&i.import({alias:`_heyApiClient`,module:oe({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:n.output}),name:`client`}),v&&i.import({module:oe({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:n.output}),name:_.split(`.`)[0]})}};var ip=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const ap={api:new ip({name:`@tanstack/angular-query-experimental`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,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:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},op=C(ap);var sp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const cp={api:new sp({name:`@tanstack/react-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/react-query`,output:`@tanstack/react-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions}),e.config.useQuery=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!1,name:`use{{name}}Query`},mappers:{boolean:e=>({enabled:e}),function:e=>({enabled:!0,name:e}),object:e=>({enabled:!0,...e}),string:e=>({enabled:!0,name:e})},value:e.config.useQuery}),e.config.useQuery.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=!0,e.config.queryOptions.exported=!1))}},lp=C(cp);var up=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const dp={api:new up({name:`@tanstack/solid-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/solid-query`,output:`@tanstack/solid-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},fp=C(dp);var pp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const mp={api:new pp({name:`@tanstack/svelte-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/svelte-query`,output:`@tanstack/svelte-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},hp=C(mp);var gp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const _p={api:new gp({name:`@tanstack/vue-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Lf,handlerLegacy:rp,name:`@tanstack/vue-query`,output:`@tanstack/vue-query`,resolveConfig:(e,t)=>{e.config.infiniteQueryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteQueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryKeys}),e.config.infiniteQueryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}InfiniteOptions`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.infiniteQueryOptions}),e.config.mutationOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}Mutation`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.mutationOptions}),e.config.queryKeys=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`{{name}}QueryKey`,tags:!1},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryKeys}),e.config.queryOptions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,exported:!0,name:`{{name}}Options`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.queryOptions})}},vp=C(_p),yp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[I.identifier({text:r})]})})})]})},bp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[I.identifier({text:r})]})})})]})};var xp=class{constructor(e){this.meta=e}createRequestValidator(e){return yp(e)}createResponseValidator(e){return bp(e)}selector(...e){return[this.meta.name,...e]}};const Sp={keywords:{false:I.identifier({text:`false`}),true:I.identifier({text:`true`})},number:{Infinity:I.identifier({text:`Infinity`}),NaN:I.identifier({text:`NaN`}),NegativeInfinity:I.identifier({text:`NegativeInfinity`}),epoch:I.identifier({text:`epoch`}),integer:I.identifier({text:`integer`}),safe:I.identifier({text:`safe`})},primitives:{bigint:I.identifier({text:`bigint`}),boolean:I.identifier({text:`boolean`}),keywords:I.identifier({text:`keywords`}),null:`null`,number:I.identifier({text:`number`}),string:`string`,symbol:I.identifier({text:`symbol`}),undefined:I.identifier({text:`undefined`}),unit:I.identifier({text:`unit`})},string:{NFC:I.identifier({text:`NFC`}),NFD:I.identifier({text:`NFD`}),NFKC:I.identifier({text:`NFKC`}),NFKD:I.identifier({text:`NFKD`}),alpha:I.identifier({text:`alpha`}),alphanumeric:I.identifier({text:`alphanumeric`}),base64:I.identifier({text:`base64`}),capitalize:I.identifier({text:`capitalize`}),creditCard:I.identifier({text:`creditCard`}),date:`date`,digits:I.identifier({text:`digits`}),email:`email`,epoch:I.identifier({text:`epoch`}),hex:I.identifier({text:`hex`}),integer:I.identifier({text:`integer`}),ip:`ip`,iso:`iso`,json:I.identifier({text:`json`}),lower:I.identifier({text:`lower`}),normalize:I.identifier({text:`normalize`}),numeric:I.identifier({text:`numeric`}),parse:I.identifier({text:`parse`}),preformatted:I.identifier({text:`preformatted`}),regex:I.identifier({text:`regex`}),semver:I.identifier({text:`semver`}),trim:I.identifier({text:`trim`}),upper:I.identifier({text:`upper`}),url:`url`,uuid:`uuid`,v1:`v1`,v2:`v2`,v3:`v3`,v4:`v4`,v5:`v5`,v6:`v6`,v7:`v7`,v8:`v8`},type:{$:I.identifier({text:`$`}),allows:I.identifier({text:`allows`}),and:I.identifier({text:`and`}),array:I.identifier({text:`array`}),as:I.identifier({text:`as`}),assert:I.identifier({text:`assert`}),brand:I.identifier({text:`brand`}),configure:I.identifier({text:`configure`}),default:I.identifier({text:`default`}),describe:I.identifier({text:`describe`}),description:I.identifier({text:`description`}),equals:I.identifier({text:`equals`}),exclude:I.identifier({text:`exclude`}),expression:I.identifier({text:`expression`}),extends:I.identifier({text:`extends`}),extract:I.identifier({text:`extract`}),filter:I.identifier({text:`filter`}),from:I.identifier({text:`from`}),ifEquals:I.identifier({text:`ifEquals`}),ifExtends:I.identifier({text:`ifExtends`}),infer:I.identifier({text:`infer`}),inferIn:I.identifier({text:`inferIn`}),intersect:I.identifier({text:`intersect`}),json:I.identifier({text:`json`}),meta:I.identifier({text:`meta`}),narrow:I.identifier({text:`narrow`}),onDeepUndeclaredKey:I.identifier({text:`onDeepUndeclaredKey`}),onUndeclaredKey:I.identifier({text:`onUndeclaredKey`}),optional:I.identifier({text:`optional`}),or:I.identifier({text:`or`}),overlaps:I.identifier({text:`overlaps`}),pipe:I.identifier({text:`pipe`}),select:I.identifier({text:`select`}),to:I.identifier({text:`to`}),toJsonSchema:I.identifier({text:`toJsonSchema`})}},Cp=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`arktype.type`)),o=I.constVariable({comment:t.config.comments?wd({schema:n}):void 0,exportConst:r.exported,expression:I.callExpression({functionName:a.placeholder,parameters:[e.def?I.stringLiteral({text:e.def}):e.expression]}),name:r.placeholder});if(t.setSymbolValue(r,o),i){let e=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:m.default.factory.createTypeQueryNode(m.default.factory.createQualifiedName(m.default.factory.createIdentifier(r.placeholder),Sp.type.infer))});t.setSymbolValue(i,e)}},wp=e=>{let t={};return t.def=Sp.primitives.null,t},Tp=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=a.includes(o),l=Op({optional:!c,plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,o])}});l.hasLazyExpression&&(r.hasLazyExpression=!0);let u=c?o:`${o}?`;u.endsWith(`?`)?u=m.default.factory.createComputedPropertyName(I.stringLiteral({text:u})):((u.match(/^[0-9]/)&&u.match(/\D+/g)||u.match(/\W/g))&&!u.startsWith(`'`)&&!u.endsWith(`'`)&&(u=`'${u}'`),A.lastIndex=0,u=A.test(u)?u.startsWith(`-`)?I.stringLiteral({text:o}):m.default.factory.createNumericLiteral(o):o),i.push(I.propertyAssignment({initializer:l.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Op({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:`TODO`,name:`record`}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:`TODO`,name:`string`}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r}return r.expression=m.default.factory.createObjectLiteralExpression(i,!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r},Ep=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=Sp.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${Sp.string.date}.${Sp.string.iso}`;break;case`email`:n=`${n}.${Sp.string.email}`;break;case`ipv4`:n=`${n}.${Sp.string.ip}.${Sp.string.v4}`;break;case`ipv6`:n=`${n}.${Sp.string.ip}.${Sp.string.v6}`;break;case`uri`:n=`${n}.${Sp.string.url}`;break;case`uuid`:n=`${n}.${Sp.string.uuid}`;break}return e.minLength===e.maxLength&&e.minLength!==void 0?n=`${e.minLength} <= ${n} <= ${e.maxLength}`:e.maxLength===void 0?e.minLength!==void 0&&(n=`${n} >= ${e.minLength}`):(n=`${n} <= ${e.maxLength}`,e.minLength!==void 0&&(n=`${e.minLength} <= ${n}`)),e.pattern&&(n=`/${e.pattern}/`),t.def=n,t},Dp=({schema:e,...t})=>{switch(e.type){case`null`:return wp({...t,schema:e});case`object`:return Tp({...t,schema:e});case`string`:return Ep({...t,schema:e})}let n=t.plugin.referenceSymbol(t.plugin.api.selector(`external`,`arktype.type`));return{def:``,expression:m.default.factory.createCallExpression(m.default.factory.createIdentifier(n.placeholder),void 0,[m.default.factory.createObjectLiteralExpression([m.default.factory.createPropertyAssignment(`name`,m.default.factory.createStringLiteral(`string`)),m.default.factory.createPropertyAssignment(`platform`,m.default.factory.createStringLiteral(`'android' | 'ios'`)),m.default.factory.createPropertyAssignment(m.default.factory.createComputedPropertyName(m.default.factory.createStringLiteral(`versions?`)),m.default.factory.createStringLiteral(`(number | string)[]`))],!0)]),hasLazyExpression:!1}},Op=({plugin:e,schema:t,state:n})=>{let r={};if(t.$ref){let i=e.api.selector(`ref`,t.$ref),a=e.referenceSymbol(i);e.isSymbolRegistered(i)?r.expression=I.identifier({text:a.placeholder}):(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:`TODO`,name:`TODO`}),parameters:[I.arrowFunction({returnType:I.keywordTypeNode({keyword:`any`}),statements:[I.returnStatement({expression:I.identifier({text:a.placeholder})})]})]}),r.hasLazyExpression=!0,n.hasLazyExpression.value=!0)}else if(t.type){let i=Dp({plugin:e,schema:t,state:n});r.def=i.def,r.expression=i.expression,r.hasLazyExpression=i.hasLazyExpression,e.config.metadata&&t.description}else if(t.items)t=D({schema:t}),t.items||(r=Op({plugin:e,schema:t,state:n}));else{let t=Dp({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=Dp({plugin:e,schema:{type:`unknown`},state:n}).expression,r},kp=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=Op({plugin:e,schema:t,state:n}),a=L(r);Cp({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},Ap=({plugin:e})=>{e.registerSymbol({external:`arktype`,name:`type`,selector:e.api.selector(`external`,`arktype.type`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:kp({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:kp({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:kp({plugin:e,schema:t.schema,state:n});break}})},jp=e=>Ap(e),Mp={api:new xp({name:`arktype`}),config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:jp,name:`arktype`,resolveConfig:(e,t)=>{e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Data`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Response`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequest`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},Np=C(Mp);var Pp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Fp=({operation:e,plugin:t})=>{let n=[],r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`data`,e.id));i&&(e.body&&n.push({isRequired:e.body.required,name:`Body`,type:`${i.placeholder}['body']`}),e.parameters&&(e.parameters.header&&n.push({isRequired:it(e.parameters.header),name:`Headers`,type:`${i.placeholder}['headers']`}),e.parameters.path&&n.push({isRequired:it(e.parameters.path),name:`Params`,type:`${i.placeholder}['path']`}),e.parameters.query&&n.push({isRequired:it(e.parameters.query),name:`Querystring`,type:`${i.placeholder}['query']`})));let{errors:a,responses:o}=ut(e),s,c=t.getSymbol(r.api.selector(`errors`,e.id));if(c&&a&&a.properties){let e=Object.keys(a.properties);if(e.length){if(!e.includes(`default`))s=I.typeReferenceNode({typeName:c.placeholder});else if(e.length>1){let e=I.typeReferenceNode({typeName:c.placeholder}),t=I.literalTypeNode({literal:I.stringLiteral({text:`default`})});s=I.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let l,u=t.getSymbol(r.api.selector(`responses`,e.id));if(u&&o&&o.properties){let e=Object.keys(o.properties);if(e.length){if(!e.includes(`default`))l=I.typeReferenceNode({typeName:u.placeholder});else if(e.length>1){let e=I.typeReferenceNode({typeName:u.placeholder}),t=I.literalTypeNode({literal:I.stringLiteral({text:`default`})});l=I.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let d=[s,l].filter(Boolean);if(d.length&&n.push({name:`Reply`,type:I.typeIntersectionNode({types:d})}),!n.length)return;let f=t.referenceSymbol(t.api.selector(`RouteHandler`));return{name:e.id,type:I.typeReferenceNode({typeArguments:[I.typeInterfaceNode({properties:n,useLegacyResolution:!1})],typeName:f.placeholder})}},Ip=({plugin:e})=>{e.registerSymbol({external:`fastify`,meta:{kind:`type`},name:`RouteHandler`,selector:e.api.selector(`RouteHandler`)});let t=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`RouteHandlers`}),n=[];e.forEach(`operation`,({operation:t})=>{let r=Fp({operation:t,plugin:e});r&&n.push(r)},{order:`declarations`});let r=I.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:I.typeInterfaceNode({properties:n,useLegacyResolution:!1})});e.setSymbolValue(t,r)},Lp={api:new Pp({name:`fastify`}),config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:Ip,name:`fastify`},Rp=C(Lp),X={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`})},storages:{},types:{GenericSchema:I.identifier({text:`GenericSchema`})},utils:{}},zp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),i=`data`;return I.arrowFunction({async:!0,parameters:[{name:i}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:X.async.parseAsync}),parameters:[I.identifier({text:n.placeholder}),I.identifier({text:i})]})})})]})},Bp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),i=`data`;return I.arrowFunction({async:!0,parameters:[{name:i}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:X.async.parseAsync}),parameters:[I.identifier({text:n.placeholder}),I.identifier({text:i})]})})})]})};var Vp=class{constructor(e){this.meta=e}createRequestValidator(e){return zp(e)}createResponseValidator(e){return Bp(e)}selector(...e){return[this.meta.name,...e]}};const Z=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let n=t.referenceSymbol(t.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.methods.pipe}),parameters:e})},Hp=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`valibot.v`)),o=I.constVariable({comment:t.config.comments?wd({schema:n}):void 0,exportConst:i.exported,expression:Z({pipes:e.pipes,plugin:t}),name:i.placeholder,typeName:r.hasLazyExpression.value?I.propertyAccessExpression({expression:a.placeholder,name:e.typeName||X.types.GenericSchema.text}):void 0});t.setSymbolValue(i,o)},Up={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:!1},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:!1},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:!0},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:!1},uint16:{max:65535,maxError:`Invalid value: Expected uint16 to be <= 2^16-1`,min:0,minError:`Invalid value: Expected uint16 to be >= 0`,needsBigInt:!1},uint32:{max:4294967295,maxError:`Invalid value: Expected uint32 to be <= 2^32-1`,min:0,minError:`Invalid value: Expected uint32 to be >= 0`,needsBigInt:!1},uint64:{max:`18446744073709551615`,maxError:`Invalid value: Expected uint64 to be <= 2^64-1`,min:`0`,minError:`Invalid value: Expected uint64 to be >= 0`,needsBigInt:!0},uint8:{max:255,maxError:`Invalid value: Expected uint8 to be <= 2^8-1`,min:0,minError:`Invalid value: Expected uint8 to be >= 0`,needsBigInt:!1}},Wp=e=>e!==void 0&&e in Up,Gp=e=>Wp(e)&&Up[e].needsBigInt,Kp=({isBigInt:e,value:t})=>{let n=I.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?I.callExpression({functionName:`BigInt`,parameters:[n]}):n},qp=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Hp({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.requests,name:t.id}),selector:n.api.selector(`data`,t.id)})})}if(n.config.responses.enabled&&t.responses){let{response:i}=ut(t);if(i){let a=[...r.path.value,`responses`];Hp({ast:e(i,a),plugin:n,schema:i,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:a,tags:r.tags?.value},name:E({config:n.config.responses,name:t.id}),selector:n.api.selector(`responses`,t.id)})})}}},Jp=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],Hp({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.webhooks,name:t.id}),selector:n.api.selector(`webhook-request`,t.id)})})}},Yp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.unknown})})},Xp=({plugin:e,schema:t,state:n})=>{let r={pipes:[]},i=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),a=I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.array});if(t.items){t=D({schema:t});let i=t.items.map((t,i)=>{let a=cm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Z({pipes:a.pipes,plugin:e})});if(i.length===1){let e=I.callExpression({functionName:a,parameters:i});r.pipes.push(e)}else{t.logicalOperator;let i=I.callExpression({functionName:a,parameters:[Yp({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(i)}}else{let t=I.callExpression({functionName:a,parameters:[Yp({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.actions.length}),parameters:[I.valueToExpression({value:t.minItems})]});r.pipes.push(e)}else{if(t.minItems!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.actions.minLength}),parameters:[I.valueToExpression({value:t.minItems})]});r.pipes.push(e)}if(t.maxItems!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.actions.maxLength}),parameters:[I.valueToExpression({value:t.maxItems})]});r.pipes.push(e)}}return r},Zp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return typeof t.const==`boolean`?I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.literal}),parameters:[I.ots.boolean(t.const)]}):I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.boolean})})},Qp=({plugin:e,schema:t,state:n})=>{let r=[],i=!1;for(let e of t.items??[])e.type===`string`&&typeof e.const==`string`?r.push(I.stringLiteral({text:e.const})):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return Yp({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),o=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.picklist}),parameters:[I.arrayLiteralExpression({elements:r,multiLine:!1})]});return i&&(o=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.nullable}),parameters:[o]})),o},$p=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.never})})},em=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.null})})},tm=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=Gp(n),a=Wp(n)?Up[n]:null,o=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.const!==void 0&&t.const!==null){let e=t.const,r;if(typeof e==`number`&&!n)r=I.ots.number(e);else if(typeof e==`number`&&n)r=i?I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(e.toString())]}):I.ots.number(e);else if(typeof e==`string`&&i){let t=e.endsWith(`n`)?e.slice(0,-1):e;r=I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(t)]})}else if(typeof e==`bigint`){let t=e.toString(),n=t.endsWith(`n`)?t.slice(0,-1):t;r=I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(n)]})}else r=I.valueToExpression({value:e});return I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.literal}),parameters:[r]})}let s=[];if(i){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.union}),parameters:[I.arrayLiteralExpression({elements:[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.number})}),I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.string})}),I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.bigInt})})],multiLine:!1})]});s.push(e);let t=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.transform}),parameters:[I.arrowFunction({parameters:[{name:`x`}],statements:I.callExpression({functionName:`BigInt`,parameters:[I.identifier({text:`x`})]})})]});s.push(t)}else{let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.number})});s.push(e)}if(!i&&r){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.integer})});s.push(e)}if(a){let e=a.min,t=a.max,n=a.minError,r=a.maxError,c=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.minValue}),parameters:[i?I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(e.toString())]}):I.ots.number(e),I.ots.string(n)]});s.push(c);let l=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.maxValue}),parameters:[i?I.callExpression({functionName:`BigInt`,parameters:[I.ots.string(t.toString())]}):I.ots.number(t),I.ots.string(r)]});s.push(l)}if(t.exclusiveMinimum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.gtValue}),parameters:[Kp({isBigInt:i,value:t.exclusiveMinimum})]});s.push(e)}else if(t.minimum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.minValue}),parameters:[Kp({isBigInt:i,value:t.minimum})]});s.push(e)}if(t.exclusiveMaximum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.ltValue}),parameters:[Kp({isBigInt:i,value:t.exclusiveMaximum})]});s.push(e)}else if(t.maximum!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.actions.maxValue}),parameters:[Kp({isBigInt:i,value:t.maximum})]});s.push(e)}return Z({pipes:s,plugin:e})},nm=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=cm({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),A.lastIndex=0;let l;l=A.test(o)?o.startsWith(`-`)?m.default.factory.createStringLiteral(o):m.default.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(l=`'${o}'`),i.push(I.propertyAssignment({initializer:Z({pipes:c.pipes,plugin:e}),name:l}))}let o=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.additionalProperties&&typeof t.additionalProperties==`object`&&t.additionalProperties.type!==void 0){let a=cm({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Object.keys(i).length?(r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.objectWithRest}),parameters:[m.default.factory.createObjectLiteralExpression(i,!0),Z({pipes:a.pipes,plugin:e})]})],r):(r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.record}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.string}),parameters:[]}),Z({pipes:a.pipes,plugin:e})]})],r)}return r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:X.schemas.object}),parameters:[m.default.factory.createObjectLiteralExpression(i,!0)]})],r},rm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(typeof t.const==`string`)return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.literal}),parameters:[I.ots.string(t.const)]});let r=[],i=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.schemas.string})});if(r.push(i),t.format)switch(t.format){case`date`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoDate})}));break;case`date-time`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoTimestamp})}));break;case`ipv4`:case`ipv6`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.ip})}));break;case`uri`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.url})}));break;case`email`:case`time`:case`uuid`:r.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:I.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.length}),parameters:[I.valueToExpression({value:t.minLength})]});r.push(e)}else{if(t.minLength!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.minLength}),parameters:[I.valueToExpression({value:t.minLength})]});r.push(e)}if(t.maxLength!==void 0){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.maxLength}),parameters:[I.valueToExpression({value:t.maxLength})]});r.push(e)}}if(t.pattern){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:X.actions.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]});r.push(e)}return Z({pipes:r,plugin:e})},im=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.literal}),parameters:[I.valueToExpression({value:e})]}));return r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]})],r}if(t.items){let a=t.items.map((t,i)=>{let a=cm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Z({pipes:a.pipes,plugin:e})});return r.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:X.schemas.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]})],r}return{pipes:[Yp({plugin:e,schema:{type:`unknown`},state:n})]}},am=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.undefined})})},om=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:X.schemas.void})})},sm=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:Z({pipes:Xp({...t,schema:e}).pipes,plugin:t.plugin})};case`boolean`:return{expression:Zp({...t,schema:e})};case`enum`:return{expression:Qp({...t,schema:e})};case`integer`:case`number`:return{expression:tm({...t,schema:e})};case`never`:return{expression:$p({...t,schema:e})};case`null`:return{expression:em({...t,schema:e})};case`object`:return{expression:Z({pipes:nm({...t,schema:e}).pipes,plugin:t.plugin})};case`string`:return e.format===`int64`||e.format===`uint64`?{expression:tm({...t,schema:e})}:{expression:rm({...t,schema:e})};case`tuple`:return{expression:Z({pipes:im({...t,schema:e}).pipes,plugin:t.plugin})};case`undefined`:return{expression:am({...t,schema:e})};case`unknown`:return{expression:Yp({...t,schema:e})};case`void`:return{expression:om({...t,schema:e})}}},cm=({optional:e,plugin:t,schema:n,state:r})=>{let i={pipes:[]},a=t.referenceSymbol(t.api.selector(`external`,`valibot.v`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);if(t.isSymbolRegistered(e)){let e=I.identifier({text:o.placeholder});i.pipes.push(e)}else{let e=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]});i.pipes.push(e),r.hasLazyExpression.value=!0}}else if(n.type){let e=sm({plugin:t,schema:n,state:r});if(i.typeName=e.anyType,i.pipes.push(e.expression),t.config.metadata&&n.description){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.actions.metadata}),parameters:[I.objectExpression({obj:[{key:`description`,value:I.stringLiteral({text:n.description})}]})]});i.pipes.push(e)}}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>Z({pipes:cm({plugin:t,schema:e,state:{...r,path:q([...r.path.value,`items`,n])}}).pipes,plugin:t}));if(n.logicalOperator===`and`){let t=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.intersect}),parameters:[I.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}else{let t=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.union}),parameters:[I.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}}else{let e=cm({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=sm({plugin:t,schema:{type:`unknown`},state:r});i.typeName=e.anyType,i.pipes.push(e.expression)}if(i.pipes.length){if(n.accessScope===`read`){let e=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.actions.readonly})});i.pipes.push(e)}let r;n.default!==void 0&&(r=Kp({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default}),r&&(i.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.optional}),parameters:[Z({pipes:i.pipes,plugin:t}),r]})])),e&&!r&&(i.pipes=[I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:X.schemas.optional}),parameters:[Z({pipes:i.pipes,plugin:t})]})])}return i},lm=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=cm({plugin:e,schema:t,state:n}),a=L(r);Hp({ast:i,plugin:e,schema:t,state:n,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)})})},um=({plugin:e})=>{e.registerSymbol({external:`valibot`,meta:{importKind:`namespace`},name:`v`,selector:e.api.selector(`external`,`valibot.v`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:qp({getAst:(n,r)=>cm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:lm({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:lm({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:lm({plugin:e,schema:t.schema,state:n});break;case`webhook`:Jp({getAst:(n,r)=>cm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},dm=e=>um(e),fm={api:new Vp({name:`valibot`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:dm,name:`valibot`,resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Data`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Response`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}WebhookRequest`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.webhooks})},tags:[`validator`]},pm=C(fm),Q={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`})},mm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},hm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},gm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},_m=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},vm=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})},ym=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return I.arrowFunction({async:!0,parameters:[{name:r}],statements:[I.returnStatement({expression:I.awaitExpression({expression:I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[I.identifier({text:r})]})})})]})};var bm=class{constructor(e){this.meta=e}createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return gm(e);case`mini`:return mm(e);case 4:default:return vm(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return _m(e);case`mini`:return hm(e);case 4:default:return ym(e)}}selector(...e){return[this.meta.name,...e]}};const xm=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`zod.z`)),o=I.constVariable({comment:t.config.comments?wd({schema:n}):void 0,exportConst:r.exported,expression:e.expression,name:r.placeholder,typeName:e.typeName?I.propertyAccessExpression({expression:a.placeholder,name:e.typeName}):void 0});if(t.setSymbolValue(r,o),i){let e=I.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:I.typeReferenceNode({typeArguments:[I.typeOfExpression({text:r.placeholder})],typeName:I.propertyAccessExpression({expression:a.placeholder,name:Q.infer})})});t.setSymbolValue(i,e)}},Sm=({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`}},$=({isBigInt:e,value:t})=>{let n=I.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?I.callExpression({functionName:`BigInt`,parameters:[n]}):n},Cm=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.requests.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],xm({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.requests,name:t.id}),selector:n.api.selector(`data`,t.id)}),typeInferSymbol:n.config.requests.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:r.path.value,tags:r.tags?.value},name:E({config:n.config.requests.types.infer,name:t.id}),selector:n.api.selector(`type-infer-data`,t.id)}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=ut(t);if(i){let a=[...r.path.value,`responses`];xm({ast:e(i,a),plugin:n,schema:i,symbol:n.registerSymbol({exported:!0,meta:{path:a,tags:r.tags?.value},name:E({config:n.config.responses,name:t.id}),selector:n.api.selector(`responses`,t.id)}),typeInferSymbol:n.config.responses.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:a,tags:r.tags?.value},name:E({config:n.config.responses.types.infer,name:t.id}),selector:n.api.selector(`type-infer-responses`,t.id)}):void 0})}}},wm=({getAst:e,operation:t,plugin:n,state:r})=>{if(n.config.webhooks.enabled){let i=new Set,a={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(t.parameters){if(t.parameters.header){let e={},n=[];for(let r in t.parameters.header){let a=t.parameters.header[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`headers`))}Object.keys(e).length&&(a.properties.headers={properties:e,required:n,type:`object`})}if(t.parameters.path){let e={},n=[];for(let r in t.parameters.path){let a=t.parameters.path[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`path`))}Object.keys(e).length&&(a.properties.path={properties:e,required:n,type:`object`})}if(t.parameters.query){let e={},n=[];for(let r in t.parameters.query){let a=t.parameters.query[r];e[a.name]=a.schema,a.required&&(n.push(a.name),i.add(`query`))}Object.keys(e).length&&(a.properties.query={properties:e,required:n,type:`object`})}}t.body&&(a.properties.body=t.body.schema,t.body.required&&i.add(`body`)),a.required=[...i],xm({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{path:r.path.value,tags:r.tags?.value},name:E({config:n.config.webhooks,name:t.id}),selector:n.api.selector(`webhook-request`,t.id)}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,path:r.path.value,tags:r.tags?.value},name:E({config:n.config.webhooks.types.infer,name:t.id}),selector:n.api.selector(`type-infer-webhook-request`,t.id)}):void 0})}},Tm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})}),n},Em=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=I.propertyAccessExpression({expression:r.placeholder,name:Q.array});if(!t.items)i.expression=I.callExpression({functionName:a,parameters:[Tm({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=D({schema:t});let o=t.items.map((t,r)=>{let a=Rm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});return a.hasLazyExpression&&(i.hasLazyExpression=!0),a.expression});if(o.length===1)i.expression=I.callExpression({functionName:a,parameters:o});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:[n,o[e]]})}i.expression=I.callExpression({functionName:a,parameters:[n]})}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o})]})]})}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.length}),parameters:[I.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.minLength}),parameters:[I.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.maxLength}),parameters:[I.valueToExpression({value:t.maxItems})]}))),o.length&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.check}),parameters:o})),i},Dm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};return typeof t.const==`boolean`?(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.boolean(t.const)]}),r):(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})}),r)},Om=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=I.stringLiteral({text:e.const});a.push(t),o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=I.ots.number(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.ots.boolean(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[I.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?i.expression=o[0]:i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.nullable}),parameters:[i.expression]})),i):Tm({plugin:e,schema:{type:`unknown`},state:n})},km=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.never})}),n},Am=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.null})}),n},jm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={},i=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.number(t.const)]}),r;r.expression=I.callExpression({functionName:i?I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):I.propertyAccessExpression({expression:n.placeholder,name:Q.number})}),!i&&t.type===`integer`&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.int})}));let a=[];return t.exclusiveMinimum===void 0?t.minimum!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.gte}),parameters:[$({isBigInt:i,value:t.minimum})]})):a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.gt}),parameters:[$({isBigInt:i,value:t.exclusiveMinimum})]})),t.exclusiveMaximum===void 0?t.maximum!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.lte}),parameters:[$({isBigInt:i,value:t.maximum})]})):a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.lt}),parameters:[$({isBigInt:i,value:t.exclusiveMaximum})]})),a.length&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Mm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=Rm({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i.hasLazyExpression=!0),A.lastIndex=0;let l;l=A.test(r)?r.startsWith(`-`)?m.default.factory.createStringLiteral(r):m.default.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(l=`'${r}'`),c.hasLazyExpression?a.push(I.getAccessorDeclaration({name:l,statements:[I.returnStatement({expression:c.expression})]})):a.push(I.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Rm({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.string}),parameters:[]}),a.expression]}),a.hasLazyExpression&&(i.hasLazyExpression=!0),i}return i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[m.default.factory.createObjectLiteralExpression(a,!0)]}),i},Nm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};if(typeof t.const==`string`)return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.string(t.const)]}),r;r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.string})});let i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[I.objectExpression({obj:i})]:[]});break;case`email`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.email})});break;case`ipv4`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.ipv4})});break;case`ipv6`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.ipv6})});break;case`time`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.url})});break;case`uuid`:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.uuid})});break}let a=[];return t.minLength===t.maxLength&&t.minLength!==void 0?a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.length}),parameters:[I.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.minLength}),parameters:[I.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.maxLength}),parameters:[I.valueToExpression({value:t.maxLength})]}))),t.pattern&&a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]})),a.length&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Pm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={};if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.valueToExpression({value:e})]}));return i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]}),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=Rm({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]}),i},Fm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})}),n},Im=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.void})}),n},Lm=({schema:e,...t})=>{switch(e.type){case`array`:return Em({...t,schema:e});case`boolean`:return Dm({...t,schema:e});case`enum`:return Om({...t,schema:e});case`integer`:case`number`:return jm({...t,schema:e});case`never`:return km({...t,schema:e});case`null`:return Am({...t,schema:e});case`object`:return Mm({...t,schema:e});case`string`:return Nm({...t,schema:e});case`tuple`:return Pm({...t,schema:e});case`undefined`:return Fm({...t,schema:e});case`unknown`:return Tm({...t,schema:e});case`void`:return Im({...t,schema:e})}},Rm=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I.identifier({text:o.placeholder}):(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({returnType:I.keywordTypeNode({keyword:`any`}),statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=Lm({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[I.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),I.objectExpression({obj:[{key:`description`,value:I.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>Rm({plugin:t,schema:e,state:{...r,path:q([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:[i.expression,e.hasLazyExpression?I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=Rm({plugin:t,schema:n,state:r});else i.expression=Lm({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.readonly}),parameters:[i.expression]})),e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.optional}),parameters:[i.expression]}),i.typeName=Q.ZodMiniOptional),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q._default}),parameters:[i.expression,e]}))}return i},zm=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=Rm({plugin:e,schema:t,state:n}),a=L(r);xm({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},Bm=({plugin:e})=>{e.registerSymbol({external:Sm({plugin:e}),meta:{importKind:`namespace`},name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Cm({getAst:(n,r)=>Rm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:zm({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:zm({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:zm({plugin:e,schema:t.schema,state:n});break;case`webhook`:wm({getAst:(n,r)=>Rm({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Vm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})})},Hm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=I.propertyAccessExpression({expression:r.placeholder,name:Q.array}),a,o=!1;if(!t.items)a=I.callExpression({functionName:i,parameters:[Vm({plugin:e,schema:{type:`unknown`},state:n})]});else{t=D({schema:t});let s=t.items.map((t,r)=>{let i=eh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});return i.hasLazyExpression&&(o=!0),i.expression});if(s.length===1)a=I.callExpression({functionName:i,parameters:s});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:s});else{n=s[0];for(let e=1;e<s.length;e++)n=I.callExpression({functionName:I.propertyAccessExpression({expression:n,name:Q.and}),parameters:[s[e]]})}a=I.callExpression({functionName:i,parameters:[n]})}else a=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:s})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?a=I.callExpression({functionName:I.propertyAccessExpression({expression:a,name:Q.length}),parameters:[I.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(a=I.callExpression({functionName:I.propertyAccessExpression({expression:a,name:Q.min}),parameters:[I.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(a=I.callExpression({functionName:I.propertyAccessExpression({expression:a,name:Q.max}),parameters:[I.valueToExpression({value:t.maxItems})]}))),{expression:a,hasLazyExpression:o}},Um=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.boolean(t.const)]}):I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})})},Wm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=[],a=[],o=!1,s=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=I.stringLiteral({text:e.const});i.push(t),a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){s=!1;let t=I.ots.number(e.const);a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=I.ots.boolean(e.const);a.push(I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return Vm({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[I.arrayLiteralExpression({elements:i,multiLine:!1})]}):a.length===1?a[0]:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:a,multiLine:a.length>3})]}),o&&(c=I.callExpression({functionName:I.propertyAccessExpression({expression:c,name:Q.nullable})})),c},Gm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.never})})},Km=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.null})})},qm=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.number(t.const)]});let i=I.callExpression({functionName:r?I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):I.propertyAccessExpression({expression:n.placeholder,name:Q.number})});return!r&&t.type===`integer`&&(i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):i=I.callExpression({functionName:I.propertyAccessExpression({expression:i,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),i},Jm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1,a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=eh({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i=!0),A.lastIndex=0;let l;l=A.test(r)?r.startsWith(`-`)?m.default.factory.createStringLiteral(r):m.default.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(l=`'${r}'`),a.push(I.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=eh({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return{anyType:`AnyZodObject`,expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[i.expression]}),hasLazyExpression:i.hasLazyExpression}}return{anyType:`AnyZodObject`,expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[m.default.factory.createObjectLiteralExpression(a,!0)]}),hasLazyExpression:i}},Ym=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[I.ots.string(t.const)]});let r=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.string})}),i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.date})});break;case`date-time`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.datetime}),parameters:i.length>0?[I.objectExpression({obj:i})]:[]});break;case`email`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.email})});break;case`ipv4`:case`ipv6`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.ip})});break;case`time`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.time})});break;case`uri`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.url})});break;case`uuid`:r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.length}),parameters:[I.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.min}),parameters:[I.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.max}),parameters:[I.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=I.callExpression({functionName:I.propertyAccessExpression({expression:r,name:Q.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]})),r},Xm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1;if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.valueToExpression({value:e})]}));return{expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]}),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=eh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]}),hasLazyExpression:i}},Zm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})})},Qm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return I.callExpression({functionName:I.propertyAccessExpression({expression:t.placeholder,name:Q.void})})},$m=({schema:e,...t})=>{switch(e.type){case`array`:return Hm({...t,schema:e});case`boolean`:return{expression:Um({...t,schema:e})};case`enum`:return{expression:Wm({...t,schema:e})};case`integer`:case`number`:return{expression:qm({...t,schema:e})};case`never`:return{expression:Gm({...t,schema:e})};case`null`:return{expression:Km({...t,schema:e})};case`object`:return Jm({...t,schema:e});case`string`:return{expression:Ym({...t,schema:e})};case`tuple`:return Xm({...t,schema:e});case`undefined`:return{expression:Zm({...t,schema:e})};case`unknown`:return{expression:Vm({...t,schema:e})};case`void`:return{expression:Qm({...t,schema:e})}}},eh=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I.identifier({text:o.placeholder}):(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=$m({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.describe}),parameters:[I.stringLiteral({text:n.description})]}))}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>eh({plugin:t,schema:e,state:{...r,path:q([...r.path.value,`items`,n])}}).expression);if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e}):(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e]})}))}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:e})]})}else i=eh({plugin:t,schema:n,state:r});else{let e=$m({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}if(i.expression&&(n.accessScope===`read`&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.optional})})),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return r.hasLazyExpression.value?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},th=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=eh({plugin:e,schema:t,state:n}),a=L(r);xm({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},nh=({plugin:e})=>{e.registerSymbol({external:Sm({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Cm({getAst:(n,r)=>eh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:th({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:th({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:th({plugin:e,schema:t.schema,state:n});break;case`webhook`:wm({getAst:(n,r)=>eh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},rh=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.unknown})}),t},ih=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),a=I.propertyAccessExpression({expression:i.placeholder,name:Q.array});if(!t.items)r.expression=I.callExpression({functionName:a,parameters:[rh({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=D({schema:t});let o=t.items.map((t,i)=>{let a=gh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),a.expression});if(o.length===1)r.expression=I.callExpression({functionName:a,parameters:o});else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=I.callExpression({functionName:I.propertyAccessExpression({expression:n,name:Q.and}),parameters:[o[e]]})}r.expression=I.callExpression({functionName:a,parameters:[n]})}else r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.array}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.length}),parameters:[I.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.min}),parameters:[I.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.expression,name:Q.max}),parameters:[I.valueToExpression({value:t.maxItems})]}))),r},ah=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.ots.boolean(t.const)]}),n):(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.boolean})}),n)},oh=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=I.stringLiteral({text:e.const});a.push(t),o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=I.ots.number(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.ots.boolean(e.const);o.push(I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.enum}),parameters:[I.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?r.expression=o[0]:r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.nullable}),parameters:[r.expression]})),r):rh({plugin:e,schema:{type:`unknown`},state:n})},sh=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.never})}),t},ch=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.null})}),t},lh=({plugin:e,schema:t})=>{let n={},r=t.type===`integer`&&t.format===`int64`,i=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`number`?(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[I.ots.number(t.const)]}),n):(n.expression=I.callExpression({functionName:r?I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:i.placeholder,name:Q.coerce}),name:Q.bigint}):I.propertyAccessExpression({expression:i.placeholder,name:Q.number})}),!r&&t.type===`integer`&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),n)},uh=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[],o=e.referenceSymbol(e.api.selector(`external`,`zod.z`));for(let o in t.properties){let s=t.properties[o],c=gh({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:q([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),A.lastIndex=0;let l;l=A.test(o)?o.startsWith(`-`)?m.default.factory.createStringLiteral(o):m.default.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(l=`'${o}'`),c.hasLazyExpression?i.push(I.getAccessorDeclaration({name:l,statements:[I.returnStatement({expression:c.expression})]})):i.push(I.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=gh({plugin:e,schema:t.additionalProperties,state:{...n,path:q([...n.path.value,`additionalProperties`])}});return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:Q.record}),parameters:[I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:Q.string}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`ZodType`}:r}return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:o.placeholder,name:Q.object}),parameters:[m.default.factory.createObjectLiteralExpression(i,!0)]}),r.hasLazyExpression?{...r,typeName:`ZodType`}:r},dh=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[I.ots.string(t.const)]}),n;n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.string})});let i=[];if(e.config.dates.offset&&i.push({key:`offset`,value:!0}),e.config.dates.local&&i.push({key:`local`,value:!0}),t.format)switch(t.format){case`date`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[I.objectExpression({obj:i})]:[]});break;case`email`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.email})});break;case`ipv4`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.ipv4})});break;case`ipv6`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.ipv6})});break;case`time`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:I.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.url})});break;case`uuid`:n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:r.placeholder,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.length}),parameters:[I.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.min}),parameters:[I.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.max}),parameters:[I.valueToExpression({value:t.maxLength})]}))),t.pattern&&(n.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.expression,name:Q.regex}),parameters:[I.regularExpressionLiteral({text:t.pattern})]})),n},fh=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[I.valueToExpression({value:e})]}));return r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:e})]}),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=gh({plugin:e,schema:t,state:{...n,path:q([...n.path.value,`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[I.arrayLiteralExpression({elements:a})]}),r},ph=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.undefined})}),t},mh=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:n.placeholder,name:Q.void})}),t},hh=({schema:e,...t})=>{switch(e.type){case`array`:return ih({...t,schema:e});case`boolean`:return ah({...t,schema:e});case`enum`:return oh({...t,schema:e});case`integer`:case`number`:return lh({...t,schema:e});case`never`:return sh({...t,schema:e});case`null`:return ch({...t,schema:e});case`object`:return uh({...t,schema:e});case`string`:return dh({...t,schema:e});case`tuple`:return fh({...t,schema:e});case`undefined`:return ph({...t,schema:e});case`unknown`:return rh({...t,schema:e});case`void`:return mh({...t,schema:e})}},gh=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol(t.api.selector(`external`,`zod.z`));if(n.$ref){let e=t.api.selector(`ref`,n.$ref),o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=I.identifier({text:o.placeholder}):(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({returnType:I.keywordTypeNode({keyword:`any`}),statements:[I.returnStatement({expression:I.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=hh({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[I.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),I.objectExpression({obj:[{key:`description`,value:I.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=D({schema:n}),n.items){let e=n.items.map((e,n)=>gh({plugin:t,schema:e,state:{...r,path:q([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e.hasLazyExpression?I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[I.arrowFunction({statements:[I.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[I.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=gh({plugin:t,schema:n,state:r});else i.expression=hh({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:a.placeholder,name:Q.optional}),parameters:[i.expression]}),i.typeName=Q.ZodOptional),n.default!==void 0)){let e=$({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=I.callExpression({functionName:I.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return i},_h=({plugin:e,schema:t,state:n})=>{let r=mr(n.path.value),i=gh({plugin:e,schema:t,state:n}),a=L(r);xm({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions,name:a}),selector:e.api.selector(`ref`,r)}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,meta:{kind:`type`,path:n.path.value,tags:n.tags?.value},name:E({config:e.config.definitions.types.infer,name:a}),selector:e.api.selector(`type-infer-ref`,r)}):void 0})},vh=({plugin:e})=>{e.registerSymbol({external:Sm({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=J({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Cm({getAst:(n,r)=>gh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:_h({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:_h({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:_h({plugin:e,schema:t.schema,state:n});break;case`webhook`:wm({getAst:(n,r)=>gh({plugin:e,schema:n,state:J({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},yh=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return nh(e);case`mini`:return Bm(e);case 4:default:return vh(e)}},bh={api:new bm({name:`zod`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:yh,name:`zod`,resolveConfig:(e,t)=>{let n=t.package.getVersion(`zod`),r=()=>n&&(n.major===4||n.major===3)?n.major:4,i=e=>{if(!e)return r();if(!n)return e;if((e===4||e===3||e===`mini`)&&!t.package.satisfies(n,`>=3.25.0 <5.0.0`)){let t=r();return console.warn(`🔌 ${u.default.yellow(`Warning:`)} Installed ${u.default.cyan(`zod`)} ${u.default.cyan(`v${n.version}`)} does not support compatibility version ${u.default.yellow(String(e))}, using ${u.default.yellow(String(t))}.`),t}return e};e.config.compatibilityVersion=i(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{local:!1,offset:!1},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}DataZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ResponseZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequestZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},xh=C(bh),Sh={"@angular/common":ml,"@hey-api/client-angular":jl,"@hey-api/client-axios":Pl,"@hey-api/client-fetch":Ll,"@hey-api/client-next":Bl,"@hey-api/client-nuxt":Ul,"@hey-api/client-ofetch":Kl,"@hey-api/schemas":yu,"@hey-api/sdk":Uu,"@hey-api/transformers":yd,"@hey-api/typescript":Zd,"@pinia/colada":_f,"@tanstack/angular-query-experimental":ap,"@tanstack/react-query":cp,"@tanstack/solid-query":dp,"@tanstack/svelte-query":mp,"@tanstack/vue-query":_p,arktype:Mp,fastify:Lp,"legacy/angular":Jl,"legacy/axios":Xl,"legacy/fetch":Ql,"legacy/node":eu,"legacy/xhr":nu,valibot:fm,zod:bh},Ch=[`@hey-api/typescript`,`@hey-api/sdk`],wh=({dependencies:e,userPlugins:t,userPluginsConfig:n})=>{let r=new Set,i=new Set,a={},o=s=>{if(r.has(s))throw Error(`Circular reference detected at '${s}'`);if(i.has(s))return;r.add(s);let c=Sh[s],l=n[s];if(!c&&!l)throw Error(`unknown plugin dependency "${s}" - do you need to register a custom plugin with this name?`);let u={...c,...l,config:{...c?.config,...l?.config},dependencies:new Set([...c?.dependencies||[],...l?.dependencies||[]])};if(u.resolveConfig){let r={package:ft(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=Sh[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=Sh[i]||n[i];if(t&&t.tags?.includes(e)&&i!==s)return i}throw Error(a||`missing plugin - no plugin with tag "${e}" found`)},valueToObject:Ue};u.resolveConfig(u,r)}for(let e of u.dependencies)o(e);r.delete(s),i.add(s),a[s]=u};for(let e of t)o(e);return{pluginOrder:Array.from(i),plugins:a}},Th=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`),Eh=({dependencies:e,userConfig:t})=>{let n={},r=Ch;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&Th(t.plugins[0])?[...Ch,...t.plugins]:t.plugins),wh({dependencies:e,userPlugins:r.map(e=>{if(typeof e==`string`)return e;let t=e.name;return t&&(e.handler?n[t]=e:(n[t]={config:{...e}},delete n[t].config.name)),t}).filter(Boolean),userPluginsConfig:n})},Dh=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),Oh=async({logger:e,userConfigs:t})=>{let n=[],r={},i=e.timeEvent(`load`);for(let i of t){let t;if(i?.configFile){let e=i.configFile.split(`.`);t=e.slice(0,e.length-1).join(`.`)}let a=e.timeEvent(`c12`),{loadConfig:o}=await import(`c12`),{config:s,configFile:c}=await o({configFile:t,name:`openapi-ts`});a.timeEnd(),Object.keys(r).length||(r=Ge(Object.keys(s).length?c:void 0));let l=s instanceof Array?s.map(e=>Be(e,i)):[Be(s,i)];for(let e of l){let t=Le(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${u.default.yellow(`Warning:`)} You provided ${u.default.cyan(String(r))} ${u.default.cyan(r===1?`input`:`inputs`)} and ${u.default.yellow(String(i))} ${u.default.yellow(`outputs`)}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let r of e.output)n.push({...e,input:t,output:r})}else e.output.forEach((r,i)=>{n.push({...e,input:t[i],output:r})});else n.push({...e,input:t,output:e.output[0]??``})}else n.push({...e,input:t})}}i.timeEnd();let a=[],o=e.timeEvent(`build`);for(let e of n){let{base:t,configFile:n=``,dryRun:i=!1,experimentalParser:o=!0,exportCore:s=!0,name:c,request:l,useOptions:d=!0}=e,p=e.interactive===void 0?Dh():e.interactive,m=Re(e),h=Le(e),g=We(e),_=qe(e),v=[];h.length||v.push(new se(`missing input - which OpenAPI specification should we use to generate your output?`)),g.path||v.push(new se(`missing output - where should we generate your output?`)),!d&&m.level!==`silent`&&console.warn(`❗️ 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`),g.path=f.default.resolve(process.cwd(),g.path);let y;try{y=Eh({dependencies:r,userConfig:e})}catch(e){v.push(e),y={pluginOrder:[],plugins:{}}}let ee=_e({...y,base:t,configFile:n,dryRun:i,experimentalParser:o,exportCore:!1,input:h,interactive:p,logs:m,name:c,output:g,parser:_,request:l,useOptions:d});ee.exportCore=S(ee)?s:!1;let te=a.length;if(m.level===`debug`){let e=u.default.gray(`[Job ${te+1}] `);console.warn(`${e}${u.default.cyan(`config:`)}`,ee)}a.push({config:ee,errors:v,jobIndex:te})}return o.timeEnd(),{dependencies:r,results:a}},kh=Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`}),Ah=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},jh=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},Mh=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Nh=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(jh(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Ah(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Ph({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Ph=({allowReserved:e,name:t,value:n})=>{if(n==null)return``;if(typeof n==`object`)throw Error("Deeply-nested arrays/objects aren’t supported. Provide your own `querySerializer()` to handle these.");return`${t}=${e?n:encodeURIComponent(n)}`},Fh=({allowReserved:e,explode:t,name:n,style:r,value:i,valueOnly:a})=>{if(i instanceof Date)return a?i.toISOString():`${n}=${i.toISOString()}`;if(r!==`deepObject`&&!t){let t=[];Object.entries(i).forEach(([n,r])=>{t=[...t,n,e?r:encodeURIComponent(r)]});let a=t.join(`,`);switch(r){case`form`:return`${n}=${a}`;case`label`:return`.${a}`;case`matrix`:return`;${n}=${a}`;default:return a}}let o=Mh(r),s=Object.entries(i).map(([t,i])=>Ph({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Ih=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=Nh({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=Fh({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=Ph({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},Lh=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Rh=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?Lh(n):Object.entries(n);for(let[n,r]of e)if(r===null)t.delete(n);else if(Array.isArray(r))for(let e of r)t.append(n,e);else r!==void 0&&t.set(n,typeof r==`object`?JSON.stringify(r):r)}return t},zh=Ih({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),Bh=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=(0,_.getResolvedInput)({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await(0,_.sendRequest)({fetchOptions:{method:`HEAD`,...e,headers:Rh(e?.headers,r.headers)},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok&&r.isHeadMethodSupported)return{error:`not-ok`,response:s};if(r.isHeadMethodSupported===void 0&&(r.isHeadMethodSupported=s.ok),s.status===304)return{error:`not-modified`,response:s};if(o===void 0){let e=s.headers.get(`ETag`);e&&(o=e!==r.headers.get(`If-None-Match`),o&&r.headers.set(`If-None-Match`,e))}if(o===void 0){let e=s.headers.get(`Last-Modified`);e&&(o=e!==r.headers.get(`If-Modified-Since`),o&&r.headers.set(`If-Modified-Since`,e))}if(o===!1)return{error:`not-modified`,response:s}}try{let t=await(0,_.sendRequest)({fetchOptions:{method:`GET`,...e},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok)return{error:`not-ok`,response:s};if(a=s.body?await s.arrayBuffer():new ArrayBuffer(0),o===void 0){let e=new TextDecoder().decode(a);o=e!==r.lastValue,r.lastValue=e}}else r.lastValue?o=!1:r.lastValue=i.type;return o===!1?{error:`not-modified`,response:s}:{arrayBuffer:a,resolvedInput:i}};Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`F`,{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,`I`,{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,`L`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,`P`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`R`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return Xn}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return kl}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return _l}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return Ss}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return ws}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return xr}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return hi}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return mu}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return Ic}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return as}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Oh}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Tl}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return ds}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Ch}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return gl}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Bh}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return Lc}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return T}});
24
+ //# sourceMappingURL=getSpec-dCba3-3n.cjs.map