@hey-api/openapi-ts 0.86.2 → 0.86.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/getSpec-DhkA7wWv.cjs +24 -0
- package/dist/getSpec-DhkA7wWv.cjs.map +1 -0
- package/dist/getSpec-DzntayfV.js +24 -0
- package/dist/getSpec-DzntayfV.js.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/{types-BT1ededZ.d.cts → types-CBGf9bNY.d.cts} +414 -302
- package/dist/{types-DGAzCzMG.d.ts → types-TTJZ61ck.d.ts} +413 -301
- package/package.json +4 -4
- package/dist/getSpec-54k1Qp12.js +0 -24
- package/dist/getSpec-54k1Qp12.js.map +0 -1
- package/dist/getSpec-BFMqYPd3.cjs +0 -24
- package/dist/getSpec-BFMqYPd3.cjs.map +0 -1
package/dist/getSpec-54k1Qp12.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import{r as e}from"./chunk-C-EqMg7d.js";import t from"ansi-colors";import n from"node:fs";import r from"node:path";import{fileURLToPath as i}from"node:url";import a from"typescript";import*as o from"semver";import{Project as s,createBinding as c,mergeBindings as l,renderIds as u}from"@hey-api/codegen-core";import{EOL as d}from"node:os";import{getResolvedInput as f,sendRequest as p}from"@hey-api/json-schema-ref-parser";const m=i(import.meta.url),h=r.dirname(m),g=()=>{let e=h;for(;e!==r.dirname(e);){let t=n.readdirSync(e).filter(e=>e===`package.json`);if(t[0]){let i=r.join(e,t[0]);return JSON.parse(n.readFileSync(i,{encoding:`utf8`}))}e=r.dirname(e)}},_=()=>{let e=g(),t={bugs:{url:``},name:``,version:``};return e&&typeof e==`object`&&(`name`in e&&typeof e.name==`string`&&(t.name=e.name),`version`in e&&typeof e.version==`string`&&(t.version=e.version),`bugs`in e&&e.bugs&&typeof e.bugs==`object`&&`url`in e.bugs&&typeof e.bugs.url==`string`&&(t.bugs.url=e.bugs.url,t.bugs.url&&!t.bugs.url.endsWith(`/`)&&(t.bugs.url+=`/`))),t},v=e=>{if(e===null)return null;if(e){let t=r.isAbsolute(e)?e:r.resolve(h,e);return n.existsSync(t)?t:null}let t=h;for(;t!==r.dirname(t);){let e=n.readdirSync(t).filter(e=>e.startsWith(`tsconfig`)&&e.endsWith(`.json`)).sort(e=>e===`tsconfig.json`?-1:1);if(e[0])return r.join(t,e[0]);t=r.dirname(t)}return null},ee=e=>{if(!e)return null;let t=a.readConfigFile(e,a.sys.readFile);if(t.error)throw Error(`Couldn't read tsconfig from path: ${e}`);return a.parseJsonConfigFileContent(t.config,a.sys,r.dirname(e))},y=e=>{n.existsSync(e)||n.mkdirSync(e,{recursive:!0})},te=e=>{n.existsSync(e)&&n.rmSync(e,{force:!0,recursive:!0})},ne=({moduleOutput:e,sourceOutput:t})=>{let n=t.split(`/`);return`${Array.from({length:n.length}).fill(``).join(`../`)||`./`}${e}`};var re=class extends Error{constructor(e){super(e),this.name=`ConfigError`}},ie=class extends Error{errors;constructor(e){super(`Found ${e.length} configuration ${e.length===1?`error`:`errors`}.`),this.name=`ConfigValidationError`,this.errors=e}},ae=class extends Error{originalError;constructor(e,t){super(e),this.name=`JobError`,this.originalError=t}},oe=class extends Error{args;event;pluginName;constructor({args:e,error:t,event:n,name:r,pluginName:i}){let a=t instanceof Error?t.message:`Unknown error`;super(a),this.args=e,this.cause=t.cause,this.event=n,this.name=r||t.name,this.pluginName=i,this.stack=t.stack}};const se=(e,t)=>{if(e instanceof re||e instanceof ie)return;e instanceof ae&&(e=e.originalError.error);let i=`openapi-ts-error-${Date.now()}.log`,a=r.resolve(process.cwd(),t);y(a);let o=r.resolve(a,i),s=`[${new Date().toISOString()}] `;e instanceof oe&&(s+=`${e.name} during event "${e.event}"\n`,e.pluginName&&(s+=`Plugin: ${e.pluginName}\n`),s+=`Arguments: ${JSON.stringify(e.args,null,2)}\n\n`);let c=e instanceof Error?e.message:String(e),l=e instanceof Error?e.stack:void 0;return s+=`Error: ${c}\n`,l&&(s+=`Stack:\n${l}\n`),n.writeFileSync(o,s),o},ce=async e=>{let t=_();if(!t.bugs.url)return;e instanceof ae&&(e=e.originalError.error);let n=``;e instanceof oe&&(e.pluginName&&(n+=`**Plugin**: \`${e.pluginName}\`\n`),n+=`**Event**: \`${e.event}\`\n`,n+=`**Arguments**:\n\`\`\`ts\n${JSON.stringify(e.args,null,2)}\n\`\`\`\n\n`);let r=e instanceof Error?e.message:String(e),i=e instanceof Error?e.stack:void 0;n+=`**Error**: \`${r}\`\n`,i&&(n+=`\n**Stack Trace**:\n\`\`\`\n${i}\n\`\`\``);let a=new URLSearchParams({body:n,labels:`bug 🔥`,title:`Crash Report`}),o=`${t.bugs.url}new?${a.toString()}`,s=(await import(`open`)).default;await s(o)},le=({error:e,logPath:n})=>{if(e instanceof ie&&e.errors.length){let n=new Map;for(let{error:t,jobIndex:r}of e.errors)n.has(r)||n.set(r,[]),n.get(r).push(t);for(let[e,r]of n.entries()){let n=t.gray(`[Job ${e+1}] `),i=r.length,a=t.red(`Found ${i} configuration ${i===1?`error`:`errors`}:`);console.error(`${n}❗️ ${a}`),r.forEach((e,r)=>{let i=` [${r+1}] `,a=t.red(i);console.error(`${n}${a}${t.white(e.message)}`)})}}else{let n=t.gray(`[root] `);e instanceof ae&&(n=t.gray(`[Job ${e.originalError.jobIndex+1}] `),e=e.originalError.error);let r=t.red(`Failed with the message:`);console.error(`${n}❌ ${r}`);let i=t.red(` `);console.error(`${n}${i}${typeof e==`string`?e:e instanceof Error?e.message:`Unknown error`}`)}if(n){let e=t.gray(`[root] `);console.error(`${e}${t.cyan(`📄 Crash log saved to:`)} ${t.gray(n)}`)}},ue=async({error:e,isInteractive:n})=>!n||e instanceof re||e instanceof ie?!1:new Promise(e=>{let n=t.gray(`[root] `);console.log(`${n}${t.yellow(`📢 Open a GitHub issue with crash details? (y/N):`)}`),process.stdin.setEncoding(`utf8`),process.stdin.once(`data`,t=>{e(t.trim().toLowerCase()===`y`)})}),de=e=>{let t=b(e);return t.name===`@hey-api/client-axios`||t.name===`@hey-api/client-nuxt`?`baseURL`:`baseUrl`},b=e=>{for(let t of e.pluginOrder){let n=e.plugins[t];if(n?.tags?.includes(`client`))return n}return{config:{name:``},name:``}};let fe;const x=()=>{let e=fe;return e.client=b(e),e},pe=e=>(fe=e,x()),S=e=>b(e).name.startsWith(`legacy/`),me=e=>{if(S(e))return e.name},he=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,ge=`https://get.heyapi.dev`,_e=(e,t,n)=>`${ge}/${e}/${t}${n?`?${n}`:``}`,ve=e=>{let t=e.organization,n=e.project,r;if(e.path){let i=e.path.match(he);if(!i)throw Error(`Invalid Hey API shorthand format. Expected "organization/project?queryParams" or "organization/project", received: ${e.path}`);t=i[1],n=i[2],r=i[3]}if(!t)throw Error(`The Hey API organization cannot be empty.`);if(!n)throw Error(`The Hey API project cannot be empty.`);return{organization:t,project:n,queryParams:r}},ye=e=>{let t=ve(e);return{path:_e(t.organization,t.project,t.queryParams),registry:`hey-api`}},be=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,xe=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,Se=`readme`,Ce=e=>{let t=e.match(be);if(!t)throw Error(`Invalid ReadMe shorthand format. Expected "${Se}:@organization/project#uuid" or "${Se}:uuid", received: ${Se}:${e}`);let[,,n,r,i]=t;if(!i)throw Error(`The ReadMe UUID cannot be empty.`);return{organization:n,project:r,uuid:i}},we=e=>{let t=Ce(e.slice(`${Se}:`.length));return{...t,path:xe(t.uuid),registry:`readme`}},Te=/^(@[\w-]+)\/([\w.-]+)$/,Ee=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,De=`scalar`,Oe=e=>{let t=e.match(Te);if(!t)throw Error(`Invalid Scalar shorthand format. Expected "${De}:@organization/project", received: ${De}:${e}`);let[,n,r]=t;if(!n)throw Error(`The Scalar organization cannot be empty.`);if(!r)throw Error(`The Scalar project cannot be empty.`);return{organization:n,project:r}},ke=e=>{let t=Oe(e.slice(`${De}:`.length));return{...t,path:Ee(t.organization,t.project),registry:`scalar`}},Ae=e=>{if(e.path.startsWith(`readme:`)){Object.assign(e,we(e.path));return}if(e.path.startsWith(`scalar:`)){Object.assign(e,ke(e.path));return}if(e.path.startsWith(`.`))return;if(e.path.startsWith(ge)){e.path=e.path.slice(23),Object.assign(e,ye(e));return}let t=e.path.split(`/`);if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,ye(e));return}},je={enabled:!1,interval:1e3,timeout:6e4},Me=e=>{let t={...je};return typeof e.path==`string`&&(typeof e.watch==`boolean`?t.enabled=e.watch:typeof e.watch==`number`?(t.enabled=!0,t.interval=e.watch):e.watch&&(t={...t,...e.watch})),t},Ne=e=>{let t=e.input instanceof Array?e.input:[e.input],n=[];for(let r of t){let t={path:``,watch:je};typeof r==`string`?t.path=r:r&&(r.path!==void 0||r.organization!==void 0)?(t={...t,path:ge,...r},t.watch!==void 0&&(t.watch=Me(t))):t={...t,path:r},typeof t.path==`string`&&Ae(t),e.watch!==void 0&&t.watch.enabled===je.enabled&&t.watch.interval===je.interval&&t.watch.timeout===je.timeout&&(t.watch=Me({path:t.path,watch:e.watch})),t.path&&n.push(t)}return n},Pe=e=>{let t={file:!0,level:`info`,path:process.cwd()};return typeof e?.logs==`string`?t.path=e.logs:t={...t,...e?.logs},t},Fe=(e,t)=>{let n=e||{},r=t||{};return{...n,...r}},Ie=(e,t)=>{let n=e||{},r=t||{},i={...n,...r};return typeof i.logs==`object`&&(i.logs=Fe(n.logs,r.logs)),i},Le=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e!=`function`,Re=(e,t)=>{for(let[n,r]of Object.entries(t))r!==void 0&&r!==``&&(e[n]=r);return e},ze=({defaultValue:e,mappers:t,value:n})=>{let r={...e};switch(typeof n){case`boolean`:if(t&&`boolean`in t){let e=t.boolean;r=Re(r,e(n))}break;case`function`:if(t&&`function`in t){let e=t.function;r=Re(r,e(n))}break;case`number`:if(t&&`number`in t){let e=t.number;r=Re(r,e(n))}break;case`string`:if(t&&`string`in t){let e=t.string;r=Re(r,e(n))}break;case`object`:if(Le(n))if(t&&`object`in t&&typeof t.object==`function`){let i=t.object;r=Re(r,i(n,e))}else r=Re(r,n);break}return r},Be=e=>{if(e.output instanceof Array)throw Error(`Unexpected array of outputs in user configuration. This should have been expanded already.`);let t=ze({defaultValue:{clean:!0,fileName:{case:`preserve`,name:`{{name}}`,suffix:`.gen`},format:null,indexFile:!0,lint:null,path:``},mappers:{object:(e,t)=>({...e,fileName:ze({defaultValue:{...t.fileName},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.fileName})}),string:e=>({path:e})},value:e.output});return t.tsConfig=ee(v(t.tsConfigPath)),t.importFileExtension===void 0&&t.tsConfig?.options.moduleResolution===a.ModuleResolutionKind.NodeNext&&(t.importFileExtension=`.js`),t.importFileExtension&&!t.importFileExtension.startsWith(`.`)&&(t.importFileExtension=`.${t.importFileExtension}`),t},Ve=e=>{let t=e?r.dirname(e):process.cwd();for(;t!==r.dirname(t);){let e=r.join(t,`package.json`);if(n.existsSync(e))try{let t=JSON.parse(n.readFileSync(e,`utf8`));return{...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies}}catch{}let i=r.dirname(t);if(i===t)break;t=i}return{}},He=[`after`,`before`,`cursor`,`offset`,`page`,`start`],Ue=e=>ze({defaultValue:{hooks:{},pagination:{keywords:He},transforms:{enums:{case:`PascalCase`,enabled:!1,mode:`root`,name:`{{name}}Enum`},propertiesRequiredByDefault:!1,readWrite:{enabled:!0,requests:{case:`preserve`,name:`{{name}}Writable`},responses:{case:`preserve`,name:`{{name}}`}}},validate_EXPERIMENTAL:!1},mappers:{object:(e,t)=>({...e,pagination:ze({defaultValue:{...t.pagination},value:e.pagination}),transforms:ze({defaultValue:{...t.transforms},mappers:{object:(e,t)=>({...e,enums:ze({defaultValue:{...t.enums,enabled:e.enums===void 0?t.enums.enabled:!!e.enums},mappers:{boolean:e=>({enabled:e}),string:e=>({mode:e})},value:e.enums}),propertiesRequiredByDefault:e.propertiesRequiredByDefault===void 0?t.propertiesRequiredByDefault:e.propertiesRequiredByDefault,readWrite:ze({defaultValue:{...t.readWrite,enabled:e.readWrite===void 0?t.readWrite.enabled:!!e.readWrite},mappers:{boolean:e=>({enabled:e}),object:(e,t)=>({...e,requests:ze({defaultValue:{...t.requests},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.requests}),responses:ze({defaultValue:{...t.responses},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.responses})})},value:e.readWrite})})},value:e.transforms}),validate_EXPERIMENTAL:e.validate_EXPERIMENTAL===!0?`warn`:e.validate_EXPERIMENTAL})},value:e.parser}),We=e=>t=>({...e,config:{...e.config,...t}}),C={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})};var Ge=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Ke=/[\p{Lu}]/u,qe=/[\p{Ll}]/u,Je=/([\p{Alpha}\p{N}_]|$)/u,Ye=/[_.\- `\\[\]{}\\/]+/,Xe=RegExp(`^${Ye.source}`),Ze=RegExp(`${Ye.source}${Je.source}`,`gu`),Qe=RegExp(`\\d+${Je.source}`,`gu`),$e=({case:e,string:t})=>{let n=!1,r=!1,i=!1,a=!1,o=e===`snake_case`||e===`SCREAMING_SNAKE_CASE`?`_`:`-`;for(let e=0;e<t.length;e++){let s=t[e];a=e>2?t[e-3]===o:!0;let c=e+1,l=t[c];for(Ye.lastIndex=0;l&&Ye.test(l);)c+=1,l=t[c];let u=c!==e+1;if(qe.lastIndex=0,Ke.lastIndex=0,Ke.test(s)&&(n||l&&!u&&l!==`s`&&qe.test(l)))t=`${t.slice(0,e)}${o}${t.slice(e)}`,e++,i=r,n=!1,r=!0;else if(r&&i&&qe.test(s)&&!a&&!(s===`s`&&(!l||l.toLocaleLowerCase()!==l)))t=`${t.slice(0,e-1)}${o}${t.slice(e-1)}`,i=r,n=!0,r=!1;else{let e=s.toLocaleLowerCase(),t=s.toLocaleUpperCase();i=r,n=e===s&&t!==s,r=t===s&&e!==s}}return t},w=({case:e,stripLeadingSeparators:t=!0,value:n})=>{let r=n.trim();return r.length?!e||e===`preserve`?r:r.length===1?(Ye.lastIndex=0,Ye.test(r)?``:e===`PascalCase`||e===`SCREAMING_SNAKE_CASE`?r.toLocaleUpperCase():r.toLocaleLowerCase()):(r!==r.toLocaleLowerCase()&&(r=$e({case:e,string:r})),(t||r[0]!==n[0])&&(r=r.replace(Xe,``)),r=e===`SCREAMING_SNAKE_CASE`?r.toLocaleUpperCase():r.toLocaleLowerCase(),e===`PascalCase`&&(r=`${r.charAt(0).toLocaleUpperCase()}${r.slice(1)}`),e===`snake_case`||e===`SCREAMING_SNAKE_CASE`?(r=r.replaceAll(Ze,(e,n,r)=>r===0&&!t?e:`_${n}`),r[r.length-1]===`_`&&(r=r.slice(0,r.length-1))):(Ze.lastIndex=0,Qe.lastIndex=0,r=r.replaceAll(Qe,(e,t,n)=>[`_`,`-`,`.`].includes(r.charAt(n+e.length))?e:e.toLocaleUpperCase()),r=r.replaceAll(Ze,(e,r,i)=>i===0&&!t&&e[0]&&n.startsWith(e[0])?e:r.toLocaleUpperCase())),r):``},T=({config:e,name:t})=>{if(typeof e.name==`function`)t=e.name(t);else if(e.name){let n=e.case===`preserve`?``:`-`;t=e.name.replace(`{{name}}`,`${n}${t}${n}`)}return w({case:e.case,value:t})},et=({context:e,parameter:t})=>{if(!t.pagination)return;if(t.pagination===!0)return t.schema;let n=t.schema;return n.$ref&&(n=e.resolveIrRef(n.$ref)),n.properties[t.pagination]},tt=e=>{for(let t in e)if(e[t].required)return!0;return!1},nt=e=>e?!!(tt(e.cookie)||tt(e.header)||tt(e.path)||tt(e.query)):!1,rt=({context:e,parameters:t})=>{if(t){for(let n in t.cookie){let r=t.cookie[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:et({context:e,parameter:r})}}for(let n in t.header){let r=t.header[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:et({context:e,parameter:r})}}for(let n in t.path){let r=t.path[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:et({context:e,parameter:r})}}for(let n in t.query){let r=t.query[n];if(r.pagination)return{in:r.location,name:r.pagination===!0?r.name:`${r.name}.${r.pagination}`,schema:et({context:e,parameter:r})}}}},E=({detectFormat:e=!0,schema:t})=>{if(!t.items)return t;let n=[],r=[];for(let i of t.items){if(!i.type&&i.items||t.type===`tuple`){n.push(i);continue}if(!i.type||i.type===`boolean`||i.type===`integer`||i.type===`null`||i.type===`number`||i.type===`string`||i.type===`unknown`||i.type===`void`){let t=i.const===void 0?``:`const-${i.const}`,a=i.format!==void 0&&e?`format-${i.format}`:``,o=[i.minLength===void 0?``:`minLength-${i.minLength}`,i.maxLength===void 0?``:`maxLength-${i.maxLength}`,i.minimum===void 0?``:`minimum-${i.minimum}`,i.maximum===void 0?``:`maximum-${i.maximum}`,i.exclusiveMinimum===void 0?``:`exclusiveMinimum-${i.exclusiveMinimum}`,i.exclusiveMaximum===void 0?``:`exclusiveMaximum-${i.exclusiveMaximum}`,i.minItems===void 0?``:`minItems-${i.minItems}`,i.maxItems===void 0?``:`maxItems-${i.maxItems}`,i.pattern===void 0?``:`pattern-${i.pattern}`].join(``),s=`${i.$ref??``}${i.type??``}${t}${a}${o}`;r.includes(s)||(r.push(s),n.push(i));continue}n.push(i)}let i={...t};if(i.items=n,i.items.length<=1&&i.type!==`array`&&i.type!==`enum`&&i.type!==`tuple`){let e=i.items[0];delete i.logicalOperator,delete i.items,i={...i,...e}}return i.type===`unknown`?{}:i},D=({items:e,logicalOperator:t=`or`,mutateSchemaOneItem:n=!1,schema:r})=>e.length?r.type===`tuple`?(r.items=e,r):e.length===1?n?(r={...r,...e[0]},r):(r.items=e,r):(r.items=e,r.logicalOperator=t,r):r,it=e=>!!(nt(e.parameters)||e.body?.required),O=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,at=({context:e,operation:t})=>{let n=t.body;if(!n||!n.pagination)return rt({context:e,parameters:t.parameters});if(n.pagination===!0)return{in:`body`,name:`body`,schema:n.schema};let r=n.schema,i=r.$ref?e.resolveIrRef(r.$ref):r,a=(`schema`in i?i.schema:i)?.properties?.[n.pagination];return a?{in:`body`,name:n.pagination,schema:a}:rt({context:e,parameters:t.parameters})},ot=({statusCode:e})=>{switch(e){case`1XX`:return`1XX`;case`2XX`:return`2XX`;case`3XX`:return`3XX`;case`4XX`:return`4XX`;case`5XX`:return`5XX`;case`default`:return`default`;default:return`${e[0]}XX`}},st=e=>{let t={};if(!e.responses)return t;let n={properties:{},type:`object`},r={properties:{},type:`object`},i;for(let t in e.responses){let a=e.responses[t];switch(ot({statusCode:t})){case`1XX`:case`3XX`:break;case`2XX`:r.properties[t]=a.schema;break;case`4XX`:case`5XX`:n.properties[t]=a.schema;break;case`default`:i=a;break}}if(i){let e=!1;Object.keys(r.properties).length||(r.properties.default=i.schema,e=!0);let t=(i.schema.description??``).toLocaleLowerCase(),a=(i.schema.$ref??``).toLocaleLowerCase();[`success`].some(e=>t.includes(e)||a.includes(e))&&(r.properties.default=i.schema,e=!0),[`error`,`problem`].some(e=>t.includes(e)||a.includes(e))&&(n.properties.default=i.schema,e=!0),e||(n.properties.default=i.schema)}let a=Object.keys(n.properties);if(a.length){n.required=a,t.errors=n;let e=D({items:Object.values(n.properties),mutateSchemaOneItem:!0,schema:{}});e=E({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.error=e)}let o=Object.keys(r.properties);if(o.length){r.required=o,t.responses=r;let e=D({items:Object.values(r.properties),mutateSchemaOneItem:!0,schema:{}});e=E({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.response=e)}return t},ct=(...e)=>o.satisfies(...e),lt=e=>({getVersion:t=>{let n=e[t];if(n)try{let e=o.parse(n);if(e)return e;let t=o.minVersion(n);if(t)return t;if(e=o.coerce(n),e)return e}catch{}},isInstalled:t=>!!e[t],satisfies:(t,n,r)=>{let i=typeof t==`string`?e[t]:t;return i?ct(i,n,r):!1}}),ut=/^[^$_\p{ID_Start}]+/u,k=/^-?\d+(\.\d+)?$/,dt=/^(document|history|location|navigator|window)$/g,ft=/^(console|Array|Date|Error|Function|JSON|Map|Math|Object|Promise|RegExp|Set|WeakMap|WeakSet)$/g,pt=/^(arguments|async|await|break|case|catch|class|const|continue|debugger|default|delete|do|else|enum|eval|export|extends|false|finally|for|from|function|if|implements|import|in|instanceof|interface|let|new|null|package|private|protected|public|return|static|super|switch|this|throw|true|try|typeof|var|void|while|with|yield)$/g,mt=/^(global|process|Buffer)$/g,ht=/^(any|as|bigint|boolean|namespace|never|null|number|string|symbol|type|undefined|unknown|void)$/g,gt=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,_t=[pt,ht,ft,mt,dt],vt=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`);if(ut.lastIndex=0,ut.test(t))return`_${t}`;for(let e of _t){if(t.startsWith(`_`))return t;t=t.replace(e,`_$1`)}return t},yt=e=>(e||e===``)&&(gt.lastIndex=0,!gt.test(e))?`'${e}'`:e,bt=e=>e&&e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,e.length-1):e,A=e=>e.replace(/\*\//g,`*`).replace(/\/\*/g,`*`).replace(/\r?\n(.*)/g,(e,t)=>d+t.trim()),xt=a.createPrinter({newLine:a.NewLineKind.LineFeed,removeComments:!1}),St=(e=>a.createSourceFile(``,e,a.ScriptTarget.ESNext,!1,a.ScriptKind.TS))(``),Ct=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));function wt({node:e,unescape:t=!1}){let n=xt.printNode(a.EmitHint.Unspecified,e,St);if(!t)return n;try{return Ct(n)}catch{return x().logs.level===`debug`&&console.warn(`Could not decode value:`,n),n}}const j=({text:e})=>a.factory.createIdentifier(e),Tt=()=>a.factory.createThis(),M=({keyword:e})=>{let t=It({keyword:e});return a.factory.createModifier(t)},Et=({initializer:e,modifier:t,name:n,type:r})=>a.factory.createPropertyDeclaration(t?[M({keyword:t})]:void 0,n,void 0,r,e),Dt={boolean:e=>e?a.factory.createTrue():a.factory.createFalse(),export:({alias:e,asType:t=!1,name:n})=>{let r=j({text:n});if(e){let n=j({text:e});return a.factory.createExportSpecifier(t,r,n)}return a.factory.createExportSpecifier(t,void 0,r)},import:({alias:e,asType:t=!1,name:n})=>{let r=j({text:n});if(e){let n=j({text:e});return a.factory.createImportSpecifier(t,r,n)}return a.factory.createImportSpecifier(t,void 0,r)},number:e=>e<0?a.factory.createPrefixUnaryExpression(a.SyntaxKind.MinusToken,a.factory.createNumericLiteral(Math.abs(e))):a.factory.createNumericLiteral(e),string:(e,t=!1)=>{let n=e;t&&(n=bt(n));let r=n.includes(`'`)&&n.includes(`"`),i=n.includes(`
|
|
2
|
-
`),a=n.startsWith("`"),o=n.startsWith("\\`")&&n.endsWith("\\`");return(i||r||a)&&!o&&(n=`\`${n.replace(/(?<!\\)`/g,"\\`").replace(/\${/g,"\\${")}\``),n.startsWith("`")?j({text:n}):en({text:n})}},Ot=e=>typeof e==`object`&&!!e&&typeof e.kind==`number`&&typeof e.flags==`number`&&typeof e.pos==`number`&&typeof e.end==`number`,kt=e=>e!==void 0,At=({commentObject:e,node:t})=>{let n=e.lines.filter(e=>!!e||e===``);if(!n.length)return;if(!e.jsdoc){for(let e of n)a.addSyntheticLeadingComment(t,a.SyntaxKind.SingleLineCommentTrivia,` ${e}`,!0);return}let r=n.map((e,t)=>{let r=e;return t!==n.length&&(r=`${r}\n`),a.factory.createJSDocText(r)}),i=wt({node:a.factory.createJSDocComment(a.factory.createNodeArray(r),void 0),unescape:!0}).replace(`/*`,``).replace(`* */`,``);a.addSyntheticLeadingComment(t,a.SyntaxKind.MultiLineCommentTrivia,i,!0)},N=({comments:e=[],node:t})=>{let n=!!e.find(e=>typeof e==`object`&&e),r=e;n||(r=[{jsdoc:!0,lines:e}]);for(let e of r)At({commentObject:e,node:t})},P=(e,t)=>a.isTypeNode(e)?e:typeof e==`number`?a.factory.createLiteralTypeNode(Dt.number(e)):an({typeArguments:t?.map(e=>P(e)),typeName:a.isIdentifier(e)?e.text:e}),jt=({expression:e,name:t})=>a.factory.createPropertyAccessChain(e,a.factory.createToken(a.SyntaxKind.QuestionDotToken),t),Mt=({expression:e,isOptional:t,name:n})=>{let r=typeof e==`string`?j({text:e}):e;if(t&&typeof n!=`number`)return jt({expression:r,name:n});if(typeof n==`string`){if(gt.lastIndex=0,!gt.test(n)){!n.startsWith(`'`)&&!n.endsWith(`'`)&&(n=`\'${n}\'`);let e=j({text:n});return a.factory.createElementAccessExpression(r,e)}let e=j({text:n});return a.factory.createPropertyAccessExpression(r,e)}if(typeof n==`number`){let e=a.factory.createNumericLiteral(n);return a.factory.createElementAccessExpression(r,e)}return a.factory.createPropertyAccessExpression(r,n)},Nt=()=>a.factory.createNull(),Pt=({identifiers:e=[],isValueAccess:t,shorthand:n,unescape:r,value:i})=>{if(i===null)return Nt();if(Array.isArray(i))return Gt({elements:i});if(typeof i==`object`)return Jt({identifiers:e,obj:i,shorthand:n});if(typeof i==`number`)return Dt.number(i);if(typeof i==`boolean`)return Dt.boolean(i);if(typeof i==`string`){if(t){let e=i.split(`.`);return Mt({expression:e[0],name:e[1]})}return Dt.string(i,r)}},Ft=e=>e.map(e=>{if(`destructure`in e)return sn({name:a.factory.createObjectBindingPattern(e.destructure.map(e=>{if(!(`destructure`in e))return a.factory.createBindingElement(void 0,void 0,j({text:e.name}),void 0)}).filter(Boolean)),type:e.type===void 0?void 0:P(e.type)});let t=e.accessLevel?[M({keyword:e.accessLevel})]:[];return e.isReadOnly&&t.push(M({keyword:`readonly`})),sn({initializer:e.default===void 0?void 0:Pt({value:e.default}),modifiers:t,name:j({text:e.name}),required:e.isRequired!==!1,type:e.type===void 0?void 0:P(e.type)})}),It=({keyword:e})=>{switch(e){case`any`:return a.SyntaxKind.AnyKeyword;case`async`:return a.SyntaxKind.AsyncKeyword;case`boolean`:return a.SyntaxKind.BooleanKeyword;case`export`:return a.SyntaxKind.ExportKeyword;case`never`:return a.SyntaxKind.NeverKeyword;case`number`:return a.SyntaxKind.NumberKeyword;case`private`:return a.SyntaxKind.PrivateKeyword;case`protected`:return a.SyntaxKind.ProtectedKeyword;case`public`:return a.SyntaxKind.PublicKeyword;case`readonly`:return a.SyntaxKind.ReadonlyKeyword;case`static`:return a.SyntaxKind.StaticKeyword;case`string`:return a.SyntaxKind.StringKeyword;case`undefined`:return a.SyntaxKind.UndefinedKeyword;case`unknown`:return a.SyntaxKind.UnknownKeyword;case`void`:return a.SyntaxKind.VoidKeyword;default:throw Error(`unsupported syntax kind keyword "${e}"`)}},Lt=({keyword:e})=>{let t=It({keyword:e});return a.factory.createKeywordTypeNode(t)},Rt=e=>e.map(e=>a.isTypeParameterDeclaration(e)?e:Bt({constraint:e.extends?typeof e.extends==`string`?Lt({keyword:`boolean`}):e.extends:void 0,defaultType:e.default===void 0?void 0:Ot(e.default)?e.default:a.factory.createLiteralTypeNode(e.default?a.factory.createTrue():a.factory.createFalse()),name:e.name})),zt=({operator:e,type:t})=>{let n=e===`keyof`?a.SyntaxKind.KeyOfKeyword:e===`readonly`?a.SyntaxKind.ReadonlyKeyword:a.SyntaxKind.UniqueKeyword;return a.factory.createTypeOperatorNode(n,t)},Bt=({constraint:e,defaultType:t,modifiers:n,name:r})=>a.factory.createTypeParameterDeclaration(n,r,e,t),Vt=({members:e,nameType:t,questionToken:n,readonlyToken:r,type:i,typeParameter:o})=>a.factory.createMappedTypeNode(r,o,t,n,i,e),Ht=({literal:e})=>a.factory.createLiteralTypeNode(e),Ut=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:o=[],types:s=[]})=>{let c=a.factory.createArrowFunction(e?[M({keyword:`async`})]:void 0,s?Rt(s):void 0,Ft(r),i?P(i):void 0,void 0,Array.isArray(o)?dn({multiLine:n,statements:o}):o);return N({comments:t,node:c}),c},Wt=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:o=[],types:s=[]})=>{let c=a.factory.createFunctionExpression(e?[M({keyword:`async`})]:void 0,void 0,void 0,s?Rt(s):void 0,Ft(r),i?P(i):void 0,dn({multiLine:n,statements:o}));return N({comments:t,node:c}),c},Gt=({elements:e,multiLine:t=!1})=>a.factory.createArrayLiteralExpression(e.map(e=>Ot(e)?e:Pt({value:e})).filter(kt),t||!Array.isArray(e[0])&&typeof e[0]==`object`),Kt=({expression:e})=>a.factory.createAwaitExpression(e),qt=({parameters:e=[],returnType:t,typeParameters:n})=>a.factory.createFunctionTypeNode(n,e,t),Jt=({comments:e,identifiers:t=[],multiLine:n=!0,obj:r,shorthand:i,unescape:o=!1})=>{let s=Array.isArray(r)?r.map(e=>{let r=!1;if(`key`in e){let{key:t}=e;r=t===e.value,(t.match(/^[0-9]/)&&t.match(/\D+/g)||t.match(/\W/g)||t===``)&&!t.startsWith(`'`)&&!t.endsWith(`'`)&&(e.key=`'${t}'`)}let s;if(`spread`in e){let t=Ot(e.spread)?e.spread:j({text:e.spread});s=a.factory.createSpreadAssignment(e.assertion?mn({expression:t,type:typeof e.assertion==`string`?Lt({keyword:e.assertion}):e.assertion}):t)}else if(e.shorthand||i&&r)s=a.factory.createShorthandPropertyAssignment(e.value);else{let r=Ot(e.value)?e.value:Array.isArray(e.value)&&(!e.value.length||typeof e.value[0]==`object`)?Jt({multiLine:n,obj:e.value,shorthand:i,unescape:o}):Pt({identifiers:t.includes(e.key)?Object.keys(e.value):[],isValueAccess:e.isValueAccess,shorthand:i,unescape:o,value:e.value});if(!r)return;t.includes(e.key)&&!a.isObjectLiteralExpression(r)&&(r=j({text:e.value})),s=fn({initializer:r,name:e.key})}return N({comments:e.comments,node:s}),s}).filter(kt):Object.entries(r).map(([e,n])=>{let r=Pt({identifiers:t.includes(e)?Object.keys(n):[],shorthand:i,unescape:o,value:n});if(!r)return;t.includes(e)&&!a.isObjectLiteralExpression(r)&&(r=j({text:n}));let s=e===n;return e.match(/^[0-9]/)&&e.match(/\D+/g)&&!e.startsWith(`'`)&&!e.endsWith(`'`)&&(e=`'${e}'`),e.match(/\W/g)&&!e.startsWith(`'`)&&!e.endsWith(`'`)&&(e=`'${e}'`),i&&s?a.factory.createShorthandPropertyAssignment(n):fn({initializer:r,name:e})}).filter(kt),c=a.factory.createObjectLiteralExpression(s,n);return N({comments:e,node:c}),c},Yt=({asConst:e,comments:t={},leadingComment:n,name:r,obj:i})=>{let o=Array.isArray(i)?i.map(e=>{let t=Xt({initializer:Pt({value:e.value}),name:e.key});return N({comments:e.comments,node:t}),t}):Object.entries(i).map(([e,n])=>{let r=a.factory.createEnumMember(e,Pt({unescape:!0,value:n}));return N({comments:t[e],node:r}),r}),s=[M({keyword:`export`})],c=e?[a.factory.createToken(a.SyntaxKind.ConstKeyword)]:[],l=[...s,...c],u=a.factory.createEnumDeclaration(l,typeof r==`string`?j({text:r}):r,o);return N({comments:n,node:u}),u},Xt=({initializer:e,name:t})=>{let n=t;return typeof n==`string`&&(n=n.includes(`'`)?en({isSingleQuote:!1,text:n}):yt(n)),a.factory.createEnumMember(n,e)},Zt=({name:e,statements:t})=>a.factory.createModuleDeclaration([M({keyword:`export`})],j({text:e}),a.factory.createModuleBlock(t),a.NodeFlags.Namespace),Qt=({indexType:e,objectType:t})=>a.factory.createIndexedAccessTypeNode(t,e),$t=({name:e,returnType:t,statements:n})=>a.factory.createGetAccessorDeclaration(void 0,e,[],t?an({typeName:t}):void 0,dn({statements:n})),en=({isSingleQuote:e,text:t})=>(e===void 0&&(e=!t.includes(`'`)),a.factory.createStringLiteral(t,e)),tn=({condition:e,whenFalse:t,whenTrue:n})=>a.factory.createConditionalExpression(e,a.factory.createToken(a.SyntaxKind.QuestionToken),n,a.factory.createToken(a.SyntaxKind.ColonToken),t),nn=({text:e})=>a.factory.createTypeOfExpression(typeof e==`string`?j({text:e}):e),rn=({comment:e,exportType:t,name:n,type:r,typeParameters:i=[]})=>{let o=a.factory.createTypeAliasDeclaration(t?[M({keyword:`export`})]:void 0,typeof n==`string`?j({text:n}):n,Rt(i),P(r));return N({comments:e,node:o}),o},an=({typeArguments:e,typeName:t})=>a.factory.createTypeReferenceNode(t,e),on=({type:e})=>a.factory.createParenthesizedType(e),sn=({initializer:e,modifiers:t,name:n,required:r=!0,type:i})=>a.factory.createParameterDeclaration(t,void 0,n,r?void 0:a.factory.createToken(a.SyntaxKind.QuestionToken),i,e),cn=({argumentsArray:e,expression:t,typeArguments:n})=>a.factory.createNewExpression(t,n,e),ln=({awaitModifier:e,expression:t,initializer:n,statement:r})=>a.factory.createForOfStatement(e,n,t,r),un=({left:e,right:t})=>a.factory.createAssignment(e,t),dn=({multiLine:e=!0,statements:t})=>a.factory.createBlock(t,e),fn=({initializer:e,name:t})=>a.factory.createPropertyAssignment(t,e),pn=({flags:e=[],text:t})=>{let n=`/${(t.startsWith(`/`)&&t.endsWith(`/`)?t.slice(1,-1):t).replace(/(?<!\\)\//g,`\\/`)}/`;return a.factory.createRegularExpressionLiteral(`${n}${e.join(``)}`)},mn=({expression:e,type:t})=>a.factory.createAsExpression(e,t),hn=({value:e})=>{let t=[],n=``;for(let r of e.slice(0).reverse())if(typeof r==`string`)n=`${r}${n}`;else{let e=t.length?a.factory.createTemplateMiddle(n):a.factory.createTemplateTail(n),i=a.factory.createTemplateLiteralTypeSpan(r,e);t.push(i),n=``}return a.factory.createTemplateLiteralType(a.factory.createTemplateHead(n),t.reverse())},gn=({module:e,shouldAppendJs:t})=>a.factory.createExportDeclaration(void 0,!1,void 0,Dt.string(t?`${e}.js`:e)),_n=({functionName:e,parameters:t=[],types:n})=>{let r=typeof e==`string`?j({text:e}):e,i=t.filter(e=>e!==void 0).map(e=>typeof e==`string`?j({text:e}):e);return a.factory.createCallExpression(r,n,i)},vn=({exports:e,module:t})=>{let n=Array.isArray(e)?e:[e],r=n.some(e=>typeof e!=`object`||!e.asType),i=n.map(e=>{let t=typeof e==`string`?{name:e}:e;return Dt.export({alias:t.alias,asType:r&&t.asType,name:t.name})}),o=a.factory.createNamedExports(i),s=Dt.string(t);return a.factory.createExportDeclaration(void 0,!r,o,s)},yn=({assertion:e,comment:t,destructure:n,exportConst:r,expression:i,name:o,typeName:s})=>{let c=e?mn({expression:i,type:typeof e==`string`?an({typeName:e}):e}):i,l=typeof o==`string`?j({text:o}):o,u=a.factory.createVariableDeclaration(n?a.factory.createObjectBindingPattern([a.factory.createBindingElement(void 0,void 0,l,void 0)]):l,void 0,s?typeof s==`string`?an({typeName:s}):s:void 0,c),d=a.factory.createVariableStatement(r?[M({keyword:`export`})]:void 0,a.factory.createVariableDeclarationList([u],a.NodeFlags.Const));return N({comments:t,node:d}),d},bn=({imports:e,module:t})=>{let n=Array.isArray(e)?e:[e],r=n.some(e=>typeof e!=`object`||!e.asType),i,o=[];n.forEach(e=>{let t=typeof e==`string`?{name:e}:e;t.name===`*`&&t.alias?i=t:o.push(Dt.import({alias:t.alias,asType:r&&t.asType,name:t.name}))});let s=i?a.factory.createNamespaceImport(j({text:i.alias})):a.factory.createNamedImports(o),c=a.factory.createImportClause(!r,void 0,s),l=Dt.string(t);return a.factory.createImportDeclaration(void 0,c,l)},xn=({accessLevel:e,comment:t,multiLine:n=!0,parameters:r=[],statements:i=[]})=>{let o=e?[M({keyword:e})]:void 0,s=a.factory.createConstructorDeclaration(o,Ft(r),dn({multiLine:n,statements:i}));return N({comments:t,node:s}),s},Sn=({accessLevel:e,comment:t,isStatic:n=!1,multiLine:r=!0,name:i,parameters:o=[],returnType:s,statements:c=[],types:l=[]})=>{let u=e?[M({keyword:e})]:[];n&&u.push(M({keyword:`static`}));let d=a.factory.createMethodDeclaration(u,void 0,j({text:i}),void 0,l?Rt(l):void 0,Ft(o),s?P(s):void 0,dn({multiLine:r,statements:c}));return N({comments:t,node:d}),d},Cn=({decorator:e,exportClass:t,extendedClasses:n,name:r,nodes:i})=>{let o=[];t&&o.push(M({keyword:`export`})),e&&o.unshift(a.factory.createDecorator(_n({functionName:e.name,parameters:e.args.map(e=>Pt({value:e})).filter(kt)})));let s=[];if(n)for(let e of n)s.push(a.factory.createHeritageClause(a.SyntaxKind.ExtendsKeyword,[a.factory.createExpressionWithTypeArguments(j({text:e}),void 0)]));return a.factory.createClassDeclaration(o,j({text:r}),void 0,s,i)},wn=({expression:e})=>a.factory.createExpressionStatement(e),Tn=({expression:e})=>a.factory.createReturnStatement(e),En=({args:e=[],name:t,types:n=[]})=>{let r=n.map(e=>an({typeName:e}));return Tn({expression:_n({functionName:t,parameters:e.map(e=>a.isExpression(e)?e:j({text:e})).filter(kt),types:r})})},Dn=({expression:e})=>Tn({expression:typeof e==`string`?j({text:e}):e}),On=e=>e.slice(1).reduce((e,t)=>(gt.lastIndex=0,gt.test(t)?jt({expression:e,name:t}):a.factory.createElementAccessChain(e,a.factory.createToken(a.SyntaxKind.QuestionDotToken),j({text:t}))),j({text:e[0]})),kn=e=>e.slice(1).reduce((e,t)=>Mt({expression:e,name:t}),j({text:e[0]})),An=({expressions:e})=>e.reduce((e,t)=>Mt({expression:e,name:t})),jn=({left:e,operator:t=`=`,right:n})=>a.factory.createBinaryExpression(e,t===`=`?a.SyntaxKind.EqualsToken:t===`===`?a.SyntaxKind.EqualsEqualsEqualsToken:t===`!==`?a.SyntaxKind.ExclamationEqualsEqualsToken:t===`??`?a.SyntaxKind.QuestionQuestionToken:a.SyntaxKind.InKeyword,typeof n==`string`?j({text:n}):n),Mn=({elseStatement:e,expression:t,thenStatement:n})=>a.factory.createIfStatement(t,n,e),Nn=({path:e})=>{let t=On(e),n=kn(e);return Mn({expression:t,thenStatement:dn({statements:[wn({expression:jn({left:n,right:cn({argumentsArray:[n],expression:j({text:`Date`})})})})]})})},Pn=({path:e,transformerName:t})=>[Mn({expression:On(e),thenStatement:dn({statements:[wn({expression:_n({functionName:t,parameters:[kn(e)]})})]})})],Fn=({path:e,transformerName:t})=>{let n=On(e),r=kn(e);return Mn({expression:_n({functionName:Mt({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:dn({statements:[wn({expression:a.factory.createCallChain(Mt({expression:r,name:`forEach`}),void 0,void 0,[j({text:t})])})]})})},In=({parameterName:e})=>{let t=j({text:`Date`});return cn({argumentsArray:[j({text:e})],expression:t})},Ln=({path:e,transformExpression:t})=>{let n=On(e),r=kn(e);return Mn({expression:_n({functionName:Mt({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:dn({statements:[wn({expression:jn({left:r,right:a.factory.createCallChain(Mt({expression:r,name:`map`}),void 0,void 0,[Ut({parameters:[{name:`item`}],statements:t})])})})]})})},Rn=an({typeName:`null`}),zn=({isNullable:e,node:t})=>e?a.factory.createUnionTypeNode([t,Rn]):t,Bn=({indexKey:e,indexProperty:t,isNullable:n,properties:r,useLegacyResolution:i})=>{let o=[],s=r.map(e=>{let t=e.isReadOnly?[M({keyword:`readonly`})]:void 0,n=e.isRequired===!1?a.factory.createToken(a.SyntaxKind.QuestionToken):void 0,r=P(e.type);o.push(r);let s=a.factory.createPropertySignature(t,i||typeof e.name==`string`&&e.name.match(gt)||typeof e.name!=`string`&&a.isPropertyName(e.name)?e.name:en({text:e.name}),n,r);return N({comments:e.comment,node:s}),s}),c=!1;if(t)if(!r.length&&e){let n=Vt({questionToken:a.factory.createToken(a.SyntaxKind.QuestionToken),type:t.type??Lt({keyword:`string`}),typeParameter:Bt({constraint:e,name:j({text:String(t.name)})})});s.push(n),c=!0}else{let e=t.isReadOnly?[M({keyword:`readonly`})]:void 0,n=a.factory.createIndexSignature(e,[sn({name:j({text:String(t.name)}),type:Lt({keyword:`string`})})],P(t.type));s.push(n)}return zn({isNullable:n,node:c?s[0]:a.factory.createTypeLiteralNode(s)})},Vn=({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=P(e);a.isUnionTypeNode(t)?n.push(...t.types):n.push(t)}return zn({isNullable:e,node:a.factory.createUnionTypeNode(n)})},F={anonymousFunction:Wt,arrayLiteralExpression:Gt,arrowFunction:Ut,asExpression:mn,assignment:un,awaitExpression:Kt,binaryExpression:jn,block:dn,callExpression:_n,classDeclaration:Cn,conditionalExpression:tn,constVariable:yn,constructorDeclaration:xn,enumDeclaration:Yt,exportAllDeclaration:gn,exportNamedDeclaration:vn,expressionToStatement:wn,forOfStatement:ln,functionTypeNode:qt,getAccessorDeclaration:$t,identifier:j,ifStatement:Mn,indexedAccessTypeNode:Qt,isTsNode:Ot,keywordTypeNode:Lt,literalTypeNode:Ht,mappedTypeNode:Vt,methodDeclaration:Sn,namedImportDeclarations:bn,namespaceDeclaration:Zt,newExpression:cn,nodeToString:wt,null:Nt,objectExpression:Jt,ots:Dt,parameterDeclaration:sn,propertyAccessExpression:Mt,propertyAccessExpressions:An,propertyAssignment:fn,propertyDeclaration:Et,regularExpressionLiteral:pn,returnFunctionCall:En,returnStatement:Tn,returnVariable:Dn,safeAccessExpression:On,stringLiteral:en,templateLiteralType:hn,this:Tt,transformArrayMap:Ln,transformArrayMutation:Fn,transformDateMutation:Nn,transformFunctionMutation:Pn,transformNewDate:In,typeAliasDeclaration:rn,typeArrayNode:(e,t=!1)=>zn({isNullable:t,node:an({typeArguments:[Array.isArray(e)?Vn({types:e}):e],typeName:`Array`})}),typeInterfaceNode:Bn,typeIntersectionNode:({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=P(e);a.isIntersectionTypeNode(t)?n.push(...t.types):n.push(t)}return zn({isNullable:e,node:a.factory.createIntersectionTypeNode(n)})},typeNode:P,typeOfExpression:nn,typeOperatorNode:zt,typeParameterDeclaration:Bt,typeParenthesizedNode:on,typeRecordNode:(e,t,n=!1,r=!0)=>{let i=Vn({types:e}),a=Vn({types:t});return zn({isNullable:n,node:Bn({properties:[{name:`[key: ${wt({node:i,unescape:!0})}]`,type:a}],useLegacyResolution:r})})},typeReferenceNode:an,typeTupleNode:({isNullable:e=!1,types:t})=>{let n=t.map(e=>P(e));return zn({isNullable:e,node:a.factory.createTupleTypeNode(n)})},typeUnionNode:Vn,valueToExpression:Pt},Hn=F,Un=new Set(`buffer.child_process.cluster.console.constants.crypto.dgram.dns.domain.events.freelist.fs.http.https.module.net.os.path.process.punycode.querystring.readline.repl.stream.string_decoder.timers.tls.tty.url.util.v8.vm.worker_threads.zlib`.split(`.`));var Wn=class{addBinding({bindings:e,file:t,meta:n,project:r,symbol:i}){if(!i.external&&!r.symbols.hasValue(i.id))return;let[a]=r.symbolIdToFiles(i.id);if(!a)return;let o=this.getBindingPath(t,a,n),s=e.get(o),u=c({file:t,modulePath:o,symbol:i,symbolFile:a});s?(l(s,u),e.set(o,s)):e.set(o,u)}getBindingPath(e,t,n){if(!e.path||!t.path)return``;if(t.external&&!r.isAbsolute(t.path))return t.path;let i=r.posix.relative(r.posix.dirname(e.path.split(r.sep).join(r.posix.sep)),t.path.split(r.sep).join(r.posix.sep));return!i.startsWith(`.`)&&i!==``&&(i=`./${i}`),t.extension===`.ts`&&(i.endsWith(t.extension)&&(i=i.slice(0,-t.extension.length)),n?.importFileExtension?i+=n.importFileExtension:i.endsWith(`/index`)&&(i=i.slice(0,-6))),i}getBodyLines(e,t){let n=[];for(let r of e.symbols.body){let e=t.symbols.getValue(r);if(typeof e==`string`)n.push(e);else if(e instanceof Array)for(let t of e)n.push(wt({node:t,unescape:!0}));else e!=null&&n.push(wt({node:e,unescape:!0}))}return n}getExportLines(e,t,n){let r=[];for(let[i,o]of e.entries()){let e=[],s,c=!1;if(o.namespaceBinding!==void 0)typeof o.namespaceBinding==`string`&&(s=u(o.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})})),o.typeNamespaceBinding&&(c=!0);else if(o.names&&o.names.length>0){o.names.every(e=>(o.typeNames??[]).includes(e))&&(c=!0);for(let r of o.names){let i=o.aliases?.[r],s=r,l;i&&i!==s&&(l=s,s=i),s=u(s,e=>{let r=n.symbols.get(e),i=this.replacerFn({file:t,project:n,symbol:r}),[a]=n.symbolIdToFiles(e),o=a?a.resolvedNames.get(e):void 0;return o&&o!==i&&(l||=o),i}),l&&(l=u(l,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),l===s&&(l=void 0));let d=a.factory.createExportSpecifier(c?!1:o.typeNames?.includes(r)??!1,l?F.identifier({text:l}):void 0,F.identifier({text:s}));e.push(d)}}let l=s?a.factory.createNamespaceExport(F.identifier({text:s})):e.length?a.factory.createNamedExports(e):void 0,d=a.factory.createExportDeclaration(void 0,c,l,F.stringLiteral({isSingleQuote:!0,text:i}));r.push(wt({node:d,unescape:!0}))}return r}getHeaderLines(){return[`// This file is auto-generated by @hey-api/openapi-ts`]}getImportLines(e,t,n){let r=[],i=-1,o=e=>{let t=e.from;return t.startsWith(`.`)?t.startsWith(`./`)?[2,0,t]:[2,t.match(/\.\.\//g)?.length??0,t]:Un.has(t.split(`/`)[0])?[0,0,t]:[1,0,t]},s=Array.from(e.values()).map(e=>({...e,k:o(e)})).sort((e,t)=>e.k[0]-t.k[0]||e.k[1]-t.k[1]||e.k[2].localeCompare(t.k[2]));for(let e of s){let o=[],s,c,l=!1;if(e.defaultBinding){let r=u(e.defaultBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})});s=F.identifier({text:r}),e.typeDefaultBinding&&(l=!0)}else if(typeof e.namespaceBinding==`string`)c=u(e.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),e.typeNamespaceBinding&&(l=!0);else if(e.names&&e.names.length>0){e.names.every(t=>e.typeNames?.includes(t))&&(l=!0);let r=[];for(let i of e.names){let a=e.aliases?.[i],o=i,s;a&&a!==o&&(s=o,o=a),o=u(o,e=>{let r=n.symbols.get(e),i=this.replacerFn({file:t,project:n,symbol:r}),[a]=n.symbolIdToFiles(e),o=a?a.resolvedNames.get(e):void 0;return o&&o!==i&&(s||=o),i}),s&&(s=u(s,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),s===o&&(s=void 0)),r.push({isTypeOnly:l?!1:e.typeNames?.includes(i)??!1,name:o,propertyName:s?F.identifier({text:s}):void 0})}o=r.sort((e,t)=>e.name.localeCompare(t.name)).map(({isTypeOnly:e,name:t,propertyName:n})=>a.factory.createImportSpecifier(e,n,F.identifier({text:t})))}let d=a.factory.createImportClause(l,s,c?a.factory.createNamespaceImport(F.identifier({text:c})):o.length?a.factory.createNamedImports(o):void 0),f=a.factory.createImportDeclaration(void 0,d,F.stringLiteral({isSingleQuote:!0,text:e.from}));i!==-1&&e.k[0]!==i&&r.push(``),r.push(wt({node:f,unescape:!0})),i=e.k[0]}return r}getUniqueName(e,t){let n=2,r=e;for(;t.hasValue(r);)r=`${e}${n}`,n+=1;return r}renderFile(e,t,n,r){let i=new Map;if(e=u(e,e=>{let a=n.symbols.get(e),o=this.replacerFn({file:t,project:n,symbol:a});return a&&this.addBinding({bindings:i,file:t,meta:r,project:n,symbol:a}),o}),!e.length)return``;let a=``,o=this.getHeaderLines();a+=`${o.join(`
|
|
3
|
-
`)}${o.length?`
|
|
4
|
-
|
|
5
|
-
`:``}`;let s=this.getImportLines(i,t,n);return a+=`${s.join(`
|
|
6
|
-
`)}${s.length?`
|
|
7
|
-
|
|
8
|
-
`:``}`,`${a}${e}`}renderSymbols(e,t,n){let r=new Map,i=``,a=this.getBodyLines(e,t);i+=`${a.join(`
|
|
9
|
-
|
|
10
|
-
`)}${a.length?`
|
|
11
|
-
`:``}`,i=u(i,n=>{if(!e.symbols.body.includes(n))return;let r=t.symbols.get(n);return this.replacerFn({file:e,project:t,symbol:r})});for(let i of e.symbols.exports){let a=t.symbols.get(i);a&&this.addBinding({bindings:r,file:e,meta:n,project:t,symbol:a})}for(let e of r.values())e.namespaceBinding=!0,e.typeNamespaceBinding=e.names&&e.typeNames&&e.names.length===e.typeNames.length&&e.names.every(t=>(e.typeNames??[]).includes(t));let o=this.getExportLines(r,e,t);return i+=`${o.join(`
|
|
12
|
-
`)}${o.length?`
|
|
13
|
-
`:``}`,i}replacerFn({file:e,project:t,symbol:n}){if(!n)return;let r=e.resolvedNames.get(n.id);if(r)return r;if(!n.name)return;let[i]=t.symbolIdToFiles(n.id),a=i?.resolvedNames.get(n.id),o=vt(a??n.name),s=e.resolvedNames.getKey(o);if(s!==void 0){let r=t.symbols.get(s);(r?.meta?.kind===`type`&&n.meta?.kind===`type`||r?.meta?.kind!==`type`&&n.meta?.kind!==`type`)&&(o=this.getUniqueName(o,e.resolvedNames))}return e.resolvedNames.set(n.id,o),o}},Gn=class{heap=[];constructor(e){this.declIndex=e}isEmpty(){return!this.heap.length}pop(){let[e]=this.heap;if(!this.heap.length)return;let t=this.heap.pop();return this.heap.length?(this.heap[0]=t,this.sinkDown(0),e):e}push(e){this.heap.push(e),this.bubbleUp(this.heap.length-1)}bubbleUp(e){let t=this.heap;for(;e>0;){let n=Math.floor((e-1)/2),r=t[n],i=t[e];if(this.declIndex.get(r)<=this.declIndex.get(i))break;t[n]=i,t[e]=r,e=n}}sinkDown(e){let t=this.heap,n=t.length;for(;;){let r=2*e+1,i=2*e+2,a=e;if(r<n){let e=t[r],n=t[a];this.declIndex.get(e)<this.declIndex.get(n)&&(a=r)}if(i<n){let e=t[i],n=t[a];this.declIndex.get(e)<this.declIndex.get(n)&&(a=i)}if(a===e)break;let o=t[a];t[a]=t[e],t[e]=o,e=a}}};const Kn=(e,t,n)=>{let r=Array.from(e.nodes.keys()),i=new Map;r.forEach((e,t)=>i.set(e,t));let a=new Map,o=n?.priority??Zn;for(let e of r){let t=(o(e)??10)*1e6+(i.get(e)??0);a.set(e,t)}let s=new Map;for(let t of r){let n=e.subtreeDependencies?.get(t)??e.nodeDependencies?.get(t)??new Set,r=new Set;for(let i of n)i!==t&&e.nodes.has(i)&&r.add(i);s.set(t,r)}let c=new Map,l=new Map;for(let e of r)c.set(e,0);for(let[e,t]of s){c.set(e,t.size);for(let n of t)l.has(n)||l.set(n,new Set),l.get(n).add(e)}let u=e=>e.sort((e,t)=>a.get(e)-a.get(t)),d=new Gn(a);for(let e of r)(c.get(e)??0)===0&&d.push(e);let f=new Set,p=[];for(;!d.isEmpty();){let e=d.pop();if(f.has(e))continue;f.add(e),p.push(e);let t=l.get(e);if(t)for(let e of t){let t=(c.get(e)??0)-1;c.set(e,t),t===0&&d.push(e)}}let m=r.filter(e=>!f.has(e));u(m);for(let e of m)f.add(e),p.push(e);let h=p,g=n?.preferGroups??Yn;if(g&&g.length>0){let e=new Map;for(let t=0;t<g.length;t++){let n=g[t];n&&e.set(n,t)}let t=t=>{let n=Jn(t);return n.matched&&e.has(n.kind)?e.get(n.kind):g.length},n=[...p].sort((e,n)=>{let r=t(e),i=t(n);return r===i?p.indexOf(e)-p.indexOf(n):r-i}),r=new Map;for(let e=0;e<n.length;e++)r.set(n[e],e);(()=>{for(let[e,n]of s)for(let i of n)if(!(t(i)<=t(e))&&r.get(i)>=r.get(e))return!0;return!1})()||(h=n)}for(let n of h)t(n,e.nodes.get(n))},qn=[`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`],Jn=(e,t)=>{let n={operation:/^#\/paths\/[^/]+\/(get|put|post|delete|options|head|patch|trace)$/,parameter:/^#\/components\/parameters\/[^/]+$/,requestBody:/^#\/components\/requestBodies\/[^/]+$/,schema:/^#\/components\/schemas\/[^/]+$/,server:/^#\/servers\/(\d+|[^/]+)$/,webhook:/^#\/webhooks\/[^/]+\/(get|put|post|delete|options|head|patch|trace)$/};if(t)return n[t].test(e)?{kind:t,matched:!0}:{matched:!1};for(let t of Object.keys(n)){let r=t;if(n[r].test(e))return{kind:r,matched:!0}}return{matched:!1}},Yn=[`schema`,`parameter`,`requestBody`,`operation`,`server`,`webhook`],Xn=(()=>{let e={};for(let t=0;t<Yn.length;t++){let n=Yn[t];n&&(e[n]=t)}for(let t of qn)e[t]===void 0&&(e[t]=Yn.length);return e})(),Zn=e=>{let t=Jn(e);return t.matched?Xn[t.kind]??10:10},Qn=/~1/g,$n=/~0/g,I=e=>{let t=L(e),n=t[t.length-1];return decodeURI(n)},er=e=>String(e).replace(/~/g,`~0`).replace(/\//g,`~1`),L=e=>{let t=e.trim();return t.startsWith(`#`)&&(t=t.slice(1)),t.startsWith(`/`)&&(t=t.slice(1)),t?t.split(`/`).map(e=>e.replace(Qn,`/`).replace($n,`~`)):[]},tr=e=>{let t=e.trim();return t.startsWith(`#`)||(t=`#${t}`),t.length>1&&t.endsWith(`/`)&&(t=t.slice(0,-1)),t=t.replace(/\/+/g,`/`),t},nr=e=>{let t=e.map(er).join(`/`);return`#`+(t?`/${t}`:``)},rr=({$ref:e,spec:t})=>{let n=L(decodeURI(e)),r=t;for(let t of n){let n=t;if(r[n]===void 0)throw Error(`Reference not found: ${e}`);r=r[n]}return r},ir=e=>{if(!(!e.meta?.pluginName||typeof e.meta.pluginName!=`string`))return e.meta.pluginName.startsWith(`@hey-api/client-`)?`client`:e.meta.pluginName===`@hey-api/typescript`?`types`:e.meta.pluginName.startsWith(`@hey-api/`)?e.meta.pluginName.split(`/`)[1]:e.meta.pluginName},ar=e=>{switch(e.method){case`delete`:case`patch`:case`post`:case`put`:return[`mutation`];case`get`:return[`query`];default:return}};var or=class{api;config;context;dependencies=[];gen;handler;name;output;package;constructor(e){this.api=e.api??{},this.config=e.config,this.context=e.context,this.dependencies=e.dependencies,this.gen=e.gen,this.handler=e.handler,this.name=e.name,this.output=e.output,this.package=e.context.package}forEach(...e){let t,n,r={order:`topological`};typeof e[e.length-1]==`function`?(n=e.slice(0,-1),t=e[e.length-1]):(n=e.slice(0,-2),t=e[e.length-2],r={...r,...e[e.length-1]});let i=new Set(n.length?n:qn);if(r.order===`declarations`){if(i.has(`server`)&&this.context.ir.servers)for(let e of this.context.ir.servers){let n={_path:[`servers`,String(this.context.ir.servers.indexOf(e))],server:e,type:`server`};try{t(n)}catch(e){this.forEachError(e,n)}}if(i.has(`schema`)&&this.context.ir.components?.schemas)for(let e in this.context.ir.components.schemas){let n={$ref:`#/components/schemas/${e}`,_path:[`components`,`schemas`,e],name:e,schema:this.context.ir.components.schemas[e],type:`schema`};try{t(n)}catch(e){this.forEachError(e,n)}}if(i.has(`parameter`)&&this.context.ir.components?.parameters)for(let e in this.context.ir.components.parameters){let n={$ref:`#/components/parameters/${e}`,_path:[`components`,`parameters`,e],name:e,parameter:this.context.ir.components.parameters[e],type:`parameter`};try{t(n)}catch(e){this.forEachError(e,n)}}if(i.has(`requestBody`)&&this.context.ir.components?.requestBodies)for(let e in this.context.ir.components.requestBodies){let n={$ref:`#/components/requestBodies/${e}`,_path:[`components`,`requestBodies`,e],name:e,requestBody:this.context.ir.components.requestBodies[e],type:`requestBody`};try{t(n)}catch(e){this.forEachError(e,n)}}if(i.has(`operation`)&&this.context.ir.paths)for(let e in this.context.ir.paths){let n=this.context.ir.paths[e];for(let r in n){let i=r,a={_path:[`paths`,e,i],method:i,operation:n[i],path:e,type:`operation`};try{t(a)}catch(e){this.forEachError(e,a)}}}if(i.has(`webhook`)&&this.context.ir.webhooks)for(let e in this.context.ir.webhooks){let n=this.context.ir.webhooks[e];for(let r in n){let i=r,a={_path:[`webhooks`,e,i],key:e,method:i,operation:n[i],type:`webhook`};try{t(a)}catch(e){this.forEachError(e,a)}}}}else r.order===`topological`&&this.context.graph&&Kn(this.context.graph,(e,n)=>{let r=Jn(e);if(!r.matched||!i.has(r.kind))return;let a;switch(r.kind){case`operation`:a={_path:L(e),method:n.key,operation:n.node,path:L(e)[1],type:r.kind};break;case`parameter`:a={$ref:e,_path:L(e),name:n.key,parameter:n.node,type:r.kind};break;case`requestBody`:a={$ref:e,_path:L(e),name:n.key,requestBody:n.node,type:r.kind};break;case`schema`:a={$ref:e,_path:L(e),name:n.key,schema:n.node,type:r.kind};break;case`server`:a={_path:L(e),server:n.node,type:r.kind};break;case`webhook`:a={_path:L(e),key:L(e)[1],method:n.key,operation:n.node,type:r.kind};break}if(a)try{t(a)}catch(e){this.forEachError(e,a)}})}forEachError(e,t){let n=e instanceof Error?e:Error(String(e));throw new oe({args:[t],error:n,event:t.type,name:`Error`,pluginName:this.name})}getPlugin(e){return this.context.plugins[e]}getPluginOrThrow(e){let t=this.getPlugin(e);if(!t)throw Error(`plugin not found ${e}`);return t}getSymbol(e){return this.gen.symbols.get(e)}getSymbolFilePath(e){let t=this.config[`~hooks`]?.symbols?.getFilePath,n=t?.(e);if(n!==void 0)return n;let r=this.context.config.parser.hooks.symbols?.getFilePath,i=r?.(e);return i===void 0?ir(e):i}getSymbolValue(e){return this.gen.symbols.getValue(this.symbolToId(e))}hasSymbolValue(e){return this.gen.symbols.hasValue(this.symbolToId(e))}hooks={operation:{isMutation:e=>this.isOperationKind(e,`mutation`),isQuery:e=>this.isOperationKind(e,`query`)},symbol:{getFilePath:e=>this.getSymbolFilePath(e)}};isOperationKind(e,t){let n=t===`query`?`isQuery`:`isMutation`,r=this.config[`~hooks`]?.operations?.[n],i=r?.(e);if(i!==void 0)return i;let a=this.config[`~hooks`]?.operations?.getKind,o=a?.(e);if(o!==void 0)return o.includes(t);let s=this.context.config.parser.hooks.operations?.[n],c=s?.(e);if(c!==void 0)return c;let l=this.context.config.parser.hooks.operations?.getKind,u=l?.(e);return u===void 0?(ar(e)??[]).includes(t):u.includes(t)}isSymbolRegistered(e){return this.gen.symbols.isRegistered(e)}referenceSymbol(e){return this.gen.symbols.reference(e)}registerSymbol(e){return this.gen.symbols.register({...e,exportFrom:e.exportFrom??(!e.external&&this.context.config.output.indexFile&&this.config.exportFromIndex?[`index`]:void 0),getFilePath:e.getFilePath??this.hooks.symbol.getFilePath,meta:{pluginName:r.isAbsolute(this.name)?`custom`:this.name,...e.meta}})}async run(){await this.handler({plugin:this})}setSymbolValue(e,t){return this.gen.symbols.setValue(this.symbolToId(e),t)}symbolToId(e){return typeof e==`number`?e:e.id}},sr=class{config;gen;graph;ir={};logger;package;plugins={};spec;constructor({config:e,dependencies:t,logger:n,spec:r}){this.config=e,this.gen=new s({defaultFileName:`index`,fileName:t=>{let n=T({config:e.output.fileName,name:t}),{suffix:r}=e.output.fileName;return r?n===`index`||n.endsWith(r)?n:`${n}${r}`:n},renderers:{".ts":new Wn},root:e.output.path}),this.logger=n,this.package=lt(t),this.spec=r}dereference(e){let t=this.resolveRef(e.$ref),n={...e,...t};return delete n.$ref,n}registerPlugin(e){let t=this.config.plugins[e],n=new or({api:t.api,config:t.config,context:this,dependencies:t.dependencies??[],gen:this.gen,handler:t.handler,name:t.name,output:t.output});return this.plugins[n.name]=n,n}registerPlugins(){return this.config.pluginOrder.map(e=>this.registerPlugin(e))}resolveIrRef(e){return rr({$ref:e,spec:this.ir})}resolveRef(e){return rr({$ref:e,spec:this.spec})}};const cr=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`);return ut.lastIndex=0,ut.test(t)?`_${t}`:t},lr=e=>e.replace(/^[^\p{ID_Start}]+/u,``).replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`-`).replace(/[$+]/g,`-`),ur=e=>lr(e.replace(`[]`,`Array`)),dr=[`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`],fr=({context:e,count:t=1,id:n,method:r,path:i,state:a})=>{let o,{output:s}=e.config,c=(s!==void 0&&typeof s==`object`&&`case`in s?s.case:void 0)??`camelCase`;return o=n&&(!e.config.plugins[`@hey-api/sdk`]||e.config.plugins[`@hey-api/sdk`].config.operationId)?w({case:c,value:lr(n)}):w({case:c,value:`${r}-${i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`)}`}),t>1&&(o=`${o}${t}`),a.ids.has(o)?fr({context:e,count:t+1,id:n,method:r,path:i,state:a}):(a.ids.set(o,O({method:r,path:i})),o)},R=(e,t=``)=>`${e}/${t}`,z=e=>{let t=e.indexOf(`/`);return{name:e.slice(t+1),namespace:e.slice(0,t)}},pr=e=>{switch(e){case`parameters`:return`parameter`;case`requestBodies`:return`body`;case`responses`:return`response`;case`definitions`:case`schemas`:return`schema`;default:return`unknown`}},mr=(e,t)=>{let n=[],r=[];if(t)for(let i of t)i.startsWith(`/`)&&i.endsWith(`/`)?r.push(new RegExp(i.slice(1,i.length-1))):n.push(R(e,i));return{regexps:r,set:new Set(n)}},hr=({excludeOperations:e,excludeSchemas:t,includeOperations:n,includeSchemas:r,spec:i})=>{if((e.regexps.length||n.regexps.length)&&i.paths)for(let t of Object.entries(i.paths)){let r=t[0],i=t[1];for(let t of dr){if(!i[t])continue;let a=O({method:t,path:r});e.regexps.some(e=>e.test(a))&&e.set.add(R(`operation`,a)),n.regexps.some(e=>e.test(a))&&n.set.add(R(`operation`,a))}}if(i.definitions&&(t.regexps.length||r.regexps.length))for(let e of Object.keys(i.definitions))t.regexps.some(t=>t.test(e))&&t.set.add(R(`schema`,e)),r.regexps.some(t=>t.test(e))&&r.set.add(R(`schema`,e))},gr=({excludeOperations:e,excludeParameters:t,excludeRequestBodies:n,excludeResponses:r,excludeSchemas:i,includeOperations:a,includeParameters:o,includeRequestBodies:s,includeResponses:c,includeSchemas:l,spec:u})=>{if((e.regexps.length||a.regexps.length)&&u.paths)for(let t of Object.entries(u.paths)){let n=t[0],r=t[1];for(let t of dr){if(!r[t])continue;let i=O({method:t,path:n});e.regexps.some(e=>e.test(i))&&e.set.add(R(`operation`,i)),a.regexps.some(e=>e.test(i))&&a.set.add(R(`operation`,i))}}if(u.components){if((t.regexps.length||o.regexps.length)&&u.components.parameters)for(let e of Object.keys(u.components.parameters))t.regexps.some(t=>t.test(e))&&t.set.add(R(`parameter`,e)),o.regexps.some(t=>t.test(e))&&o.set.add(R(`parameter`,e));if((n.regexps.length||s.regexps.length)&&u.components.requestBodies)for(let e of Object.keys(u.components.requestBodies))n.regexps.some(t=>t.test(e))&&n.set.add(R(`body`,e)),s.regexps.some(t=>t.test(e))&&s.set.add(R(`body`,e));if((r.regexps.length||c.regexps.length)&&u.components.responses)for(let e of Object.keys(u.components.responses))r.regexps.some(t=>t.test(e))&&r.set.add(R(`response`,e)),c.regexps.some(t=>t.test(e))&&c.set.add(R(`response`,e));if((i.regexps.length||l.regexps.length)&&u.components.schemas)for(let e of Object.keys(u.components.schemas))i.regexps.some(t=>t.test(e))&&i.set.add(R(`schema`,e)),l.regexps.some(t=>t.test(e))&&l.set.add(R(`schema`,e))}},_r=({spec:e,...t})=>{`swagger`in e?hr({...t,spec:e}):gr({...t,spec:e})},vr=(e,t,n)=>{let r=n.timeEvent(`create-filters`),i=mr(`operation`,e?.operations?.exclude),a=mr(`operation`,e?.operations?.include),o=mr(`parameter`,e?.parameters?.exclude),s=mr(`parameter`,e?.parameters?.include),c=mr(`body`,e?.requestBodies?.exclude),l=mr(`body`,e?.requestBodies?.include),u=mr(`response`,e?.responses?.exclude),d=mr(`response`,e?.responses?.include),f=mr(`schema`,e?.schemas?.exclude),p=mr(`schema`,e?.schemas?.include);_r({excludeOperations:i,excludeParameters:o,excludeRequestBodies:c,excludeResponses:u,excludeSchemas:f,includeOperations:a,includeParameters:s,includeRequestBodies:l,includeResponses:d,includeSchemas:p,spec:t});let m={deprecated:e?.deprecated??!0,operations:{exclude:i.set,include:a.set},orphans:e?.orphans??!1,parameters:{exclude:o.set,include:s.set},preserveOrder:e?.preserveOrder??!1,requestBodies:{exclude:c.set,include:l.set},responses:{exclude:u.set,include:d.set},schemas:{exclude:f.set,include:p.set},tags:{exclude:new Set(e?.tags?.exclude),include:new Set(e?.tags?.include)}};return r.timeEnd(),m},yr=e=>e?e.orphans===!1||e.deprecated===!1?!0:!!(e.operations?.exclude?.length||e.operations?.include?.length||e.parameters?.exclude?.length||e.parameters?.include?.length||e.requestBodies?.exclude?.length||e.requestBodies?.include?.length||e.responses?.exclude?.length||e.responses?.include?.length||e.schemas?.exclude?.length||e.schemas?.include?.length||e.tags?.exclude?.length||e.tags?.include?.length):!1,br=({filters:e,parameters:t,requestBodies:n,resourceMetadata:r,responses:i,schemas:a})=>{let o=new Set,s=[...e.operations.include.size?e.operations.include:new Set(r.operations.keys())];for(;s.length;){let c=s.pop();if(e.operations.exclude.has(c)||o.has(c))continue;let l=r.operations.get(c);l&&(!e.deprecated&&l.deprecated||e.tags.exclude.size&&l.tags.size&&[...e.tags.exclude].some(e=>l.tags.has(e))||e.tags.include.size&&!new Set([...e.tags.include].filter(e=>l.tags.has(e))).size||[...l.dependencies].some(e=>{let{namespace:r}=z(e);switch(r){case`body`:return!n.has(e);case`parameter`:return!t.has(e);case`response`:return!i.has(e);case`schema`:return!a.has(e);default:return!1}})||o.add(c))}return{operations:o}},xr=({filters:e,resourceMetadata:t,schemas:n})=>{let r=new Set,i=[...e.parameters.include.size?e.parameters.include:new Set(t.parameters.keys())];for(;i.length;){let a=i.pop();if(e.parameters.exclude.has(a)||r.has(a))continue;let o=t.parameters.get(a);if(o&&!(!e.deprecated&&o.deprecated)&&(r.add(a),o.dependencies.size))for(let t of o.dependencies){let{namespace:o}=z(t);switch(o){case`body`:e.requestBodies.exclude.has(t)?r.delete(a):r.has(t)||i.push(t);break;case`schema`:e.schemas.exclude.has(t)?r.delete(a):n.has(t)||n.add(t);break}}}return{parameters:r}},Sr=({filters:e,resourceMetadata:t,schemas:n})=>{let r=new Set,i=[...e.requestBodies.include.size?e.requestBodies.include:new Set(t.requestBodies.keys())];for(;i.length;){let a=i.pop();if(e.requestBodies.exclude.has(a)||r.has(a))continue;let o=t.requestBodies.get(a);if(o&&!(!e.deprecated&&o.deprecated)&&(r.add(a),o.dependencies.size))for(let t of o.dependencies){let{namespace:o}=z(t);switch(o){case`body`:e.requestBodies.exclude.has(t)?r.delete(a):r.has(t)||i.push(t);break;case`schema`:e.schemas.exclude.has(t)?r.delete(a):n.has(t)||n.add(t);break}}}return{requestBodies:r}},Cr=({filters:e,resourceMetadata:t,schemas:n})=>{let r=new Set,i=[...e.responses.include.size?e.responses.include:new Set(t.responses.keys())];for(;i.length;){let a=i.pop();if(e.responses.exclude.has(a)||r.has(a))continue;let o=t.responses.get(a);if(o&&!(!e.deprecated&&o.deprecated)&&(r.add(a),o.dependencies.size))for(let t of o.dependencies){let{namespace:o}=z(t);switch(o){case`body`:e.requestBodies.exclude.has(t)?r.delete(a):r.has(t)||i.push(t);break;case`schema`:e.schemas.exclude.has(t)?r.delete(a):n.has(t)||n.add(t);break}}}return{responses:r}},wr=({filters:e,resourceMetadata:t})=>{let n=new Set,r=[...e.schemas.include.size?e.schemas.include:new Set(t.schemas.keys())];for(;r.length;){let i=r.pop();if(e.schemas.exclude.has(i)||n.has(i))continue;let a=t.schemas.get(i);if(a&&!(!e.deprecated&&a.deprecated)&&(n.add(i),a.dependencies.size))for(let t of a.dependencies){let{namespace:i}=z(t);switch(i){case`schema`:!n.has(t)&&!e.schemas.exclude.has(t)&&r.push(t);break}}}return{schemas:n}},Tr=({filters:e,parameters:t,resourceMetadata:n})=>{if(e.parameters.exclude.size)for(let r of t){let i=n.parameters.get(r);if(i?.dependencies.size){for(let n of e.parameters.exclude)if(i.dependencies.has(n)){t.delete(r);break}}}},Er=({filters:e,requestBodies:t,resourceMetadata:n})=>{if(e.requestBodies.exclude.size)for(let r of t){let i=n.requestBodies.get(r);if(i?.dependencies.size){for(let n of e.requestBodies.exclude)if(i.dependencies.has(n)){t.delete(r);break}}}},Dr=({filters:e,resourceMetadata:t,responses:n})=>{if(e.responses.exclude.size)for(let r of n){let i=t.responses.get(r);if(i?.dependencies.size){for(let t of e.responses.exclude)if(i.dependencies.has(t)){n.delete(r);break}}}},Or=({filters:e,resourceMetadata:t,schemas:n})=>{if(e.schemas.exclude.size)for(let r of n){let i=t.schemas.get(r);if(i?.dependencies.size){for(let t of e.schemas.exclude)if(i.dependencies.has(t)){n.delete(r);break}}}},kr=({operationDependencies:e,parameters:t,requestBodies:n,responses:r,schemas:i})=>{for(let t of i)e.has(t)||i.delete(t);for(let n of t)e.has(n)||t.delete(n);for(let t of n)e.has(t)||n.delete(t);for(let t of r)e.has(t)||r.delete(t)},Ar=({operations:e,resourceMetadata:t})=>{let n=new Set,r=[...new Set([...e].flatMap(e=>[...t.operations.get(e)?.dependencies??[]]))];for(;r.length;){let e=r.pop();if(n.has(e))continue;n.add(e);let{namespace:i}=z(e),a;if(i===`body`?a=t.requestBodies.get(e)?.dependencies:i===`operation`?a=t.operations.get(e)?.dependencies:i===`parameter`?a=t.parameters.get(e)?.dependencies:i===`response`?a=t.responses.get(e)?.dependencies:i===`schema`&&(a=t.schemas.get(e)?.dependencies),a?.size)for(let e of a)n.has(e)||r.push(e)}return{operationDependencies:n}},jr=({filters:e,logger:t,resourceMetadata:n})=>{let r=t.timeEvent(`create-filtered-dependencies`),{schemas:i}=wr({filters:e,resourceMetadata:n}),{parameters:a}=xr({filters:e,resourceMetadata:n,schemas:i}),{requestBodies:o}=Sr({filters:e,resourceMetadata:n,schemas:i}),{responses:s}=Cr({filters:e,resourceMetadata:n,schemas:i});Or({filters:e,resourceMetadata:n,schemas:i}),Tr({filters:e,parameters:a,resourceMetadata:n}),Er({filters:e,requestBodies:o,resourceMetadata:n}),Dr({filters:e,resourceMetadata:n,responses:s});let{operations:c}=br({filters:e,parameters:a,requestBodies:o,resourceMetadata:n,responses:s,schemas:i});if(!e.orphans&&c.size){let{operationDependencies:e}=Ar({operations:c,resourceMetadata:n});kr({operationDependencies:e,parameters:a,requestBodies:o,responses:s,schemas:i})}return r.timeEnd(),{operations:c,parameters:a,requestBodies:o,responses:s,schemas:i}},Mr=(e,t)=>{let n=t.timeEvent(`build-resource-metadata`),r={operations:new Map,parameters:new Map,requestBodies:new Map,responses:new Map,schemas:new Map},i=t=>{let n=new Set,r=e.transitiveDependencies.get(t);if(r?.size)for(let e of r){let t=L(e),r=t[t.length-2],i=t[t.length-1];if(r&&i){let e=pr(r);e===`unknown`&&console.warn(`unsupported type: ${r}`),n.add(R(e,i))}}return n};for(let[t,n]of e.nodes){let e=L(t);if(e[0]===`components`){if(e.length===3){if(e[1]===`schemas`){let a=e[e.length-1];r.schemas.set(R(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`parameters`){let a=e[e.length-1];r.parameters.set(R(`parameter`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`requestBodies`){let a=e[e.length-1];r.requestBodies.set(R(`body`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`responses`){let a=e[e.length-1];r.responses.set(R(`response`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}}continue}if(e[0]===`paths`){if(e.length===3&&dr.includes(e[2])){let a=e[e.length-1],o=O({method:a,path:e.slice(1,-1).join(`/`)});r.operations.set(R(`operation`,o),{dependencies:i(t),deprecated:n.deprecated??!1,tags:n.tags??new Set})}continue}if(e[0]===`definitions`){if(e.length===2){let a=e[e.length-1];r.schemas.set(R(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}continue}}return n.timeEnd(),{resourceMetadata:r}},Nr=e=>JSON.parse(JSON.stringify(e)),Pr=[[`additionalProperties`,`single`],[`allOf`,`array`],[`anyOf`,`array`],[`contains`,`single`],[`dependentSchemas`,`objectMap`],[`else`,`single`],[`if`,`single`],[`items`,`singleOrArray`],[`oneOf`,`array`],[`patternProperties`,`objectMap`],[`properties`,`objectMap`],[`propertyNames`,`single`],[`then`,`single`]],Fr=e=>{if(Ir(e))return e.components.schemas;if(Lr(e))return e.definitions},Ir=e=>typeof e==`object`&&!!e&&`components`in e&&typeof e.components==`object`&&e.components!==null&&`schemas`in e.components&&typeof e.components.schemas==`object`&&e.components.schemas!==null,Lr=e=>typeof e==`object`&&!!e&&`definitions`in e&&typeof e.definitions==`object`&&e.definitions!==null,Rr=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,zr=({base:e,components:t,extraComponents:n})=>{let r=2,i=e;for(;Rr(t,i)||n&&Rr(n,i);)i=`${e}${r}`,r+=1;return i},Br=e=>e.length===3&&e[0]===`components`&&e[1]===`schemas`||e.length===2&&e[0]===`definitions`,Vr=e=>{if(e&&typeof e==`object`){if(`swagger`in e)return`#/definitions/`;if(`openapi`in e)return`#/components/schemas/`}return``},Hr=e=>{if(!e||typeof e!=`object`||!(`enum`in e)||!(e.enum instanceof Array))return;let t=(`type`in e?e.type:void 0)||``,n=[...e.enum].sort();return JSON.stringify({type:t,values:n})},Ur=({key:e,node:t,parent:n,path:r,visitor:i})=>{if(!t||typeof t!=`object`||t instanceof Array)return;let a=t;(`type`in a||`enum`in a||Pr.some(([e])=>e in a))&&i({key:e,node:t,parent:n,path:r});for(let[e,n]of Object.entries(a))typeof n==`object`&&n&&(n instanceof Array?n.forEach((t,a)=>Ur({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):Ur({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Wr=({spec:e})=>{let t=Fr(e);if(!t)return;let n=Vr(e),r={};for(let[e,i]of Object.entries(t))Hr(i)&&(r[`${n}${e}`]=i);let i=e=>{if(e instanceof Array)e.forEach(i);else if(e&&typeof e==`object`)for(let[t,n]of Object.entries(e))t===`$ref`&&typeof n==`string`&&n in r?(Object.assign(e,Nr(r[n])),delete e.$ref):i(n)};i(e);for(let e of Object.keys(r)){let n=L(e),r=n[n.length-1];r&&delete t[r]}},Gr=({config:e,spec:t})=>{let n=Fr(t);if(!n)return;let r={};for(let[e,t]of Object.entries(n)){let n=Hr(t);n&&(r[n]=e)}let i=[];Ur({key:null,node:t,parent:null,path:[],visitor:e=>{if(!Br(e.path)){let t=Hr(e.node);t&&i.push({...e,signature:t})}}});let a={},o={};for(let{key:t,node:s,signature:c}of i)if(!(c in a)){if(c in r){a[c]=r[c];continue}a[c]=zr({base:T({config:e,name:typeof s==`object`&&s&&`title`in s&&typeof s.title==`string`?s.title:String(t)}),components:n,extraComponents:Object.values(a)}),o[c]=s}for(let[e,t]of Object.entries(a)){let r=o[e];t&&!(t in n)&&r&&typeof r==`object`&&(n[t]=r)}let s=Vr(t);for(let{key:e,parent:t,signature:n}of i){let r=a[n];r&&e!=null&&t&&typeof t==`object`&&(t[e]={$ref:`${s}${r}`})}},Kr=({config:e,spec:t})=>{if(e.mode===`inline`){Wr({spec:t});return}if(e.mode===`root`){Gr({config:e,spec:t});return}},qr=({key:e,node:t,parent:n,path:r,visitor:i})=>{if(!t||typeof t!=`object`||t instanceof Array)return;let a=t;(`type`in a||Pr.some(([e])=>e in a))&&i({key:e,node:t,parent:n,path:r});for(let[e,n]of Object.entries(a))typeof n==`object`&&n&&(n instanceof Array?n.forEach((t,a)=>qr({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):qr({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Jr=({spec:e})=>{qr({key:null,node:e,parent:null,path:[],visitor:e=>{if(e.node&&typeof e.node==`object`&&`type`in e.node&&e.node.type===`object`&&`properties`in e.node&&e.node.properties&&typeof e.node.properties==`object`&&!(`required`in e.node)){let t=Object.keys(e.node.properties);t.length>0&&(e.node.required=t)}}})},Yr=(e,t)=>{if(e===t)return!0;if(e===null||t===null)return e===t;let n=typeof e;if(n!==typeof t||n!==`object`)return!1;if(Array.isArray(e)||Array.isArray(t)){if(!Array.isArray(e)||!Array.isArray(t)||e.length!==t.length)return!1;for(let n=0;n<e.length;n++)if(!Yr(e[n],t[n]))return!1;return!0}let r=e,i=t,a=Object.keys(r).sort(),o=Object.keys(i).sort();if(a.length!==o.length)return!1;for(let e=0;e<a.length;e++)if(a[e]!==o[e])return!1;for(let e of a)if(!Yr(r[e],i[e]))return!1;return!0};var Xr=Yr;const Zr=e=>{for(let[,t]of e)if(!t.scopes&&t.parentPointer){let n=e.get(t.parentPointer);n?.scopes&&(t.scopes=new Set(n.scopes))}},Qr=({cache:e,graph:t,pointer:n,visited:r})=>{let i=e.transitiveDependencies.get(n);if(i)return{subtreeDependencies:e.subtreeDependencies.get(n),transitiveDependencies:i};if(r.has(n)||(r.add(n),!t.nodes.get(n)))return{subtreeDependencies:new Set,transitiveDependencies:new Set};let a=new Set,o=new Set,s=t.nodeDependencies.get(n);if(s)for(let n of s){a.add(n),o.add(n);let i=Qr({cache:e,graph:t,pointer:n,visited:r});for(let e of i.transitiveDependencies)a.add(e)}let c=e.parentToChildren.get(n)??[];for(let n of c){let i={subtreeDependencies:e.subtreeDependencies.get(n),transitiveDependencies:e.transitiveDependencies.get(n)};(!i.subtreeDependencies||!i.transitiveDependencies)&&(i=Qr({cache:e,graph:t,pointer:n,visited:r}),e.transitiveDependencies.set(n,i.transitiveDependencies),e.subtreeDependencies.set(n,i.subtreeDependencies));for(let e of i.transitiveDependencies)a.add(e);for(let e of i.subtreeDependencies)o.add(e)}return e.transitiveDependencies.set(n,a),e.subtreeDependencies.set(n,o),{subtreeDependencies:o,transitiveDependencies:a}},$r=e=>{let t=new Set(Array.from(e.nodes.entries()).filter(([,e])=>e.scopes&&e.scopes.size>0).map(([e])=>e)),n=(n,r,i)=>{r.parentPointer&&t.add(r.parentPointer);let a=e.reverseNodeDependencies.get(n);if(a)for(let e of a)t.add(e);if(i){let e=i.match(/(.*)\/(allOf|anyOf|oneOf)\/\d+$/);if(e){let n=e[1];n&&t.add(n)}}},r=(t,r,i)=>{if(!r?.scopes)return;let a=e.nodes.get(i);a?.scopes&&ei(a,r)&&n(t,r,i)};for(;t.size>0;){let i=t.values().next().value;t.delete(i);let a=e.nodes.get(i);if(!a)continue;a.scopes||=new Set;let o=a.node;for(let[e,t]of Pr){if(!o||typeof o!=`object`||!(e in o))continue;let n=o[e];if(t===`array`&&n instanceof Array)for(let t=0;t<n.length;t++)r(i,a,`${i}/${e}/${t}`);else if(t===`objectMap`&&typeof n==`object`&&n&&!(n instanceof Array))for(let t of Object.keys(n))r(i,a,`${i}/${e}/${t}`);else if(t===`single`&&typeof n==`object`&&n)r(i,a,`${i}/${e}`);else if(t===`singleOrArray`)if(n instanceof Array)for(let t=0;t<n.length;t++)r(i,a,`${i}/${e}/${t}`);else typeof n==`object`&&n&&r(i,a,`${i}/${e}`)}let s=e.nodeDependencies.get(i);if(s)for(let t of s){let r=e.nodes.get(t);r?.scopes&&ei(r,a)&&n(i,a)}if(a.parentPointer){let t=e.nodes.get(a.parentPointer);t&&ei(a,t)&&n(a.parentPointer,t)}}},ei=(e,t)=>{if(!e.scopes)return!1;t.scopes||=new Set;let n=!1;for(let r of e.scopes)t.scopes.has(r)||(t.scopes.add(r),n=!0);return n},ti=e=>{for(let[t,n]of e){let{node:e}=n;typeof e!=`object`||!e||e instanceof Array||(`readOnly`in e&&e.readOnly===!0?n.scopes=new Set([`read`]):`writeOnly`in e&&e.writeOnly===!0?n.scopes=new Set([`write`]):t.match(/\/properties\/[^/]+$/)&&(n.scopes=new Set([`normal`])))}},ni=(e,t)=>{let n=t.timeEvent(`build-graph`),r={nodeDependencies:new Map,nodes:new Map,reverseNodeDependencies:new Map,subtreeDependencies:new Map,transitiveDependencies:new Map},i=({key:e,node:t,parentPointer:n,path:a})=>{if(typeof t!=`object`||!t)return;let o=nr(a),s,c;if(typeof t==`object`&&t){if(`deprecated`in t&&typeof t.deprecated==`boolean`&&(s=!!t.deprecated),`$ref`in t&&typeof t.$ref==`string`){let e=tr(t.$ref);r.nodeDependencies.has(o)||r.nodeDependencies.set(o,new Set),r.nodeDependencies.get(o).add(e)}`tags`in t&&t.tags instanceof Array&&(c=new Set(t.tags.filter(e=>typeof e==`string`)))}if(r.nodes.set(o,{deprecated:s,key:e,node:t,parentPointer:n,tags:c}),t instanceof Array)t.forEach((e,t)=>i({key:t,node:e,parentPointer:o,path:[...a,t]}));else for(let[e,n]of Object.entries(t))i({key:e,node:n,parentPointer:o,path:[...a,e]})};i({key:null,node:e,parentPointer:null,path:[]});let a={parentToChildren:new Map,subtreeDependencies:new Map,transitiveDependencies:new Map};for(let[e,t]of r.nodes){let n=t.parentPointer;n&&(a.parentToChildren.has(n)||a.parentToChildren.set(n,[]),a.parentToChildren.get(n).push(e))}for(let[e,t]of r.nodeDependencies)for(let n of t)r.reverseNodeDependencies.has(n)||r.reverseNodeDependencies.set(n,new Set),r.reverseNodeDependencies.get(n).add(e);ti(r.nodes),$r(r),Zr(r.nodes);for(let e of r.nodes.keys()){let t=Qr({cache:a,graph:r,pointer:e,visited:new Set});r.transitiveDependencies.set(e,t.transitiveDependencies),r.subtreeDependencies.set(e,t.subtreeDependencies)}return n.timeEnd(),{graph:r}},ri=new Set([`additionalProperties`,`allOf`,`anyOf`,`items`,`not`,`oneOf`,`patternProperties`,`properties`,`schema`]),ii=e=>{if(e.length===3&&e[0]===`components`){let t=e[1];if(t===`parameters`||t===`requestBodies`)return`write`;if(t===`responses`||t===`headers`)return`read`}if(e.length===2){let t=e[0];if(t===`parameters`)return`write`;if(t===`responses`)return`read`}},ai=(e,t)=>{let n=t.timeEvent(`capture-original-schemas`),r={};if(Ir(e))for(let[t,n]of Object.entries(e.components.schemas))r[`#/components/schemas/${t}`]=n;else if(Lr(e))for(let[t,n]of Object.entries(e.definitions))r[`#/definitions/${t}`]=n;return n.timeEnd(),r},oi=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`insert-split-schemas-into-spec`);Ir(t)?Object.assign(t.components.schemas,n.schemas):Lr(t)&&Object.assign(t.definitions,n.schemas),r.timeEnd()},si=(e,t,n)=>{if(t&&typeof t==`object`){if(`$ref`in t&&typeof t.$ref==`string`){let r=e.nodes.get(t.$ref);if(r?.scopes&&(n===`writeOnly`&&r.scopes.size===1&&r.scopes.has(`write`)||n===`readOnly`&&r.scopes.size===1&&r.scopes.has(`read`))&&(delete t.$ref,!Pr.some(([e])=>e in t)))return!0}for(let[r,i]of Pr){if(!(r in t))continue;let a=t[r];if(i===`array`&&a instanceof Array){for(let t=a.length-1;t>=0;t--){let r=a[t];(r&&typeof r==`object`&&r[n]===!0||si(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else if(i===`objectMap`&&typeof a==`object`&&a&&!(a instanceof Array)){let i=a,o=new Set;for(let t of Object.keys(i)){let a=i[t];(a&&typeof a==`object`&&a[n]===!0||si(e,a,n))&&(delete i[t],r===`properties`&&o.add(t))}if(o.size>0&&r===`properties`&&`required`in t&&Array.isArray(t.required)){let e=t.required.filter(e=>!o.has(e));e.length?t.required=e:delete t.required}Object.keys(i).length||delete t[r]}else if(i===`single`&&typeof a==`object`&&a)(a[n]===!0||si(e,a,n))&&delete t[r];else if(i===`singleOrArray`)if(a instanceof Array){for(let t=a.length-1;t>=0;t--){let r=a[t];(r&&typeof r==`object`&&r[n]===!0||si(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else typeof a==`object`&&a&&(a[n]===!0||si(e,a,n))&&delete t[r]}if(t.type===`object`&&!Pr.some(([e])=>e in t))return!0}return!1},ci=({logger:e,originalSchemas:t,spec:n,split:r})=>{let i=e.timeEvent(`remove-original-split-schemas`),a=Fr(n);for(let e of Object.keys(r.mapping)){let n=L(e),r=n[n.length-1];typeof r==`string`&&a&&Object.prototype.hasOwnProperty.call(a,r)&&a[r]===t[e]&&delete a[r]}i.timeEnd()},li=({config:e,graph:t,logger:n,spec:r})=>{let i=n.timeEvent(`split-schemas`),a=new Set,o={mapping:{},reverseMapping:{},schemas:{}},s=Vr(r),c=s.split(`/`).length-1,l=e=>{if(e.startsWith(s)){let t=L(e);if(t.length===c)return t[c-1]||``}return``};for(let e of t.nodes.keys()){let t=l(e);t&&a.add(t)}for(let[n,r]of t.nodes){let i=l(n);if(!i||!(r.scopes?.has(`read`)||r.scopes?.has(`write`))||!r.scopes?.has(`normal`))continue;let c=Nr(r.node);si(t,c,`writeOnly`);let u=T({config:e.responses,name:i}),d=u===i?u:zr({base:u,components:a});a.add(d),o.schemas[d]=c;let f=`${s}${d}`,p=Nr(r.node);if(si(t,p,`readOnly`),Xr(c,p)&&Xr(c,r.node))continue;let m=T({config:e.requests,name:i}),h=m===i&&m!==d?m:zr({base:m,components:a});a.add(h),o.schemas[h]=p;let g=`${s}${h}`;o.mapping[n]={read:f,write:g},o.reverseMapping[f]=n,o.reverseMapping[g]=n}return i.timeEnd(),o},ui=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`update-refs-in-spec`),i=Vr(t),a=({context:e,currentPointer:t,inSchema:r,node:o,path:s})=>{if(o instanceof Array)o.forEach((n,i)=>a({context:e,currentPointer:t,inSchema:r,node:n,path:[...s,i]}));else if(o&&typeof o==`object`){let c=t,l=e;if(Br(s)){c=`${i}${s[s.length-1]}`;let e=n.reverseMapping[c];if(e){let t=n.mapping[e];t?.read===c?l=`read`:t?.write===c&&(l=`write`)}}let u=ii(s);if(u!==void 0){for(let e in o)Object.prototype.hasOwnProperty.call(o,e)&&a({context:u,currentPointer:c,inSchema:!1,node:o[e],path:[...s,e]});return}for(let e in o){if(!Object.prototype.hasOwnProperty.call(o,e))continue;let t=o[e];if(!r){if(e===`requestBody`){a({context:`write`,currentPointer:c,inSchema:!1,node:t,path:[...s,e]});continue}if(e===`responses`){a({context:`read`,currentPointer:c,inSchema:!1,node:t,path:[...s,e]});continue}if(e===`parameters`&&Array.isArray(t)){t.forEach((t,n)=>{t&&typeof t==`object`&&`schema`in t&&a({context:`write`,currentPointer:c,inSchema:!0,node:t.schema,path:[...s,e,n,`schema`]}),t&&typeof t==`object`&&`content`in t&&a({context:`write`,currentPointer:c,inSchema:!1,node:t.content,path:[...s,e,n,`content`]})});continue}if(e===`headers`&&typeof t==`object`&&t){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&a({context:`read`,currentPointer:c,inSchema:!1,node:t[n],path:[...s,e,n]});continue}}if(ri.has(e))a({context:l,currentPointer:c,inSchema:!0,node:t,path:[...s,e]});else if(e===`$ref`&&typeof t==`string`){let r=n.mapping[t];r&&(r.read&&(!l||l===`read`)?o[e]=r.read:r.write&&(!l||l===`write`)&&(o[e]=r.write))}else a({context:l,currentPointer:c,inSchema:r,node:t,path:[...s,e]})}}};a({context:null,currentPointer:null,inSchema:!1,node:t,path:[]}),r.timeEnd()},di=({config:e,logger:t,spec:n})=>{let{graph:r}=ni(n,t),i=ai(n,t),a=li({config:e,graph:r,logger:t,spec:n});oi({logger:t,spec:n,split:a}),ui({logger:t,spec:n,split:a}),ci({logger:t,originalSchemas:i,spec:n,split:a})},fi=({context:e})=>{let{logger:t}=e,n=t.timeEvent(`transform-openapi-spec`);e.config.parser.transforms.enums.enabled&&Kr({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&Jr({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&di({config:e.config.parser.transforms.readWrite,logger:t,spec:e.spec}),n.timeEnd()},B=({source:e,target:t})=>{let n={...t};if(e&&(e.cookie&&(n.cookie?n.cookie={...n.cookie,...e.cookie}:n.cookie=e.cookie),e.header&&(n.header?n.header={...n.header,...e.header}:n.header=e.header),e.path&&(n.path?n.path={...n.path,...e.path}:n.path=e.path),e.query&&(n.query?n.query={...n.query,...e.query}:n.query=e.query)),Object.keys(n).length)return n},pi=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),mi=e=>e.map((e,t)=>typeof e==`number`?`[${e}]`:t===0?e:pi(e)?`.${e}`:`['${e.replace(/"/g,`\\'`)}']`).join(``),hi=e=>{let n=mi(e.path),r=e.severity===`error`?t.bold.red:t.bold.yellow,i=e.message.replace(/`([^`]+)`/g,(e,n)=>t.yellow(`\`${n}\``));return`${r(`[${e.severity.toUpperCase()}]`)} ${t.cyan(n)}: ${i}`},gi=({context:e,issue:t})=>e.config.logs.level===`silent`?!1:t.severity===`error`?e.config.logs.level!==`warn`:!0,_i=({context:e,result:t})=>{for(let n of t.issues)gi({context:e,issue:n})&&console.log(hi(n));t.valid||process.exit(1)},vi=({logger:e,operations:t,preserveOrder:n,schemas:r,spec:i})=>{let a=e.timeEvent(`filter-spec`);if(i.definitions){let e={};if(n)for(let[t,n]of Object.entries(i.definitions))r.has(R(`schema`,t))&&(e[t]=n);else for(let t of r){let{name:n}=z(t),r=i.definitions[n];r&&(e[n]=r)}i.definitions=e}if(i.paths)for(let e of Object.entries(i.paths)){let n=e[0],r=e[1];for(let e of dr){if(!r[e])continue;let i=R(`operation`,O({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete i.paths[n]}a.timeEnd()},yi=/^(application\/(pdf|rtf|msword|vnd\.(ms-|openxmlformats-officedocument\.)|zip|x-(7z|tar|rar|zip|iso)|octet-stream|gzip|x-msdownload|json\+download|xml|x-yaml|x-7z-compressed|x-tar)|text\/(yaml|css|javascript)|audio\/(mpeg|wav)|video\/(mp4|x-matroska)|image\/(vnd\.adobe\.photoshop|svg\+xml))(; ?charset=[^;]+)?$/i,bi=/^application\/(.*\+)?json(;.*)?$/i,xi=/^multipart\/form-data(;.*)?$/i,Si=/^text\/[a-z0-9.+-]+(;.*)?$/i,Ci=/^application\/x-www-form-urlencoded(;.*)?$/i,wi=/^application\/octet-stream(;.*)?$/i,Ti=({mediaType:e})=>(yi.lastIndex=0,yi.test(e)),Ei=({mediaType:e})=>{if(bi.lastIndex=0,bi.test(e))return`json`;if(xi.lastIndex=0,xi.test(e))return`form-data`;if(Si.lastIndex=0,Si.test(e))return`text`;if(Ci.lastIndex=0,Ci.test(e))return`url-search-params`;if(wi.lastIndex=0,wi.test(e))return`octet-stream`},Di=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Ti({mediaType:t})?{...n,format:`binary`}:n:Ti({mediaType:t})?{format:`binary`,type:`string`}:void 0},Oi=({mimeTypes:e,response:t})=>{let n=[];for(let r of e??[])n.push({mediaType:r,schema:t.schema,type:Ei({mediaType:r})});return n};function ki(e){let t=`^(${e.keywords.join(`|`)})$`;return new RegExp(t)}const Ai=(e,t,n)=>{let r=[];for(let n in t)t[n]===e&&r.push(n);return!r.length&&(!n||n())?[I(e)]:r},ji=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},Mi=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},Ni=({irSchema:e,schema:t})=>{t.default!==void 0&&(e.default=t.default),t.exclusiveMaximum?t.maximum!==void 0&&(e.exclusiveMaximum=t.maximum):t.maximum!==void 0&&(e.maximum=t.maximum),t.exclusiveMinimum?t.minimum!==void 0&&(e.exclusiveMinimum=t.minimum):t.minimum!==void 0&&(e.minimum=t.minimum),t.format&&(e.format=t.format),t.maxItems!==void 0&&(e.maxItems=t.maxItems),t.maxLength!==void 0&&(e.maxLength=t.maxLength),t.minItems!==void 0&&(e.minItems=t.minItems),t.minLength!==void 0&&(e.minLength=t.minLength),t.pattern&&(e.pattern=t.pattern),t.readOnly&&(e.accessScope=`read`)},Pi=({context:e,irSchema:t={},schema:n,state:r})=>{n.maxItems&&n.maxItems===n.minItems?t.type=`tuple`:t.type=`array`;let i=[];if(n.items){let a=qi({context:e,schema:n.items,state:r});if(!i.length&&n.maxItems&&n.maxItems===n.minItems)i=Array(n.maxItems).fill(a);else if(`$ref`in n.items)i.push(a);else{let e=n.items.allOf;e&&e.length>1&&!n.items[`x-nullable`]?t={...t,...a}:i.push(a)}}return t=D({items:i,schema:t}),t},Fi=({irSchema:e={}})=>(e.type=`boolean`,e),Ii=({irSchema:e={},schema:t})=>(e.type=t.type,e),Li=({context:e,irSchema:t={},schema:n,state:r})=>{t.type=`object`;let i={};for(let t in n.properties){let a=n.properties[t];typeof a==`boolean`||(i[t]=qi({context:e,schema:a,state:r}))}return Object.keys(i).length&&(t.properties=i),n.additionalProperties===void 0?t.properties||(t.additionalProperties={type:`unknown`}):typeof n.additionalProperties==`boolean`?r.inAllOf&&n.additionalProperties===!1&&(!n.properties||!Object.keys(n.properties).length)||(t.additionalProperties={type:n.additionalProperties?`unknown`:`never`}):t.additionalProperties=qi({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},Ri=({irSchema:e={}})=>(e.type=`string`,e),zi=({schema:e})=>{let t={};return Mi({irSchema:t,schema:e}),t},Bi=({context:e,schema:t,state:n})=>{let r=zi({schema:t}),i=[],a=ji({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=qi({context:e,schema:r,state:n});if(n.inAllOf=a,n.inAllOf===void 0&&delete n.inAllOf,t.required&&(o.required?o.required=[...o.required,...t.required]:o.required=t.required),i.push(o),r.$ref){let t=e.resolveRef(r.$ref);if(t.discriminator&&n.$ref){let e=Ai(n.$ref).map(e=>({const:e,type:`string`})),r={properties:{[t.discriminator]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`};t.required?.includes(t.discriminator)&&(r.required=[t.discriminator]),i.push(r)}}}if(a===`object`){let r=Gi({context:e,schema:{...t,type:`object`},state:n});if(r.properties){for(let t of r.required??[])if(!r.properties[t])for(let i of o){let a=i.$ref?e.resolveRef(i.$ref):i;if(ji({schema:a})===`object`){let i=Gi({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=D({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),t[`x-nullable`]){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`},e[0].deprecated&&(r.deprecated=e[0].deprecated),e[0].description&&(r.description=e[0].description)}return r},Vi=({context:e,schema:t,state:n})=>{let r=zi({schema:t});r.type=`enum`;let i=[];for(let[r,a]of t.enum.entries()){let o=typeof a,s;if(o===`string`||o===`number`||o===`boolean`?s=o:o===`object`&&Array.isArray(a)?s=`array`:a===null?t[`x-nullable`]&&(s=`null`):console.warn(`🚨`,`unhandled "${o}" typeof value "${a}" for enum`,t.enum),!s)continue;let c=Gi({context:e,schema:{description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:s===`null`?`string`:s},state:n});c.const=a,s===`null`&&(c.type=s),c.type===`array`&&(c.type=`tuple`),i.push(c)}return r=D({items:i,schema:r}),r},Hi=({context:e,schema:t,state:n})=>{let r={};if(!t.$ref.startsWith(`#/definitions/`)&&!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref;let a=qi({context:e,schema:r,state:n});return n.$ref=i,a}if(r.$ref=decodeURI(t.$ref),r.$ref=r.$ref.replace(/#\/definitions\/([^/]+)/g,`#/components/schemas/$1`),!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref,qi({context:e,schema:r,state:n}),n.$ref=i}return r},Ui=({context:e,irSchema:t,schema:n,state:r})=>{t||=zi({schema:n});let i={};return Ni({irSchema:i,schema:n}),i.default===null&&delete i.default,t=D({items:[Gi({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},Wi=({context:e,schema:t,state:n})=>{let r=zi({schema:t});Ni({irSchema:r,schema:t});let i=ji({schema:t});return i?t[`x-nullable`]?Ui({context:e,irSchema:r,schema:{...t,type:i},state:n}):Gi({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},Gi=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=zi({schema:n}),Ni({irSchema:t,schema:n})),n.type){case`array`:return Pi({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Fi({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Ii({context:e,irSchema:t,schema:n,state:r});case`object`:return Li({context:e,irSchema:t,schema:n,state:r});case`string`:return Ri({context:e,irSchema:t,schema:n,state:r});default:return Ki({context:e,irSchema:t,schema:n})}},Ki=({irSchema:e,schema:t})=>(e||=zi({schema:t}),e.type=`unknown`,Ni({irSchema:e,schema:t}),e),qi=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?Hi({context:e,schema:t,state:n}):t.enum?Vi({context:e,schema:t,state:n}):t.allOf?Bi({context:e,schema:t,state:n}):t.type||t.properties?Wi({context:e,schema:t,state:n}):Ki({context:e,schema:t})),Ji=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[I(e)]=qi({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Yi=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,Xi=({context:e,name:t,schema:n})=>{if(ki(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref??``);return`in`in r&&r.in?Xi({context:e,name:t,schema:`schema`in r?r.schema:{...r,in:void 0}}):Xi({context:e,name:t,schema:r})}if(`in`in n)return n.in?Xi({context:e,name:t,schema:`schema`in n?n.schema:{...n,in:void 0}}):!1;for(let t in n.properties)if(ki(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&Yi(ji({schema:e})))return t}for(let r of n.allOf??[]){let n=Xi({context:e,name:t,schema:r});if(n)return n}return!1},Zi=({irOperation:e,operation:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.description&&(e.description=t.description),t.summary&&(e.summary=t.summary),t.tags?.length&&(e.tags=t.tags)},Qi=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:fr({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Zi({irOperation:a,operation:n}),a},$i=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Qi({context:e,method:t,operation:n,path:r,state:a});n.parameters&&(o.parameters=n.parameters);let s=!1,c={mediaType:``,schema:{properties:{},required:[],type:`object`}},l=[];for(let t of n.requestBody??[]){let r=`$ref`in t?e.resolveRef(t.$ref):t,i=r.in===`body`?r.schema:{...r,format:r.type===`file`?`binary`:r.format,required:void 0,type:r.type===`file`?`string`:r.type},a=Oi({mimeTypes:n.consumes,response:{schema:i}}),o=a.find(e=>e.type===`json`)||a[0];if(o){let t=Xi({context:e,name:``,schema:o.schema&&`$ref`in o.schema?{allOf:[{...o.schema}],description:r.description}:{description:r.description,...o.schema}}),n=qi({context:e,schema:`$ref`in r?{allOf:[{...r,$ref:r.$ref,required:[],type:`string`}],description:r.description}:o.schema&&`$ref`in o.schema?{allOf:[{...o.schema}],description:r.description}:{description:r.description,...o.schema},state:void 0});c.mediaType=o.mediaType,r.in===`body`?c.schema=n:(c.schema.properties[r.name]=n,r.required&&l.push(r.name)),t&&(c.pagination=t),o.type&&(c.type=o.type)}r.required&&(s=!0)}for(let t in c.mediaType&&(l.length&&(c.schema.required=l),o.body=c,s&&(o.body.required=s)),n.responses){o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=Oi({mimeTypes:n.produces?n.produces:[`application/json`],response:i}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:qi({context:e,schema:{description:i.description,...Di({content:s})},state:void 0})}:o.responses[t]={schema:{description:i.description,type:t===`204`?`void`:`unknown`}}}if(n.security){let e=new Map;for(let t of n.security)for(let n in t){let t=i.get(n);if(!t)continue;let r;if(t.type===`apiKey`&&(r=t),t.type===`basic`&&(r={description:t.description,scheme:`basic`,type:`http`}),t.type===`oauth2`)switch(r={description:t.description,flows:{},type:`oauth2`},t.flow){case`accessCode`:r.flows.authorizationCode={authorizationUrl:t.authorizationUrl,scopes:t.scopes,tokenUrl:t.tokenUrl};break;case`application`:r.flows.clientCredentials={scopes:t.scopes,tokenUrl:t.tokenUrl};break;case`implicit`:r.flows.implicit={authorizationUrl:t.authorizationUrl,scopes:t.scopes};break;case`password`:r.flows.password={scopes:t.scopes,tokenUrl:t.tokenUrl};break}r&&e.set(n,r)}e.size&&(o.security=Array.from(e.values()))}return o},ea=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[r]||(e.ir.paths[r]={}),e.ir.paths[r][t]=$i({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},ta=e=>{switch(e){case`multi`:return!0;case`csv`:case`pipes`:case`ssv`:case`tsv`:default:return!1}},na=e=>{switch(e){case`header`:case`path`:return`simple`;case`query`:default:return`form`}},ra=({context:e,operation:t,parameters:n})=>{if(!n||!Object.keys(n).length)return;let r={};for(let i of n){let n=`$ref`in i?e.dereference(i):i;if(n.in===`body`||n.in===`formData`){t.requestBody||=[],t.requestBody.push(n);continue}r[n.in]||(r[n.in]={}),r[n.in][n.name.toLocaleLowerCase()]=ia({$ref:`#/todo/real/path/to/parameter/${n.name}`,context:e,parameter:n})}return r},ia=({$ref:e,context:t,parameter:n})=>{let r=n,i=r&&`$ref`in r?{allOf:[{...r,$ref:r.$ref,required:Array.isArray(r.required)?r.required:[],type:r.type}],description:n.description}:{description:n.description,...r,required:Array.isArray(r.required)?r.required:[],type:r.type},a=Xi({context:t,name:n.name,schema:i}),o=na(n.in),s={allowReserved:!1,explode:ta(n.collectionFormat),location:n.in,name:n.name,schema:qi({context:t,schema:i,state:{$ref:e,circularReferenceTracker:new Set}}),style:o};return n.description&&(s.description=n.description),a&&(s.pagination=a),n.required&&(s.required=n.required),s},aa=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,oa=e=>{let t={host:``,path:``,port:``,protocol:``};aa.lastIndex=0;let n=e.match(aa);if(!n)return t;let r=n[5]||``;if(r===`.`||r===`..`)return t;let i=n[8]||``,a=n[2]||``;return a.length===1?t:{host:r,path:i===`/`?``:i,port:n[7]||``,protocol:a}},sa=({context:e})=>{let t=e.spec.schemes??[],n=e.spec.host??``,r=e.spec.basePath??``;for(let r of e.config.input)if(typeof r.path==`string`){let e=oa(r.path);t.length||e.protocol&&(t=[e.protocol]),n||=`${e.host}${e.port?`:${e.port}`:``}`}t.length||(t=[``]);let i=t.map(e=>`${e?`${e}://`:``}${n}${r}`).filter(Boolean);i.length&&(e.ir.servers=i.map(e=>({url:e})))},ca=(e,t)=>{let n=t.timeEvent(`validate`),r=[],i=new Map;if(e.paths)for(let t of Object.entries(e.paths)){let e=t[0],n=t[1];for(let t of dr){if(t===`trace`)continue;let a=n[t];if(!a)continue;let o=O({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},la=e=>{if(e.config.parser.validate_EXPERIMENTAL&&_i({context:e,result:ca(e.spec,e.logger)}),yr(e.config.parser.filters)){let t=vr(e.config.parser.filters,e.spec,e.logger),{graph:n}=ni(e.spec,e.logger),{resourceMetadata:r}=Mr(n,e.logger);vi({...jr({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}fi({context:e});let t={ids:new Map},n=new Map;for(let t in e.spec.securityDefinitions){let r=e.spec.securityDefinitions[t];n.set(t,r)}if(e.spec.definitions)for(let t in e.spec.definitions){let n=`#/definitions/${t}`,r=e.spec.definitions[t];Ji({$ref:n,context:e,schema:r})}for(let r in sa({context:e}),e.spec.paths){if(r.startsWith(`x-`))continue;let i=e.spec.paths[r],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,o={consumes:e.spec.consumes,produces:e.spec.produces,responses:{},security:e.spec.security},s={context:e,operation:{...o,parameters:ra({context:e,operation:o,parameters:a.parameters})},path:r,securitySchemesMap:n,state:t};if(a.delete){let t=B({source:ra({context:e,operation:a.delete,parameters:a.delete.parameters}),target:s.operation.parameters});ea({...s,method:`delete`,operation:{...s.operation,...a.delete,parameters:t}})}if(a.get){let t=B({source:ra({context:e,operation:a.get,parameters:a.get.parameters}),target:s.operation.parameters});ea({...s,method:`get`,operation:{...s.operation,...a.get,parameters:t}})}if(a.head){let t=B({source:ra({context:e,operation:a.head,parameters:a.head.parameters}),target:s.operation.parameters});ea({...s,method:`head`,operation:{...s.operation,...a.head,parameters:t}})}if(a.options){let t=B({source:ra({context:e,operation:a.options,parameters:a.options.parameters}),target:s.operation.parameters});ea({...s,method:`options`,operation:{...s.operation,...a.options,parameters:t}})}if(a.patch){let t=B({source:ra({context:e,operation:a.patch,parameters:a.patch.parameters}),target:s.operation.parameters});ea({...s,method:`patch`,operation:{...s.operation,...a.patch,parameters:t}})}if(a.post){let t=B({source:ra({context:e,operation:a.post,parameters:a.post.parameters}),target:s.operation.parameters});ea({...s,method:`post`,operation:{...s.operation,...a.post,parameters:t}})}if(a.put){let t=B({source:ra({context:e,operation:a.put,parameters:a.put.parameters}),target:s.operation.parameters});ea({...s,method:`put`,operation:{...s.operation,...a.put,parameters:t}})}}},ua=({logger:e,operations:t,parameters:n,preserveOrder:r,requestBodies:i,responses:a,schemas:o,spec:s})=>{let c=e.timeEvent(`filter-spec`);if(s.components){if(s.components.parameters){let e={};if(r)for(let[t,r]of Object.entries(s.components.parameters))n.has(R(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=z(t),r=s.components.parameters[n];r&&(e[n]=r)}s.components.parameters=e}if(s.components.requestBodies){let e={};if(r)for(let[t,n]of Object.entries(s.components.requestBodies))i.has(R(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=z(t),r=s.components.requestBodies[n];r&&(e[n]=r)}s.components.requestBodies=e}if(s.components.responses){let e={};if(r)for(let[t,n]of Object.entries(s.components.responses))a.has(R(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=z(t),r=s.components.responses[n];r&&(e[n]=r)}s.components.responses=e}if(s.components.schemas){let e={};if(r)for(let[t,n]of Object.entries(s.components.schemas))o.has(R(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=z(t),r=s.components.schemas[n];r&&(e[n]=r)}s.components.schemas=e}}if(s.paths)for(let e of Object.entries(s.paths)){let n=e[0],r=e[1];for(let e of dr){if(!r[e])continue;let i=R(`operation`,O({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},da=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Ti({mediaType:t})?{...n,format:`binary`}:n:Ti({mediaType:t})?{format:`binary`,type:`string`}:void 0},fa=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:Ei({mediaType:n})});return t},pa=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},ma=({irSchema:e,schema:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},ha=({irSchema:e,schema:t})=>{t.default!==void 0&&(e.default=t.default),t.exclusiveMaximum?t.maximum!==void 0&&(e.exclusiveMaximum=t.maximum):t.maximum!==void 0&&(e.maximum=t.maximum),t.exclusiveMinimum?t.minimum!==void 0&&(e.exclusiveMinimum=t.minimum):t.minimum!==void 0&&(e.minimum=t.minimum),t.format&&(e.format=t.format),t.maxItems!==void 0&&(e.maxItems=t.maxItems),t.maxLength!==void 0&&(e.maxLength=t.maxLength),t.minItems!==void 0&&(e.minItems=t.minItems),t.minLength!==void 0&&(e.minLength=t.minLength),t.pattern&&(e.pattern=t.pattern),t.readOnly?e.accessScope=`read`:t.writeOnly&&(e.accessScope=`write`)},ga=({context:e,irSchema:t={},schema:n,state:r})=>{n.maxItems&&n.maxItems===n.minItems?t.type=`tuple`:t.type=`array`;let i=[];if(n.items){let a=V({context:e,schema:n.items,state:r});if(!i.length&&n.maxItems&&n.maxItems===n.minItems)i=Array(n.maxItems).fill(a);else if(`$ref`in n.items)i.push(a);else{let e=n.items.allOf||n.items.anyOf||n.items.oneOf;e&&e.length>1&&!n.items.nullable?t={...t,...a}:i.push(a)}}return t=D({items:i,schema:t}),t},_a=({irSchema:e={}})=>(e.type=`boolean`,e),va=({irSchema:e={},schema:t})=>(e.type=t.type,e),ya=({context:e,irSchema:t={},schema:n,state:r})=>{t.type=`object`;let i={};for(let t in n.properties){let a=n.properties[t];typeof a==`boolean`||(i[t]=V({context:e,schema:a,state:r}))}return Object.keys(i).length&&(t.properties=i),n.additionalProperties===void 0?t.properties||(t.additionalProperties={type:`unknown`}):typeof n.additionalProperties==`boolean`?r.inAllOf&&n.additionalProperties===!1&&(!n.properties||!Object.keys(n.properties).length)||(t.additionalProperties={type:n.additionalProperties?`unknown`:`never`}):t.additionalProperties=V({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},ba=({irSchema:e={}})=>(e.type=`string`,e),xa=({schema:e})=>{let t={};return ma({irSchema:t,schema:e}),t},Sa=({context:e,schema:t,state:n})=>{let r=xa({schema:t}),i=[],a=pa({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=V({context:e,schema:r,state:n});if(n.inAllOf=a,n.inAllOf===void 0&&delete n.inAllOf,t.required&&(o.required?o.required=[...o.required,...t.required]:o.required=t.required),i.push(o),`$ref`in r){let t=e.resolveRef(r.$ref);if(t.discriminator&&n.$ref){let e=Ai(n.$ref,t.discriminator.mapping,t.oneOf?()=>t.oneOf.some(e=>`$ref`in e&&e.$ref===n.$ref):void 0);if(e.length>0){let n=e.map(e=>({const:e,type:`string`})),r={properties:{[t.discriminator.propertyName]:n.length>1?{items:n,logicalOperator:`or`}:n[0]},type:`object`};t.required?.includes(t.discriminator.propertyName)&&(r.required=[t.discriminator.propertyName]),i.push(r)}}}}if(a===`object`){let r=ka({context:e,schema:{...t,type:`object`},state:n});if(r.properties){for(let t of r.required??[])if(!r.properties[t])for(let i of o){let a=`$ref`in i?e.resolveRef(i.$ref):i;if(pa({schema:a})===`object`){let i=ka({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=D({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),t.nullable){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`},e[0].deprecated&&(r.deprecated=e[0].deprecated),e[0].description&&(r.description=e[0].description)}return r},Ca=({context:e,schema:t,state:n})=>{let r=xa({schema:t}),i=[],a=pa({schema:t}),o=t.anyOf;for(let r of o){let a=V({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=Ai(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`},a],logicalOperator:`and`}}i.push(a)}if(t.nullable&&i.push({type:`null`}),r=D({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=ka({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},wa=({context:e,schema:t,state:n})=>{let r=xa({schema:t});r.type=`enum`;let i=[];for(let[r,a]of t.enum.entries()){let o=typeof a,s;if(o===`string`||o===`number`||o===`boolean`?s=o:o===`object`&&Array.isArray(a)?s=`array`:a===null?t.nullable&&(s=`null`):console.warn(`🚨`,`unhandled "${o}" typeof value "${a}" for enum`,t.enum),!s)continue;let c=ka({context:e,schema:{description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:s===`null`?`string`:s},state:n});c.const=a,s===`null`&&(c.type=s),c.type===`array`&&(c.type=`tuple`),i.push(c)}return r=D({items:i,schema:r}),r},Ta=({context:e,schema:t,state:n})=>{let r=xa({schema:t}),i=[],a=pa({schema:t}),o=t.oneOf;for(let r of o){let a=V({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=Ai(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},required:[t.discriminator.propertyName],type:`object`},a],logicalOperator:`and`}}a.logicalOperator===`or`&&a.type!==`array`&&a.items?i=i.concat(a.items):i.push(a)}if(t.nullable&&i.push({type:`null`}),r=D({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=ka({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Ea=({context:e,schema:t,state:n})=>{if(!t.$ref.startsWith(`#/components/`)&&!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref;let a=V({context:e,schema:r,state:n});return n.$ref=i,a}let r={};if(r.$ref=decodeURI(t.$ref),!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref,V({context:e,schema:r,state:n}),n.$ref=i}return r},Da=({context:e,irSchema:t,schema:n,state:r})=>{t||=xa({schema:n});let i={};return ha({irSchema:i,schema:n}),i.default===null&&delete i.default,t=D({items:[ka({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},Oa=({context:e,schema:t,state:n})=>{let r=xa({schema:t});ha({irSchema:r,schema:t});let i=pa({schema:t});return i?t.nullable?Da({context:e,irSchema:r,schema:{...t,type:i},state:n}):ka({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},ka=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=xa({schema:n}),ha({irSchema:t,schema:n})),n.type){case`array`:return ga({context:e,irSchema:t,schema:n,state:r});case`boolean`:return _a({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return va({context:e,irSchema:t,schema:n,state:r});case`object`:return ya({context:e,irSchema:t,schema:n,state:r});case`string`:return ba({context:e,irSchema:t,schema:n,state:r});default:return Aa({context:e,irSchema:t,schema:n})}},Aa=({irSchema:e,schema:t})=>(e||=xa({schema:t}),e.type=`unknown`,ha({irSchema:e,schema:t}),e),V=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),`$ref`in t?Ea({context:e,schema:t,state:n}):t.enum?wa({context:e,schema:t,state:n}):t.allOf?Sa({context:e,schema:t,state:n}):t.anyOf?Ca({context:e,schema:t,state:n}):t.oneOf?Ta({context:e,schema:t,state:n}):t.type||t.properties?Oa({context:e,schema:t,state:n}):Aa({context:e,schema:t})),ja=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[I(e)]=V({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Ma=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,Na=({context:e,name:t,schema:n})=>{if(ki(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref);if(`content`in r||`in`in r){let n;if(`in`in r&&(n=r.schema),!n){let e=fa({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?Na({context:e,name:t,schema:n}):!1}return Na({context:e,name:t,schema:r})}for(let t in n.properties)if(ki(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&Ma(pa({schema:e})))return t}for(let r of n.allOf??[]){let n=Na({context:e,name:t,schema:r});if(n)return n}return!1},Pa=({irOperation:e,operation:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.description&&(e.description=t.description),t.summary&&(e.summary=t.summary),t.tags?.length&&(e.tags=t.tags)},Fa=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:fr({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Pa({irOperation:a,operation:n}),a},Ia=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Fa({context:e,method:t,operation:n,path:r,state:a});if(n.parameters&&(o.parameters=n.parameters),n.requestBody){let t=`$ref`in n.requestBody?e.resolveRef(n.requestBody.$ref):n.requestBody,r=fa({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=Na({context:e,name:``,schema:i.schema&&`$ref`in i.schema?{allOf:[{...i.schema}],description:t.description}:{description:t.description,...i.schema}});o.body={mediaType:i.mediaType,schema:V({context:e,schema:`$ref`in n.requestBody?{allOf:[{...n.requestBody}],description:t.description}:i.schema&&`$ref`in i.schema?{allOf:[{...i.schema}],description:t.description}:{description:t.description,...i.schema},state:void 0})},r&&(o.body.pagination=r),t.required&&(o.body.required=t.required),i.type&&(o.body.type=i.type)}}for(let t in n.responses){o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=fa({content:i.content}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:V({context:e,schema:{description:i.description,...da({content:s})},state:void 0})}:o.responses[t]={schema:{description:i.description,type:t===`204`?`void`:`unknown`}}}if(n.security){let e=new Map;for(let t of n.security)for(let n in t){let t=i.get(n);t&&e.set(n,t)}e.size&&(o.security=Array.from(e.values()))}return o},La=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[r]||(e.ir.paths[r]={}),n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),e.ir.paths[r][t]=Ia({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},Ra=e=>{switch(e){case`query`:return!1;default:return}},za=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},Ba=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},Va=({context:e,parameters:t})=>{if(!t||!Object.keys(t).length)return;let n={};for(let r of t){let t=`$ref`in r?e.dereference(r):r;n[t.in]||(n[t.in]={}),n[t.in][t.name.toLocaleLowerCase()]=Ha({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Ha=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=fa({content:n.content}),t=e.find(e=>e.type===`json`)||e[0];t&&(r=t.schema)}let i=r&&`$ref`in r?{allOf:[{...r}],deprecated:n.deprecated,description:n.description}:{deprecated:n.deprecated,description:n.description,...r},a=Na({context:t,name:n.name,schema:i}),o=n.style||Ba(n.in),s=n.explode===void 0?za(o):n.explode,c={allowReserved:n.allowReserved===void 0?Ra(n.in):n.allowReserved,explode:s,location:n.in,name:n.name,schema:V({context:t,schema:i,state:{$ref:e,circularReferenceTracker:new Set}}),style:o};return n.deprecated&&(c.deprecated=n.deprecated),n.description&&(c.description=n.description),a&&(c.pagination=a),n.required&&(c.required=n.required),c},Ua=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[I(e)]=Ha({$ref:e,context:t,parameter:n})},Wa=({$ref:e,context:t,requestBody:n})=>{let r=fa({content:n.content}),i=r.find(e=>e.type===`json`)||r[0],a=i?i.schema:void 0,o={schema:V({context:t,schema:{description:n.description,...a},state:{$ref:e,circularReferenceTracker:new Set}})};return n.description&&(o.description=n.description),n.required&&(o.required=n.required),o},Ga=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[I(e)]=Wa({$ref:e,context:t,requestBody:n})},Ka=({context:e})=>{if(e.spec.servers){e.ir.servers=e.spec.servers;return}for(let t of e.config.input)if(typeof t.path==`string`){let n=oa(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},qa=(e,t)=>{let n=t.timeEvent(`validate`),r=[],i=new Map;if(e.paths)for(let t of Object.entries(e.paths)){let e=t[0],n=t[1];for(let t of dr){let a=n[t];if(!a)continue;let o=O({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}if(e.servers){(typeof e.servers!=`object`||!Array.isArray(e.servers))&&r.push({code:`invalid_type`,message:"`servers` must be an array.",path:[],severity:`error`});for(let t=0;t<e.servers.length;t++){let n=e.servers[t];!n||typeof n!=`object`?r.push({code:`invalid_type`,context:{actual:typeof n,expected:`object`},message:"Each entry in `servers` must be an object.",path:[`servers`,t],severity:`error`}):n.url||r.push({code:`missing_required_field`,context:{field:`url`},message:"Missing required field `url` in server object.",path:[`servers`,t],severity:`error`})}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},Ja=e=>{if(e.config.parser.validate_EXPERIMENTAL&&_i({context:e,result:qa(e.spec,e.logger)}),yr(e.config.parser.filters)){let t=vr(e.config.parser.filters,e.spec,e.logger),{graph:n}=ni(e.spec,e.logger),{resourceMetadata:r}=Mr(n,e.logger);ua({...jr({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}fi({context:e});let t={ids:new Map},n=new Map;if(e.spec.components){for(let t in e.spec.components.securitySchemes){let r=e.spec.components.securitySchemes[t],i=`$ref`in r?e.resolveRef(r.$ref):r;n.set(t,i)}for(let t in e.spec.components.parameters){let n=`#/components/parameters/${t}`,r=e.spec.components.parameters[t];Ua({$ref:n,context:e,parameter:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.requestBodies){let n=`#/components/requestBodies/${t}`,r=e.spec.components.requestBodies[t];Ga({$ref:n,context:e,requestBody:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.schemas){let n=`#/components/schemas/${t}`,r=e.spec.components.schemas[t];ja({$ref:n,context:e,schema:r})}}for(let r in Ka({context:e}),e.spec.paths){let i=e.spec.paths[r],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,o={context:e,operation:{description:a.description,parameters:Va({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&La({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:B({source:Va({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&La({...o,method:`get`,operation:{...o.operation,...a.get,parameters:B({source:Va({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&La({...o,method:`head`,operation:{...o.operation,...a.head,parameters:B({source:Va({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&La({...o,method:`options`,operation:{...o.operation,...a.options,parameters:B({source:Va({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&La({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:B({source:Va({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&La({...o,method:`post`,operation:{...o.operation,...a.post,parameters:B({source:Va({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&La({...o,method:`put`,operation:{...o.operation,...a.put,parameters:B({source:Va({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&La({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:B({source:Va({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},Ya=({logger:e,operations:t,parameters:n,preserveOrder:r,requestBodies:i,responses:a,schemas:o,spec:s})=>{let c=e.timeEvent(`filter-spec`);if(s.components){if(s.components.parameters){let e={};if(r)for(let[t,r]of Object.entries(s.components.parameters))n.has(R(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=z(t),r=s.components.parameters[n];r&&(e[n]=r)}s.components.parameters=e}if(s.components.requestBodies){let e={};if(r)for(let[t,n]of Object.entries(s.components.requestBodies))i.has(R(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=z(t),r=s.components.requestBodies[n];r&&(e[n]=r)}s.components.requestBodies=e}if(s.components.responses){let e={};if(r)for(let[t,n]of Object.entries(s.components.responses))a.has(R(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=z(t),r=s.components.responses[n];r&&(e[n]=r)}s.components.responses=e}if(s.components.schemas){let e={};if(r)for(let[t,n]of Object.entries(s.components.schemas))o.has(R(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=z(t),r=s.components.schemas[n];r&&(e[n]=r)}s.components.schemas=e}}if(s.paths)for(let e of Object.entries(s.paths)){let n=e[0],r=e[1];for(let e of dr){if(!r[e])continue;let i=R(`operation`,O({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},Xa=({content:e})=>{let{mediaType:t,schema:n}=e;return n?n.type===`string`&&!n.format&&Ti({mediaType:t})?{...n,format:`binary`}:n:Ti({mediaType:t})?{format:`binary`,type:`string`}:void 0},Za=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:Ei({mediaType:n})});return t},Qa=({schema:e})=>typeof e.type==`string`?[e.type]:e.type?e.type:e.properties?[`object`]:[],$a=({irSchema:e,schema:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},eo=({irSchema:e,schema:t})=>{if(t.const!==void 0&&(e.const=t.const,!t.type))if(t.const===null)e.type=`null`;else switch(typeof t.const){case`bigint`:case`number`:e.type=`number`;break;case`boolean`:e.type=`boolean`;break;case`string`:e.type=`string`;break}t.default!==void 0&&(e.default=t.default),t.exclusiveMaximum!==void 0&&(e.exclusiveMaximum=t.exclusiveMaximum),t.exclusiveMinimum!==void 0&&(e.exclusiveMinimum=t.exclusiveMinimum),t.format&&(e.format=t.format),t.maximum!==void 0&&(e.maximum=t.maximum),t.maxItems!==void 0&&(e.maxItems=t.maxItems),t.maxLength!==void 0&&(e.maxLength=t.maxLength),t.minimum!==void 0&&(e.minimum=t.minimum),t.minItems!==void 0&&(e.minItems=t.minItems),t.minLength!==void 0&&(e.minLength=t.minLength),t.pattern&&(e.pattern=t.pattern),t.readOnly?e.accessScope=`read`:t.writeOnly&&(e.accessScope=`write`)},to=({context:e,irSchema:t={},schema:n,state:r})=>{n.prefixItems&&n.prefixItems.length||n.maxItems&&n.maxItems===n.minItems||n.const!==void 0?t.type=`tuple`:t.type=`array`;let i=[];for(let t of n.prefixItems??[]){let n=H({context:e,schema:t,state:r});i.push(n)}if(n.items){let a=H({context:e,schema:n.items,state:r});if(!i.length&&n.maxItems&&n.maxItems===n.minItems)i=Array(n.maxItems).fill(a);else{let e=n.items.allOf||n.items.anyOf||n.items.oneOf;e&&e.length>1&&!Qa({schema:n.items}).includes(`null`)?t={...t,...a}:i.push(a)}}return t=D({items:i,schema:t}),t},no=({irSchema:e={}})=>(e.type=`boolean`,e),ro=({irSchema:e={}})=>(e.type=`null`,e),io=({irSchema:e={},schema:t})=>(e.type=t.type,e),ao=({context:e,irSchema:t={},schema:n,state:r})=>{t.type=`object`;let i={};for(let t in n.properties){let a=n.properties[t];typeof a==`boolean`||(i[t]=H({context:e,schema:a,state:r}))}if(Object.keys(i).length&&(t.properties=i),n.additionalProperties===void 0?t.properties||(t.additionalProperties={type:`unknown`}):typeof n.additionalProperties==`boolean`?r.inAllOf&&n.additionalProperties===!1&&(!n.properties||!Object.keys(n.properties).length)&&(!n.patternProperties||!Object.keys(n.patternProperties).length)||(t.additionalProperties={type:n.additionalProperties?`unknown`:`never`}):t.additionalProperties=H({context:e,schema:n.additionalProperties,state:r}),n.patternProperties){let i={};for(let t in n.patternProperties){let a=n.patternProperties[t];i[t]=H({context:e,schema:a,state:r})}Object.keys(i).length&&(t.patternProperties=i)}return n.propertyNames&&(t.propertyNames=H({context:e,schema:n.propertyNames,state:r})),n.required&&(t.required=n.required),t},oo=({irSchema:e={}})=>(e.type=`string`,e),so=({schema:e})=>{let t={};return $a({irSchema:t,schema:e}),t},co=({context:e,schema:t,state:n})=>{let r=so({schema:t}),i=[],a=Qa({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=H({context:e,schema:r,state:n});if(n.inAllOf=a,n.inAllOf===void 0&&delete n.inAllOf,t.required&&(o.required?o.required=[...o.required,...t.required]:o.required=t.required),i.push(o),r.$ref){let t=e.resolveRef(r.$ref);if(t.discriminator&&n.$ref){let e=Ai(n.$ref,t.discriminator.mapping,t.oneOf?()=>t.oneOf.some(e=>`$ref`in e&&e.$ref===n.$ref):void 0);if(e.length>0){let n=e.map(e=>({const:e,type:`string`})),r={properties:{[t.discriminator.propertyName]:n.length>1?{items:n,logicalOperator:`or`}:n[0]},type:`object`};t.required?.includes(t.discriminator.propertyName)&&(r.required=[t.discriminator.propertyName]),i.push(r)}}}}if(a.includes(`object`)){let r=mo({context:e,schema:{...t,type:`object`},state:n});if(r.properties){for(let t of r.required??[])if(!r.properties[t])for(let i of o){let a=i.$ref?e.resolveRef(i.$ref):i;if(Qa({schema:a}).includes(`object`)){let i=mo({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=D({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),a.includes(`null`)){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`}}return r},lo=({context:e,schema:t,state:n})=>{let r=so({schema:t}),i=[],a=Qa({schema:t}),o=t.anyOf;for(let r of o){let a=H({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=Ai(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`},a],logicalOperator:`and`}}i.push(a)}if(a.includes(`null`)&&i.push({type:`null`}),r=D({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=mo({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},uo=({context:e,schema:t,state:n})=>{let r=so({schema:t});r.type=`enum`;let i=[],a=Qa({schema:t});for(let[r,o]of t.enum.entries()){let s=typeof o,c;if(s===`string`||s===`number`||s===`boolean`?c=s:s===`object`&&Array.isArray(o)?c=`array`:o===null?a.includes(`null`)&&(c=`null`):console.warn(`🚨`,`unhandled "${s}" typeof value "${o}" for enum`,t.enum),!c)continue;let l=mo({context:e,schema:{const:o,description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:c},state:n});i.push(l)}return r=D({items:i,schema:r}),r},fo=({context:e,schema:t,state:n})=>{let r=so({schema:t}),i=[],a=Qa({schema:t}),o=t.oneOf;for(let r of o){let a=H({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=Ai(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},required:[t.discriminator.propertyName],type:`object`},a],logicalOperator:`and`}}a.logicalOperator===`or`&&a.type!==`array`&&a.items?i=i.concat(a.items):i.push(a)}if(a.includes(`null`)&&i.push({type:`null`}),r=D({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=mo({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},po=({context:e,schema:t,state:n})=>{if(!t.$ref.startsWith(`#/components/`)&&!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref;let a=H({context:e,schema:r,state:n});return n.$ref=i,a}let r=so({schema:t}),i={};if(i.$ref=decodeURI(t.$ref),!n.circularReferenceTracker.has(t.$ref)){let r=e.resolveRef(t.$ref),i=n.$ref;n.$ref=t.$ref,H({context:e,schema:r,state:n}),n.$ref=i}let a=[];return a.push(i),t.type&&typeof t.type!=`string`&&t.type.includes(`null`)&&a.push({type:`null`}),r=D({items:a,mutateSchemaOneItem:!0,schema:r}),r},mo=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=so({schema:n}),eo({irSchema:t,schema:n})),n.type){case`array`:return to({context:e,irSchema:t,schema:n,state:r});case`boolean`:return no({context:e,irSchema:t,schema:n});case`integer`:case`number`:return io({context:e,irSchema:t,schema:n});case`null`:return ro({context:e,irSchema:t,schema:n});case`object`:return ao({context:e,irSchema:t,schema:n,state:r});case`string`:return oo({context:e,irSchema:t,schema:n});default:return _o({context:e,irSchema:t,schema:n})}},ho=({context:e,irSchema:t,schema:n,state:r})=>{t||=so({schema:n});let i={};eo({irSchema:i,schema:n}),n.type.includes(`null`)&&i.default===null&&delete i.default;let a=[];for(let t of n.type)if(t===`null`)a.push({type:`null`});else{let o=mo({context:e,irSchema:{...i},schema:{...n,type:t},state:r});a.push(o)}return t=D({items:a,schema:t}),t},go=({context:e,schema:t,state:n})=>{let r=so({schema:t});eo({irSchema:r,schema:t});let i=Qa({schema:t});return i.length===1?mo({context:e,irSchema:r,schema:{...t,type:i[0]},state:n}):ho({context:e,irSchema:r,schema:{...t,type:i},state:n})},_o=({irSchema:e,schema:t})=>(e||=so({schema:t}),e.type=`unknown`,eo({irSchema:e,schema:t}),e),H=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?po({context:e,schema:t,state:n}):t.enum?uo({context:e,schema:t,state:n}):t.allOf?co({context:e,schema:t,state:n}):t.anyOf?lo({context:e,schema:t,state:n}):t.oneOf?fo({context:e,schema:t,state:n}):t.type||t.properties?go({context:e,schema:t,state:n}):_o({context:e,schema:t})),vo=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[I(e)]=H({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},yo=e=>e.includes(`boolean`)||e.includes(`integer`)||e.includes(`number`)||e.includes(`string`),bo=({context:e,name:t,schema:n})=>{if(ki(e.config.parser.pagination).test(t))return!0;if(n.$ref){let r=e.resolveRef(n.$ref);if(`content`in r||`in`in r){let n;if(`in`in r&&(n=r.schema),!n){let e=Za({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?bo({context:e,name:t,schema:n}):!1}return bo({context:e,name:t,schema:r})}for(let t in n.properties)if(ki(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`){let n=Qa({schema:e});if(!n.length){let n=(e.anyOf??e.oneOf??[]).filter(e=>e.type!==`null`);if(n.length===1&&yo(Qa({schema:n[0]})))return t}if(yo(n))return t}}for(let r of n.allOf??[]){let n=bo({context:e,name:t,schema:r});if(n)return n}return!1},xo=({irOperation:e,operation:t})=>{t.deprecated!==void 0&&(e.deprecated=t.deprecated),t.description&&(e.description=t.description),t.summary&&(e.summary=t.summary),t.tags?.length&&(e.tags=t.tags)},So=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:fr({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),xo({irOperation:a,operation:n}),a},Co=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=So({context:e,method:t,operation:n,path:r,state:a});if(n.parameters&&(o.parameters=n.parameters),n.requestBody){let t=`$ref`in n.requestBody?e.resolveRef(n.requestBody.$ref):n.requestBody,r=Za({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=bo({context:e,name:``,schema:{description:t.description,...i.schema}});o.body={mediaType:i.mediaType,schema:H({context:e,schema:{description:t.description,...`$ref`in n.requestBody?n.requestBody:i.schema},state:void 0})},r&&(o.body.pagination=r),t.required&&(o.body.required=t.required),i.type&&(o.body.type=i.type)}}for(let t in n.responses){o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=Za({content:i.content}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:H({context:e,schema:{description:i.description,...Xa({content:s})},state:void 0})}:o.responses[t]={schema:{description:i.description,type:t===`204`?`void`:`unknown`}}}if(n.security){let e=new Map;for(let t of n.security)for(let n in t){let t=i.get(n);t&&e.set(n,t)}e.size&&(o.security=Array.from(e.values()))}return o},wo=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>(n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),{parsed:Co({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})}),To=({context:e,method:t,path:n,...r})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={});let{parsed:i}=wo({context:e,method:t,path:n,...r});e.ir.paths[n][t]=i},Eo=({context:e,key:t,method:n,...r})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:i}=wo({context:e,method:n,path:t,...r});e.ir.webhooks[t][n]=i},Do=e=>{switch(e){case`query`:return!1;default:return}},Oo=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},ko=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},U=({context:e,parameters:t})=>{if(!t||!Object.keys(t).length)return;let n={};for(let r of t){let t=`$ref`in r?e.dereference(r):r;n[t.in]||(n[t.in]={}),n[t.in][t.name.toLocaleLowerCase()]=Ao({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Ao=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=Za({content:n.content}),t=e.find(e=>e.type===`json`)||e[0];t&&(r=t.schema)}let i={deprecated:n.deprecated,description:n.description,...r},a=bo({context:t,name:n.name,schema:i}),o=n.style||ko(n.in),s=n.explode===void 0?Oo(o):n.explode,c={allowReserved:n.allowReserved===void 0?Do(n.in):n.allowReserved,explode:s,location:n.in,name:n.name,schema:H({context:t,schema:i,state:{$ref:e,circularReferenceTracker:new Set}}),style:o};return n.deprecated&&(c.deprecated=n.deprecated),n.description&&(c.description=n.description),a&&(c.pagination=a),n.required&&(c.required=n.required),c},jo=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[I(e)]=Ao({$ref:e,context:t,parameter:n})},Mo=({$ref:e,context:t,requestBody:n})=>{let r=Za({content:n.content}),i=r.find(e=>e.type===`json`)||r[0],a=i?i.schema:void 0,o={schema:H({context:t,schema:{description:n.description,...a},state:{$ref:e,circularReferenceTracker:new Set}})};return n.description&&(o.description=n.description),n.required&&(o.required=n.required),o},No=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[I(e)]=Mo({$ref:e,context:t,requestBody:n})},Po=({context:e})=>{if(e.spec.servers){e.ir.servers=e.spec.servers;return}for(let t of e.config.input)if(typeof t.path==`string`){let n=oa(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},Fo=(e,t)=>{let n=t.timeEvent(`validate`),r=[],i=new Map;if(e.paths)for(let t of Object.entries(e.paths)){let e=t[0],n=t[1];for(let t of dr){let a=n[t];if(!a)continue;let o=O({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}if(e.servers){(typeof e.servers!=`object`||!Array.isArray(e.servers))&&r.push({code:`invalid_type`,message:"`servers` must be an array.",path:[],severity:`error`});for(let t=0;t<e.servers.length;t++){let n=e.servers[t];!n||typeof n!=`object`?r.push({code:`invalid_type`,context:{actual:typeof n,expected:`object`},message:"Each entry in `servers` must be an object.",path:[`servers`,t],severity:`error`}):n.url||r.push({code:`missing_required_field`,context:{field:`url`},message:"Missing required field `url` in server object.",path:[`servers`,t],severity:`error`})}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},Io=({context:e,securitySchemesMap:t})=>{let n={ids:new Map};for(let r in e.spec.webhooks){let i=e.spec.webhooks[r],a=`$ref`in i?{...e.resolveRef(i.$ref),...i}:i,o={context:e,key:r,operation:{description:a.description,parameters:U({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},securitySchemesMap:t,state:n};a.delete&&Eo({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:B({source:U({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Eo({...o,method:`get`,operation:{...o.operation,...a.get,parameters:B({source:U({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Eo({...o,method:`head`,operation:{...o.operation,...a.head,parameters:B({source:U({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Eo({...o,method:`options`,operation:{...o.operation,...a.options,parameters:B({source:U({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Eo({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:B({source:U({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Eo({...o,method:`post`,operation:{...o.operation,...a.post,parameters:B({source:U({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Eo({...o,method:`put`,operation:{...o.operation,...a.put,parameters:B({source:U({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Eo({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:B({source:U({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},Lo=e=>{if(e.config.parser.validate_EXPERIMENTAL&&_i({context:e,result:Fo(e.spec,e.logger)}),yr(e.config.parser.filters)){let t=vr(e.config.parser.filters,e.spec,e.logger),{graph:n}=ni(e.spec,e.logger),{resourceMetadata:r}=Mr(n,e.logger);Ya({...jr({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}fi({context:e});let t={ids:new Map},n=new Map;if(e.spec.components){for(let t in e.spec.components.securitySchemes){let r=e.spec.components.securitySchemes[t],i=`$ref`in r?e.resolveRef(r.$ref):r;n.set(t,i)}for(let t in e.spec.components.parameters){let n=`#/components/parameters/${t}`,r=e.spec.components.parameters[t];jo({$ref:n,context:e,parameter:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.requestBodies){let n=`#/components/requestBodies/${t}`,r=e.spec.components.requestBodies[t];No({$ref:n,context:e,requestBody:`$ref`in r?e.resolveRef(r.$ref):r})}for(let t in e.spec.components.schemas){let n=`#/components/schemas/${t}`,r=e.spec.components.schemas[t];vo({$ref:n,context:e,schema:r})}}for(let r in Po({context:e}),e.spec.paths){let i=e.spec.paths[r],a=i.$ref?{...e.resolveRef(i.$ref),...i}:i,o={context:e,operation:{description:a.description,parameters:U({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&To({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:B({source:U({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&To({...o,method:`get`,operation:{...o.operation,...a.get,parameters:B({source:U({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&To({...o,method:`head`,operation:{...o.operation,...a.head,parameters:B({source:U({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&To({...o,method:`options`,operation:{...o.operation,...a.options,parameters:B({source:U({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&To({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:B({source:U({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&To({...o,method:`post`,operation:{...o.operation,...a.post,parameters:B({source:U({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&To({...o,method:`put`,operation:{...o.operation,...a.put,parameters:B({source:U({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&To({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:B({source:U({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}Io({context:e,securitySchemesMap:n})},Ro=[`connect`,`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`];function zo(e=`1.0`){return String(e).replace(/^v/gi,``)}const Bo=(e,t)=>{if(e.enum&&!t.includes(`boolean`))return`enum`},Vo=e=>Uo(e).includes(`null`),Ho=e=>e.nullable===!0||Vo(e),Uo=({type:e})=>Array.isArray(e)?e:e?[e]:[],Wo=`#/components/parameters/`,Go=`#/components/schemas/`,Ko=({config:e,name:t})=>{let n=e.plugins[`@hey-api/sdk`];if(n?.config.classNameBuilder){let e=``;return e=typeof n.config.classNameBuilder==`function`?n.config.classNameBuilder(t):n.config.classNameBuilder.replace(`{{name}}`,t),e}return t},qo=e=>x().plugins[`@hey-api/typescript`]?.config.style===`PascalCase`?w({case:`PascalCase`,value:e}):e,Jo=e=>cr(qo(e)).replace(pt,`_$1`),Yo=e=>e.trim().replace(/^#\/definitions\//,``).replace(/^#\/parameters\//,``).replace(/^#\/responses\//,``).replace(/^#\/securityDefinitions\//,``).replace(/^#\/components\/schemas\//,``).replace(/^#\/components\/responses\//,``).replace(/^#\/components\/parameters\//,``).replace(/^#\/components\/examples\//,``).replace(/^#\/components\/requestBodies\//,``).replace(/^#\/components\/headers\//,``).replace(/^#\/components\/securitySchemes\//,``).replace(/^#\/components\/links\//,``).replace(/^#\/components\/callbacks\//,``),Xo=(e,t)=>{if(t===`binary`)return`binary`;switch(e){case`any`:case`object`:case`unknown`:return`unknown`;case`array`:return`unknown[]`;case`boolean`:return`boolean`;case`byte`:case`double`:case`float`:case`int`:case`integer`:case`long`:case`number`:case`short`:return`number`;case`char`:case`date`:case`date-time`:case`password`:case`string`:return`string`;case`file`:return`binary`;case`null`:return`null`;case`void`:return`void`;default:return}},Zo=/(?<!`1)\[.*\]$/g,W=({debug:e,format:t,type:n=`unknown`})=>{let r={$refs:[],base:`unknown`,imports:[],isNullable:!1,template:null,type:`unknown`};if(Array.isArray(n)){let e=n.filter(e=>e!==`null`).map(e=>Xo(e,t)).filter(Boolean).join(` | `);return r.type=e,r.base=e,r.isNullable=Vo({type:n}),r}let i=Xo(n,t);if(i)return r.type=i,r.base=i,r;let a=decodeURIComponent(Yo(n));if(Zo.lastIndex=0,Zo.test(a)){let t=a.match(/(.*?)\[(.*)\]$/);if(t?.length){let n=W({debug:e,type:cr(t[1])}),i=W({debug:e,type:cr(t[2])});return n.type===`unknown[]`?(r.type=`${i.type}[]`,r.base=`${i.type}`,n.$refs=[],n.imports=[]):i.type?(r.type=`${n.type}<${i.type}>`,r.base=n.type,r.template=i.type):(r.type=n.type,r.base=n.type,r.template=n.type),r.$refs=[...r.$refs,...n.$refs,...i.$refs],r.imports=[...r.imports,...n.imports,...i.imports],r}}if(a){let e=qo(cr(a));return n.startsWith(Wo)&&(e=`Parameter${e}`),r.type=e,r.base=e,n.startsWith(`#`)&&(r.$refs=[...r.$refs,decodeURIComponent(n)]),r.imports=[...r.imports,e],r}return r};function Qo(e,t,n){return n.indexOf(e)===t}const $o=(e,t)=>{if(!Array.isArray(t))return[];let n=(e[`x-enum-descriptions`]??[]).filter(e=>typeof e==`string`),r=(e[`x-enum-varnames`]??e[`x-enumNames`]??[]).filter(e=>typeof e==`string`);return t.filter(Qo).filter(e=>typeof e==`number`||typeof e==`string`).map((e,t)=>({customDescription:n[t],customName:r[t],description:void 0,value:e}))},es=e=>e?.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`),ts=({definition:e,getModel:t,openApi:n,types:r})=>{let i=[];return Object.entries(e.properties??{}).forEach(([a,o])=>{let s=!!e.required?.includes(a);if(o.$ref){let e=W({type:o.$ref});i.push({$refs:[],base:e.base,description:o.description||null,enum:[],enums:[],exclusiveMaximum:o.exclusiveMaximum,exclusiveMinimum:o.exclusiveMinimum,export:`reference`,format:o.format,imports:e.imports,in:``,isDefinition:!1,isNullable:o[`x-nullable`]===!0,isReadOnly:o.readOnly===!0,isRequired:s,link:null,maxItems:o.maxItems,maxLength:o.maxLength,maxProperties:o.maxProperties,maximum:o.maximum,minItems:o.minItems,minLength:o.minLength,minProperties:o.minProperties,minimum:o.minimum,multipleOf:o.multipleOf,name:yt(a),pattern:es(o.pattern),properties:[],template:e.template,type:e.type,uniqueItems:o.uniqueItems})}else{let e=t({definition:o,openApi:n,types:r});i.push({$refs:[],base:e.base,description:o.description||null,enum:e.enum,enums:e.enums,exclusiveMaximum:o.exclusiveMaximum,exclusiveMinimum:o.exclusiveMinimum,export:e.export,format:o.format,imports:e.imports,in:``,isDefinition:!1,isNullable:o[`x-nullable`]===!0,isReadOnly:o.readOnly===!0,isRequired:s,link:e.link,maxItems:o.maxItems,maxLength:o.maxLength,maxProperties:o.maxProperties,maximum:o.maximum,minItems:o.minItems,minLength:o.minLength,minProperties:o.minProperties,minimum:o.minimum,multipleOf:o.multipleOf,name:yt(a),pattern:es(o.pattern),properties:e.properties,template:e.template,type:e.type,uniqueItems:o.uniqueItems})}}),i},ns=/~1/g,rs=/~0/g;function is(e,t){if(t.$ref){let n=t.$ref.replace(/^#/g,``).split(`/`).filter(Boolean),r=e;return n.forEach(e=>{let n=decodeURIComponent(e.replace(ns,`/`).replace(rs,`~`));if(r.hasOwnProperty(n))r=r[n];else throw Error(`Could not find reference: "${t.$ref}"`)}),r}return t}const as=({definitions:e,getModel:t,openApi:n,required:r,types:i})=>e.reduce((e,r)=>{if(r.$ref){let a=is(n,r);return[...e,...t({definition:a,openApi:n,types:i}).properties]}return[...e,...t({definition:r,openApi:n,types:i}).properties]},[]).filter(e=>!e.isRequired&&r.includes(e.name)).map(e=>({...e,isRequired:!0})),os=({definition:e,definitions:t,getModel:n,openApi:r,type:i,types:a})=>{let o={$refs:[],enums:[],export:i,imports:[],properties:[]},s=[];if(t.map(e=>n({definition:e,openApi:r,types:a})).filter(e=>{let t=e.properties.length,n=e.enums.length;return!(e.type===`unknown`&&!t&&!n)}).forEach(e=>{o.imports.push(...e.imports),o.enums.push(...e.enums),o.properties.push(e)}),e.required&&i===`all-of`){let i=as({definitions:t,getModel:n,openApi:r,required:e.required,types:a});i.forEach(e=>{o.imports.push(...e.imports),o.enums.push(...e.enums)}),s.push(...i)}if(e.properties){let t=ts({definition:e,getModel:n,openApi:r,types:a});t.forEach(e=>{o.imports.push(...e.imports),o.enums.push(...e.enums),e.export===`enum`&&o.enums.push(e)}),s.push(...t)}return s.length&&o.properties.push({$refs:[],base:`unknown`,description:``,enum:[],enums:[],export:`interface`,imports:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:`properties`,properties:s,template:null,type:`unknown`}),o},ss=({definition:e,isDefinition:t=!1,meta:n,openApi:r,types:i})=>{let a={$refs:[],base:`unknown`,description:e.description||null,enum:[],enums:[],exclusiveMaximum:e.exclusiveMaximum,exclusiveMinimum:e.exclusiveMinimum,export:`interface`,format:e.format,imports:[],in:``,isDefinition:t,isNullable:e[`x-nullable`]===!0,isReadOnly:e.readOnly===!0,isRequired:!1,link:null,maxItems:e.maxItems,maxLength:e.maxLength,maxProperties:e.maxProperties,maximum:e.maximum,meta:n,minItems:e.minItems,minLength:e.minLength,minProperties:e.minProperties,minimum:e.minimum,multipleOf:e.multipleOf,name:n?.name??``,pattern:es(e.pattern),properties:[],template:null,type:`unknown`,uniqueItems:e.uniqueItems};if(e.$ref){let t=W({type:e.$ref});return a.export=`reference`,a.type=t.type,a.base=t.base,a.template=t.template,a.imports.push(...t.imports),a}if(e.enum&&e.type!==`boolean`){let t=$o(e,e.enum);if(t.length)return a.base=`string`,a.enum=[...a.enum,...t],a.export=`enum`,a.type=`string`,a}if(e.type===`array`&&e.items)if(e.items.$ref){let t=W({type:e.items.$ref});return a.export=`array`,a.type=t.type,a.base=t.base,a.template=t.template,a.imports.push(...t.imports),a}else{let t=ss({definition:e.items,openApi:r,types:i});return a.export=`array`,a.type=t.type,a.base=t.base,a.template=t.template,a.link=t,a.imports.push(...t.imports),a}if(e.type===`object`&&typeof e.additionalProperties==`object`)if(e.additionalProperties.$ref){let t=W({type:e.additionalProperties.$ref});return a.export=`dictionary`,a.type=t.type,a.base=t.base,a.template=t.template,a.imports.push(...t.imports),a}else{let t=ss({definition:e.additionalProperties,openApi:r,types:i});return a.export=`dictionary`,a.type=t.type,a.base=t.base,a.template=t.template,a.link=t,a.imports.push(...t.imports),a}if(e.allOf?.length){let t=os({definition:e,definitions:e.allOf,getModel:ss,openApi:r,type:`all-of`,types:i});return a.export=t.export,a.imports.push(...t.imports),a.properties.push(...t.properties),a.enums=[...a.enums,...t.enums],a}if(e.type===`object`)return a.export=`interface`,a.type=`unknown`,a.base=`unknown`,e.properties&&ts({definition:e,getModel:ss,openApi:r,types:i}).forEach(e=>{a.imports.push(...e.imports),a.enums=[...a.enums,...e.enums],a.properties.push(e),e.export===`enum`&&(a.enums=[...a.enums,e])}),a;if(e.type){let t=W({format:e.format,type:e.type});return a.export=`generic`,a.type=t.type,a.base=t.base,a.template=t.template,a.imports.push(...t.imports),a}return a},cs=e=>{let t={},n=[];return Object.entries(e.definitions??{}).forEach(([r,i])=>{let a=W({type:r}).base.replace(pt,`_$1`),o={$ref:`#/definitions/${r}`,name:a};t[a]=o;let s=ss({definition:i,isDefinition:!0,meta:o,openApi:e,types:t});n=[...n,s]}),{models:n,types:t}};function ls(e,t){let n=e.toLocaleLowerCase(),r=t.toLocaleLowerCase();return n.localeCompare(r,`en`)}const us=(e,t)=>ls(e.name,t.name);function ds(e){return e.sort(us)}const fs=(e,t)=>{if(t)return t;if(typeof e==`number`)return`'_${e}'`;let n=``;return typeof e==`string`&&(n=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`).replace(/^([^$_\p{ID_Start}])/u,`_$1`).replace(/(\p{Lowercase})(\p{Uppercase}+)/gu,`$1_$2`)),n=n.trim(),n||=`empty_string`,n.toUpperCase()},ps=e=>e.map(e=>ms(e.value,!0)).filter(Qo).join(` | `),ms=(e,t=!1)=>typeof e==`string`?e.includes(`'`)&&t?`"${e}"`:`'${e}'`:e,hs=e=>({key:fs(e.value,e.customName),value:ms(e.value)}),gs=e=>{let t=e.enum.map(e=>hs(e)).sort((e,t)=>ls(e.key,t.key)).map(e=>`${e.key}=${e.value}`).join(`&`);return{$ref:`enum/${e.name}/${t}`,name:cr(bt(e.name))}},_s=e=>{let t=`Parameter${W({type:e}).base.replace(pt,`_$1`)}`;return{$ref:Wo+e,name:t}},vs=e=>{let t=Jo(e);return{$ref:Go+e,name:t}},ys=e=>e.format===`date`||e.format===`date-time`,bs=e=>{let t=x();return e.base===`binary`?F.typeUnionNode({types:[`Blob`,`File`]}):t.plugins[`@hey-api/transformers`]?.config.dates&&ys(e)?F.typeNode(`Date`):F.typeNode(e.base)},xs=e=>{let t=e.base===`null`?!1:e.isNullable,n=bs(e);if(e.export===`reference`&&e.$refs.length===1&&e.$refs[0].startsWith(Go)){let t=vs(e.base);n=F.typeNode(t.name)}return F.typeUnionNode({isNullable:t,types:[n]})},Ss=e=>{if(e.link){if(Array.isArray(e.link)){let t=e.link.map(e=>Ds(e));return F.typeTupleNode({isNullable:e.isNullable,types:t})}if(e.export===`array`&&e.maxItems&&e.minItems&&e.maxItems===e.minItems&&e.maxItems<=100){let t=Array(e.maxItems).fill(Ds(e.link));return F.typeTupleNode({isNullable:e.isNullable,types:t})}return F.typeArrayNode([Ds(e.link)],e.isNullable)}return F.typeArrayNode([bs(e)],e.isNullable)},Cs=e=>{let t=e.enum.map(e=>ms(e.value));return F.typeUnionNode({isNullable:e.isNullable,types:t})},ws=e=>{let t=e.link&&!Array.isArray(e.link)?Ds(e.link):bs(e);return F.typeRecordNode([`string`],[t],e.isNullable,!0)},Ts=({model:e,style:t})=>{let n=e.properties.map(e=>F.nodeToString({node:Ds(e),unescape:!0})).filter(Qo),r=t===`union`?F.typeUnionNode({isNullable:e.isNullable&&!e.properties.find(e=>e.isNullable),types:n}):F.typeIntersectionNode({isNullable:e.isNullable,types:n});return e.meta?r:F.typeParenthesizedNode({type:r})},Es=e=>{if(!e.properties.length)return F.typeNode(`unknown`);let t=S(x()),n=e.properties.map(e=>{let n=e.isRequired?``:`?`,r=Ds(e),i=t?/^\dXX$/.test(e.name)?yt(e.name):e.name:yt(bt(As(e.name)));return e.name===`[key: string]`&&(i=e.name,n&&(n=``,r=F.typeUnionNode({types:[r,`undefined`]}))),{comment:[e.description&&A(e.description),e.deprecated&&`@deprecated`],isReadOnly:e.isReadOnly,isRequired:n===``,name:i,type:r}});return F.typeInterfaceNode({isNullable:e.isNullable,properties:n,useLegacyResolution:!0})},Ds=e=>{switch(e.export){case`all-of`:return Ts({model:e,style:`intersection`});case`any-of`:case`one-of`:return Ts({model:e,style:`union`});case`array`:return Ss(e);case`dictionary`:return ws(e);case`enum`:return Cs(e);case`interface`:return Es(e);case`const`:case`generic`:case`reference`:default:return xs(e)}},Os=({client:e,count:t=1,create:n=!1,meta:r,nameTransformer:i})=>{let a={created:!1,name:``},o=r.name;i&&(o=i(o)),t>1&&(o=`${o}${t}`);let s=e.types[o];return s?a=s.$ref===r.$ref?{created:!1,name:o}:Os({client:e,count:t+1,create:n,meta:r,nameTransformer:i}):n&&(e.types[o]=r,a={created:!0,name:o}),a},ks=({client:e,name:t})=>{let n={deleted:!1,name:``};return e.types[t]?(delete e.types[t],n={deleted:!0,name:t},n):n},As=e=>S(x())?w({case:`camelCase`,value:ur(e)}).replace(pt,`_$1`):e,js=e=>{let t=e.find(e=>e.in===`header`);return t?t.name:null},Ms=e=>e.some(e=>e.isRequired),Ns=e=>{if(e===`default`)return`default`;if(e===`1XX`)return`1XX`;if(e===`2XX`)return`2XX`;if(e===`3XX`)return`3XX`;if(e===`4XX`)return`4XX`;if(e===`5XX`)return`5XX`;if(/\d{3}/g.test(e)){let t=Number.parseInt(e,10);if(t>=100&&t<600)return t}return null},Ps=(e,t)=>e.code>t.code?1:e.code<t.code?-1:0,Fs=e=>e===`3XX`||e===`4XX`||e===`5XX`||typeof e==`number`&&e>=300,Is=e=>e===`2XX`||typeof e==`number`&&e>=200&&e<300,Ls=(e,t)=>{let n=[],r=e=>{n.includes(e)||(n=[...n,e])};t.some(({code:e})=>Is(e))||r(`success`);let i=(e.description??``).toLocaleLowerCase(),a=e.$refs.join(`|`).toLocaleLowerCase();return[`success`].some(e=>i.includes(e)||a.includes(e))&&r(`success`),[`error`,`problem`].some(e=>i.includes(e)||a.includes(e))&&r(`error`),n.length||r(`error`),n},Rs=({config:e,operationKey:t})=>{let n=e.plugins[`@hey-api/sdk`]?.config.filter?new RegExp(e.plugins[`@hey-api/sdk`]?.config.filter):void 0;return!n||n.test(t)},zs=({config:e,method:t,operationId:n,path:r})=>{if(e.plugins[`@hey-api/sdk`]?.config.operationId&&n)return w({case:`camelCase`,value:lr(n)});let i=r;return S(e)&&(i=i.replace(/[^/]*?{api-version}.*?\//g,``)),i=i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`),w({case:`camelCase`,value:`${t}-${i}`})},Bs=e=>!S(x())||e.prop!==`api-version`,Vs=e=>S(x())?As(e.prop):e.prop,Hs=e=>e.map(t=>{let{code:n}=t;return n===`default`?t.responseTypes=Ls(t,e):Is(n)?t.responseTypes=[`success`]:Fs(n)&&(t.responseTypes=[`error`]),t}),G=(e,t)=>{if(e.default===void 0||e.default===null)return e.default;switch(Uo(e).find(e=>e!==`null`)||typeof e.default){case`int`:case`integer`:case`number`:if(t?.export===`enum`&&t.enum?.[e.default]){let{value:n}=t.enum[e.default];return n}return e.default;case`array`:case`boolean`:case`object`:case`string`:return e.default;default:return}},Us=({openApi:e,parameter:t,types:n})=>{let r={$refs:[],base:`unknown`,description:t.description||null,enum:[],enums:[],exclusiveMaximum:t.exclusiveMaximum,exclusiveMinimum:t.exclusiveMinimum,export:`interface`,format:t.format,imports:[],in:t.in,isDefinition:!1,isNullable:t[`x-nullable`]===!0,isReadOnly:!1,isRequired:t.required===!0,link:null,maxItems:t.maxItems,maxLength:t.maxLength,maximum:t.maximum,mediaType:null,minItems:t.minItems,minLength:t.minLength,minimum:t.minimum,multipleOf:t.multipleOf,pattern:es(t.pattern),prop:t.name,properties:[],template:null,type:`unknown`,uniqueItems:t.uniqueItems},i={...r,name:Vs(r)};if(t.$ref){let e=W({type:t.$ref});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`reference`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(t,i),i}if(t.enum){let e=$o(t,t.enum);if(e.length)return i={...i,base:`string`,enum:[...i.enum,...e],export:`enum`,type:`string`},i.default=G(t,i),i}if(t.type===`array`&&t.items){let e=W({format:t.items.format,type:t.items.type});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`array`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(t,i),i}if(t.type===`object`&&t.items){let e=W({format:t.items.format,type:t.items.type});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`dictionary`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(t,i),i}let a=t.schema;if(a){if(a.$ref?.startsWith(`#/parameters/`)&&(a=is(e,a)),a.$ref){let e=W({type:a.$ref});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`reference`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(t,i),i}let r=ss({definition:a,openApi:e,types:n});return i={...i,$refs:[...i.$refs,...r.$refs],base:r.base,enum:[...i.enum,...r.enum],enums:[...i.enums,...r.enums],export:r.export,imports:[...i.imports,...r.imports],link:r.link,properties:[...i.properties,...r.properties],template:r.template,type:r.type},i.default=G(t,i),i}if(t.type){let e=W({format:t.format,type:t.type});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`generic`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(t,i),i}return i},Ws=[`body`,`formData`,`header`,`path`,`query`],Gs=({openApi:e,parameters:t,types:n})=>{let r={$refs:[],imports:[],parameters:[],parametersBody:null,parametersCookie:[],parametersForm:[],parametersHeader:[],parametersPath:[],parametersQuery:[]};return t.forEach(t=>{let i=is(e,t),a=Us({openApi:e,parameter:i,types:n}),o=!Bs(a);if(!(!Ws.includes(i.in)||o)){switch(i.in){case`body`:r.parametersBody=a;break;case`formData`:r.parametersForm=[...r.parametersForm,a];break;case`header`:r.parametersHeader=[...r.parametersHeader,a];break;case`path`:r.parametersPath=[...r.parametersPath,a];break;case`query`:r.parametersQuery=[...r.parametersQuery,a];break}r.$refs=[...r.$refs,...a.$refs],r.imports=[...r.imports,...a.imports],r.parameters=[...r.parameters,a]}}),r};function Ks(e){return e.sort((e,t)=>{let n=e.isRequired&&e.default===void 0,r=t.isRequired&&t.default===void 0;return n&&!r?-1:r&&!n?1:0})}const qs=({code:e,openApi:t,response:n,types:r})=>{let i={$refs:[],base:e===204?`void`:`unknown`,code:e,description:n.description||null,enum:[],enums:[],export:`generic`,imports:[],in:`response`,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:``,properties:[],responseTypes:[],template:null,type:e===204?`void`:`unknown`},a=n.schema;if(a){if(a.$ref?.startsWith(`#/responses/`)&&(a=is(t,a)),a.$ref){let e=W({type:a.$ref});return i.export=`reference`,i.type=e.type,i.base=e.base,i.template=e.template,i.imports=[...i.imports,...e.imports],i}let e=ss({definition:a,openApi:t,types:r});return i.export=e.export,i.type=e.type,i.base=e.base,i.template=e.template,i.link=e.link,i.isReadOnly=e.isReadOnly,i.isRequired=e.isRequired,i.isNullable=e.isNullable,i.format=e.format,i.maximum=e.maximum,i.exclusiveMaximum=e.exclusiveMaximum,i.minimum=e.minimum,i.exclusiveMinimum=e.exclusiveMinimum,i.multipleOf=e.multipleOf,i.maxLength=e.maxLength,i.minLength=e.minLength,i.maxItems=e.maxItems,i.minItems=e.minItems,i.uniqueItems=e.uniqueItems,i.maxProperties=e.maxProperties,i.minProperties=e.minProperties,i.pattern=es(e.pattern),i.imports=[...i.imports,...e.imports],i.enum=[...i.enum,...e.enum],i.enums=[...i.enums,...e.enums],i.properties=[...i.properties,...e.properties],i}if(n.headers)for(let e in n.headers)return i.in=`header`,i.name=e,i.type=`string`,i.base=`string`,i;return i},Js=({openApi:e,responses:t,types:n})=>{let r=[];return Object.entries(t).forEach(([t,i])=>{let a=Ns(t);if(!a)return;let o=qs({code:a,openApi:e,response:is(e,i),types:n});r=[...r,o]}),r=Hs(r),r.sort(Ps)},Ys=({method:e,op:t,openApi:n,pathParams:r,types:i,url:a})=>{let o={$refs:[],deprecated:t.deprecated===!0,description:t.description||null,id:t.operationId||null,imports:[],method:e.toUpperCase(),parameters:[...r.parameters],parametersBody:r.parametersBody,parametersCookie:[...r.parametersCookie],parametersForm:[...r.parametersForm],parametersHeader:[...r.parametersHeader],parametersPath:[...r.parametersPath],parametersQuery:[...r.parametersQuery],path:a,responseHeader:null,responses:[],summary:t.summary||null,tags:t.tags||null},s={...o,name:zs({config:x(),method:o.method,operationId:t.operationId,path:o.path})};if(t.parameters){let e=Gs({openApi:n,parameters:t.parameters,types:i});s.$refs=[...s.$refs,...e.$refs],s.imports=[...s.imports,...e.imports],s.parameters=[...s.parameters,...e.parameters],s.parametersBody=e.parametersBody,s.parametersCookie=[...s.parametersCookie,...e.parametersCookie],s.parametersForm=[...s.parametersForm,...e.parametersForm],s.parametersHeader=[...s.parametersHeader,...e.parametersHeader],s.parametersPath=[...s.parametersPath,...e.parametersPath],s.parametersQuery=[...s.parametersQuery,...e.parametersQuery]}if(t.responses){s.responses=Js({openApi:n,responses:t.responses,types:i});let e=s.responses.filter(e=>e.responseTypes.includes(`success`));s.responseHeader=js(e),e.forEach(e=>{s.$refs=[...s.$refs,...e.$refs],s.imports=[...s.imports,...e.imports]})}return s.parameters=Ks(s.parameters),s},Xs=({openApi:e,types:t})=>{let n=new Map,r=[],i=x();for(let a in e.paths){let o=e.paths[a],s=Gs({openApi:e,parameters:o.parameters??[],types:t});for(let c in o){let l=c,u=O({method:l,path:a});if(Ro.includes(l)){let c=o[l];if(c.operationId&&(n.has(c.operationId)?i.logs.level!==`silent`&&console.warn(`❗️ Duplicate operationId: ${c.operationId} in ${u}. Please ensure your operation IDs are unique. This behavior is not supported and will likely lead to unexpected results.`):n.set(c.operationId,u)),Rs({config:i,operationKey:u})){let n=Ys({method:l,op:c,openApi:e,pathParams:s,types:t,url:a});r.push(n)}}}}return r},Zs=e=>{let t=e.schemes?.[0]||`http`,n=e.host,r=e.basePath||``;return(n?`${t}://${n}${r}`:r).replace(/\/$/g,``)},Qs=e=>{let t=zo(e.info.version),n=Zs(e),{models:r,types:i}=cs(e);return{models:r,operations:Xs({openApi:e,types:i}),server:n,types:i,version:t}},$s=e=>{let t={};for(let n in e)t[e[n]]=n;return t},ec=(e,t)=>{if(e.components&&t){for(let n in e.components.schemas)if(e.components.schemas.hasOwnProperty(n)){let r=e.components.schemas[n];if(r.discriminator&&r.oneOf?.length&&r.oneOf.some(e=>e.$ref&&Yo(e.$ref)==t.name))return r.discriminator}}},tc=(e,t)=>{if(e.mapping){let n=$s(e.mapping),r=Object.keys(n).find(e=>Yo(e)==t.name);if(r&&n[r])return n[r]}return t.name},nc=({debug:e,definition:t,getModel:n,model:r,openApi:i,types:a})=>{let o=typeof t.additionalProperties==`object`?t.additionalProperties:{},s=n({debug:e,definition:o,openApi:i,parentDefinition:t,types:a});if(o.$ref){let e=W({type:o.$ref});return r.base=e.base,r.default=G(t,r),r.export=`dictionary`,r.imports.push(...e.imports),r.template=e.template,r.type=e.type,r}return t.additionalProperties&&t.properties&&Object.keys(t.properties).length>0?(s.base=[W({type:typeof t.additionalProperties==`object`&&t.additionalProperties.type&&!Array.isArray(t.additionalProperties.type)?t.additionalProperties.type:s.base}).base,...r.properties.map(e=>e.base)].filter(Qo).join(` | `),s.default=G(t,r),s.export=`generic`,s.isRequired=t.additionalProperties===!0,s.name=`[key: string]`,s):(r.base=s.base,r.default=G(t,r),r.export=`dictionary`,r.imports.push(...s.imports),r.link=s,r.template=s.template,r.type=s.type,r)},rc=({debug:e,definition:t,getModel:n,openApi:r,parent:i,types:a})=>{let o=[],s=ec(r,i);return Object.entries(t.properties??{}).forEach(([c,l])=>{let u=!!t.required?.includes(c),d={default:l.default,deprecated:l.deprecated===!0,description:l.description||null,exclusiveMaximum:l.exclusiveMaximum,exclusiveMinimum:l.exclusiveMinimum,format:l.type===`array`?l.items?.format??l.format:l.format,in:``,isDefinition:!1,isReadOnly:l.readOnly===!0,isRequired:u,maxItems:l.maxItems,maxLength:l.maxLength,maxProperties:l.maxProperties,maximum:l.maximum,minItems:l.minItems,minLength:l.minLength,minProperties:l.minProperties,minimum:l.minimum,multipleOf:l.multipleOf,name:yt(c),pattern:es(l.pattern),uniqueItems:l.uniqueItems};if(i&&s?.propertyName==c){o=[...o,{...d,$refs:[],base:`'${tc(s,i)}'`,enum:[],enums:[],export:`reference`,imports:[],isNullable:Ho(l),link:null,properties:[],template:null,type:`string`}];return}if(l.$ref){let e=W({type:l.$ref});o=[...o,{...d,$refs:e.$refs,base:e.base,enum:[],enums:[],export:`reference`,imports:e.imports,isNullable:e.isNullable||Ho(l),link:null,properties:[],template:e.template,type:e.type}];return}let f=n({debug:e,definition:l,initialValues:d,openApi:r,parentDefinition:t,types:a});f.isNullable=f.isNullable||Ho(l),o=[...o,f]}),o},ic=({debug:e,definitions:t,getModel:n,openApi:r,required:i,types:a})=>t.reduce((t,i)=>{if(i.$ref){let o=W({type:i.$ref}),s={$ref:i.$ref,name:o.base};a[o.base]=s;let c=is(r,i);return[...t,...n({debug:e,definition:c,meta:s,openApi:r,types:a}).properties]}return[...t,...n({debug:e,definition:i,openApi:r,parentDefinition:i,types:a}).properties]},[]).filter(e=>!e.isRequired&&i.includes(e.name)).map(e=>({...e,isRequired:!0})),ac=e=>[{definitions:e.allOf,type:`all-of`},{definitions:e.anyOf,type:`any-of`},{definitions:e.oneOf,type:`one-of`}].find(e=>e.definitions?.length),oc=({debug:e,definition:t,definitions:n,getModel:r,model:i,openApi:a,type:o,types:s})=>{let c={$refs:i.$refs,enums:i.enums,export:o,imports:i.imports,properties:i.properties},l=[];if(n.map(n=>r({debug:e,definition:n,openApi:a,parentDefinition:t,types:s})).forEach(e=>{c.$refs=[...c.$refs,...e.$refs],c.imports=[...c.imports,...e.imports],c.enums=[...c.enums,...e.enums],c.properties=[...c.properties,e]}),t.required&&o===`all-of`){let i=ic({debug:e,definitions:n,getModel:r,openApi:a,required:t.required,types:s});i.forEach(e=>{c.$refs=[...c.$refs,...e.$refs],c.imports=[...c.imports,...e.imports],c.enums=[...c.enums,...e.enums]}),l=[...l,...i]}if(t.properties){let e=rc({definition:t,getModel:r,openApi:a,types:s});e.forEach(e=>{c.$refs=[...c.$refs,...e.$refs],c.imports=[...c.imports,...e.imports],c.enums=[...c.enums,...e.enums],e.export===`enum`&&(c.enums=[...c.enums,e])}),l=[...l,...e]}if(l.length){let e=ac(t);if(e){let t={$refs:[],base:`unknown`,description:``,enum:[],enums:[],export:`interface`,imports:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:`properties`,properties:l,template:null,type:`unknown`};e.type===`one-of`?(c.properties=[{...c,base:``,description:null,enum:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!0,link:null,name:``,template:null,type:``},t],c.export=`all-of`):c.properties=[...c.properties,t]}}return c},K=({debug:e,definition:t,initialValues:n={},isDefinition:r=!1,meta:i,openApi:a,parentDefinition:o=null,types:s})=>{let c=Uo(t),l=Bo(t,c),u={$refs:[],base:`unknown`,deprecated:!!t.deprecated,description:t.description||null,enum:[],enums:[],exclusiveMaximum:t.exclusiveMaximum,exclusiveMinimum:t.exclusiveMinimum,export:`interface`,format:t.format,imports:[],in:``,isDefinition:r,isNullable:Ho(t),isReadOnly:t.readOnly===!0,isRequired:!1,link:null,maxItems:t.maxItems,maxLength:t.maxLength,maxProperties:t.maxProperties,maximum:t.maximum,meta:i,minItems:t.minItems,minLength:t.minLength,minProperties:t.minProperties,minimum:t.minimum,multipleOf:t.multipleOf,name:i?.name??``,pattern:es(t.pattern),properties:[],template:null,type:`unknown`,uniqueItems:t.uniqueItems,...n};if(t.$ref){let n=W({debug:e,type:t.$ref});return u.$refs=[...u.$refs,decodeURIComponent(t.$ref)],u.base=n.base,u.export=`reference`,u.imports=[...u.imports,...n.imports],u.template=n.template,u.type=n.type,u.default=G(t,u),u}if(l===`enum`){let e=$o(t,t.enum);if(e.length)return u.base=`string`,u.enum=[...u.enum,...e],u.export=`enum`,u.type=`string`,u.default=G(t,u),u.meta||=gs(u),u}if(c.includes(`array`)&&(t.items||t.prefixItems)){if(t.prefixItems){let e=t.prefixItems.map(e=>K({definition:e,openApi:a,parentDefinition:t,types:s}));return u.export=`array`,u.$refs=[...u.$refs,...e.reduce((e,t)=>[...e,...t.$refs],[])],u.imports=[...u.imports,...e.reduce((e,t)=>[...e,...t.imports],[])],u.link=e,u.default=G(t,u),u}if(!t.items)return u;if(t.items.$ref){let e=W({type:t.items.$ref});return u.$refs=[...u.$refs,decodeURIComponent(t.items.$ref)],u.base=e.base,u.export=`array`,u.imports=[...u.imports,...e.imports],u.template=e.template,u.type=e.type,u.default=G(t,u),u}if(t.items.anyOf&&o&&o.type){let e=ac(o);if(e&&e.definitions.some(e=>!Uo(e).includes(`array`)))return K({definition:t.items,openApi:a,parentDefinition:t,types:s})}let e=K({definition:Array.isArray(t.items)?{anyOf:t.items}:t.items,openApi:a,parentDefinition:t,types:s});return u.base=e.base,u.export=`array`,u.$refs=[...u.$refs,...e.$refs],u.imports=[...u.imports,...e.imports],u.link=e,u.template=e.template,u.type=e.type,u.default=G(t,u),u}let d=ac(t);if(d){let n=oc({...d,debug:e,definition:t,getModel:K,model:u,openApi:a,types:s});return{...u,...n}}if(c.includes(`object`)||t.properties||t.additionalProperties){if(t.properties&&(Object.keys(t.properties).length>0||!t.additionalProperties)){if(u.base=`unknown`,u.export=`interface`,u.type=`unknown`,u.default=G(t,u),rc({debug:e,definition:t,getModel:K,openApi:a,parent:u,types:s}).forEach(e=>{u.$refs=[...u.$refs,...e.$refs],u.enums=[...u.enums,...e.enums],u.imports=[...u.imports,...e.imports],u.properties=[...u.properties,e],e.export===`enum`&&(u.enums=[...u.enums,e])}),t.additionalProperties){let n=nc({debug:e,definition:t,getModel:K,model:u,openApi:a,types:s});u.properties=[...u.properties,n]}return!u.properties.length&&u.base===`unknown`&&u.type===`unknown`&&(u.export=`dictionary`,u.name||=`[key: string]`),u}return nc({debug:e,definition:t,getModel:K,model:u,openApi:a,types:s})}if(t.const!==void 0){let e=t.const,n=typeof e==`string`?`"${e}"`:`${e}`;return u.base=n,u.export=`const`,u.type=n,u}if(c.length){let e=W({format:t.format,type:t.type});return u.base=e.base,u.export=`generic`,u.$refs=[...u.$refs,...e.$refs],u.imports=[...u.imports,...e.imports],u.isNullable=e.isNullable||u.isNullable,u.template=e.template,u.type=e.type,u.default=G(t,u),u}return u},sc=e=>{if(e.schema)return e.schema;if(e.content){let t=Object.entries(e.content);for(let[n,r]of t)if(r.schema){let t=n;return e.content[t].schema}}},cc=e=>{let t={},n=[];return e.components?(Object.entries(e.components.schemas??{}).forEach(([r,i])=>{let a=vs(r);t[a.name]=a;let o=K({definition:i,isDefinition:!0,meta:a,openApi:e,types:t});n=[...n,o]}),Object.entries(e.components.parameters??{}).forEach(([r,i])=>{let a=sc(i);if(!a)return;let o=_s(r);t[o.name]=o;let s=K({definition:a,isDefinition:!0,meta:o,openApi:e,types:t});s.deprecated=i.deprecated,s.description=i.description||null,n=[...n,s]}),{models:n,types:t}):{models:n,types:t}},lc=({openApi:e,parameter:t,types:n})=>{let r={$refs:[],base:`unknown`,deprecated:t.deprecated===!0,description:t.description||null,enum:[],enums:[],export:`interface`,imports:[],in:t.in,isDefinition:!1,isNullable:Ho(t),isReadOnly:!1,isRequired:t.required===!0,link:null,mediaType:null,prop:t.name,properties:[],template:null,type:`unknown`},i={...r,name:Vs(r)};if(t.$ref){let e=W({type:t.$ref});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`reference`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i}let a=sc(t);if(a){if(a.$ref?.startsWith(Wo)&&(a=is(e,a)),a.$ref){let e=W({type:a.$ref});return i={...i,$refs:[...i.$refs,...e.$refs],base:e.base,export:`reference`,imports:[...i.imports,...e.imports],template:e.template,type:e.type},i.default=G(a),i}let t=K({definition:a,openApi:e,types:n});return i={...i,$refs:[...i.$refs,...t.$refs],base:t.base,enum:[...i.enum,...t.enum],enums:[...i.enums,...t.enums],exclusiveMaximum:t.exclusiveMaximum,exclusiveMinimum:t.exclusiveMinimum,export:t.export,format:t.format,imports:[...i.imports,...t.imports],isNullable:i.isNullable||t.isNullable,isReadOnly:t.isReadOnly,isRequired:i.isRequired||t.isRequired,link:t.link,maxItems:t.maxItems,maxLength:t.maxLength,maxProperties:t.maxProperties,maximum:t.maximum,minItems:t.minItems,minLength:t.minLength,minProperties:t.minProperties,minimum:t.minimum,multipleOf:t.multipleOf,pattern:es(t.pattern),properties:[...i.properties,...t.properties],template:t.template,type:t.type,uniqueItems:t.uniqueItems},(i.enum.length||i.enums.length)&&!i.meta&&(i.meta=gs(i)),i.default=t.default,i}return i},uc=[`cookie`,`formData`,`header`,`path`,`query`],dc=({openApi:e,parameters:t,types:n})=>{let r={$refs:[],imports:[],parameters:[],parametersBody:null,parametersCookie:[],parametersForm:[],parametersHeader:[],parametersPath:[],parametersQuery:[]};return t.forEach(t=>{let i=is(e,t),a=lc({openApi:e,parameter:i,types:n}),o=!Bs(a);if(!(!uc.includes(i.in)||o)){switch(i.in){case`cookie`:r.parametersCookie=[...r.parametersCookie,a];break;case`formData`:r.parametersForm=[...r.parametersForm,a];break;case`header`:r.parametersHeader=[...r.parametersHeader,a];break;case`path`:r.parametersPath=[...r.parametersPath,a];break;case`query`:r.parametersQuery=[...r.parametersQuery,a];break}r.$refs=[...r.$refs,...a.$refs],r.imports=[...r.imports,...a.imports],r.parameters=[...r.parameters,a]}}),r},fc=[`application/json-patch+json`,`application/json`,`application/ld+json`,`application/x-www-form-urlencoded`,`multipart/batch`,`multipart/form-data`,`multipart/mixed`,`multipart/related`,`text/json`,`text/plain`],pc=(e,t)=>{let n=Object.keys(t).filter(e=>{let t=e.split(`;`)[0].trim();return fc.includes(t)}).find(e=>!!t[e]?.schema);if(n)return{mediaType:n,schema:t[n].schema};let r=Object.keys(t).find(e=>!!t[e]?.schema);if(r)return{mediaType:r,schema:t[r].schema}},mc=({body:e,debug:t,openApi:n,types:r})=>{let i=e[`x-body-name`]??`requestBody`,a={$refs:[],base:`unknown`,default:void 0,description:e.description||null,enum:[],enums:[],export:`interface`,imports:[],in:`body`,isDefinition:!1,isNullable:e.nullable===!0,isReadOnly:!1,isRequired:e.required===!0,link:null,mediaType:null,name:i,prop:i,properties:[],template:null,type:`unknown`};if(!e.content)return a;let o=pc(n,e.content);if(!o)return a;switch(a.mediaType=o.mediaType,a.mediaType){case`application/x-www-form-urlencoded`:case`multipart/form-data`:a.in=`formData`,a.name=`formData`,a.prop=`formData`;break}if(o.schema.$ref){let e=W({type:o.schema.$ref});return a.export=`reference`,a.type=e.type,a.base=e.base,a.template=e.template,a.$refs=[...a.$refs,...e.$refs],a.imports=[...a.imports,...e.imports],a}let s=K({debug:t,definition:o.schema,openApi:n,types:r});return a.$refs=[...a.$refs,...s.$refs],a.base=s.base,a.enum=[...a.enum,...s.enum],a.enums=[...a.enums,...s.enums],a.exclusiveMaximum=s.exclusiveMaximum,a.exclusiveMinimum=s.exclusiveMinimum,a.export=s.export,a.format=s.format,a.imports=[...a.imports,...s.imports],a.isNullable=a.isNullable||s.isNullable,a.isReadOnly=s.isReadOnly,a.isRequired=a.isRequired||s.isRequired,a.link=s.link,a.maximum=s.maximum,a.maxItems=s.maxItems,a.maxLength=s.maxLength,a.maxProperties=s.maxProperties,a.minimum=s.minimum,a.minItems=s.minItems,a.minLength=s.minLength,a.minProperties=s.minProperties,a.multipleOf=s.multipleOf,a.pattern=es(s.pattern),a.properties=[...a.properties,...s.properties],a.template=s.template,a.type=s.type,a.uniqueItems=s.uniqueItems,a},hc=({code:e,openApi:t,response:n,types:r})=>{let i={$refs:[],base:e===204?`void`:`unknown`,code:e,description:n.description||null,enum:[],enums:[],export:`generic`,imports:[],in:`response`,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:``,properties:[],responseTypes:[],template:null,type:e===204?`void`:`unknown`};if(n.content){let e=pc(t,n.content);if(e){if(e.schema.$ref?.startsWith(`#/components/responses/`)&&(e.schema=is(t,e.schema)),e.schema.$ref){let t=W({type:e.schema.$ref});return i.base=t.base,i.export=`reference`,i.$refs=[...i.$refs,...t.$refs],i.imports=[...i.imports,...t.imports],i.template=t.template,i.type=t.type,i}let n=K({definition:e.schema,openApi:t,types:r});return i.export=n.export,i.type=n.type,i.base=n.base,i.template=n.template,i.link=n.link,i.isReadOnly=n.isReadOnly,i.isRequired=n.isRequired,i.isNullable=n.isNullable,i.format=n.format,i.maximum=n.maximum,i.exclusiveMaximum=n.exclusiveMaximum,i.minimum=n.minimum,i.exclusiveMinimum=n.exclusiveMinimum,i.multipleOf=n.multipleOf,i.maxLength=n.maxLength,i.minLength=n.minLength,i.maxItems=n.maxItems,i.minItems=n.minItems,i.uniqueItems=n.uniqueItems,i.maxProperties=n.maxProperties,i.minProperties=n.minProperties,i.pattern=es(n.pattern),i.$refs=[...i.$refs,...n.$refs],i.imports=[...i.imports,...n.imports],i.enum=[...i.enum,...n.enum],i.enums=[...i.enums,...n.enums],i.properties=[...i.properties,...n.properties],i}}if(n.headers)for(let e in n.headers)return i.in=`header`,i.name=e,i.type=`string`,i.base=`string`,i;return i},gc=({openApi:e,responses:t,types:n})=>{let r=[];return Object.entries(t).forEach(([t,i])=>{let a=Ns(t);if(!a)return;let o=hc({code:a,openApi:e,response:is(e,i),types:n});r=[...r,o]}),r=Hs(r),r.sort(Ps)},_c=(e,t)=>{let n=[...e],r=[...t];for(;r.length>0;){let e=r[0];r=r.slice(1),n.every(t=>t.in!==e.in||t.name!==e.name)&&(n=[...n,e])}return n},vc=({debug:e,method:t,op:n,openApi:r,pathParams:i,types:a,url:o})=>{let s={$refs:[],deprecated:!!n.deprecated,description:n.description||null,id:n.operationId||null,imports:[],method:t.toUpperCase(),parameters:[],parametersBody:i.parametersBody,parametersCookie:[],parametersForm:[],parametersHeader:[],parametersPath:[],parametersQuery:[],path:o,responseHeader:null,responses:[],summary:n.summary||null,tags:n.tags||null},c={...s,name:zs({config:x(),method:s.method,operationId:n.operationId,path:s.path})};if(n.parameters){let e=dc({openApi:r,parameters:n.parameters,types:a});c.$refs=[...c.$refs,...e.$refs],c.imports=[...c.imports,...e.imports],c.parameters=[...c.parameters,...e.parameters],c.parametersBody=e.parametersBody,c.parametersCookie=[...c.parametersCookie,...e.parametersCookie],c.parametersForm=[...c.parametersForm,...e.parametersForm],c.parametersHeader=[...c.parametersHeader,...e.parametersHeader],c.parametersPath=[...c.parametersPath,...e.parametersPath],c.parametersQuery=[...c.parametersQuery,...e.parametersQuery]}if(n.requestBody){let t=mc({body:is(r,n.requestBody),debug:e,openApi:r,types:a});c.$refs=[...c.$refs,...t.$refs],c.imports=[...c.imports,...t.imports],c.parameters=[...c.parameters,t],c.parametersBody=t}if(n.responses){c.responses=gc({openApi:r,responses:n.responses,types:a});let e=c.responses.filter(e=>e.responseTypes.includes(`success`));c.responseHeader=js(e),e.forEach(e=>{c.$refs=[...c.$refs,...e.$refs],c.imports=[...c.imports,...e.imports]})}return c.parameters=_c(c.parameters,i.parameters),c.parametersCookie=_c(c.parametersCookie,i.parametersCookie),c.parametersForm=_c(c.parametersForm,i.parametersForm),c.parametersHeader=_c(c.parametersHeader,i.parametersHeader),c.parametersPath=_c(c.parametersPath,i.parametersPath),c.parametersQuery=_c(c.parametersQuery,i.parametersQuery),c.parameters=Ks(c.parameters),c},yc=({openApi:e,types:t})=>{let n=new Map,r=[],i=x();for(let a in e.paths){let o=e.paths[a],s=dc({openApi:e,parameters:o.parameters??[],types:t});for(let c in o){let l=c,u=O({method:l,path:a});if(Ro.includes(l)){let c=o[l];if(c.operationId&&(n.has(c.operationId)?i.logs.level!==`silent`&&console.warn(`❗️ Duplicate operationId: ${c.operationId} in ${u}. Please ensure your operation IDs are unique. This behavior is not supported and will likely lead to unexpected results.`):n.set(c.operationId,u)),Rs({config:i,operationKey:u})){let n=vc({method:l,op:c,openApi:e,pathParams:s,types:t,url:a});r.push(n)}}}}return r},bc=e=>{let t=e.servers?.[0],n=t?.variables||{},r=t?.url||``;return Object.entries(n).forEach(([e,t])=>{r=r.replace(`{${e}}`,t.default)}),r.replace(/\/$/g,``)},xc=e=>{let t=zo(e.info.version),n=bc(e),{models:r,types:i}=cc(e);return{models:r,operations:yc({openApi:e,types:i}),server:n,types:i,version:t}};function Sc({openApi:e}){let t=e;if(`openapi`in t)return xc(t);if(`swagger`in t)return Qs(t);throw Error(`Unsupported OpenAPI specification: ${JSON.stringify(t,null,2)}`)}const Cc=({config:e,dependencies:t,logger:n,spec:r})=>{let i=new sr({config:e,dependencies:t,logger:n,spec:r});if(`swagger`in i.spec)return la(i),i;if(ct(i.spec.openapi,`>=3.0.0 <3.1.0`))return Ja(i),i;if(ct(i.spec.openapi,`>=3.1.0`))return Lo(i),i;throw Error(`Unsupported OpenAPI specification`)},wc=({securitySchemeObject:e})=>{if(e.type===`openIdConnect`)return{scheme:`bearer`,type:`http`};if(e.type===`oauth2`)return e.flows.password||e.flows.authorizationCode||e.flows.clientCredentials||e.flows.implicit?{scheme:`bearer`,type:`http`}:void 0;if(e.type===`apiKey`)return e.in===`header`?{name:e.name,type:`apiKey`}:e.in===`query`||e.in==`cookie`?{in:e.in,name:e.name,type:`apiKey`}:void 0;if(e.type===`http`){let t=e.scheme.toLowerCase();return t===`bearer`||t===`basic`?{scheme:t,type:`http`}:void 0}},Tc=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return[];let n=[];for(let t of e.security){let e=wc({securitySchemeObject:t});e?n.push(e):console.warn(`❗️ SDK warning: unsupported security scheme. Please open an issue if you'd like it added https://github.com/hey-api/openapi-ts/issues\n${JSON.stringify(t,null,2)}`)}return n},Ec=`TComposable`,Dc=`DefaultT`,Oc=`ResT`,kc=({operation:e,plugin:t})=>{if(!t.config.validator.request)return;let n=t.getPluginOrThrow(t.config.validator.request);if(n.api.createRequestValidator)return n.api.createRequestValidator({operation:e,plugin:n})},Ac=({operation:e,plugin:t})=>{if(!t.config.validator.response)return;let n=t.getPluginOrThrow(t.config.validator.response);if(n.api.createResponseValidator)return n.api.createResponseValidator({operation:e,plugin:n})},jc=({context:e,value:t})=>{let n=w({case:`PascalCase`,value:lr(t)});return Ko({config:e.config,name:n})},Mc=({operation:e,plugin:t})=>t.config.methodNameBuilder?t.config.methodNameBuilder(e):!t.config.asClass&&e.id.match(pt)?`${e.id}_`:e.id,Nc=({context:e,operation:t,plugin:n})=>{let r=new Map,i,a,o=[];n.config.classStructure===`auto`&&t.operationId&&(o=t.operationId.split(/[./]/).filter(Boolean),o.length>1&&(a=w({case:`camelCase`,value:lr(o.pop())}),i=o.pop()));let s=n.config.instance?[n.config.instance]:t.tags??[`default`];for(let c of s){let s=jc({context:e,value:i||c}),l=[c];i&&(l=o.includes(c)||c===i?[...o,i]:[c,...o,i]),r.set(c,{className:s,methodName:a||Mc({operation:t,plugin:n}),path:l.map(t=>jc({context:e,value:t}))})}return r},Pc=({operation:e,plugin:t,throwOnError:n})=>{let r=b(t.context.config).name===`@hey-api/client-nuxt`,i=t.getPluginOrThrow(`@hey-api/typescript`),a=t.getSymbol(i.api.selector(`data`,e.id)),o=a?.placeholder||`unknown`,s=t.referenceSymbol(t.api.selector(`Options`));if(r){let n=t.getSymbol(i.api.selector(`response`,e.id))?.placeholder||`unknown`;return`${s.placeholder}<${Ec}, ${o}, ${n}, ${Dc}>`}return n?`${s.placeholder}<${o}, ${n}>`:a?`${s.placeholder}<${a.placeholder}>`:s.placeholder},Fc=({isRequiredOptions:e,operation:t,plugin:n})=>{let r={argNames:[],fields:[],parameters:[]},i=n.getPluginOrThrow(`@hey-api/typescript`),a=b(n.context.config).name===`@hey-api/client-nuxt`;if(n.config.params_EXPERIMENTAL===`experiment`){if(t.parameters?.path)for(let e in t.parameters.path){let n=t.parameters.path[e],a=vt(n.name);r.argNames.push(a),r.fields.push({in:`path`,key:a}),r.parameters.push({isRequired:n.required,name:a,type:i.api.schemaToType({plugin:i,schema:n.schema})})}if(t.parameters?.query)for(let e in t.parameters.query){let n=t.parameters.query[e],a=vt(n.name);r.argNames.push(a),r.fields.push({in:`path`,key:a}),r.parameters.push({isRequired:n.required,name:a,type:i.api.schemaToType({plugin:i,schema:n.schema})})}if(t.body){let e=`body`;r.argNames.push(e),r.fields.push({in:`body`}),r.parameters.push({isRequired:t.body.required,name:e,type:i.api.schemaToType({plugin:i,schema:t.body.schema})})}}return r.parameters.push({isRequired:e,name:`options`,type:Pc({operation:t,plugin:n,throwOnError:a?void 0:`ThrowOnError`})}),r},Ic=e=>{if(!e)return;let t=e.split(`;`)[0]?.trim();if(t){if(t.startsWith(`application/json`)||t.endsWith(`+json`))return`json`;if([`application/`,`audio/`,`image/`,`video/`].some(e=>t.startsWith(e)))return`blob`;if(t.startsWith(`text/`))return`text`}},Lc=({isRequiredOptions:e,opParameters:t,operation:n,plugin:r})=>{let i=b(r.context.config),a=i.name===`@hey-api/client-nuxt`,o=r.getPluginOrThrow(`@hey-api/typescript`),s=r.getSymbol(o.api.selector(a?`response`:`responses`,n.id))?.placeholder||`unknown`,c=r.getSymbol(o.api.selector(a?`error`:`errors`,n.id))?.placeholder||`unknown`,l=[];if(n.body)switch(n.body.type){case`form-data`:{let e=r.referenceSymbol(r.api.selector(`formDataBodySerializer`));l.push({spread:e.placeholder});break}case`json`:break;case`text`:case`octet-stream`:l.push({key:`bodySerializer`,value:null});break;case`url-search-params`:{let e=r.referenceSymbol(r.api.selector(`urlSearchParamsBodySerializer`));l.push({spread:e.placeholder});break}}for(let e in n.parameters?.query){let t=n.parameters.query[e];if((t.schema.type===`array`||t.schema.type===`tuple`)&&(t.style!==`form`||!t.explode)){l.push({key:`querySerializer`,value:[{key:`array`,value:[{key:`explode`,value:!1},{key:`style`,value:`form`}]}]});break}}let u=kc({operation:n,plugin:r});if(u&&l.push({key:`requestValidator`,value:u}),r.config.transformer===`@hey-api/transformers`){let e=r.getPluginOrThrow(r.config.transformer),t=r.getSymbol(e.api.selector(`response`,n.id));t&&r.getSymbolValue(t)&&l.push({key:`responseTransformer`,value:t.placeholder})}let d=!1,f;for(let e in n.responses){let t=n.responses[e];!f&&i.name===`@hey-api/client-axios`&&ot({statusCode:e})===`2XX`&&(f=Ic(t.mediaType),f&&l.push({key:`responseType`,value:f})),t.mediaType===`text/event-stream`&&(d=!0)}let p=Ac({operation:n,plugin:r});p&&l.push({key:`responseValidator`,value:p}),r.config.responseStyle===`data`&&l.push({key:`responseStyle`,value:r.config.responseStyle});let m=Tc({context:r.context,operation:n,plugin:r});m.length&&l.push({key:`security`,value:F.arrayLiteralExpression({elements:m})}),l.push({key:`url`,value:n.path}),l.push({spread:`options`});let h=[],g=t.argNames.length;if(g){let e=[],n=[];for(let n of t.argNames)e.push(F.identifier({text:n}));for(let e of t.fields){let t=[];`in`in e&&(t.push({key:`in`,value:e.in}),e.key&&t.push({key:`key`,value:e.key}),e.map&&t.push({key:`map`,value:e.map})),n.push(F.objectExpression({obj:t}))}let i=r.referenceSymbol(r.api.selector(`buildClientParams`));h.push(F.constVariable({expression:F.callExpression({functionName:i.placeholder,parameters:[F.arrayLiteralExpression({elements:e}),F.arrayLiteralExpression({elements:n})]}),name:`params`})),l.push({spread:`params`})}if(n.body){let t=n.parameters?.header?.[`content-type`];if(!t?.required){let r=[{key:t?.name??`Content-Type`,value:n.body.type===`form-data`?null:n.body.mediaType},{spread:F.propertyAccessExpression({expression:F.identifier({text:`options`}),isOptional:!e,name:`headers`})}];g&&r.push({spread:F.propertyAccessExpression({expression:F.identifier({text:`params`}),name:`headers`})}),l.push({key:`headers`,value:r})}}let _=r.config.client&&i.api&&`selector`in i.api?r.getSymbol(i.api.selector(`client`)):void 0,v=F.propertyAccessExpression({expression:F.identifier({text:`options`}),isOptional:!e,name:`client`}),ee;ee=r.config.instance?F.binaryExpression({left:v,operator:`??`,right:F.propertyAccessExpression({expression:F.this(),name:`_client`})}):_?F.binaryExpression({left:v,operator:`??`,right:_.placeholder}):v;let y=[];a?y.push(Ec,`${s} | ${Dc}`,c,Dc):y.push(s,c,`ThrowOnError`),r.config.responseStyle===`data`&&y.push(F.stringLiteral({text:r.config.responseStyle}));let te=d?F.propertyAccessExpression({expression:ee,name:F.identifier({text:`sse`})}):ee;return te=F.propertyAccessExpression({expression:te,name:F.identifier({text:n.method})}),h.push(F.returnFunctionCall({args:[F.objectExpression({identifiers:[`responseTransformer`],obj:l})],name:te,types:y})),h},Rc=({context:e,operation:t})=>{let n=b(e.config).name===`@hey-api/client-nuxt`,r=e.config.plugins[`@hey-api/sdk`];return r&&!r.config.client&&!r.config.instance||n||it(t)},zc=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType===`text/event-stream`)return!0;return!1},Bc=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=Rc({context:e.context,operation:n}),a=Nc({context:e.context,operation:n,plugin:r});for(let r of a.values())r.path.forEach((a,o)=>{t.has(a)||t.set(a,{className:a,classes:new Set,methods:new Set,nodes:[],root:!o});let s=r.path[o-1];if(s&&s!==a){let e=t.get(s);e.classes.add(a),t.set(s,e)}if(r.path.length!==o+1)return;let c=t.get(a),l=e.config.httpRequests.methodNameBuilder(n);if(c.methods.has(l))return;let u=Uc({isRequiredOptions:i,methodName:l,operation:n,plugin:e});c.nodes.length?c.nodes.push(F.identifier({text:`
|
|
14
|
-
`}),u):c.nodes.push(u),c.methods.add(l),t.set(a,c)})},{order:`declarations`});let i=r=>{if(n.has(r.className))return;if(r.classes.size)for(let n of r.classes){let a=t.get(n);i(a),r.nodes.push(F.propertyDeclaration({initializer:F.newExpression({argumentsArray:[],expression:F.identifier({text:T({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:a.className})})}),name:w({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol(e.api.selector(`Injectable`)),o=e.registerSymbol({exported:!0,name:T({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:r.className}),selector:e.api.selector(`class`,r.className)}),s=F.classDeclaration({decorator:r.root?{args:[{providedIn:`root`}],name:a.placeholder}:void 0,exportClass:o.exported,name:o.placeholder,nodes:r.nodes});e.setSymbolValue(o,s),n.add(r.className)};for(let e of t.values())i(e)},Vc=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=Rc({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,name:e.config.httpRequests.methodNameBuilder(t),selector:e.api.selector(`httpRequest`,t.id)}),i=Wc({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},Hc=({operation:e,plugin:t})=>{let n=b(t.context.config),r=n.api&&`selector`in n.api?t.getSymbol(n.api.selector(`client`)):void 0,i=F.propertyAccessExpression({expression:F.identifier({text:`options`}),isOptional:!0,name:`client`}),a;return a=r?F.binaryExpression({left:i,operator:`??`,right:r.placeholder}):i,F.callExpression({functionName:F.propertyAccessExpression({expression:a,name:`requestOptions`}),parameters:[F.objectExpression({obj:[{key:`responseStyle`,value:F.identifier({text:`'data'`})},{key:`method`,value:F.identifier({text:`'${e.method.toUpperCase()}'`})},{key:`url`,value:F.identifier({text:`'${e.path}'`})},{spread:`options`}]})]})},Uc=({isRequiredOptions:e,methodName:t,operation:n,plugin:r})=>{let i=r.getPluginOrThrow(`@hey-api/typescript`),a=r.referenceSymbol(r.api.selector(`HttpRequest`)),o=r.getPluginOrThrow(`@hey-api/sdk`),s=r.referenceSymbol(o.api.selector(`Options`)),c=r.getSymbol(i.api.selector(`data`,n.id))?.placeholder||`unknown`;return F.methodDeclaration({accessLevel:`public`,comment:o.api.createOperationComment({operation:n}),name:t,parameters:[{isRequired:e,name:`options`,type:`${s.placeholder}<${c}, ThrowOnError>`}],returnType:`${a.placeholder}<unknown>`,statements:[F.returnStatement({expression:Hc({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},Wc=({isRequiredOptions:e,operation:t,plugin:n,symbol:r})=>{let i=n.getPluginOrThrow(`@hey-api/typescript`),a=n.referenceSymbol(n.api.selector(`HttpRequest`)),o=n.getPluginOrThrow(`@hey-api/sdk`),s=n.referenceSymbol(o.api.selector(`Options`)),c=n.getSymbol(i.api.selector(`data`,t.id))?.placeholder||`unknown`;return F.constVariable({comment:o.api.createOperationComment({operation:t}),exportConst:r.exported,expression:F.arrowFunction({parameters:[{isRequired:e,name:`options`,type:`${s.placeholder}<${c}, ThrowOnError>`}],returnType:`${a.placeholder}<unknown>`,statements:[F.returnStatement({expression:Hc({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},Gc=({plugin:e})=>{e.config.httpRequests.asClass?Bc({plugin:e}):Vc({plugin:e})},Kc=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=Rc({context:e.context,operation:n}),a=Nc({context:e.context,operation:n,plugin:r});for(let r of a.values())r.path.forEach((a,o)=>{t.has(a)||t.set(a,{className:a,classes:new Set,methods:new Set,nodes:[],root:!o});let s=r.path[o-1];if(s&&s!==a){let e=t.get(s);e.classes.add(a),t.set(s,e)}if(r.path.length!==o+1)return;let c=t.get(a),l=e.config.httpResources.methodNameBuilder(n);if(c.methods.has(l))return;let u=Yc({isRequiredOptions:i,methodName:l,operation:n,plugin:e});c.nodes.length?c.nodes.push(F.identifier({text:`
|
|
15
|
-
`}),u):c.nodes.push(u),c.methods.add(l),t.set(a,c)})},{order:`declarations`});let i=r=>{if(n.has(r.className))return;if(r.classes.size)for(let n of r.classes){let a=t.get(n);i(a),r.nodes.push(F.propertyDeclaration({initializer:F.newExpression({argumentsArray:[],expression:F.identifier({text:T({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:a.className})})}),name:w({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol(e.api.selector(`Injectable`)),o=e.registerSymbol({exported:!0,name:T({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:r.className})}),s=F.classDeclaration({decorator:r.root?{args:[{providedIn:`root`}],name:a.placeholder}:void 0,exportClass:o.exported,name:o.placeholder,nodes:r.nodes});e.setSymbolValue(o,s),n.add(r.className)};for(let e of t.values())i(e)},qc=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=Rc({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,name:e.config.httpResources.methodNameBuilder(t)}),i=Xc({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},Jc=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/sdk`),r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.referenceSymbol(t.api.selector(`httpResource`)),a=t.getSymbol(r.api.selector(`response`,e.id))?.placeholder||`unknown`;if(t.config.httpRequests.asClass){let r=Nc({context:t.context,operation:e,plugin:n}),o=Array.from(r.values())[0];if(o){let n=o.path[0],r=t.referenceSymbol(t.api.selector(`class`,n)),s=t.referenceSymbol(t.api.selector(`inject`)),c=F.callExpression({functionName:s.placeholder,parameters:[F.identifier({text:r.placeholder})]});for(let e=1;e<o.path.length;e++){let t=o.path[e];t&&(c=F.propertyAccessExpression({expression:c,name:w({case:`camelCase`,value:t})}))}return c=F.propertyAccessExpression({expression:c,name:t.config.httpRequests.methodNameBuilder(e)}),F.callExpression({functionName:i.placeholder,parameters:[F.arrowFunction({parameters:[],statements:[F.constVariable({expression:F.conditionalExpression({condition:F.identifier({text:`options`}),whenFalse:F.identifier({text:`undefined`}),whenTrue:F.callExpression({functionName:`options`,parameters:[]})}),name:`opts`}),F.returnStatement({expression:F.conditionalExpression({condition:F.identifier({text:`opts`}),whenFalse:F.identifier({text:`undefined`}),whenTrue:F.callExpression({functionName:c,parameters:[F.identifier({text:`opts`})]})})})]})],types:[F.typeNode(a)]})}}else{let n=t.referenceSymbol(t.api.selector(`httpRequest`,e.id));return F.callExpression({functionName:i.placeholder,parameters:[F.arrowFunction({parameters:[],statements:[F.constVariable({expression:F.conditionalExpression({condition:F.identifier({text:`options`}),whenFalse:F.identifier({text:`undefined`}),whenTrue:F.callExpression({functionName:`options`,parameters:[]})}),name:`opts`}),F.returnStatement({expression:F.conditionalExpression({condition:F.identifier({text:`opts`}),whenFalse:F.identifier({text:`undefined`}),whenTrue:F.callExpression({functionName:n.placeholder,parameters:[F.identifier({text:`opts`})]})})})]})],types:[F.typeNode(a)]})}return F.callExpression({functionName:i.placeholder,parameters:[F.arrowFunction({parameters:[],statements:[F.returnStatement({expression:F.identifier({text:`undefined`})})]})],types:[F.typeNode(a)]})},Yc=({isRequiredOptions:e,methodName:t,operation:n,plugin:r})=>{let i=r.getPluginOrThrow(`@hey-api/typescript`),a=r.getPluginOrThrow(`@hey-api/sdk`),o=r.referenceSymbol(a.api.selector(`Options`)),s=r.getSymbol(i.api.selector(`data`,n.id))?.placeholder||`unknown`;return F.methodDeclaration({accessLevel:`public`,comment:a.api.createOperationComment({operation:n}),name:t,parameters:[{isRequired:e,name:`options`,type:`() => ${o.placeholder}<${s}, ThrowOnError> | undefined`}],returnType:void 0,statements:[F.returnStatement({expression:Jc({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},Xc=({isRequiredOptions:e,operation:t,plugin:n,symbol:r})=>{let i=n.getPluginOrThrow(`@hey-api/typescript`),a=n.getPluginOrThrow(`@hey-api/sdk`),o=n.referenceSymbol(a.api.selector(`Options`)),s=n.getSymbol(i.api.selector(`data`,t.id))?.placeholder||`unknown`;return F.constVariable({comment:a.api.createOperationComment({operation:t}),exportConst:r.exported,expression:F.arrowFunction({parameters:[{isRequired:e,name:`options`,type:`() => ${o.placeholder}<${s}, ThrowOnError> | undefined`}],statements:[F.returnStatement({expression:Jc({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},Zc=({plugin:e})=>{e.config.httpResources.asClass?Kc({plugin:e}):qc({plugin:e})},Qc={api:new Ge({name:`@angular/common`}),config:{exportFromIndex:!1},dependencies:[`@hey-api/client-angular`,`@hey-api/sdk`],handler:({plugin:e})=>{e.registerSymbol({external:`@angular/common/http`,meta:{kind:`type`},name:`HttpRequest`,selector:e.api.selector(`HttpRequest`)}),e.registerSymbol({external:`@angular/core`,name:`inject`,selector:e.api.selector(`inject`)}),e.registerSymbol({external:`@angular/core`,name:`Injectable`,selector:e.api.selector(`Injectable`)}),e.registerSymbol({external:`@angular/common/http`,name:`httpResource`,selector:e.api.selector(`httpResource`)}),e.config.httpRequests.enabled&&Gc({plugin:e}),e.config.httpResources.enabled&&Zc({plugin:e})},name:`@angular/common`,output:`@angular/common`,resolveConfig:(e,t)=>{if(e.config.httpRequests=t.valueToObject({defaultValue:{asClass:!1,classNameBuilder:`{{name}}Requests`,enabled:!0},mappers:{boolean:e=>({enabled:e})},value:e.config.httpRequests}),!e.config.httpRequests.methodNameBuilder){let{asClass:t}=e.config.httpRequests;e.config.httpRequests.methodNameBuilder=e=>t?String(e.id):`${String(e.id)}Request`}if(e.config.httpResources=t.valueToObject({defaultValue:{asClass:!1,classNameBuilder:`{{name}}Resources`,enabled:!0},mappers:{boolean:e=>({enabled:e})},value:e.config.httpResources}),!e.config.httpResources.methodNameBuilder){let{asClass:t}=e.config.httpResources;e.config.httpResources.methodNameBuilder=e=>t?String(e.id):`${String(e.id)}Resource`}}},$c={baseUrl:!0,bundle:!0,exportFromIndex:!1},el={dependencies:[`@hey-api/typescript`],tags:[`client`]},tl=i(import.meta.url),nl=r.dirname(tl),rl=({config:e,sourceOutput:t})=>{let n=b(e);if(`bundle`in n.config&&n.config.bundle)return ne({moduleOutput:`client`,sourceOutput:t});if(r.isAbsolute(n.name)){let t=r.dirname(n.name),i=r.resolve(e.output.path);return r.relative(i,t).replace(/\\/g,`/`)}return n.name},il=e=>{let t=b(e);if(`bundle`in t.config&&t.config.bundle){let t=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return r.resolve(e.output.path,`client`,`${t?.get(`index`)??`index`}.ts`)}return t.name},al=(e,t)=>{if(n.statSync(e).isDirectory()){n.existsSync(t)||n.mkdirSync(t,{recursive:!0});let i=n.readdirSync(e);for(let n of i)al(r.join(e,n),r.join(t,n))}else{let r=n.readFileSync(e);n.writeFileSync(t,r)}},ol=({filePath:e,project:t,renamed:i})=>{let a=r.extname(e),o=r.basename(e,a),s=t.fileName?.(o)||o;if(s!==o){let t=r.dirname(e);n.renameSync(e,r.resolve(t,`${s}${a}`)),i.set(o,s)}},sl=({filePath:e,meta:t,renamed:i})=>{let a=n.readFileSync(e,`utf8`);a=a.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g,(e,n)=>{let a=e.indexOf(n),o=r.extname(n),s=r.basename(n,o),c=r.dirname(n),l=(i.get(s)??s)+(t.importFileExtension?t.importFileExtension:o);return e.slice(0,a)+[c,l].filter(Boolean).join(`/`)+e.slice(a+n.length)}),a=`// This file is auto-generated by @hey-api/openapi-ts
|
|
16
|
-
|
|
17
|
-
${a}`,n.writeFileSync(e,a,`utf8`)},cl=({meta:t,outputPath:i,plugin:a,project:o})=>{let s=new Map;if(a.name.startsWith(`@hey-api/client-`)){let e=r.resolve(i,`core`);y(e),al(r.resolve(nl,`clients`,`core`),e);let c=r.resolve(i,`client`);y(c);let l=a.name.slice(16);if(al(r.resolve(nl,`clients`,l),c),o){let t=n.readdirSync(e);for(let n of t)ol({filePath:r.resolve(e,n),project:o,renamed:s});let i=n.readdirSync(c);for(let e of i)ol({filePath:r.resolve(c,e),project:o,renamed:s})}let u=n.readdirSync(e);for(let n of u)sl({filePath:r.resolve(e,n),meta:t,renamed:s});let d=n.readdirSync(c);for(let e of d)sl({filePath:r.resolve(c,e),meta:t,renamed:s});return s}let c=r.isAbsolute(a.name)?r.dirname(a.name):void 0;if(c){let e=r.resolve(i,`client`);y(e),al(c,e);return}let l=r.normalize(e.resolve(a.name)).split(r.sep),u=l.slice(0,l.indexOf(`dist`)+1).join(r.sep),d=[l[l.length-1],`index.d.ts`,`index.d.cts`],f=r.resolve(i,`client`);y(f);for(let e of d)n.copyFileSync(r.resolve(u,e),r.resolve(f,e))},ll=({plugin:e})=>{let{baseUrl:t}=e.config;if(t===!1)return;if(typeof t==`string`)return t;let{servers:n}=e.context.ir;if(n)return n[typeof t==`number`?t:0]?.url},ul=({plugin:e})=>{let t=il(e.context.config),n=e.registerSymbol({external:t,name:`createClient`}),r=e.registerSymbol({external:t,name:`createConfig`}),i=e.getPluginOrThrow(`@hey-api/typescript`),a=e.referenceSymbol(i.api.selector(`ClientOptions`)),{runtimeConfigPath:o}=e.config,s=o?e.registerSymbol({external:o,name:`createClientConfig`}):void 0,c=[],l=ll({plugin:e});if(l){let t=oa(l);if(t.protocol&&t.host&&!l.includes(`{`))c.push({key:de(e.context.config),value:l});else if(l!==`/`&&l.startsWith(`/`)){let t=l.endsWith(`/`)?l.slice(0,-1):l;c.push({key:de(e.context.config),value:t})}}`throwOnError`in e.config&&e.config.throwOnError&&c.push({key:`throwOnError`,value:!0});let u=[F.callExpression({functionName:r.placeholder,parameters:c.length?[F.objectExpression({obj:c})]:void 0,types:[F.typeReferenceNode({typeName:a.placeholder})]})],d=e.registerSymbol({name:`client`,selector:e.api.selector(`client`)}),f=F.constVariable({exportConst:!0,expression:F.callExpression({functionName:n.placeholder,parameters:s?[F.callExpression({functionName:s.placeholder,parameters:u})]:u}),name:d.placeholder});e.setSymbolValue(d,f)},dl=({plugin:e})=>{let t=il(e.context.config),n=e.getPluginOrThrow(`@hey-api/typescript`),r=e.referenceSymbol(n.api.selector(`ClientOptions`)),i=e.registerSymbol({external:t,meta:{kind:`type`},name:`Config`}),a=e.registerSymbol({external:t,meta:{kind:`type`},name:`ClientOptions`}),o=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`CreateClientConfig`}),s=F.typeReferenceNode({typeName:a.placeholder}),c=F.typeReferenceNode({typeName:`T`}),l=F.typeAliasDeclaration({comment:["The `createClientConfig()` function will be called on client initialization",`and the returned object will become the client's initial configuration.`,``,`You may want to initialize your client this way instead of calling`,"`setConfig()`. This is useful for example if you're using Next.js",`to ensure your client always has the correct values.`],exportType:o.exported,name:o.placeholder,type:F.functionTypeNode({parameters:[F.parameterDeclaration({name:`override`,required:!1,type:F.typeReferenceNode({typeArguments:[F.typeIntersectionNode({types:[s,c]})],typeName:i.placeholder})})],returnType:F.typeReferenceNode({typeArguments:[F.typeIntersectionNode({types:[F.typeReferenceNode({typeArguments:[s],typeName:`Required`}),c]})],typeName:i.placeholder})}),typeParameters:[{default:F.typeReferenceNode({typeName:r.placeholder}),extends:s,name:`T`}]});e.setSymbolValue(o,l)},fl=({plugin:e})=>{dl({plugin:e}),ul({plugin:e})};var pl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const ml={...el,api:new pl({name:`@hey-api/client-angular`}),config:{...$c,throwOnError:!1},handler:fl,name:`@hey-api/client-angular`};var hl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const gl={...el,api:new hl({name:`@hey-api/client-axios`}),config:{...$c,throwOnError:!1},handler:fl,name:`@hey-api/client-axios`};var _l=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const vl={...el,api:new _l({name:`@hey-api/client-fetch`}),config:{...$c,throwOnError:!1},handler:fl,name:`@hey-api/client-fetch`};var yl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const bl={...el,api:new yl({name:`@hey-api/client-next`}),config:{...$c,throwOnError:!1},handler:fl,name:`@hey-api/client-next`};var xl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Sl={...el,api:new xl({name:`@hey-api/client-nuxt`}),config:$c,handler:fl,name:`@hey-api/client-nuxt`};var Cl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const wl={...el,api:new Cl({name:`@hey-api/client-ofetch`}),config:{...$c,throwOnError:!1},handler:fl,name:`@hey-api/client-ofetch`},Tl={config:{},handler:()=>{},name:`legacy/angular`,output:`client`,tags:[`client`]},El={config:{},handler:()=>{},name:`legacy/axios`,output:`client`,tags:[`client`]},Dl={config:{},handler:()=>{},name:`legacy/fetch`,output:`client`,tags:[`client`]},Ol={config:{},handler:()=>{},name:`legacy/node`,output:`client`,tags:[`client`]},kl={config:{},handler:()=>{},name:`legacy/xhr`,output:`client`,tags:[`client`]};var Al=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const jl=({plugin:e,schema:t})=>{e.config.type===`form`&&(t.description&&delete t.description,t[`x-enum-descriptions`]&&delete t[`x-enum-descriptions`],t[`x-enum-varnames`]&&delete t[`x-enum-varnames`],t[`x-enumNames`]&&delete t[`x-enumNames`],t.title&&delete t.title)},Ml=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Ml({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(r.$ref)return r.$ref=decodeURI(r.$ref),r;if(jl({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Ml({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Ml({context:e,plugin:t,schema:n})),r.items&&=Ml({context:e,plugin:t,schema:r.items}),r.properties)for(let n in r.properties){let i=r.properties[n];typeof i!=`boolean`&&(r.properties[n]=Ml({context:e,plugin:t,schema:i}))}return r},Nl=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Nl({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(`$ref`in r)return r.$ref=decodeURI(r.$ref),r;if(jl({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Nl({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Nl({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>Nl({context:e,plugin:t,schema:n})),r.items&&=Nl({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>Nl({context:e,plugin:t,schema:n})),r.properties)for(let n in r.properties){let i=r.properties[n];typeof i!=`boolean`&&(r.properties[n]=Nl({context:e,plugin:t,schema:i}))}return r},Pl=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Pl({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(jl({plugin:t,schema:r}),r.$ref&&=decodeURI(r.$ref),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Pl({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Pl({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>Pl({context:e,plugin:t,schema:n})),r.items&&=Pl({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>Pl({context:e,plugin:t,schema:n})),r.prefixItems&&=r.prefixItems.map(n=>Pl({context:e,plugin:t,schema:n})),r.properties)for(let n in r.properties){let i=r.properties[n];typeof i!=`boolean`&&(r.properties[n]=Pl({context:e,plugin:t,schema:i}))}return r},Fl=({name:e,plugin:t,schema:n})=>{let r=``;return t.config.nameBuilder&&(r=typeof t.config.nameBuilder==`function`?t.config.nameBuilder(e,n):t.config.nameBuilder.replace(`{{name}}`,e)),r||=`${e}Schema`,vt(r)},Il=({context:e,plugin:t})=>{if(e.spec.definitions)for(let n in e.spec.definitions){let r=e.spec.definitions[n],i=t.registerSymbol({exported:!0,name:Fl({name:n,plugin:t,schema:r}),selector:t.api.selector(`ref`,n)}),a=Ml({context:e,plugin:t,schema:r}),o=F.constVariable({assertion:`const`,exportConst:i.exported,expression:F.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},Ll=({context:e,plugin:t})=>{if(e.spec.components)for(let n in e.spec.components.schemas){let r=e.spec.components.schemas[n],i=t.registerSymbol({exported:!0,name:Fl({name:n,plugin:t,schema:r}),selector:t.api.selector(`ref`,n)}),a=Nl({context:e,plugin:t,schema:r}),o=F.constVariable({assertion:`const`,exportConst:i.exported,expression:F.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},Rl=({context:e,plugin:t})=>{if(e.spec.components)for(let n in e.spec.components.schemas){let r=e.spec.components.schemas[n],i=t.registerSymbol({exported:!0,name:Fl({name:n,plugin:t,schema:r}),selector:t.api.selector(`ref`,n)}),a=Pl({context:e,plugin:t,schema:r}),o=F.constVariable({assertion:`const`,exportConst:i.exported,expression:F.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},zl=({plugin:e})=>{if(`swagger`in e.context.spec){Il({context:e.context,plugin:e});return}if(ct(e.context.spec.openapi,`>=3.0.0 <3.1.0`)){Ll({context:e.context,plugin:e});return}if(ct(e.context.spec.openapi,`>=3.1.0`)){Rl({context:e.context,plugin:e});return}throw Error(`Unsupported OpenAPI specification`)};var Bl=class{_exportFromIndex;_headers=[];_id;_imports=new Map;_items=[];_name;_path;constructor({dir:e,exportFromIndex:t=!1,header:n=!0,id:i,name:a}){this._exportFromIndex=t,this._id=i,this._name=this._setName(a),this._path=r.resolve(e,this._name),n&&this._headers.push(`// This file is auto-generated by @hey-api/openapi-ts`)}add(...e){this._items=this._items.concat(e)}get exportFromIndex(){return this._exportFromIndex}get id(){return this._id}import({module:e,...t}){if(!t.name)return{name:void 0};let n=this._imports.get(e);n||(n=new Map,this._imports.set(e,n));let r=n.get(t.name);return r?{...r,name:r.alias||r.name}:(n.set(t.name,t),{...t,name:t.alias||t.name})}isEmpty(){return!this._items.length}nameWithoutExtension(){let{name:e}=Vl(this._name);return e}remove(e){n.rmSync(this._path,e)}removeNode_LEGACY(){this._items=this._items.slice(0,this._items.length-1)}_setName(e){if(e.includes(`index`))return e;let{extension:t,name:n}=Vl(e);return[n,`gen`,t].filter(Boolean).join(`.`)}_toString(e,t){let n=[];this._headers.length&&n.push(this._headers.join(`
|
|
18
|
-
`));let r=t?.options.moduleResolution===a.ModuleResolutionKind.NodeNext,i=[];for(let[e,t]of this._imports.entries()){let n=Array.from(t.values()),a=e;r&&(a.startsWith(`./`)||a.startsWith(`../`))&&(a=a===`./client`?`./client/index.js`:`${a}.js`);let o=F.namedImportDeclarations({imports:n,module:a});i.push(wt({node:o}))}return i.length&&n.push(i.join(`
|
|
19
|
-
`)),n=n.concat(this._items.map(e=>typeof e==`string`?e:wt({node:e,unescape:!0}))),n.join(e)}write(e=`
|
|
20
|
-
`,t=null){if(this.isEmpty()){this.remove({force:!0});return}let i=this._path;if(typeof this._path==`string`){let e=this._path.split(r.sep);i=e.slice(0,e.length-1).join(r.sep)}y(i),n.writeFileSync(this._path,this._toString(e,t))}};const Vl=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))}},Hl=(e,t)=>{let n=x();if(Array.isArray(e))return e.map(e=>Hl(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]=Hl(i,e))}),r},Ul=(e,t)=>{let n=x(),r=cr(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`},Wl={api:new Al({name:`@hey-api/schemas`}),config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:zl,handlerLegacy:({files:e,openApi:t,plugin:n})=>{e.schemas=new Bl({dir:x().output.path,exportFromIndex:n.config.exportFromIndex,id:`schemas`,name:`schemas.ts`});let r=(t,n)=>{let r=Hl(n),i=F.objectExpression({obj:r}),a=F.constVariable({assertion:`const`,exportConst:!0,expression:i,name:Ul(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)})},name:`@hey-api/schemas`},Gl=({operation:e})=>{let t=[];if(e.summary&&t.push(A(e.summary)),e.description&&(t.length&&t.push(``),t.push(A(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length)return t};var Kl=class{constructor(e){this.meta=e}createOperationComment(...e){return Gl(...e)}selector(...e){return[this.meta.name,...e]}};const ql=({meta:e,onImport:t,...n})=>{if(!e)return{created:!1,name:``};let{created:r,name:i}=Os({meta:e,...n});return i&&t(i),{created:r,name:i}},Jl=e=>`${e}ModelResponseTransformer`,Yl=e=>`${w({case:`PascalCase`,value:e})}Data`,Xl=e=>`${w({case:`PascalCase`,value:e})}Error`,Zl=e=>`${e}Transformer`,Ql=e=>`${w({case:`PascalCase`,value:e})}Response`,$l=({importedType:e,throwOnError:t})=>{let n=`OptionsLegacyParser`;return t?`${n}<${e||`unknown`}, ${t}>`:e?`${n}<${e}>`:n},eu=(e,t)=>{let n=x(),{name:r}=Os({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Yl}),i=Ms(t.parameters);if(!S(n))return[{isRequired:i,name:`options`,type:$l({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}})},tu=(e,t)=>{let n=x(),r=F.typeNode(`void`);if(t.responses.filter(e=>e.responseTypes.includes(`success`)).length){let{name:n}=Os({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Ql});r=F.typeUnionNode({types:[n]})}return n.useOptions&&n.plugins[`@hey-api/sdk`]?.config.response===`response`&&(r=F.typeNode(`ApiResult`,[r])),r=b(n).name===`legacy/angular`?F.typeNode(`Observable`,[r]):F.typeNode(`CancelablePromise`,[r]),r},nu=e=>{let t=x();if(!S(t))return[e.deprecated&&`@deprecated`,e.summary&&A(e.summary),e.description&&A(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?A(e.description):``}`)]:e.parameters.map(e=>`@param ${e.name} ${e.description?A(e.description):``}`));let r=e.responses.filter(e=>e.responseTypes.includes(`success`));return[e.deprecated&&`@deprecated`,e.summary&&A(e.summary),e.description&&A(e.description),...n,...r.map(e=>`@returns ${e.type} ${e.description?A(e.description):``}`),`@throws ApiError`]},ru=({client:e,onClientImport:t,onImport:n,operation:r})=>{let i=x(),a=Ql(r.name),{name:o}=Os({client:e,meta:{$ref:`transformers/${a}`,name:a},nameTransformer:Zl});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(Qo);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}]),F.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:yt(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 F.objectExpression({identifiers:[`body`,`cookies`,`formData`,`headers`,`path`,`query`,`responseTransformer`],obj:c,shorthand:!0})},iu=({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(pt)?`${n}_`:n,au=({client:e,onClientImport:t,onImport:n,operation:r})=>{let i=x(),a=ru({client:e,onClientImport:t,onImport:n,operation:r});if(!S(i)){let t=Os({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Xl}).name,n=r.responses.filter(e=>e.responseTypes.includes(`success`)).length?Os({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Ql}).name:`void`;return[F.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 me(i)?[F.returnFunctionCall({args:[a],name:`this.httpRequest.request`})]:b(i).name===`legacy/angular`?[F.returnFunctionCall({args:[`OpenAPI`,`this.http`,a],name:`__request`})]:[F.returnFunctionCall({args:[`OpenAPI`,a],name:`__request`})]},ou=({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&&ql({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Yl,onImport:n}),s||ql({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Xl,onImport:n}),t.responses.filter(e=>e.responseTypes.includes(`success`)).length&&ql({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Ql,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&&!me(a)){for(let l of i.operations){let i={parameters:eu(e,l),returnType:s?tu(e,l):void 0,statements:au({client:e,onClientImport:t,onImport:n,operation:l}),types:s?void 0:[c]},u=o.name===`legacy/angular`?F.anonymousFunction(i):F.arrowFunction(i);r(F.constVariable({comment:nu(l),exportConst:!0,expression:u,name:iu({config:a,handleIllegal:!0,id:l.name,operation:l})}))}return}let l=i.operations.map(r=>F.methodDeclaration({accessLevel:`public`,comment:nu(r),isStatic:me(a)===void 0&&o.name!==`legacy/angular`,name:iu({config:a,id:r.name,operation:r}),parameters:eu(e,r),returnType:s?tu(e,r):void 0,statements:au({client:e,onClientImport:t,onImport:n,operation:r}),types:s?void 0:[c]}));if(!l.length)return;me(a)?l=[F.constructorDeclaration({multiLine:!1,parameters:[{accessLevel:`public`,isReadOnly:!0,name:`httpRequest`,type:`BaseHttpRequest`}]}),...l]:o.name===`legacy/angular`&&(l=[F.constructorDeclaration({multiLine:!1,parameters:[{accessLevel:`public`,isReadOnly:!0,name:`http`,type:`HttpClient`}]}),...l]);let u=[];l.forEach((e,t)=>{t&&u.push(F.identifier({text:`
|
|
21
|
-
`})),u.push(e)}),r(F.classDeclaration({decorator:o.name===`legacy/angular`?{args:[{providedIn:`root`}],name:`Injectable`}:void 0,exportClass:!0,name:Ko({config:a,name:i.name}),nodes:u}))},su=({client:e,files:t,plugin:n})=>{let r=x(),i=S(r);if(t.sdk=new Bl({dir:r.output.path,exportFromIndex:n.config.exportFromIndex,id:`sdk`,name:`sdk.ts`}),!i)t.sdk.import({module:rl({config:r,sourceOutput:`sdk`}),name:`createClient`}),t.sdk.import({module:rl({config:r,sourceOutput:`sdk`}),name:`createConfig`}),t.sdk.import({asType:!0,module:rl({config:r,sourceOutput:`sdk`}),name:`OptionsLegacyParser`});else if(b(r).name===`legacy/angular`?(t.sdk.import({module:`@angular/core`,name:`Injectable`}),me(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`}),me(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=F.constVariable({exportConst:!0,expression:F.callExpression({functionName:`createClient`,parameters:[F.callExpression({functionName:`createConfig`,parameters:[`throwOnError`in e&&e.throwOnError?F.objectExpression({obj:[{key:`throwOnError`,value:!0}]}):void 0]})]}),name:`client`});t.sdk.add(n)}for(let n of e.services)ou({client:e,onClientImport:e=>{t.sdk.import({module:rl({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})},cu=({plugin:e})=>{let t=il(e.context.config),n=b(e.context.config).name===`@hey-api/client-nuxt`,r=e.registerSymbol({external:t,meta:{kind:`type`},name:`TDataShape`}),i=e.registerSymbol({external:t,meta:{kind:`type`},name:`Client`,selector:e.api.selector(`Client`)}),a=e.registerSymbol({external:t,meta:{kind:`type`},name:`Options`}),o=e.registerSymbol({exported:!0,meta:{kind:`type`},name:`Options`,selector:e.api.selector(`Options`)}),s=F.typeAliasDeclaration({exportType:o.exported,name:o.placeholder,type:F.typeIntersectionNode({types:[F.typeReferenceNode({typeArguments:n?[F.typeReferenceNode({typeName:`TComposable`}),F.typeReferenceNode({typeName:`TData`}),F.typeReferenceNode({typeName:Oc}),F.typeReferenceNode({typeName:Dc})]:[F.typeReferenceNode({typeName:`TData`}),F.typeReferenceNode({typeName:`ThrowOnError`})],typeName:a.placeholder}),F.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:F.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:F.typeReferenceNode({typeArguments:[F.keywordTypeNode({keyword:`string`}),F.keywordTypeNode({keyword:`unknown`})],typeName:`Record`})}],useLegacyResolution:!1})]}),typeParameters:n?[F.typeParameterDeclaration({constraint:F.typeReferenceNode({typeName:e.referenceSymbol(e.api.selector(`Composable`)).placeholder}),defaultType:F.typeNode(`'$fetch'`),name:`TComposable`}),F.typeParameterDeclaration({constraint:F.typeReferenceNode({typeName:r.placeholder}),defaultType:F.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),F.typeParameterDeclaration({defaultType:F.keywordTypeNode({keyword:`unknown`}),name:Oc}),F.typeParameterDeclaration({defaultType:F.keywordTypeNode({keyword:`undefined`}),name:Dc})]:[F.typeParameterDeclaration({constraint:F.typeReferenceNode({typeName:r.placeholder}),defaultType:F.typeReferenceNode({typeName:r.placeholder}),name:`TData`}),F.typeParameterDeclaration({constraint:F.keywordTypeNode({keyword:`boolean`}),defaultType:F.keywordTypeNode({keyword:`boolean`}),name:`ThrowOnError`})]});e.setSymbolValue(o,s)},lu=({plugin:e})=>{let t=F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:F.this(),name:`_client`}),operator:`=`,right:F.propertyAccessExpression({expression:F.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[F.propertyDeclaration({initializer:i?F.identifier({text:i.placeholder}):void 0,modifier:`protected`,name:`_client`,type:F.typeReferenceNode({typeName:n.placeholder})}),F.identifier({text:`
|
|
22
|
-
`}),F.constructorDeclaration({multiLine:!0,parameters:[{isRequired:!e.config.client,name:`args`,type:F.typeInterfaceNode({properties:[{isRequired:!e.config.client,name:`client`,type:n.placeholder}],useLegacyResolution:!1})}],statements:[e.config.client?F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`args`}),isOptional:!0,name:`client`}),thenStatement:F.block({statements:[t]})}):t]})]},uu=({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?lu({plugin:e}):[];e.forEach(`operation`,({operation:a})=>{let o=Rc({context:e.context,operation:a}),s=e.getPluginOrThrow(`@hey-api/typescript`),c=r?e.getSymbol(s.api.selector(`response`,a.id)):void 0,l=Nc({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=Fc({isRequiredOptions:o,operation:a,plugin:e}),h=Lc({isRequiredOptions:o,opParameters:m,operation:a,plugin:e}),g=F.methodDeclaration({accessLevel:`public`,comment:e.api.createOperationComment({operation:a}),isStatic:n?!1:!e.config.instance,name:s.methodName,parameters:m.parameters,returnType:void 0,statements:h,types:r?[{default:F.ots.string(`$fetch`),extends:F.typeNode(e.referenceSymbol(e.api.selector(`Composable`)).placeholder),name:Ec},{default:c?F.typeReferenceNode({typeName:c.placeholder}):F.typeNode(`undefined`),extends:c?F.typeReferenceNode({typeName:c.placeholder}):void 0,name:Dc}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]});p.nodes.length?p.nodes.push(F.identifier({text:`
|
|
23
|
-
`}),g):p.nodes.push(g),p.methods.add(s.methodName),i.set(d.id,p)})},{order:`declarations`});let s=e.registerSymbol({exported:!1,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(F.propertyDeclaration({initializer:e.config.instance?F.newExpression({argumentsArray:e.config.instance?[F.objectExpression({multiLine:!1,obj:[{key:`client`,value:F.propertyAccessExpression({expression:F.this(),name:`_client`})}]})]:[],expression:F.identifier({text:e.referenceSymbol(r.id).placeholder})}):F.identifier({text:e.referenceSymbol(r.id).placeholder}),modifier:e.config.instance?void 0:`static`,name:w({case:`camelCase`,value:r.className})}))}let r=e.registerSymbol({exported:!0,name:t.className,selector:e.api.selector(`class`,t.className)}),o=F.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=F.classDeclaration({exportClass:s.exported,name:s.placeholder,nodes:o});e.setSymbolValue(s,t)}for(let e of i.values())c(e)},du=({plugin:e})=>{let t=b(e.context.config),n=t.name===`@hey-api/client-nuxt`;e.forEach(`operation`,({operation:r})=>{let i=Rc({context:e.context,operation:r}),a=e.getPluginOrThrow(`@hey-api/typescript`),o=n?e.getSymbol(a.api.selector(`response`,r.id)):void 0,s=Fc({isRequiredOptions:i,operation:r,plugin:e}),c=Lc({isRequiredOptions:i,opParameters:s,operation:r,plugin:e}),l=e.registerSymbol({name:iu({config:e.context.config,handleIllegal:!0,id:r.id,operation:r}),selector:e.api.selector(`function`,r.id)}),u=F.constVariable({comment:e.api.createOperationComment({operation:r}),exportConst:!0,expression:F.arrowFunction({parameters:s.parameters,returnType:void 0,statements:c,types:n?[{default:F.ots.string(`$fetch`),extends:F.typeNode(e.referenceSymbol(e.api.selector(`Composable`)).placeholder),name:Ec},{default:o?F.typeReferenceNode({typeName:o.placeholder}):F.typeNode(`undefined`),extends:o?F.typeReferenceNode({typeName:o.placeholder}):void 0,name:Dc}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]}),name:l.placeholder});e.setSymbolValue(l,u)},{order:`declarations`})},fu={api:new Kl({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:({plugin:e})=>{let t=il(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`)}),cu({plugin:e}),e.config.asClass?uu({plugin:e}):du({plugin:e})},handlerLegacy:su,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`)}};var pu=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const mu=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:F.callExpression({functionName:`BigInt`,parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:e,name:`toString`})})]});if(n){if(typeof e==`string`)return[n];if(e)return[F.assignment({left:e,right:n})]}},hu=({dataExpression:e,schema:t})=>{if(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))return;let n=F.identifier({text:`Date`});if(typeof e==`string`)return[F.newExpression({argumentsArray:[F.identifier({text:e})],expression:n})];if(e)return[F.assignment({left:e,right:F.newExpression({argumentsArray:[e],expression:n})})]},gu=`data`,_u=e=>e.map(e=>a.isStatement(e)?e:F.expressionToStatement({expression:e})),vu=({node:e})=>e.kind===a.SyntaxKind.ReturnStatement,yu=({plugin:e,schema:t})=>{let n=F.identifier({text:gu}),r=bu({dataExpression:n,plugin:e,schema:t});return r.length&&!vu({node:r[r.length-1]})&&r.push(F.returnStatement({expression:n})),r},bu=({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:T({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:I(n.$ref)}),selector:r}),i=yu({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(i.length){let n=F.constVariable({expression:F.arrowFunction({async:!1,multiLine:!0,parameters:[{name:gu,type:F.keywordTypeNode({keyword:`any`})}],statements:_u(i)}),name:e.placeholder});t.setSymbolValue(e,n)}else t.setSymbolValue(e,null)}let i=t.referenceSymbol(r);if(t.getSymbolValue(i)!==null){let t=F.callExpression({functionName:i.placeholder,parameters:[e]});if(e)return typeof e==`string`&&e===`item`?[F.returnStatement({expression:t})]:[typeof e==`string`?t:F.assignment({left:e,right:t})]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?bu({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=_u(r);return i.some(e=>vu({node:e}))||i.push(F.returnStatement({expression:F.identifier({text:`item`})})),[F.assignment({left:e,right:F.callExpression({functionName:F.propertyAccessExpression({expression:e,name:`map`}),parameters:[F.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=F.propertyAccessExpression({expression:e||gu,name:a}),c=bu({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(F.ifStatement({expression:s,thenStatement:F.block({statements:_u(c)})}))}return r}if(n.items){if(n.items.length===1)return bu({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=bu({dataExpression:e||`item`,plugin:t,schema:i});if(n.length)if(e)r=r.concat(n);else{let e=F.identifier({text:`item`});r.push(F.ifStatement({expression:e,thenStatement:F.block({statements:_u(n)})}),F.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[]},xu=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=st(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${O(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=e.registerSymbol({exported:!0,name:T({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id}),selector:e.api.selector(`response`,t.id)}),o=yu({plugin:e,schema:n});if(o.length){let t=F.constVariable({exportConst:a.exported,expression:F.arrowFunction({async:!0,multiLine:!0,parameters:[{name:gu,type:F.keywordTypeNode({keyword:`any`})}],returnType:F.typeReferenceNode({typeArguments:[F.typeReferenceNode({typeName:i.placeholder})],typeName:`Promise`}),statements:_u(o)}),name:a.placeholder});e.setSymbolValue(a,t)}else e.setSymbolValue(a,null)},{order:`declarations`})},q={$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:``},Su=({comments:e,leadingComment:t,meta:n,obj:r,onNode:i,...a})=>{if(!n)return;let{created:o,name:s}=Os({create:!0,meta:n,...a});if(o){let n=x().plugins[`@hey-api/typescript`];i(F.enumDeclaration({asConst:typeof n?.config.enums==`object`&&n.config.enums.mode===`typescript-const`,comments:e,leadingComment:t,name:s,obj:r}))}},Cu=({comment:e,meta:t,onCreated:n,onNode:r,type:i,...a})=>{if(!t)return{created:!1,name:``};let o=Os({create:!0,meta:t,...a}),{created:s,name:c}=o;return s&&(r(F.typeAliasDeclaration({comment:e,exportType:!0,name:c,type:i})),n?.(c)),o},wu=e=>{let t=[];Du(e),e.model.enums.forEach(n=>Eu({...e,model:n,onNode:e=>{t.push(e)}})),t.length&&e.onNode(F.namespaceDeclaration({name:e.model.name,statements:t}))},Tu=({client:e,model:t,onNode:n})=>{let r=x(),i={},a={};t.enum.forEach(e=>{let{key:t,value:n}=hs(e);i[t]=n;let r=e.customDescription||e.description;r&&(a[t]=[A(r)])});let o=[t.description&&A(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`)){Su({asConst:s.config.enums.mode===`typescript-const`,client:e,comments:a,leadingComment:o,meta:t.meta,obj:i,onNode:n});return}Cu({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=F.objectExpression({multiLine:!0,obj:Object.entries(i).map(([e,t])=>({comments:a[e],key:e,value:t})),unescape:!0});n(F.constVariable({assertion:`const`,comment:o,exportConst:!0,expression:t,name:e}))}},onNode:n,type:ps(t.enum)})},Eu=({model:e,onNode:t})=>{let n={},r={};e.enum.forEach(e=>{let{key:t,value:i}=hs(e);n[t]=i;let a=e.customDescription||e.description;a&&(r[t]=[A(a)])});let i=x().plugins[`@hey-api/typescript`];t(F.enumDeclaration({asConst:typeof i?.config.enums==`object`&&i.config.enums.mode===`typescript-const`,comments:r,leadingComment:[e.description&&A(e.description),e.deprecated&&`@deprecated`],name:e.meta?.name||e.name,obj:n}))},Du=({client:e,model:t,onNode:n})=>{Cu({client:e,comment:[t.description&&A(t.description),t.deprecated&&`@deprecated`],meta:t.meta,onNode:n,type:Ds(t)})},Ou=e=>{switch(e.model.export){case`all-of`:case`any-of`:case`one-of`:case`interface`:return wu(e);case`enum`:return Tu(e);default:return Du(e)}},ku=({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,...q,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={...q,...r[0],in:`body`,isRequired:r[0].isRequired,name:`body`,prop:`body`}:r.length>1&&(n={...q,in:`body`,isRequired:r.some(e=>e.isRequired),mediaType:`multipart/form-data`,name:`body`,prop:`body`,properties:r});let s={...q,in:`header`,isRequired:Ms(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(us)},c={...q,in:`path`,isRequired:Ms(a.parameters.filter(e=>e.in===`path`)),mediaType:null,name:`path`,prop:`path`,properties:a.parameters.filter(e=>e.in===`path`).sort(us)},l={...q,in:`query`,isRequired:Ms(a.parameters.filter(e=>e.in===`query`)),mediaType:null,name:`query`,prop:`query`,properties:a.parameters.filter(e=>e.in===`query`).sort(us)},u=i?ds([...a.parameters]):[n,s,c,l].filter(e=>e.properties.length||e.$refs.length||e.mediaType);o.req=u,Cu({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:Yl,onNode:t,type:Ds({...q,isRequired:!0,properties:u})})}let s=a.responses.filter(e=>e.responseTypes.includes(`success`));if(s.length>0){Cu({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:Ql,onNode:t,type:Ds({...q,export:`any-of`,isRequired:!0,properties:s})});let n=a.responses.filter(e=>e.responseTypes.includes(`error`));i||Cu({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:Xl,onNode:t,type:Ds(n.length?{...q,export:`one-of`,isRequired:!0,properties:n}:{...q,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}=Os({client:e,meta:{$ref:t,name:t},nameTransformer:Yl}),a={...q,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])=>({...q,...t,isRequired:!0,name:String(e)})),t={...q,isRequired:!0,name:`res`,properties:e};i=[...i,t]}return{...q,isRequired:!0,name:r.toLocaleLowerCase(),properties:i}}).filter(Boolean);return{...q,isRequired:!0,name:`'${t}'`,properties:r}});r.plugins[`@hey-api/typescript`]?.config.tree&&Cu({client:e,meta:{$ref:`@hey-api/openapi-ts`,name:`$OpenApiTs`},onNode:t,type:Ds({...q,properties:a})})},Au=({client:e,files:t,plugin:n})=>{t.types=new Bl({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)Ou({client:e,model:t,onNode:r});ku({client:e,onNode:r})},ju=`data`,Mu=e=>e.base===`unknown`&&e.export===`generic`&&e.type===`unknown`,Nu=({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}),Pu=e=>{let t=e.model.meta.name,{name:n}=Cu({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:Jl,onCreated:n=>{let r=Lu({...e,meta:{$ref:`transformers/${t}`,name:n},path:[ju]});Ru({...e,async:!1,name:n,statements:r})},type:`(${ju}: any) => ${t}`});return{created:!!e.client.types[n],name:n}},Fu=e=>{let{model:t}=e,n=Nu(e);if(n.length===1){let{created:t,name:r}=Pu({...e,model:n[0]});return t?[F.transformArrayMutation({path:e.path,transformerName:r})]:[]}return ys(t)||t.link&&!Array.isArray(t.link)&&t.link.export===`any-of`&&t.link.properties.find(e=>ys(e))?[F.transformArrayMap({path:e.path,transformExpression:F.conditionalExpression({condition:F.identifier({text:`item`}),whenFalse:F.identifier({text:`item`}),whenTrue:F.transformNewDate({parameterName:`item`})})})]:[]},Iu=e=>{let{model:t}=e,n=[...e.path,t.name];return t.type===`string`&&t.export!==`array`&&ys(t)?[F.transformDateMutation({path:n})]:Lu({...e,model:t,path:n})},Lu=e=>{let{model:t}=e;switch(t.export){case`array`:return Fu(e);case`interface`:return t.properties.flatMap(t=>Iu({...e,model:t}));case`reference`:{if(t.$refs.length!==1)return[];let n=Nu(e),{created:r,name:i}=Pu({...e,model:n[0]});return r?t.in===`response`?[F.expressionToStatement({expression:F.callExpression({functionName:i,parameters:[ju]})})]:F.transformFunctionMutation({path:e.path,transformerName:i}):[]}default:return[]}},Ru=({async:e,client:t,name:n,onNode:r,onRemoveNode:i,statements:a})=>{let o={created:!1,name:n};if(!a.length)return ks({client:t,name:n}),i?.(),o;let s=F.arrowFunction({async:e,multiLine:!0,parameters:[{name:ju}],statements:[...a,F.returnVariable({expression:ju})]});return r(F.constVariable({exportConst:!0,expression:s,name:n,typeName:n})),{created:!0,name:n}},zu={api:new pu({name:`@hey-api/transformers`}),config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:xu,handlerLegacy:({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=>!Mu(e));if(!o.length)continue;if(o.length>1){n.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${O(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=Ql(a.name);Cu({client:e,meta:{$ref:`transformers/${s}`,name:s},nameTransformer:Zl,onCreated:n=>{Ru({async:!0,client:e,name:n,onNode:r,onRemoveNode:i,statements:t.length>1?t.flatMap(t=>{let n=Lu({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t,onNode:r,onRemoveNode:i,path:[ju]});return n.length?[F.ifStatement({expression:F.safeAccessExpression([`data`]),thenStatement:F.block({statements:n})})]:[]}):Lu({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t[0],onNode:r,onRemoveNode:i,path:[ju]})})},onNode:r,type:`(${ju}: any) => Promise<${s}>`})}},name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,hu]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,mu])},tags:[`transformer`]},Bu=({context:e,name:t})=>(k.lastIndex=0,k.test(t)?t.startsWith(`-`)?a.factory.createStringLiteral(t):a.factory.createNumericLiteral(t):w({case:e.config.output.case,value:t})),Vu=({schema:e})=>{let t=[];return e.title&&t.push(A(e.title)),e.description&&(t.length&&t.push(``),t.push(A(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Hu=F.keywordTypeNode({keyword:`string`}),Uu=({server:e})=>{let t=oa(e.url);return t.protocol&&t.host?F.literalTypeNode({literal:F.stringLiteral({text:e.url})}):F.templateLiteralType({value:[t.protocol||Hu,`://`,t.host||Hu,t.port?`:${t.port}`:``,t.path||``]})},Wu=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=b(e.context.config),i=t.map(e=>Uu({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(F.typeIntersectionNode({types:[Hu,a.factory.createTypeLiteralNode([])]})):i.push(Hu);let o=F.typeInterfaceNode({properties:[{name:de(e.context.config),type:F.typeUnionNode({types:i})}],useLegacyResolution:!1}),s=F.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:o});e.setSymbolValue(n,s)},Gu=({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=w({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),k.lastIndex=0,k.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{comments:Vu({schema:t}),key:a,value:t.const}}),typeofItems:n}},Ku=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=Gu({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=F.constVariable({assertion:`const`,comment:Vu({schema:t}),exportConst:!0,expression:F.objectExpression({multiLine:!0,obj:r.obj}),name:n.placeholder}),a=F.typeOfExpression({text:n.placeholder}),o=F.typeAliasDeclaration({comment:Vu({schema:t}),exportType:!0,name:n.placeholder,type:F.indexedAccessTypeNode({indexType:F.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=F.enumDeclaration({asConst:e.config.enums.mode===`typescript-const`,leadingComment:Vu({schema:t}),name:n.placeholder,obj:r.obj});e.setSymbolValue(n,i);return}}let i=F.typeAliasDeclaration({comment:Vu({schema:t}),exportType:n.exported,name:n.placeholder,type:r});e.setSymbolValue(n,i)},qu=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=E({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},Ju=({operation:e,plugin:t})=>{let n={type:`object`},r=[];n.properties||={},e.body?(n.properties.body=e.body.schema,e.body.required&&r.push(`body`)):n.properties.body={type:`never`},e.parameters?.header&&(n.properties.headers=qu({parameters:e.parameters.header}),n.properties.headers.required&&r.push(`headers`)),e.parameters?.path?(n.properties.path=qu({parameters:e.parameters.path}),n.properties.path.required&&r.push(`path`)):n.properties.path={type:`never`},e.parameters?.query?(n.properties.query=qu({parameters:e.parameters.query}),n.properties.query.required&&r.push(`query`)):n.properties.query={type:`never`},n.properties.url={const:e.path,type:`string`},r.push(`url`),n.required=r;let i=t.registerSymbol({exported:!0,meta:{kind:`type`},name:T({config:t.config.requests,name:e.id}),selector:t.api.selector(`data`,e.id)}),a=J({plugin:t,schema:n}),o=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});t.setSymbolValue(i,o)},Yu=({operation:e,plugin:t})=>{Ju({operation:e,plugin:t});let{error:n,errors:r,response:i,responses:a}=st(e);if(r){let i=t.registerSymbol({exported:!0,meta:{kind:`type`},name:T({config:t.config.errors,name:e.id}),selector:t.api.selector(`errors`,e.id)}),a=J({plugin:t,schema:r}),o=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});if(t.setSymbolValue(i,o),n){let n=t.registerSymbol({exported:!0,meta:{kind:`type`},name:T({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id}),selector:t.api.selector(`error`,e.id)}),r=F.indexedAccessTypeNode({indexType:F.typeOperatorNode({operator:`keyof`,type:F.typeReferenceNode({typeName:i.placeholder})}),objectType:F.typeReferenceNode({typeName:i.placeholder})}),a=F.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:r});t.setSymbolValue(n,a)}}if(a){let n=t.registerSymbol({exported:!0,meta:{kind:`type`},name:T({config:t.config.responses,name:e.id}),selector:t.api.selector(`responses`,e.id)}),r=J({plugin:t,schema:a}),o=F.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:r});if(t.setSymbolValue(n,o),i){let r=t.registerSymbol({exported:!0,meta:{kind:`type`},name:T({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id}),selector:t.api.selector(`response`,e.id)}),i=F.indexedAccessTypeNode({indexType:F.typeOperatorNode({operator:`keyof`,type:F.typeReferenceNode({typeName:n.placeholder})}),objectType:F.typeReferenceNode({typeName:n.placeholder})}),a=F.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});t.setSymbolValue(r,a)}}},Xu=({operation:e,plugin:t})=>{let n={type:`object`},r=[];if(n.properties||={},e.body){let i=t.registerSymbol({exported:!0,meta:{kind:`type`},name:T({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id}),selector:t.api.selector(`webhook-payload`,e.id)}),a=J({plugin:t,schema:e.body.schema}),o=F.typeAliasDeclaration({comment:Vu({schema:e.body.schema}),exportType:i.exported,name:i.placeholder,type:a});t.setSymbolValue(i,o),t.registerSymbol({exported:!0,meta:{kind:`type`},name:i.name,placeholder:i.placeholder,selector:t.api.selector(`ref`,i.placeholder)}),n.properties.body={$ref:i.placeholder},r.push(`body`)}else n.properties.body={type:`never`};n.properties.key={const:e.path,type:`string`},r.push(`key`),n.properties.path={type:`never`},n.properties.query={type:`never`},n.required=r;let i=t.registerSymbol({exported:!0,meta:{kind:`type`},name:T({config:t.config.webhooks,name:e.id}),selector:t.api.selector(`webhook-request`,e.id)}),a=J({plugin:t,schema:n}),o=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});return t.setSymbolValue(i,o),i.placeholder},Zu=({operation:e,plugin:t})=>Xu({operation:e,plugin:t}),Qu=({plugin:e,symbolWebhooks:t,webhookNames:n})=>{if(!n.length)return;let r=F.typeUnionNode({types:n.map(e=>F.typeReferenceNode({typeName:e}))}),i=F.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:r});e.setSymbolValue(t,i)},$u=({plugin:e,schema:t})=>{if(!t.items)return F.typeArrayNode(F.keywordTypeNode({keyword:e.config.topType}));t=E({detectFormat:!0,schema:t});let n=[];for(let r of t.items){let t=J({plugin:e,schema:r});n.push(t)}return n.length===1?F.typeArrayNode(n[0]):t.logicalOperator===`and`?F.typeArrayNode(F.typeIntersectionNode({types:n})):F.typeArrayNode(F.typeUnionNode({types:n}))},ed=({schema:e})=>e.const===void 0?F.keywordTypeNode({keyword:`boolean`}):F.literalTypeNode({literal:F.ots.boolean(e.const)}),td=({plugin:e,schema:t})=>J({plugin:e,schema:{...t,type:void 0}}),nd=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?F.typeReferenceNode({typeName:`bigint`}):F.keywordTypeNode({keyword:`number`}):F.literalTypeNode({literal:F.ots.number(t.const)}),rd=({plugin:e,schema:t})=>{let n,r,i=[],a=[],o=t.required??[],s=!1;for(let n in t.properties){let r=t.properties[n],c=J({plugin:e,schema:r}),l=o.includes(n);i.push({comment:Vu({schema:r}),isReadOnly:r.accessScope===`read`,isRequired:l,name:Bu({context:e.context,name:n}),type:c}),a.push(r),l||(s=!0)}if(t.patternProperties)for(let e in t.patternProperties){let n=t.patternProperties[e];a.unshift(n)}let c=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,l=t.additionalProperties,u=l!==!1&&l?l:void 0;if(c||u&&(u.type!==`never`||!a.length)){let i=u;i&&i.type!==`never`?a.unshift(i):!c&&!a.length&&i&&i.type===`never`&&(a=[i]),s&&a.push({type:`undefined`}),r={isRequired:!t.propertyNames,name:`key`,type:a.length===1?J({plugin:e,schema:a[0]}):J({plugin:e,schema:{items:a,logicalOperator:`or`}})},t.propertyNames?.$ref&&(n=J({plugin:e,schema:{$ref:t.propertyNames.$ref}}))}return F.typeInterfaceNode({indexKey:n,indexProperty:r,properties:i,useLegacyResolution:!1})},id=({plugin:e,schema:t})=>{if(t.const!==void 0)return F.literalTypeNode({literal:F.stringLiteral({text:t.const})});if(t.format){if(t.format===`binary`)return F.typeUnionNode({types:[F.typeReferenceNode({typeName:`Blob`}),F.typeReferenceNode({typeName:`File`})]});if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return F.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`},name:`TypeID`,selector:t}),r=F.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:F.templateLiteralType({value:[F.typeReferenceNode({typeName:`T`}),`_`,F.keywordTypeNode({keyword:`string`})]}),typeParameters:[F.typeParameterDeclaration({constraint:F.keywordTypeNode({keyword:`string`}),name:`T`})]});e.setSymbolValue(n,r)}let n=e.referenceSymbol(t),a=e.registerSymbol({exported:!0,meta:{kind:`type`},name:w({case:e.config.case,value:`${r}_id`}),selector:i}),o=F.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:F.typeReferenceNode({typeArguments:[F.literalTypeNode({literal:F.stringLiteral({text:r})})],typeName:n.placeholder})});e.setSymbolValue(a,o)}let a=e.referenceSymbol(i);return F.typeReferenceNode({typeName:a.placeholder})}}return F.keywordTypeNode({keyword:`string`})},ad=({plugin:e,schema:t})=>{let n=[];if(t.const&&Array.isArray(t.const))n=t.const.map(t=>F.valueToExpression({value:t})??F.identifier({text:e.config.topType}));else if(t.items)for(let r of t.items){let t=J({plugin:e,schema:r});n.push(t)}return F.typeTupleNode({types:n})},od=({plugin:e,schema:t})=>{let n=e.getPlugin(`@hey-api/transformers`);if(n?.config.typeTransformers)for(let e of n.config.typeTransformers){let n=e({schema:t});if(n)return n}switch(t.type){case`array`:return $u({plugin:e,schema:t});case`boolean`:return ed({schema:t});case`enum`:return td({plugin:e,schema:t});case`integer`:case`number`:return nd({plugin:e,schema:t});case`never`:return F.keywordTypeNode({keyword:`never`});case`null`:return F.literalTypeNode({literal:F.null()});case`object`:return rd({plugin:e,schema:t});case`string`:return id({plugin:e,schema:t});case`tuple`:return ad({plugin:e,schema:t});case`undefined`:return F.keywordTypeNode({keyword:`undefined`});case`unknown`:return F.keywordTypeNode({keyword:e.config.topType});case`void`:return F.keywordTypeNode({keyword:`void`})}},J=({plugin:e,schema:t})=>{if(t.$ref){let n=e.referenceSymbol(e.api.selector(`ref`,t.$ref));return F.typeReferenceNode({typeName:n.placeholder})}if(t.type)return od({plugin:e,schema:t});if(t.items){if(t=E({detectFormat:!1,schema:t}),t.items){let n=[];for(let r of t.items){let t=J({plugin:e,schema:r});n.push(t)}return t.logicalOperator===`and`?F.typeIntersectionNode({types:n}):F.typeUnionNode({types:n})}return J({plugin:e,schema:t})}return od({plugin:e,schema:{type:`unknown`}})},sd=({id:e,plugin:t,schema:n})=>{let r=J({plugin:t,schema:n}),i=n.type===`enum`&&t.config.enums.enabled;Ku({plugin:t,schema:n,symbol:t.registerSymbol({exported:!0,meta:{kind:i?void 0:`type`},name:T({config:t.config.definitions,name:I(e)}),selector:t.api.selector(`ref`,e)}),type:r})},cd={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}schemaToType(e){return J(e)}}({name:`@hey-api/typescript`}),config:{case:`PascalCase`,exportFromIndex:!0,style:`preserve`,topType:`unknown`,tree:!1},handler:({plugin:e})=>{let t=e.registerSymbol({exported:!0,meta:{kind:`type`},name:T({config:{case:e.config.case},name:`ClientOptions`}),selector:e.api.selector(`ClientOptions`)}),n=e.registerSymbol({exported:!0,meta:{kind:`type`},name:T({config:{case:e.config.case},name:`Webhooks`}),selector:e.api.selector(`Webhooks`)}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{switch(t.type){case`operation`:Yu({operation:t.operation,plugin:e});break;case`parameter`:sd({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case`requestBody`:sd({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case`schema`:sd({id:t.$ref,plugin:e,schema:t.schema});break;case`server`:r.push(t.server);break;case`webhook`:i.push(Zu({operation:t.operation,plugin:e}));break}},{order:`declarations`}),Wu({plugin:e,servers:r,symbolClientOptions:t}),Qu({plugin:e,symbolWebhooks:n,webhookNames:i})},handlerLegacy:Au,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})}};var ld=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const ud=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return F.valueToExpression({value:i})},dd=({operation:e,plugin:t})=>Pc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),fd=({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},pd=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},md=({plugin:e,typeData:t})=>{let n=b(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},hd=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`UseMutationOptions`)),i=dd({operation:e,plugin:t}),a=fd({operation:e,plugin:t}),o=pd({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=md({plugin:t,typeData:i}),l=s?`${r.placeholder}<${o}, ${c}, ${a}>`:`${r.placeholder}<${o}, ${i}, ${a}>`,u=`fnOptions`,d=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:u},{key:`throwOnError`,value:!0}]})]})}),f=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?f.push(F.returnVariable({expression:d})):f.push(F.constVariable({destructure:!0,expression:d,name:`data`}),F.returnVariable({expression:`data`}));let p=[{key:`mutation`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[s?{name:u,type:`Partial<${c}>`}:{name:u}],statements:f})}],m=ud(t,e,`mutationOptions`);m&&p.push({key:`meta`,value:m});let h=t.getPluginOrThrow(`@hey-api/sdk`),g=t.registerSymbol({exported:!0,name:T({config:t.config.mutationOptions,name:e.id})}),_=F.constVariable({comment:t.config.comments?h.api.createOperationComment({operation:e}):void 0,exportConst:g.exported,expression:F.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${c}>`}],returnType:l,statements:[F.returnStatement({expression:F.objectExpression({obj:p})})]}),name:g.placeholder});t.setSymbolValue(g.id,_)},gd=`TOptions`,_d=F.identifier({text:`options`}),vd=({plugin:e})=>{let t=e.registerSymbol({name:T({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=F.indexedAccessTypeNode({indexType:F.literalTypeNode({literal:F.ots.number(0)}),objectType:F.typeReferenceNode({typeArguments:[F.typeReferenceNode({typeName:gd})],typeName:n.placeholder})}),a=de(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=il(e.context.config),d=e.registerSymbol({external:u,name:`serializeQueryKeyValue`}),f=F.constVariable({expression:F.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:F.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:F.typeReferenceNode({typeName:gd})},{isRequired:!1,name:`tags`,type:F.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:F.typeTupleNode({types:[i]}),statements:[F.constVariable({assertion:i,expression:F.objectExpression({multiLine:!1,obj:[{key:`_id`,value:F.identifier({text:`id`})},{key:a,value:F.identifier({text:`options?.${a} || (options?.client ?? ${l?.placeholder}).getConfig().${a}`})}]}),name:`params`,typeName:i}),F.ifStatement({expression:F.identifier({text:`tags`}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`tags`}),right:F.asExpression({expression:F.asExpression({expression:F.identifier({text:`tags`}),type:F.keywordTypeNode({keyword:`unknown`})}),type:F.typeReferenceNode({typeName:r.placeholder})})})})]})}),F.ifStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:_d,isOptional:!0,name:F.identifier({text:`body`})}),operator:`!==`,right:`undefined`}),thenStatement:F.block({statements:[F.constVariable({expression:F.callExpression({functionName:d.placeholder,parameters:[F.propertyAccessExpression({expression:`options`,name:`body`})]}),name:`normalizedBody`}),F.ifStatement({expression:F.binaryExpression({left:F.identifier({text:`normalizedBody`}),operator:`!==`,right:`undefined`}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`body`}),right:F.identifier({text:`normalizedBody`})})})]})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:_d,isOptional:!0,name:F.identifier({text:`path`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`path`}),right:F.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),F.ifStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:_d,isOptional:!0,name:F.identifier({text:`query`})}),operator:`!==`,right:`undefined`}),thenStatement:F.block({statements:[F.constVariable({expression:F.callExpression({functionName:d.placeholder,parameters:[F.propertyAccessExpression({expression:`options`,name:`query`})]}),name:`normalizedQuery`}),F.ifStatement({expression:F.binaryExpression({left:F.identifier({text:`normalizedQuery`}),operator:`!==`,right:`undefined`}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`query`}),right:F.identifier({text:`normalizedQuery`})})})]})})]})}),F.returnStatement({expression:F.arrayLiteralExpression({elements:[F.identifier({text:`params`})]})})],types:[{extends:F.typeReferenceNode({typeName:F.identifier({text:s.placeholder})}),name:gd}]}),name:t.placeholder});e.setSymbolValue(t,f)},yd=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;r.tags&&t.tags&&t.tags.length>0&&(i=F.arrayLiteralExpression({elements:t.tags.map(e=>F.stringLiteral({text:e}))}));let a=n.referenceSymbol(n.api.selector(`createQueryKey`));return F.callExpression({functionName:a.placeholder,parameters:[F.ots.string(e),`options`,i]})},bd=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`_JSONValue`)),n=[{name:`_id`,type:F.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:de(e.context.config),type:F.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`body`,type:F.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`query`,type:F.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`tags`,type:F.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=F.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:F.typeTupleNode({types:[F.typeIntersectionNode({types:[F.typeReferenceNode({typeName:`Pick<${gd}, 'path'>`}),F.typeInterfaceNode({properties:n,useLegacyResolution:!0})]})]}),typeParameters:[{extends:F.typeReferenceNode({typeName:F.identifier({text:i.placeholder})}),name:gd}]});e.setSymbolValue(a,o)},xd=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=md({plugin:t,typeData:dd({operation:e,plugin:t})});return F.constVariable({exportConst:n.exported,expression:F.arrowFunction({parameters:[{isRequired:it(e),name:`options`,type:r}],statements:yd({id:e.id,operation:e,plugin:t})}),name:n.placeholder})},Sd=`options`,Cd=`context`,wd=({operation:e,plugin:t,queryFn:n})=>{if(zc({operation:e}))return;let r=Rc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(bd({plugin:t}),vd({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:T({config:t.config.queryKeys,name:e.id})}),r=xd({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=F.callExpression({functionName:n.placeholder,parameters:[Sd]})}else{let n=t.referenceSymbol(t.api.selector(`createQueryKey`)),r;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(r=F.arrayLiteralExpression({elements:e.tags.map(e=>F.stringLiteral({text:e}))})),i=F.callExpression({functionName:n.placeholder,parameters:[F.ots.string(e.id),Sd,r]})}let{strippedTypeData:a}=md({plugin:t,typeData:dd({operation:e,plugin:t})}),o=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:Sd},{spread:Cd},{key:`throwOnError`,value:!0}]})]})}),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(F.returnVariable({expression:o})):s.push(F.constVariable({destructure:!0,expression:o,name:`data`}),F.returnVariable({expression:`data`}));let c=[{key:`key`,value:i},{key:`query`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[{name:Cd}],statements:s})}],l=ud(t,e,`queryOptions`);l&&c.push({key:`meta`,value:l});let u=t.getPluginOrThrow(`@hey-api/sdk`),d=t.registerSymbol({exported:!0,name:T({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),f=t.registerSymbol({external:t.name,name:`defineQueryOptions`,selector:t.api.selector(`defineQueryOptions`)}),p=F.constVariable({comment:t.config.comments?u.api.createOperationComment({operation:e}):void 0,exportConst:d.exported,expression:F.callExpression({functionName:f.placeholder,parameters:[F.arrowFunction({parameters:[{isRequired:r,name:Sd,type:a}],statements:F.objectExpression({obj:c})})]}),name:d.placeholder});t.setSymbolValue(d,p)},Td={api:new ld({name:`@pinia/colada`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:({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?Nc({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=>w({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&&wd({operation:n,plugin:e,queryFn:a}),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&hd({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},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})}},Ed=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return F.valueToExpression({value:i})},Dd=({operation:e,plugin:t})=>Pc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Od=({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},kd=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},Ad=`TOptions`,jd=F.identifier({text:`infinite`}),Md=F.identifier({text:`options`}),Nd=({plugin:e})=>{let t=e.registerSymbol({name:T({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=F.indexedAccessTypeNode({indexType:F.literalTypeNode({literal:F.ots.number(0)}),objectType:F.typeReferenceNode({typeArguments:[F.typeReferenceNode({typeName:Ad})],typeName:n.placeholder})}),i=de(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=F.constVariable({expression:F.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:F.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:F.typeReferenceNode({typeName:Ad})},{isRequired:!1,name:`infinite`,type:F.typeReferenceNode({typeName:`boolean`})},{isRequired:!1,name:`tags`,type:F.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:F.typeTupleNode({types:[r]}),statements:[F.constVariable({assertion:r,expression:F.objectExpression({multiLine:!1,obj:[{key:`_id`,value:F.identifier({text:`id`})},{key:i,value:F.identifier({text:`options?.${i} || (options?.client ?? ${o?.placeholder}).getConfig().${i}`})}]}),name:`params`,typeName:r}),F.ifStatement({expression:jd,thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:jd})})]})}),F.ifStatement({expression:F.identifier({text:`tags`}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`tags`}),right:F.identifier({text:`tags`})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:Md,isOptional:!0,name:F.identifier({text:`body`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`body`}),right:F.propertyAccessExpression({expression:`options`,name:`body`})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:Md,isOptional:!0,name:F.identifier({text:`headers`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`headers`}),right:F.propertyAccessExpression({expression:`options`,name:`headers`})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:Md,isOptional:!0,name:F.identifier({text:`path`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`path`}),right:F.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:Md,isOptional:!0,name:F.identifier({text:`query`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`query`}),right:F.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),F.returnStatement({expression:F.arrayLiteralExpression({elements:[F.identifier({text:`params`})]})})],types:[{extends:F.typeReferenceNode({typeName:F.identifier({text:c.placeholder})}),name:Ad}]}),name:t.placeholder});e.setSymbolValue(t,l)},Pd=({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=F.arrayLiteralExpression({elements:n.tags.map(e=>F.stringLiteral({text:e}))}));let o=r.referenceSymbol(r.api.selector(`createQueryKey`));return F.callExpression({functionName:o.placeholder,parameters:[F.ots.string(e),`options`,t||a?F.ots.boolean(!!t):void 0,a]})},Fd=({plugin:e})=>{let t=[{name:`_id`,type:F.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:F.keywordTypeNode({keyword:`boolean`})},{isRequired:!1,name:`tags`,type:F.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=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:F.typeTupleNode({types:[F.typeIntersectionNode({types:[F.typeReferenceNode({typeName:`Pick<${Ad}, '${de(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),F.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:F.typeReferenceNode({typeName:F.identifier({text:r.placeholder})}),name:Ad}]});e.setSymbolValue(i,a)},Id=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=Dd({operation:t,plugin:n});return F.constVariable({exportConst:r.exported,expression:F.arrowFunction({parameters:[{isRequired:it(t),name:`options`,type:a}],returnType:e?i:void 0,statements:Pd({id:t.id,isInfinite:e,operation:t,plugin:n})}),name:r.placeholder})},Ld=({plugin:e})=>{let t=e.registerSymbol({name:T({config:{case:e.config.case},name:`createInfiniteParams`}),selector:e.api.selector(`createInfiniteParams`)}),n=F.constVariable({expression:F.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:F.typeReferenceNode({typeName:`QueryKey<Options>`})},{name:`page`,type:F.typeReferenceNode({typeName:`K`})}],statements:[F.constVariable({expression:F.objectExpression({obj:[{spread:F.propertyAccessExpression({expression:`queryKey`,name:0})}]}),name:`params`}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`body`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`body`}),right:F.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].body`},{assertion:`any`,spread:`page.body`}]})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`headers`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`headers`}),right:F.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].headers`},{spread:`page.headers`}]})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`path`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`path`}),right:F.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].path`},{assertion:`any`,spread:`page.path`}]})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`query`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`query`}),right:F.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].query`},{assertion:`any`,spread:`page.query`}]})})})]})}),F.returnVariable({expression:F.asExpression({expression:F.asExpression({expression:F.identifier({text:`params`}),type:F.keywordTypeNode({keyword:`unknown`})}),type:a.factory.createTypeQueryNode(F.identifier({text:`page`}))})})],types:[{extends:F.typeReferenceNode({typeName:F.identifier({text:`Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:t.placeholder});e.setSymbolValue(t,n)},Rd=({operation:e,plugin:t,queryFn:n})=>{let r=at({context:t.context,operation:e});if(!r)return;let i=Rc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Fd({plugin:t}),Nd({plugin:t})),t.getSymbol(t.api.selector(`createInfiniteParams`))||Ld({plugin:t});let a=t.referenceSymbol(t.api.selector(`infiniteQueryOptions`)),o=t.referenceSymbol(t.api.selector(`InfiniteData`)),s=Dd({operation:e,plugin:t}),c=Od({operation:e,plugin:t}),l=kd({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=`${wt({node:f.api.schemaToType({plugin:f,schema:r.schema}),unescape:!0})} | ${d}`,m=t.registerSymbol({exported:!0,name:T({config:t.config.infiniteQueryKeys,name:e.id})}),h=Id({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.setSymbolValue(m,h);let g=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:F.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),_=t.referenceSymbol(t.api.selector(`createInfiniteParams`)),v=[F.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:F.conditionalExpression({condition:F.binaryExpression({left:F.typeOfExpression({text:`pageParam`}),operator:`===`,right:F.ots.string(`object`)}),whenFalse:F.objectExpression({multiLine:!0,obj:[{key:r.in,value:F.objectExpression({multiLine:!0,obj:[{key:r.name,value:F.identifier({text:`pageParam`})}]})}]}),whenTrue:F.identifier({text:`pageParam`})}),name:`page`,typeName:d}),F.constVariable({expression:F.callExpression({functionName:_.placeholder,parameters:[`queryKey`,`page`]}),name:`params`})];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?v.push(F.returnVariable({expression:g})):v.push(F.constVariable({destructure:!0,expression:g,name:`data`}),F.returnVariable({expression:`data`}));let ee=[{key:`queryFn`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:v})},{key:`queryKey`,value:F.callExpression({functionName:m.placeholder,parameters:[`options`]})}],y=Ed(t,e,`infiniteQueryOptions`);y&&ee.push({key:`meta`,value:y});let te=t.getPluginOrThrow(`@hey-api/sdk`),ne=t.registerSymbol({exported:!0,name:T({config:t.config.infiniteQueryOptions,name:e.id})}),re=F.constVariable({comment:t.config.comments?te.api.createOperationComment({operation:e}):void 0,exportConst:ne.exported,expression:F.arrowFunction({parameters:[{isRequired:i,name:`options`,type:s}],statements:[F.returnFunctionCall({args:[F.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:ee})],name:a.placeholder,types:[l,c||`unknown`,`${o.placeholder}<${l}>`,u,p]})]}),name:ne.placeholder});t.setSymbolValue(ne,re)},zd=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`MutationOptions`)),i=Dd({operation:e,plugin:t}),a=Od({operation:e,plugin:t}),o=kd({operation:e,plugin:t}),s=`${r.placeholder}<${o}, ${a}, ${i}>`,c=`fnOptions`,l=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),u=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?u.push(F.returnVariable({expression:l})):u.push(F.constVariable({destructure:!0,expression:l,name:`data`}),F.returnVariable({expression:`data`}));let d=[{key:`mutationFn`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:u})}],f=Ed(t,e,`mutationOptions`);f&&d.push({key:`meta`,value:f});let p=t.getPluginOrThrow(`@hey-api/sdk`),m=`mutationOptions`,h=F.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${i}>`}],returnType:s,statements:[F.constVariable({expression:F.objectExpression({obj:d}),name:m,typeName:s}),F.returnVariable({expression:m})]}),g=t.registerSymbol({exported:!0,name:T({config:t.config.mutationOptions,name:e.id})}),_=F.constVariable({comment:t.config.comments?p.api.createOperationComment({operation:e}):void 0,exportConst:g.exported,expression:h,name:g.placeholder});t.setSymbolValue(g,_)},Bd=`options`,Vd=({operation:e,plugin:t,queryFn:n})=>{if(zc({operation:e}))return;let r=Rc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(Fd({plugin:t}),Nd({plugin:t}));let i=t.referenceSymbol(t.api.selector(`queryOptions`)),a=t.registerSymbol({exported:!0,name:T({config:t.config.queryKeys,name:e.id})}),o=Id({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=Dd({operation:e,plugin:t}),c=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:Bd},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:F.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),l=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?l.push(F.returnVariable({expression:c})):l.push(F.constVariable({destructure:!0,expression:c,name:`data`}),F.returnVariable({expression:`data`}));let u=[{key:`queryFn`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:l})},{key:`queryKey`,value:F.callExpression({functionName:a.placeholder,parameters:[Bd]})}],d=Ed(t,e,`queryOptions`);d&&u.push({key:`meta`,value:d});let f=t.getPluginOrThrow(`@hey-api/sdk`),p=t.registerSymbol({exported:t.config.queryOptions.exported,name:T({config:t.config.queryOptions,name:e.id}),selector:t.api.selector(`queryOptionsFn`,e.id)}),m=F.constVariable({comment:t.config.comments?f.api.createOperationComment({operation:e}):void 0,exportConst:p.exported,expression:F.arrowFunction({parameters:[{isRequired:r,name:Bd,type:s}],statements:[F.returnFunctionCall({args:[F.objectExpression({obj:u})],name:i.placeholder})]}),name:p.placeholder});t.setSymbolValue(p,m)},Hd=`options`,Ud=({operation:e,plugin:t})=>{if(zc({operation:e})||!(`useQuery`in t.config))return;let n=t.getPluginOrThrow(`@hey-api/sdk`),r=t.registerSymbol({exported:!0,name:T({config:t.config.useQuery,name:e.id})}),i=t.referenceSymbol(t.api.selector(`useQuery`)),a=Rc({context:t.context,operation:e}),o=Dd({operation:e,plugin:t}),s=t.referenceSymbol(t.api.selector(`queryOptionsFn`,e.id)),c=F.constVariable({comment:t.config.comments?n.api.createOperationComment({operation:e}):void 0,exportConst:r.exported,expression:F.arrowFunction({parameters:[{isRequired:a,name:Hd,type:o}],statements:[F.returnStatement({expression:F.callExpression({functionName:i.placeholder,parameters:[F.callExpression({functionName:s.placeholder,parameters:[Hd]})]})})]}),name:r.placeholder});t.setSymbolValue(r,c)},Wd=({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?Nc({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=>w({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&&Vd({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&Rd({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&Ud({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&zd({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},Gd=e=>`${iu({config:x(),id:e.name,operation:e})}InfiniteOptions`,Kd=e=>`${iu({config:x(),id:e.name,operation:e})}Mutation`,qd=({config:e,id:t,operation:n})=>`${iu({config:e,id:t,operation:n})}Options`,Jd=({config:e,id:t,isInfinite:n,operation:r})=>`${iu({config:e,id:t,operation:r})}${n?`Infinite`:``}QueryKey`,Yd=e=>{switch(e.in){case`formData`:return`body`;case`header`:return`headers`;default:return e.in}},Xd=`createQueryKey`,Zd=`infiniteQueryOptions`,Qd=`mutationOptions`,$d=`QueryKey`,ef=`queryOptions`,tf=`TOptions`,nf=({file:e})=>{let t=F.constVariable({expression:F.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:F.typeNode(`QueryKey<OptionsLegacyParser>`)},{name:`page`,type:F.typeNode(`K`)}],statements:[F.constVariable({expression:F.identifier({text:`queryKey[0]`}),name:`params`}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`body`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`body`}),right:F.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].body`},{assertion:`any`,spread:`page.body`}]})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`headers`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`headers`}),right:F.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].headers`},{spread:`page.headers`}]})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`path`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`path`}),right:F.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].path`},{spread:`page.path`}]})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`page`}),name:F.identifier({text:`query`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`query`}),right:F.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].query`},{spread:`page.query`}]})})})]})}),F.returnVariable({expression:a.factory.createAsExpression(a.factory.createAsExpression(F.identifier({text:`params`}),a.factory.createKeywordTypeNode(a.SyntaxKind.UnknownKeyword)),a.factory.createTypeQueryNode(F.identifier({text:`page`})))})],types:[{extends:F.typeReferenceNode({typeName:F.identifier({text:`Pick<QueryKey<OptionsLegacyParser>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:`createInfiniteParams`});e.add(t)},rf=({file:e})=>{let t=F.indexedAccessTypeNode({indexType:F.typeNode(0),objectType:F.typeNode($d,[F.typeNode(tf)])}),n=F.identifier({text:`infinite`}),r=de(x()),i=F.constVariable({expression:F.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:F.typeNode(`string`)},{isRequired:!1,name:`options`,type:F.typeNode(tf)},{isRequired:!1,name:`infinite`,type:F.typeNode(`boolean`)}],returnType:t,statements:[F.constVariable({assertion:t,expression:F.objectExpression({multiLine:!1,obj:[{key:`_id`,value:F.identifier({text:`id`})},{key:r,value:F.identifier({text:`options?.${r} || (options?.client ?? _heyApiClient).getConfig().${r}`})}]}),name:`params`,typeName:t}),F.ifStatement({expression:n,thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:n})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`options`}),isOptional:!0,name:F.identifier({text:`body`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`body`}),right:F.propertyAccessExpression({expression:`options`,name:`body`})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`options`}),isOptional:!0,name:F.identifier({text:`headers`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`headers`}),right:F.propertyAccessExpression({expression:`options`,name:`headers`})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`options`}),isOptional:!0,name:F.identifier({text:`path`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`path`}),right:F.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),F.ifStatement({expression:F.propertyAccessExpression({expression:F.identifier({text:`options`}),isOptional:!0,name:F.identifier({text:`query`})}),thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`query`}),right:F.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),F.returnVariable({expression:`params`})],types:[{extends:F.typeReferenceNode({typeName:F.identifier({text:`OptionsLegacyParser`})}),name:tf}]}),name:Xd});e.add(i)},af=({file:e})=>{let t=[{name:`_id`,type:F.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:F.keywordTypeNode({keyword:`boolean`})}],n=F.typeAliasDeclaration({name:$d,type:F.typeTupleNode({types:[F.typeIntersectionNode({types:[F.typeReferenceNode({typeName:`Pick<${tf}, '${de(x())}' | 'body' | 'headers' | 'path' | 'query'>`}),F.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:F.typeReferenceNode({typeName:F.identifier({text:`OptionsLegacyParser`})}),name:tf}]});e.add(n)},of=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=ql({client:e,meta:n.parameters.length?{$ref:n.name,name:n.name}:void 0,nameTransformer:Yl,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeData:$l({importedType:i})}},sf=({client:e,file:t,operation:n,pluginName:r,typesModulePath:i})=>{let a=x(),{name:o}=ql({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:Xl,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}},cf=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=ql({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:Ql,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeResponse:i||`void`}},lf=({id:e,isInfinite:t})=>F.arrayLiteralExpression({elements:[F.callExpression({functionName:Xd,parameters:[F.ots.string(e),`options`,t?F.ots.boolean(!0):void 0]})],multiLine:!1}),uf=({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:rl({config:r,sourceOutput:n.output}),name:`OptionsLegacyParser`});let a=ne({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=O(h);if(p.has(g))continue;p.set(g,!0);let _=[r.plugins[`@hey-api/sdk`]?.config.asClass&&Ko({config:r,name:m.name}),iu({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||=(af({file:i}),rf({file:i}),!0),i.import({module:n.name,name:ef})),v=!0;let{typeData:t}=of({client:e,file:i,operation:h,typesModulePath:a}),o=Ms(h.parameters),s=F.constVariable({exportConst:!0,expression:F.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:lf({id:h.name})}),name:Jd({config:r,id:h.name,operation:h})});i.add(s);let c=F.constVariable({comment:[],exportConst:!0,expression:F.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:[F.returnFunctionCall({args:[F.objectExpression({obj:[{key:`queryFn`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:[F.constVariable({destructure:!0,expression:F.awaitExpression({expression:F.callExpression({functionName:_,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:F.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),F.returnVariable({expression:`data`})]})},{key:`queryKey`,value:F.callExpression({functionName:Jd({config:r,id:h.name,operation:h}),parameters:[`options`]})}]})],name:ef})]}),name:qd({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(ki(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(ki(r.parser.pagination).test(e.name))return t=e,!0})}return n.properties.find(e=>{if(ki(r.parser.pagination).test(e.name))return t=e,!0})}});if(o&&t){u||(u=!0,l||=(af({file:i}),rf({file:i}),!0),c||=(nf({file:i}),!0),i.import({module:n.name,name:Zd}),s=i.import({asType:!0,module:n.name,name:`InfiniteData`})),v=!0;let{typeData:d}=of({client:e,file:i,operation:h,typesModulePath:a}),{typeError:f}=sf({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:p}=cf({client:e,file:i,operation:h,typesModulePath:a}),m=Ms(h.parameters),g=`${$d}<${d}>`,ee=`Pick<${g}[0], 'body' | 'headers' | 'path' | 'query'>`,y=`${t.base} | ${ee}`,te=F.constVariable({exportConst:!0,expression:F.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],returnType:g,statements:lf({id:h.name,isInfinite:!0})}),name:Jd({config:r,id:h.name,isInfinite:!0,operation:h})});i.add(te);let ne=F.constVariable({comment:[],exportConst:!0,expression:F.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],statements:[F.returnFunctionCall({args:[F.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:[{key:`queryFn`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:[F.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:F.conditionalExpression({condition:F.binaryExpression({left:F.typeOfExpression({text:`pageParam`}),operator:`===`,right:F.ots.string(`object`)}),whenFalse:F.objectExpression({multiLine:!0,obj:[{key:Yd(o),value:F.objectExpression({multiLine:!0,obj:[{key:t.name,value:F.identifier({text:`pageParam`})}]})}]}),whenTrue:F.identifier({text:`pageParam`})}),name:`page`,typeName:ee}),F.constVariable({expression:F.callExpression({functionName:`createInfiniteParams`,parameters:[`queryKey`,`page`]}),name:`params`}),F.constVariable({destructure:!0,expression:F.awaitExpression({expression:F.callExpression({functionName:_,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:F.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),F.returnVariable({expression:`data`})]})},{key:`queryKey`,value:F.callExpression({functionName:Jd({config:r,id:h.name,isInfinite:!0,operation:h}),parameters:[`options`]})}]})],name:Zd,types:[p,f.name,`${typeof s==`string`?s:s.name}<${p}>`,g,y]})]}),name:Gd(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}=of({client:e,file:i,operation:h,typesModulePath:a}),{typeError:r}=sf({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:s}=cf({client:e,file:i,operation:h,typesModulePath:a}),c=`fnOptions`,l=F.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${t}>`}],statements:[F.constVariable({expression:F.objectExpression({obj:[{key:`mutationFn`,value:F.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:[F.constVariable({destructure:!0,expression:F.awaitExpression({expression:F.callExpression({functionName:_,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),name:`data`}),F.returnVariable({expression:`data`})]})}]}),name:Qd,typeName:`${o}<${s}, ${r.name}, ${t}>`}),F.returnVariable({expression:Qd})]}),u=F.constVariable({comment:[],exportConst:!0,expression:l,name:Kd(h)});i.add(u)}(f||u)&&i.import({alias:`_heyApiClient`,module:ne({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:n.output}),name:`client`}),v&&i.import({module:ne({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:n.output}),name:_.split(`.`)[0]})}},df={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/angular-query-experimental`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Wd,handlerLegacy:uf,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})}},ff={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/react-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Wd,handlerLegacy:uf,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))}},pf={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/solid-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Wd,handlerLegacy:uf,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})}},mf={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/svelte-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Wd,handlerLegacy:uf,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})}},hf={api:new class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}}({name:`@tanstack/vue-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Wd,handlerLegacy:uf,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})}},gf=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[F.identifier({text:r})]})})})]})},_f=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[F.identifier({text:r})]})})})]})};var vf=class{constructor(e){this.meta=e}createRequestValidator(e){return gf(e)}createResponseValidator(e){return _f(e)}selector(...e){return[this.meta.name,...e]}};const yf=e=>{if(e.length>=2){if(e[0]===`components`){if(e[1]===`schemas`)return`schema`;if(e[1]===`parameters`)return`parameter`;if(e[1]===`requestBodies`)return`requestBody`}if(e[0]===`paths`)return`operation`;if(e[0]===`servers`)return`server`;if(e[0]===`webhooks`)return`webhook`}},Y=e=>({value:e}),X=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=Y(e[n]));return t},bf={keywords:{false:F.identifier({text:`false`}),true:F.identifier({text:`true`})},number:{Infinity:F.identifier({text:`Infinity`}),NaN:F.identifier({text:`NaN`}),NegativeInfinity:F.identifier({text:`NegativeInfinity`}),epoch:F.identifier({text:`epoch`}),integer:F.identifier({text:`integer`}),safe:F.identifier({text:`safe`})},primitives:{bigint:F.identifier({text:`bigint`}),boolean:F.identifier({text:`boolean`}),keywords:F.identifier({text:`keywords`}),null:`null`,number:F.identifier({text:`number`}),string:`string`,symbol:F.identifier({text:`symbol`}),undefined:F.identifier({text:`undefined`}),unit:F.identifier({text:`unit`})},string:{NFC:F.identifier({text:`NFC`}),NFD:F.identifier({text:`NFD`}),NFKC:F.identifier({text:`NFKC`}),NFKD:F.identifier({text:`NFKD`}),alpha:F.identifier({text:`alpha`}),alphanumeric:F.identifier({text:`alphanumeric`}),base64:F.identifier({text:`base64`}),capitalize:F.identifier({text:`capitalize`}),creditCard:F.identifier({text:`creditCard`}),date:`date`,digits:F.identifier({text:`digits`}),email:`email`,epoch:F.identifier({text:`epoch`}),hex:F.identifier({text:`hex`}),integer:F.identifier({text:`integer`}),ip:`ip`,iso:`iso`,json:F.identifier({text:`json`}),lower:F.identifier({text:`lower`}),normalize:F.identifier({text:`normalize`}),numeric:F.identifier({text:`numeric`}),parse:F.identifier({text:`parse`}),preformatted:F.identifier({text:`preformatted`}),regex:F.identifier({text:`regex`}),semver:F.identifier({text:`semver`}),trim:F.identifier({text:`trim`}),upper:F.identifier({text:`upper`}),url:`url`,uuid:`uuid`,v1:`v1`,v2:`v2`,v3:`v3`,v4:`v4`,v5:`v5`,v6:`v6`,v7:`v7`,v8:`v8`},type:{$:F.identifier({text:`$`}),allows:F.identifier({text:`allows`}),and:F.identifier({text:`and`}),array:F.identifier({text:`array`}),as:F.identifier({text:`as`}),assert:F.identifier({text:`assert`}),brand:F.identifier({text:`brand`}),configure:F.identifier({text:`configure`}),default:F.identifier({text:`default`}),describe:F.identifier({text:`describe`}),description:F.identifier({text:`description`}),equals:F.identifier({text:`equals`}),exclude:F.identifier({text:`exclude`}),expression:F.identifier({text:`expression`}),extends:F.identifier({text:`extends`}),extract:F.identifier({text:`extract`}),filter:F.identifier({text:`filter`}),from:F.identifier({text:`from`}),ifEquals:F.identifier({text:`ifEquals`}),ifExtends:F.identifier({text:`ifExtends`}),infer:F.identifier({text:`infer`}),inferIn:F.identifier({text:`inferIn`}),intersect:F.identifier({text:`intersect`}),json:F.identifier({text:`json`}),meta:F.identifier({text:`meta`}),narrow:F.identifier({text:`narrow`}),onDeepUndeclaredKey:F.identifier({text:`onDeepUndeclaredKey`}),onUndeclaredKey:F.identifier({text:`onUndeclaredKey`}),optional:F.identifier({text:`optional`}),or:F.identifier({text:`or`}),overlaps:F.identifier({text:`overlaps`}),pipe:F.identifier({text:`pipe`}),select:F.identifier({text:`select`}),to:F.identifier({text:`to`}),toJsonSchema:F.identifier({text:`toJsonSchema`})}},xf=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let o=t.referenceSymbol(t.api.selector(`external`,`arktype.type`)),s=F.constVariable({comment:t.config.comments?Vu({schema:n}):void 0,exportConst:r.exported,expression:F.callExpression({functionName:o.placeholder,parameters:[e.def?F.stringLiteral({text:e.def}):e.expression]}),name:r.placeholder});if(t.setSymbolValue(r,s),i){let e=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a.factory.createTypeQueryNode(a.factory.createQualifiedName(a.factory.createIdentifier(r.placeholder),bf.type.infer))});t.setSymbolValue(i,e)}},Sf=e=>{let t={};return t.def=bf.primitives.null,t},Cf=({plugin:e,schema:t,state:n})=>{let r={},i=[],o=t.required??[];for(let s in t.properties){let c=t.properties[s],l=o.includes(s),u=Ef({optional:!l,plugin:e,schema:c,state:{...n,_path:Y([...n._path.value,`properties`,s])}});u.hasLazyExpression&&(r.hasLazyExpression=!0);let d=l?s:`${s}?`;d.endsWith(`?`)?d=a.factory.createComputedPropertyName(F.stringLiteral({text:d})):((d.match(/^[0-9]/)&&d.match(/\D+/g)||d.match(/\W/g))&&!d.startsWith(`'`)&&!d.endsWith(`'`)&&(d=`'${d}'`),k.lastIndex=0,d=k.test(d)?d.startsWith(`-`)?F.stringLiteral({text:s}):a.factory.createNumericLiteral(s):s),i.push(F.propertyAssignment({initializer:u.expression,name:d}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Ef({plugin:e,schema:t.additionalProperties,state:{...n,_path:Y([...n._path.value,`additionalProperties`])}});return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:`TODO`,name:`record`}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:`TODO`,name:`string`}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r}return r.expression=a.factory.createObjectLiteralExpression(i,!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r},wf=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=bf.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${bf.string.date}.${bf.string.iso}`;break;case`email`:n=`${n}.${bf.string.email}`;break;case`ipv4`:n=`${n}.${bf.string.ip}.${bf.string.v4}`;break;case`ipv6`:n=`${n}.${bf.string.ip}.${bf.string.v6}`;break;case`uri`:n=`${n}.${bf.string.url}`;break;case`uuid`:n=`${n}.${bf.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},Tf=({schema:e,...t})=>{switch(e.type){case`null`:return Sf({...t,schema:e});case`object`:return Cf({...t,schema:e});case`string`:return wf({...t,schema:e})}let n=t.plugin.referenceSymbol(t.plugin.api.selector(`external`,`arktype.type`));return{def:``,expression:a.factory.createCallExpression(a.factory.createIdentifier(n.placeholder),void 0,[a.factory.createObjectLiteralExpression([a.factory.createPropertyAssignment(`name`,a.factory.createStringLiteral(`string`)),a.factory.createPropertyAssignment(`platform`,a.factory.createStringLiteral(`'android' | 'ios'`)),a.factory.createPropertyAssignment(a.factory.createComputedPropertyName(a.factory.createStringLiteral(`versions?`)),a.factory.createStringLiteral(`(number | string)[]`))],!0)]),hasLazyExpression:!1}},Ef=({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=F.identifier({text:a.placeholder}):(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:`TODO`,name:`TODO`}),parameters:[F.arrowFunction({returnType:F.keywordTypeNode({keyword:`any`}),statements:[F.returnStatement({expression:F.identifier({text:a.placeholder})})]})]}),r.hasLazyExpression=!0,n.hasLazyExpression.value=!0)}else if(t.type){let i=Tf({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=E({schema:t}),t.items||(r=Ef({plugin:e,schema:t,state:n}));else{let t=Tf({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=Tf({plugin:e,schema:{type:`unknown`},state:n}).expression,r},Df=({$ref:e,plugin:t,schema:n,state:r})=>{let i=Ef({plugin:t,schema:n,state:r}),a=I(e),o=yf(r._path.value);xf({ast:i,plugin:t,schema:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:o},name:T({config:t.config.definitions,name:a}),selector:t.api.selector(`ref`,e)}),typeInferSymbol:t.config.definitions.types.infer.enabled?t.registerSymbol({exported:!0,meta:{kind:`type`,resourceType:o},name:T({config:t.config.definitions.types.infer,name:a}),selector:t.api.selector(`type-infer-ref`,e)}):void 0})},Of=({plugin:e})=>{e.registerSymbol({external:`arktype`,name:`type`,selector:e.api.selector(`external`,`arktype.type`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{switch(t.type){case`parameter`:Df({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:X({_path:t._path,hasLazyExpression:!1})});break;case`requestBody`:Df({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:X({_path:t._path,hasLazyExpression:!1})});break;case`schema`:Df({$ref:t.$ref,plugin:e,schema:t.schema,state:X({_path:t._path,hasLazyExpression:!1})});break}})},kf={api:new vf({name:`arktype`}),config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>Of(e),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:C,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:{...C,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:C,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:{...C,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:C,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:{...C,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:C,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:{...C,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:C,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]};var Af=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const jf=({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:tt(e.parameters.header),name:`Headers`,type:`${i.placeholder}['headers']`}),e.parameters.path&&n.push({isRequired:tt(e.parameters.path),name:`Params`,type:`${i.placeholder}['path']`}),e.parameters.query&&n.push({isRequired:tt(e.parameters.query),name:`Querystring`,type:`${i.placeholder}['query']`})));let{errors:a,responses:o}=st(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=F.typeReferenceNode({typeName:c.placeholder});else if(e.length>1){let e=F.typeReferenceNode({typeName:c.placeholder}),t=F.literalTypeNode({literal:F.stringLiteral({text:`default`})});s=F.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=F.typeReferenceNode({typeName:u.placeholder});else if(e.length>1){let e=F.typeReferenceNode({typeName:u.placeholder}),t=F.literalTypeNode({literal:F.stringLiteral({text:`default`})});l=F.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let d=[s,l].filter(Boolean);if(d.length&&n.push({name:`Reply`,type:F.typeIntersectionNode({types:d})}),!n.length)return;let f=t.referenceSymbol(t.api.selector(`RouteHandler`));return{name:e.id,type:F.typeReferenceNode({typeArguments:[F.typeInterfaceNode({properties:n,useLegacyResolution:!1})],typeName:f.placeholder})}},Mf={api:new Af({name:`fastify`}),config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:({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=jf({operation:t,plugin:e});r&&n.push(r)},{order:`declarations`});let r=F.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:F.typeInterfaceNode({properties:n,useLegacyResolution:!1})});e.setSymbolValue(t,r)},name:`fastify`},Z={actions:{args:F.identifier({text:`args`}),base64:F.identifier({text:`base64`}),bic:F.identifier({text:`bic`}),brand:F.identifier({text:`brand`}),bytes:F.identifier({text:`bytes`}),check:F.identifier({text:`check`}),checkItems:F.identifier({text:`checkItems`}),creditCard:F.identifier({text:`creditCard`}),cuid2:F.identifier({text:`cuid2`}),decimal:F.identifier({text:`decimal`}),description:F.identifier({text:`description`}),digits:F.identifier({text:`digits`}),email:F.identifier({text:`email`}),emoji:F.identifier({text:`emoji`}),empty:F.identifier({text:`empty`}),endsWith:F.identifier({text:`endsWith`}),entries:F.identifier({text:`entries`}),everyItem:F.identifier({text:`everyItem`}),excludes:F.identifier({text:`excludes`}),filterItems:F.identifier({text:`filterItems`}),findItem:F.identifier({text:`findItem`}),finite:F.identifier({text:`finite`}),flavor:F.identifier({text:`flavor`}),graphemes:F.identifier({text:`graphemes`}),gtValue:F.identifier({text:`gtValue`}),hash:F.identifier({text:`hash`}),hexColor:F.identifier({text:`hexColor`}),hexadecimal:F.identifier({text:`hexadecimal`}),imei:F.identifier({text:`imei`}),includes:F.identifier({text:`includes`}),integer:F.identifier({text:`integer`}),ip:F.identifier({text:`ip`}),ipv4:F.identifier({text:`ipv4`}),ipv6:F.identifier({text:`ipv6`}),isoDate:F.identifier({text:`isoDate`}),isoDateTime:F.identifier({text:`isoDateTime`}),isoTime:F.identifier({text:`isoTime`}),isoTimeSecond:F.identifier({text:`isoTimeSecond`}),isoTimestamp:F.identifier({text:`isoTimestamp`}),isoWeek:F.identifier({text:`isoWeek`}),length:F.identifier({text:`length`}),ltValue:F.identifier({text:`ltValue`}),mac:F.identifier({text:`mac`}),mac48:F.identifier({text:`mac48`}),mac64:F.identifier({text:`mac64`}),mapItems:F.identifier({text:`mapItems`}),maxBytes:F.identifier({text:`maxBytes`}),maxEntries:F.identifier({text:`maxEntries`}),maxGraphemes:F.identifier({text:`maxGraphemes`}),maxLength:F.identifier({text:`maxLength`}),maxSize:F.identifier({text:`maxSize`}),maxValue:F.identifier({text:`maxValue`}),maxWords:F.identifier({text:`maxWords`}),metadata:F.identifier({text:`metadata`}),mimeType:F.identifier({text:`mimeType`}),minBytes:F.identifier({text:`minBytes`}),minEntries:F.identifier({text:`minEntries`}),minGraphemes:F.identifier({text:`minGraphemes`}),minLength:F.identifier({text:`minLength`}),minSize:F.identifier({text:`minSize`}),minValue:F.identifier({text:`minValue`}),minWords:F.identifier({text:`minWords`}),multipleOf:F.identifier({text:`multipleOf`}),nanoid:F.identifier({text:`nanoid`}),nonEmpty:F.identifier({text:`nonEmpty`}),normalize:F.identifier({text:`normalize`}),notBytes:F.identifier({text:`notBytes`}),notEntries:F.identifier({text:`notEntries`}),notGraphemes:F.identifier({text:`notGraphemes`}),notLength:F.identifier({text:`notLength`}),notSize:F.identifier({text:`notSize`}),notValue:F.identifier({text:`notValue`}),notValues:F.identifier({text:`notValues`}),notWords:F.identifier({text:`notWords`}),octal:F.identifier({text:`octal`}),parseJson:F.identifier({text:`parseJson`}),partialCheck:F.identifier({text:`partialCheck`}),rawCheck:F.identifier({text:`rawCheck`}),rawTransform:F.identifier({text:`rawTransform`}),readonly:F.identifier({text:`readonly`}),reduceItems:F.identifier({text:`reduceItems`}),regex:F.identifier({text:`regex`}),returns:F.identifier({text:`returns`}),rfcEmail:F.identifier({text:`rfcEmail`}),safeInteger:F.identifier({text:`safeInteger`}),size:F.identifier({text:`size`}),slug:F.identifier({text:`slug`}),someItem:F.identifier({text:`someItem`}),sortItems:F.identifier({text:`sortItems`}),startsWith:F.identifier({text:`startsWith`}),stringifyJson:F.identifier({text:`stringifyJson`}),title:F.identifier({text:`title`}),toLowerCase:F.identifier({text:`toLowerCase`}),toMaxValue:F.identifier({text:`toMaxValue`}),toMinValue:F.identifier({text:`toMinValue`}),toUpperCase:F.identifier({text:`toUpperCase`}),transform:F.identifier({text:`transform`}),trim:F.identifier({text:`trim`}),trimEnd:F.identifier({text:`trimEnd`}),trimStart:F.identifier({text:`trimStart`}),ulid:F.identifier({text:`ulid`}),url:F.identifier({text:`url`}),uuid:F.identifier({text:`uuid`}),value:F.identifier({text:`value`}),values:F.identifier({text:`values`}),words:F.identifier({text:`words`})},async:{argsAsync:F.identifier({text:`argsAsync`}),arrayAsync:F.identifier({text:`arrayAsync`}),awaitAsync:F.identifier({text:`awaitAsync`}),checkAsync:F.identifier({text:`checkAsync`}),checkItemsAsync:F.identifier({text:`checkItemsAsync`}),customAsync:F.identifier({text:`customAsync`}),exactOptionalAsync:F.identifier({text:`exactOptionalAsync`}),fallbackAsync:F.identifier({text:`fallbackAsync`}),forwardAsync:F.identifier({text:`forwardAsync`}),getDefaultsAsync:F.identifier({text:`getDefaultsAsync`}),getFallbacksAsync:F.identifier({text:`getFallbacksAsync`}),intersectAsync:F.identifier({text:`intersectAsync`}),lazyAsync:F.identifier({text:`lazyAsync`}),looseObjectAsync:F.identifier({text:`looseObjectAsync`}),looseTupleAsync:F.identifier({text:`looseTupleAsync`}),mapAsync:F.identifier({text:`mapAsync`}),nonNullableAsync:F.identifier({text:`nonNullableAsync`}),nonNullishAsync:F.identifier({text:`nonNullishAsync`}),nonOptionalAsync:F.identifier({text:`nonOptionalAsync`}),nullableAsync:F.identifier({text:`nullableAsync`}),nullishAsync:F.identifier({text:`nullishAsync`}),objectAsync:F.identifier({text:`objectAsync`}),objectWithRestAsync:F.identifier({text:`objectWithRestAsync`}),optionalAsync:F.identifier({text:`optionalAsync`}),parseAsync:F.identifier({text:`parseAsync`}),parserAsync:F.identifier({text:`parserAsync`}),partialAsync:F.identifier({text:`partialAsync`}),partialCheckAsync:F.identifier({text:`partialCheckAsync`}),pipeAsync:F.identifier({text:`pipeAsync`}),rawCheckAsync:F.identifier({text:`rawCheckAsync`}),rawTransformAsync:F.identifier({text:`rawTransformAsync`}),recordAsync:F.identifier({text:`recordAsync`}),requiredAsync:F.identifier({text:`requiredAsync`}),returnsAsync:F.identifier({text:`returnsAsync`}),safeParseAsync:F.identifier({text:`safeParseAsync`}),safeParserAsync:F.identifier({text:`safeParserAsync`}),setAsync:F.identifier({text:`setAsync`}),strictObjectAsync:F.identifier({text:`strictObjectAsync`}),strictTupleAsync:F.identifier({text:`strictTupleAsync`}),transformAsync:F.identifier({text:`transformAsync`}),tupleAsync:F.identifier({text:`tupleAsync`}),tupleWithRestAsync:F.identifier({text:`tupleWithRestAsync`}),undefinedableAsync:F.identifier({text:`undefinedableAsync`}),unionAsync:F.identifier({text:`unionAsync`}),variantAsync:F.identifier({text:`variantAsync`})},methods:{assert:F.identifier({text:`assert`}),config:F.identifier({text:`config`}),fallback:F.identifier({text:`fallback`}),flatten:F.identifier({text:`flatten`}),forward:F.identifier({text:`forward`}),getDefault:F.identifier({text:`getDefault`}),getDefaults:F.identifier({text:`getDefaults`}),getDescription:F.identifier({text:`getDescription`}),getFallback:F.identifier({text:`getFallback`}),getFallbacks:F.identifier({text:`getFallbacks`}),getMetadata:F.identifier({text:`getMetadata`}),getTitle:F.identifier({text:`getTitle`}),is:F.identifier({text:`is`}),keyof:F.identifier({text:`keyof`}),message:F.identifier({text:`message`}),omit:F.identifier({text:`omit`}),parse:F.identifier({text:`parse`}),parser:F.identifier({text:`parser`}),partial:F.identifier({text:`partial`}),pick:F.identifier({text:`pick`}),pipe:F.identifier({text:`pipe`}),required:F.identifier({text:`required`}),safeParse:F.identifier({text:`safeParse`}),safeParser:F.identifier({text:`safeParser`}),summarize:F.identifier({text:`summarize`}),unwrap:F.identifier({text:`unwrap`})},schemas:{any:F.identifier({text:`any`}),array:F.identifier({text:`array`}),bigInt:F.identifier({text:`bigint`}),blob:F.identifier({text:`blob`}),boolean:F.identifier({text:`boolean`}),custom:F.identifier({text:`custom`}),date:F.identifier({text:`date`}),enum:F.identifier({text:`enum`}),exactOptional:F.identifier({text:`exactOptional`}),file:F.identifier({text:`file`}),function:F.identifier({text:`function`}),instance:F.identifier({text:`instance`}),intersect:F.identifier({text:`intersect`}),lazy:F.identifier({text:`lazy`}),literal:F.identifier({text:`literal`}),looseObject:F.identifier({text:`looseObject`}),looseTuple:F.identifier({text:`looseTuple`}),map:F.identifier({text:`map`}),nan:F.identifier({text:`nan`}),never:F.identifier({text:`never`}),nonNullable:F.identifier({text:`nonNullable`}),nonNullish:F.identifier({text:`nonNullish`}),nonOptional:F.identifier({text:`nonOptional`}),null:F.identifier({text:`null`}),nullable:F.identifier({text:`nullable`}),nullish:F.identifier({text:`nullish`}),number:F.identifier({text:`number`}),object:F.identifier({text:`object`}),objectWithRest:F.identifier({text:`objectWithRest`}),optional:F.identifier({text:`optional`}),picklist:F.identifier({text:`picklist`}),promise:F.identifier({text:`promise`}),record:F.identifier({text:`record`}),set:F.identifier({text:`set`}),strictObject:F.identifier({text:`strictObject`}),strictTuple:F.identifier({text:`strictTuple`}),string:F.identifier({text:`string`}),symbol:F.identifier({text:`symbol`}),tuple:F.identifier({text:`tuple`}),tupleWithRest:F.identifier({text:`tupleWithRest`}),undefined:F.identifier({text:`undefined`}),undefinedable:F.identifier({text:`undefinedable`}),union:F.identifier({text:`union`}),unknown:F.identifier({text:`unknown`}),variant:F.identifier({text:`variant`}),void:F.identifier({text:`void`})},storages:{},types:{GenericSchema:F.identifier({text:`GenericSchema`})},utils:{}},Nf=({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 F.arrowFunction({async:!0,parameters:[{name:i}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Z.async.parseAsync}),parameters:[F.identifier({text:n.placeholder}),F.identifier({text:i})]})})})]})},Pf=({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 F.arrowFunction({async:!0,parameters:[{name:i}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Z.async.parseAsync}),parameters:[F.identifier({text:n.placeholder}),F.identifier({text:i})]})})})]})};var Ff=class{constructor(e){this.meta=e}createRequestValidator(e){return Nf(e)}createResponseValidator(e){return Pf(e)}selector(...e){return[this.meta.name,...e]}};const If={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}},Lf=e=>e!==void 0&&e in If,Rf=e=>Lf(e)&&If[e].needsBigInt,zf=({isBigInt:e,value:t})=>{let n=F.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?F.callExpression({functionName:`BigInt`,parameters:[n]}):n},Bf=({operation:e,plugin:t,state:n})=>{if(t.config.requests.enabled){let r=new Set,i={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(e.parameters){if(e.parameters.header){let t={},n=[];for(let i in e.parameters.header){let a=e.parameters.header[i];t[a.name]=a.schema,a.required&&(n.push(a.name),r.add(`headers`))}Object.keys(t).length&&(i.properties.headers={properties:t,required:n,type:`object`})}if(e.parameters.path){let t={},n=[];for(let i in e.parameters.path){let a=e.parameters.path[i];t[a.name]=a.schema,a.required&&(n.push(a.name),r.add(`path`))}Object.keys(t).length&&(i.properties.path={properties:t,required:n,type:`object`})}if(e.parameters.query){let t={},n=[];for(let i in e.parameters.query){let a=e.parameters.query[i];t[a.name]=a.schema,a.required&&(n.push(a.name),r.add(`query`))}Object.keys(t).length&&(i.properties.query={properties:t,required:n,type:`object`})}}e.body&&(i.properties.body=e.body.schema,e.body.required&&r.add(`body`)),i.required=[...r],np({plugin:t,schema:i,state:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:yf(n._path.value)},name:T({config:t.config.requests,name:e.id}),selector:t.api.selector(`data`,e.id)})})}if(t.config.responses.enabled&&e.responses){let{response:r}=st(e);if(r){let i=[...n._path.value,`responses`],a=t.registerSymbol({exported:!0,meta:{resourceType:yf(i)},name:T({config:t.config.responses,name:e.id}),selector:t.api.selector(`responses`,e.id)});np({plugin:t,schema:r,state:{...n,_path:Y(i)},symbol:a})}}},Vf=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let n=t.referenceSymbol(t.api.selector(`external`,`valibot.v`));return F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.methods.pipe}),parameters:e})},Hf=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Z.schemas.unknown})})},Uf=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),i=F.propertyAccessExpression({expression:r.placeholder,name:Z.schemas.array}),a=[];if(t.items){t=E({schema:t});let r=t.items.map((t,r)=>Vf({pipes:np({plugin:e,schema:t,state:{...n,_path:Y([...n._path.value,`items`,r])}}),plugin:e}));if(r.length===1){let e=F.callExpression({functionName:i,parameters:r});a.push(e)}else{t.logicalOperator;let r=F.callExpression({functionName:i,parameters:[Hf({plugin:e,schema:{type:`unknown`},state:n})]});a.push(r)}}else{let t=F.callExpression({functionName:i,parameters:[Hf({plugin:e,schema:{type:`unknown`},state:n})]});a.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Z.actions.length}),parameters:[F.valueToExpression({value:t.minItems})]});a.push(e)}else{if(t.minItems!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Z.actions.minLength}),parameters:[F.valueToExpression({value:t.minItems})]});a.push(e)}if(t.maxItems!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Z.actions.maxLength}),parameters:[F.valueToExpression({value:t.maxItems})]});a.push(e)}}return Vf({pipes:a,plugin:e})},Wf=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return typeof t.const==`boolean`?F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.schemas.literal}),parameters:[F.ots.boolean(t.const)]}):F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.schemas.boolean})})},Gf=({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(F.stringLiteral({text:e.const})):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return Hf({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),o=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Z.schemas.picklist}),parameters:[F.arrayLiteralExpression({elements:r,multiLine:!1})]});return i&&(o=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Z.schemas.nullable}),parameters:[o]})),o},Kf=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Z.schemas.never})})},qf=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Z.schemas.null})})},Jf=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=Rf(n),a=Lf(n)?If[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=F.ots.number(e);else if(typeof e==`number`&&n)r=i?F.callExpression({functionName:`BigInt`,parameters:[F.ots.string(e.toString())]}):F.ots.number(e);else if(typeof e==`string`&&i){let t=e.endsWith(`n`)?e.slice(0,-1):e;r=F.callExpression({functionName:`BigInt`,parameters:[F.ots.string(t)]})}else if(typeof e==`bigint`){let t=e.toString(),n=t.endsWith(`n`)?t.slice(0,-1):t;r=F.callExpression({functionName:`BigInt`,parameters:[F.ots.string(n)]})}else r=F.valueToExpression({value:e});return F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.literal}),parameters:[r]})}let s=[];if(i){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.union}),parameters:[F.arrayLiteralExpression({elements:[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.number})}),F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.string})}),F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.bigInt})})],multiLine:!1})]});s.push(e);let t=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.actions.transform}),parameters:[F.arrowFunction({parameters:[{name:`x`}],statements:F.callExpression({functionName:`BigInt`,parameters:[F.identifier({text:`x`})]})})]});s.push(t)}else{let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.number})});s.push(e)}if(!i&&r){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.actions.integer})});s.push(e)}if(a){let e=a.min,t=a.max,n=a.minError,r=a.maxError,c=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.actions.minValue}),parameters:[i?F.callExpression({functionName:`BigInt`,parameters:[F.ots.string(e.toString())]}):F.ots.number(e),F.ots.string(n)]});s.push(c);let l=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.actions.maxValue}),parameters:[i?F.callExpression({functionName:`BigInt`,parameters:[F.ots.string(t.toString())]}):F.ots.number(t),F.ots.string(r)]});s.push(l)}if(t.exclusiveMinimum!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.actions.gtValue}),parameters:[zf({isBigInt:i,value:t.exclusiveMinimum})]});s.push(e)}else if(t.minimum!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.actions.minValue}),parameters:[zf({isBigInt:i,value:t.minimum})]});s.push(e)}if(t.exclusiveMaximum!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.actions.ltValue}),parameters:[zf({isBigInt:i,value:t.exclusiveMaximum})]});s.push(e)}else if(t.maximum!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.actions.maxValue}),parameters:[zf({isBigInt:i,value:t.maximum})]});s.push(e)}return Vf({pipes:s,plugin:e})},Yf=({plugin:e,schema:t,state:n})=>{let r=[],i=t.required??[];for(let o in t.properties){let s=t.properties[o],c=np({optional:!i.includes(o),plugin:e,schema:s,state:{...n,_path:Y([...n._path.value,`properties`,o])}});k.lastIndex=0;let l;l=k.test(o)?o.startsWith(`-`)?a.factory.createStringLiteral(o):a.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(l=`'${o}'`),r.push(F.propertyAssignment({initializer:Vf({pipes:c,plugin:e}),name:l}))}let o=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.additionalProperties&&t.additionalProperties.type===`object`&&!Object.keys(r).length){let r=np({plugin:e,schema:t.additionalProperties,state:{...n,_path:Y([...n._path.value,`additionalProperties`])}});return{anyType:`AnyZodObject`,expression:F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.record}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.string}),parameters:[]}),Vf({pipes:r,plugin:e})]})}}let s=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.object}),parameters:[a.factory.createObjectLiteralExpression(r,!0)]});return{anyType:Z.types.GenericSchema.text,expression:s}},Xf=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(typeof t.const==`string`)return F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.schemas.literal}),parameters:[F.ots.string(t.const)]});let r=[],i=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.schemas.string})});if(r.push(i),t.format)switch(t.format){case`date`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.actions.isoDate})}));break;case`date-time`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.actions.isoTimestamp})}));break;case`ipv4`:case`ipv6`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.actions.ip})}));break;case`uri`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.actions.url})}));break;case`email`:case`time`:case`uuid`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:F.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.actions.length}),parameters:[F.valueToExpression({value:t.minLength})]});r.push(e)}else{if(t.minLength!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.actions.minLength}),parameters:[F.valueToExpression({value:t.minLength})]});r.push(e)}if(t.maxLength!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.actions.maxLength}),parameters:[F.valueToExpression({value:t.maxLength})]});r.push(e)}}if(t.pattern){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Z.actions.regex}),parameters:[F.regularExpressionLiteral({text:t.pattern})]});r.push(e)}return Vf({pipes:r,plugin:e})},Zf=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Z.schemas.literal}),parameters:[F.valueToExpression({value:e})]}));return F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Z.schemas.tuple}),parameters:[F.arrayLiteralExpression({elements:e})]})}if(t.items){let i=t.items.map((t,r)=>Vf({pipes:np({plugin:e,schema:t,state:{...n,_path:Y([...n._path.value,`items`,r])}}),plugin:e}));return F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Z.schemas.tuple}),parameters:[F.arrayLiteralExpression({elements:i})]})}return Hf({plugin:e,schema:{type:`unknown`},state:n})},Qf=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Z.schemas.undefined})})},$f=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Z.schemas.void})})},ep=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:Uf({...t,schema:e})};case`boolean`:return{expression:Wf({...t,schema:e})};case`enum`:return{expression:Gf({...t,schema:e})};case`integer`:case`number`:return{expression:Jf({...t,schema:e})};case`never`:return{expression:Kf({...t,schema:e})};case`null`:return{expression:qf({...t,schema:e})};case`object`:return Yf({...t,schema:e});case`string`:return e.format===`int64`||e.format===`uint64`?{expression:Jf({...t,schema:e})}:{expression:Xf({...t,schema:e})};case`tuple`:return{expression:Zf({...t,schema:e})};case`undefined`:return{expression:Qf({...t,schema:e})};case`unknown`:return{expression:Hf({...t,schema:e})};case`void`:return{expression:$f({...t,schema:e})}}},tp=({operation:e,plugin:t,state:n})=>{if(t.config.webhooks.enabled){let r=new Set,i={properties:{body:{type:`never`},path:{type:`never`},query:{type:`never`}},type:`object`};if(e.parameters){if(e.parameters.header){let t={},n=[];for(let i in e.parameters.header){let a=e.parameters.header[i];t[a.name]=a.schema,a.required&&(n.push(a.name),r.add(`headers`))}Object.keys(t).length&&(i.properties.headers={properties:t,required:n,type:`object`})}if(e.parameters.path){let t={},n=[];for(let i in e.parameters.path){let a=e.parameters.path[i];t[a.name]=a.schema,a.required&&(n.push(a.name),r.add(`path`))}Object.keys(t).length&&(i.properties.path={properties:t,required:n,type:`object`})}if(e.parameters.query){let t={},n=[];for(let i in e.parameters.query){let a=e.parameters.query[i];t[a.name]=a.schema,a.required&&(n.push(a.name),r.add(`query`))}Object.keys(t).length&&(i.properties.query={properties:t,required:n,type:`object`})}}e.body&&(i.properties.body=e.body.schema,e.body.required&&r.add(`body`)),i.required=[...r],np({plugin:t,schema:i,state:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:yf(n._path.value)},name:T({config:t.config.webhooks,name:e.id}),selector:t.api.selector(`webhook-request`,e.id)})})}},np=({$ref:e,optional:t,plugin:n,schema:r,state:i,symbol:a})=>{if(e&&!a){let t=n.api.selector(`ref`,e);a=n.getSymbol(t)||n.referenceSymbol(t)}let o=n.referenceSymbol(n.api.selector(`external`,`valibot.v`)),s,c=[];if(r.$ref){let e=n.api.selector(`ref`,r.$ref),t=n.referenceSymbol(e);if(n.isSymbolRegistered(e)){let e=F.identifier({text:t.placeholder});c.push(e)}else{let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.lazy}),parameters:[F.arrowFunction({statements:[F.returnStatement({expression:F.identifier({text:t.placeholder})})]})]});c.push(e),i.hasLazyExpression.value=!0}}else if(r.type){let e=ep({plugin:n,schema:r,state:i});if(s=e.anyType,c.push(e.expression),n.config.metadata&&r.description){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.actions.metadata}),parameters:[F.objectExpression({obj:[{key:`description`,value:F.stringLiteral({text:r.description})}]})]});c.push(e)}}else if(r.items)if(r=E({schema:r}),r.items){let e=r.items.map((e,t)=>Vf({pipes:np({plugin:n,schema:e,state:{...i,_path:Y([...i._path.value,`items`,t])}}),plugin:n}));if(r.logicalOperator===`and`){let t=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.intersect}),parameters:[F.arrayLiteralExpression({elements:e})]});c.push(t)}else{let t=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.union}),parameters:[F.arrayLiteralExpression({elements:e})]});c.push(t)}}else{let e=np({plugin:n,schema:r,state:i});c.push(...e)}else{let e=ep({plugin:n,schema:{type:`unknown`},state:i});s=e.anyType,c.push(e.expression)}if(c.length){if(r.accessScope===`read`){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.actions.readonly})});c.push(e)}let e;r.default!==void 0&&(e=zf({isBigInt:r.type===`integer`&&r.format===`int64`,value:r.default}),e&&(c=[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.optional}),parameters:[Vf({pipes:c,plugin:n}),e]})])),t&&!e&&(c=[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Z.schemas.optional}),parameters:[Vf({pipes:c,plugin:n})]})])}if(a){e&&(a=n.registerSymbol({exported:!0,meta:{resourceType:yf(i._path.value)},name:T({config:{case:i.nameCase.value,name:i.nameTransformer.value},name:I(e)}),selector:n.api.selector(`ref`,e)}));let t=F.constVariable({comment:n.config.comments?Vu({schema:r}):void 0,exportConst:a.exported,expression:Vf({pipes:c,plugin:n}),name:a.placeholder,typeName:i.hasLazyExpression.value?F.propertyAccessExpression({expression:o.placeholder,name:s||Z.types.GenericSchema.text}):void 0});return n.setSymbolValue(a,t),[]}return c},rp=({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=X({_path:t._path,hasLazyExpression:!1,nameCase:e.config.definitions.case,nameTransformer:e.config.definitions.name});switch(t.type){case`operation`:Bf({operation:t.operation,plugin:e,state:n});break;case`parameter`:np({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:np({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:np({$ref:t.$ref,plugin:e,schema:t.schema,state:n});break;case`webhook`:tp({operation:t.operation,plugin:e,state:n});break}})},ip={api:new Ff({name:`valibot`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>rp(e),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`]},Q={ZodMiniOptional:F.identifier({text:`ZodMiniOptional`}),ZodOptional:F.identifier({text:`ZodOptional`}),_default:F.identifier({text:`_default`}),and:F.identifier({text:`and`}),array:F.identifier({text:`array`}),bigint:F.identifier({text:`bigint`}),boolean:F.identifier({text:`boolean`}),check:F.identifier({text:`check`}),coerce:F.identifier({text:`coerce`}),date:F.identifier({text:`date`}),datetime:F.identifier({text:`datetime`}),default:F.identifier({text:`default`}),describe:F.identifier({text:`describe`}),email:F.identifier({text:`email`}),enum:F.identifier({text:`enum`}),globalRegistry:F.identifier({text:`globalRegistry`}),gt:F.identifier({text:`gt`}),gte:F.identifier({text:`gte`}),infer:F.identifier({text:`infer`}),int:F.identifier({text:`int`}),intersection:F.identifier({text:`intersection`}),ip:F.identifier({text:`ip`}),ipv4:F.identifier({text:`ipv4`}),ipv6:F.identifier({text:`ipv6`}),iso:F.identifier({text:`iso`}),lazy:F.identifier({text:`lazy`}),length:F.identifier({text:`length`}),literal:F.identifier({text:`literal`}),lt:F.identifier({text:`lt`}),lte:F.identifier({text:`lte`}),max:F.identifier({text:`max`}),maxLength:F.identifier({text:`maxLength`}),min:F.identifier({text:`min`}),minLength:F.identifier({text:`minLength`}),never:F.identifier({text:`never`}),null:F.identifier({text:`null`}),nullable:F.identifier({text:`nullable`}),number:F.identifier({text:`number`}),object:F.identifier({text:`object`}),optional:F.identifier({text:`optional`}),parseAsync:F.identifier({text:`parseAsync`}),readonly:F.identifier({text:`readonly`}),record:F.identifier({text:`record`}),regex:F.identifier({text:`regex`}),register:F.identifier({text:`register`}),string:F.identifier({text:`string`}),time:F.identifier({text:`time`}),tuple:F.identifier({text:`tuple`}),undefined:F.identifier({text:`undefined`}),union:F.identifier({text:`union`}),unknown:F.identifier({text:`unknown`}),url:F.identifier({text:`url`}),uuid:F.identifier({text:`uuid`}),void:F.identifier({text:`void`})},ap=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[F.identifier({text:r})]})})})]})},op=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[F.identifier({text:r})]})})})]})},sp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[F.identifier({text:r})]})})})]})},cp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[F.identifier({text:r})]})})})]})},lp=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`data`,e.id));if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[F.identifier({text:r})]})})})]})},up=({operation:e,plugin:t})=>{let n=t.getSymbol(t.api.selector(`responses`,e.id));if(!n)return;let r=`data`;return F.arrowFunction({async:!0,parameters:[{name:r}],statements:[F.returnStatement({expression:F.awaitExpression({expression:F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.parseAsync}),parameters:[F.identifier({text:r})]})})})]})};var dp=class{constructor(e){this.meta=e}createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return sp(e);case`mini`:return ap(e);case 4:default:return lp(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return cp(e);case`mini`:return op(e);case 4:default:return up(e)}}selector(...e){return[this.meta.name,...e]}};const fp=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`zod.z`)),o=F.constVariable({comment:t.config.comments?Vu({schema:n}):void 0,exportConst:r.exported,expression:e.expression,name:r.placeholder,typeName:e.typeName?F.propertyAccessExpression({expression:a.placeholder,name:e.typeName}):void 0});if(t.setSymbolValue(r,o),i){let e=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:F.typeReferenceNode({typeArguments:[F.typeOfExpression({text:r.placeholder})],typeName:F.propertyAccessExpression({expression:a.placeholder,name:Q.infer})})});t.setSymbolValue(i,e)}},pp=({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=F.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?F.callExpression({functionName:`BigInt`,parameters:[n]}):n},mp=({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];let o=r._path?.value||[],s=e(a,o),c=yf(o);fp({ast:s,plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{resourceType:c},name:T({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`,resourceType:c},name:T({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}=st(t);if(i){let a=[...r._path?.value||[],`responses`],o=e(i,a),s=yf(a);fp({ast:o,plugin:n,schema:i,symbol:n.registerSymbol({exported:!0,meta:{resourceType:s},name:T({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`,resourceType:s},name:T({config:n.config.responses.types.infer,name:t.id}),selector:n.api.selector(`type-infer-responses`,t.id)}):void 0})}}},hp=({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];let o=r._path?.value||[],s=e(a,o),c=yf(o);fp({ast:s,plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{resourceType:c},name:T({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`,resourceType:c},name:T({config:n.config.webhooks.types.infer,name:t.id}),selector:n.api.selector(`type-infer-webhook-request`,t.id)}):void 0})}},gp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})}),n},_p=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=F.propertyAccessExpression({expression:r.placeholder,name:Q.array});if(!t.items)i.expression=F.callExpression({functionName:a,parameters:[gp({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=E({schema:t});let o=t.items.map((t,r)=>{let a=kp({plugin:e,schema:t,state:{...n,_path:Y([...n._path.value,`items`,r])}});return a.hasLazyExpression&&(i.hasLazyExpression=!0),a.expression});if(o.length===1)i.expression=F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:[n,o[e]]})}i.expression=F.callExpression({functionName:a,parameters:[n]})}else i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[F.arrayLiteralExpression({elements:o})]})]})}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.length}),parameters:[F.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.minLength}),parameters:[F.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.maxLength}),parameters:[F.valueToExpression({value:t.maxItems})]}))),o.length&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:Q.check}),parameters:o})),i},vp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};return typeof t.const==`boolean`?(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[F.ots.boolean(t.const)]}),r):(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})}),r)},yp=({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=F.stringLiteral({text:e.const});a.push(t),o.push(F.callExpression({functionName:F.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=F.ots.number(e.const);o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=F.ots.boolean(e.const);o.push(F.callExpression({functionName:F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[F.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?i.expression=o[0]:i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[F.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.nullable}),parameters:[i.expression]})),i):gp({plugin:e,schema:{type:`unknown`},state:n})},bp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.never})}),n},xp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.null})}),n},Sp=({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=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[F.ots.number(t.const)]}),r;r.expression=F.callExpression({functionName:i?F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):F.propertyAccessExpression({expression:n.placeholder,name:Q.number})}),!i&&t.type===`integer`&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.int})}));let a=[];return t.exclusiveMinimum===void 0?t.minimum!==void 0&&a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.gte}),parameters:[$({isBigInt:i,value:t.minimum})]})):a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.gt}),parameters:[$({isBigInt:i,value:t.exclusiveMinimum})]})),t.exclusiveMaximum===void 0?t.maximum!==void 0&&a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.lte}),parameters:[$({isBigInt:i,value:t.maximum})]})):a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.lt}),parameters:[$({isBigInt:i,value:t.exclusiveMaximum})]})),a.length&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Cp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},o=[],s=t.required??[];for(let r in t.properties){let c=t.properties[r],l=kp({optional:!s.includes(r),plugin:e,schema:c,state:{...n,_path:Y([...n._path.value,`properties`,r])}});l.hasLazyExpression&&(i.hasLazyExpression=!0),k.lastIndex=0;let u;u=k.test(r)?r.startsWith(`-`)?a.factory.createStringLiteral(r):a.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(u=`'${r}'`),l.hasLazyExpression?o.push(F.getAccessorDeclaration({name:u,statements:[F.returnStatement({expression:l.expression})]})):o.push(F.propertyAssignment({initializer:l.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=kp({plugin:e,schema:t.additionalProperties,state:{...n,_path:Y([...n._path.value,`additionalProperties`])}});return i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.string}),parameters:[]}),a.expression]}),a.hasLazyExpression&&(i.hasLazyExpression=!0),i}return i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[a.factory.createObjectLiteralExpression(o,!0)]}),i},wp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),r={};if(typeof t.const==`string`)return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[F.ots.string(t.const)]}),r;r.expression=F.callExpression({functionName:F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[F.objectExpression({obj:i})]:[]});break;case`email`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.email})});break;case`ipv4`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.ipv4})});break;case`ipv6`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.ipv6})});break;case`time`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:n.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.url})});break;case`uuid`:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.uuid})});break}let a=[];return t.minLength===t.maxLength&&t.minLength!==void 0?a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.length}),parameters:[F.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.minLength}),parameters:[F.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.maxLength}),parameters:[F.valueToExpression({value:t.maxLength})]}))),t.pattern&&a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.regex}),parameters:[F.regularExpressionLiteral({text:t.pattern})]})),a.length&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.expression,name:Q.check}),parameters:a})),r},Tp=({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=>F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[F.valueToExpression({value:e})]}));return i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[F.arrayLiteralExpression({elements:e})]}),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=kp({plugin:e,schema:t,state:{...n,_path:Y([...n._path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[F.arrayLiteralExpression({elements:a})]}),i},Ep=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})}),n},Dp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),n={};return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.void})}),n},Op=({schema:e,...t})=>{switch(e.type){case`array`:return _p({...t,schema:e});case`boolean`:return vp({...t,schema:e});case`enum`:return yp({...t,schema:e});case`integer`:case`number`:return Sp({...t,schema:e});case`never`:return bp({...t,schema:e});case`null`:return xp({...t,schema:e});case`object`:return Cp({...t,schema:e});case`string`:return wp({...t,schema:e});case`tuple`:return Tp({...t,schema:e});case`undefined`:return Ep({...t,schema:e});case`unknown`:return gp({...t,schema:e});case`void`:return Dp({...t,schema:e})}},kp=({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=F.identifier({text:o.placeholder}):(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[F.arrowFunction({returnType:F.keywordTypeNode({keyword:`any`}),statements:[F.returnStatement({expression:F.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=Op({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[F.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),F.objectExpression({obj:[{key:`description`,value:F.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=E({schema:n}),n.items){let e=n.items.map((e,n)=>kp({plugin:t,schema:e,state:{...r,_path:Y([...r._path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=F.callExpression({functionName:F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:[i.expression,e.hasLazyExpression?F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[F.arrowFunction({statements:[F.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[F.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=kp({plugin:t,schema:n,state:r});else i.expression=Op({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q.readonly}),parameters:[i.expression]})),e&&(i.expression=F.callExpression({functionName:F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q._default}),parameters:[i.expression,e]}))}return i},Ap=({$ref:e,plugin:t,schema:n,state:r})=>{let i=kp({plugin:t,schema:n,state:r}),a=I(e),o=yf(r._path.value);fp({ast:i,plugin:t,schema:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:o},name:T({config:t.config.definitions,name:a}),selector:t.api.selector(`ref`,e)}),typeInferSymbol:t.config.definitions.types.infer.enabled?t.registerSymbol({exported:!0,meta:{kind:`type`,resourceType:o},name:T({config:t.config.definitions.types.infer,name:a}),selector:t.api.selector(`type-infer-ref`,e)}):void 0})},jp=({plugin:e})=>{e.registerSymbol({external:pp({plugin:e}),meta:{importKind:`namespace`},name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{switch(t.type){case`operation`:mp({getAst:(t,n)=>kp({plugin:e,schema:t,state:X({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:X({_path:t._path})});break;case`parameter`:Ap({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:X({_path:t._path,hasLazyExpression:!1})});break;case`requestBody`:Ap({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:X({_path:t._path,hasLazyExpression:!1})});break;case`schema`:Ap({$ref:t.$ref,plugin:e,schema:t.schema,state:X({_path:t._path,hasLazyExpression:!1})});break;case`webhook`:hp({getAst:(t,n)=>kp({plugin:e,schema:t,state:X({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:X({_path:t._path})});break}})},Mp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})})},Np=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=F.propertyAccessExpression({expression:r.placeholder,name:Q.array}),a,o=!1;if(!t.items)a=F.callExpression({functionName:i,parameters:[Mp({plugin:e,schema:{type:`unknown`},state:n})]});else{t=E({schema:t});let s=t.items.map((t,r)=>{let i=Gp({plugin:e,schema:t,state:{...n,_path:Y([...n._path.value,`items`,r])}});return i.hasLazyExpression&&(o=!0),i.expression});if(s.length===1)a=F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.intersection}),parameters:s});else{n=s[0];for(let e=1;e<s.length;e++)n=F.callExpression({functionName:F.propertyAccessExpression({expression:n,name:Q.and}),parameters:[s[e]]})}a=F.callExpression({functionName:i,parameters:[n]})}else a=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.array}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[F.arrayLiteralExpression({elements:s})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?a=F.callExpression({functionName:F.propertyAccessExpression({expression:a,name:Q.length}),parameters:[F.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(a=F.callExpression({functionName:F.propertyAccessExpression({expression:a,name:Q.min}),parameters:[F.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(a=F.callExpression({functionName:F.propertyAccessExpression({expression:a,name:Q.max}),parameters:[F.valueToExpression({value:t.maxItems})]}))),{expression:a,hasLazyExpression:o}},Pp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[F.ots.boolean(t.const)]}):F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.boolean})})},Fp=({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=F.stringLiteral({text:e.const});i.push(t),a.push(F.callExpression({functionName:F.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=F.ots.number(e.const);a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=F.ots.boolean(e.const);a.push(F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return Mp({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.enum}),parameters:[F.arrayLiteralExpression({elements:i,multiLine:!1})]}):a.length===1?a[0]:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.union}),parameters:[F.arrayLiteralExpression({elements:a,multiLine:a.length>3})]}),o&&(c=F.callExpression({functionName:F.propertyAccessExpression({expression:c,name:Q.nullable})})),c},Ip=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.never})})},Lp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.null})})},Rp=({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 F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[F.ots.number(t.const)]});let i=F.callExpression({functionName:r?F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:n.placeholder,name:Q.coerce}),name:Q.bigint}):F.propertyAccessExpression({expression:n.placeholder,name:Q.number})});return!r&&t.type===`integer`&&(i=F.callExpression({functionName:F.propertyAccessExpression({expression:i,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(i=F.callExpression({functionName:F.propertyAccessExpression({expression:i,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):i=F.callExpression({functionName:F.propertyAccessExpression({expression:i,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(i=F.callExpression({functionName:F.propertyAccessExpression({expression:i,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):i=F.callExpression({functionName:F.propertyAccessExpression({expression:i,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),i},zp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1,o=[],s=t.required??[];for(let r in t.properties){let c=t.properties[r],l=Gp({optional:!s.includes(r),plugin:e,schema:c,state:{...n,_path:Y([...n._path.value,`properties`,r])}});l.hasLazyExpression&&(i=!0),k.lastIndex=0;let u;u=k.test(r)?r.startsWith(`-`)?a.factory.createStringLiteral(r):a.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(u=`'${r}'`),o.push(F.propertyAssignment({initializer:l.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Gp({plugin:e,schema:t.additionalProperties,state:{...n,_path:Y([...n._path.value,`additionalProperties`])}});return{anyType:`AnyZodObject`,expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.record}),parameters:[i.expression]}),hasLazyExpression:i.hasLazyExpression}}return{anyType:`AnyZodObject`,expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.object}),parameters:[a.factory.createObjectLiteralExpression(o,!0)]}),hasLazyExpression:i}},Bp=({plugin:e,schema:t})=>{let n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.literal}),parameters:[F.ots.string(t.const)]});let r=F.callExpression({functionName:F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:Q.date})});break;case`date-time`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:Q.datetime}),parameters:i.length>0?[F.objectExpression({obj:i})]:[]});break;case`email`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:Q.email})});break;case`ipv4`:case`ipv6`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:Q.ip})});break;case`time`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:Q.time})});break;case`uri`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:Q.url})});break;case`uuid`:r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:Q.length}),parameters:[F.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:Q.min}),parameters:[F.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:Q.max}),parameters:[F.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=F.callExpression({functionName:F.propertyAccessExpression({expression:r,name:Q.regex}),parameters:[F.regularExpressionLiteral({text:t.pattern})]})),r},Vp=({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=>F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[F.valueToExpression({value:e})]}));return{expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[F.arrayLiteralExpression({elements:e})]}),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=Gp({plugin:e,schema:t,state:{...n,_path:Y([...n._path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.tuple}),parameters:[F.arrayLiteralExpression({elements:a})]}),hasLazyExpression:i}},Hp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})})},Up=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.void})})},Wp=({schema:e,...t})=>{switch(e.type){case`array`:return Np({...t,schema:e});case`boolean`:return{expression:Pp({...t,schema:e})};case`enum`:return{expression:Fp({...t,schema:e})};case`integer`:case`number`:return{expression:Rp({...t,schema:e})};case`never`:return{expression:Ip({...t,schema:e})};case`null`:return{expression:Lp({...t,schema:e})};case`object`:return zp({...t,schema:e});case`string`:return{expression:Bp({...t,schema:e})};case`tuple`:return Vp({...t,schema:e});case`undefined`:return{expression:Hp({...t,schema:e})};case`unknown`:return{expression:Mp({...t,schema:e})};case`void`:return{expression:Up({...t,schema:e})}}},Gp=({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=F.identifier({text:o.placeholder}):(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[F.arrowFunction({statements:[F.returnStatement({expression:F.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=Wp({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:Q.describe}),parameters:[F.stringLiteral({text:n.description})]}))}else if(n.items)if(n=E({schema:n}),n.items){let e=n.items.map((e,n)=>Gp({plugin:t,schema:e,state:{...r,_path:Y([...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=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q.intersection}),parameters:e}):(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e]})}))}else i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[F.arrayLiteralExpression({elements:e})]})}else i=Gp({plugin:t,schema:n,state:r});else{let e=Wp({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}if(i.expression&&(n.accessScope===`read`&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=F.callExpression({functionName:F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return r.hasLazyExpression.value?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},Kp=({$ref:e,plugin:t,schema:n,state:r})=>{let i=Gp({plugin:t,schema:n,state:r}),a=I(e),o=yf(r._path.value);fp({ast:i,plugin:t,schema:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:o},name:T({config:t.config.definitions,name:a}),selector:t.api.selector(`ref`,e)}),typeInferSymbol:t.config.definitions.types.infer.enabled?t.registerSymbol({exported:!0,meta:{kind:`type`,resourceType:o},name:T({config:t.config.definitions.types.infer,name:a}),selector:t.api.selector(`type-infer-ref`,e)}):void 0})},qp=({plugin:e})=>{e.registerSymbol({external:pp({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{switch(t.type){case`operation`:mp({getAst:(t,n)=>Gp({plugin:e,schema:t,state:X({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:X({_path:t._path})});break;case`parameter`:Kp({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:X({_path:t._path,hasLazyExpression:!1})});break;case`requestBody`:Kp({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:X({_path:t._path,hasLazyExpression:!1})});break;case`schema`:Kp({$ref:t.$ref,plugin:e,schema:t.schema,state:X({_path:t._path,hasLazyExpression:!1})});break;case`webhook`:hp({getAst:(t,n)=>Gp({plugin:e,schema:t,state:X({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:X({_path:t._path})});break}})},Jp=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.unknown})}),t},Yp=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),a=F.propertyAccessExpression({expression:i.placeholder,name:Q.array});if(!t.items)r.expression=F.callExpression({functionName:a,parameters:[Jp({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=E({schema:t});let o=t.items.map((t,i)=>{let a=sm({plugin:e,schema:t,state:{...n,_path:Y([...n._path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),a.expression});if(o.length===1)r.expression=F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=F.callExpression({functionName:F.propertyAccessExpression({expression:n,name:Q.and}),parameters:[o[e]]})}r.expression=F.callExpression({functionName:a,parameters:[n]})}else r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.array}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[F.arrayLiteralExpression({elements:o})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.expression,name:Q.length}),parameters:[F.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.expression,name:Q.min}),parameters:[F.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.expression,name:Q.max}),parameters:[F.valueToExpression({value:t.maxItems})]}))),r},Xp=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return typeof t.const==`boolean`?(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[F.ots.boolean(t.const)]}),n):(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.boolean})}),n)},Zp=({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=F.stringLiteral({text:e.const});a.push(t),o.push(F.callExpression({functionName:F.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=F.ots.number(e.const);o.push(F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=F.ots.boolean(e.const);o.push(F.callExpression({functionName:F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.enum}),parameters:[F.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?r.expression=o[0]:r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.union}),parameters:[F.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.nullable}),parameters:[r.expression]})),r):Jp({plugin:e,schema:{type:`unknown`},state:n})},Qp=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.never})}),t},$p=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.null})}),t},em=({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=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[F.ots.number(t.const)]}),n):(n.expression=F.callExpression({functionName:r?F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:i.placeholder,name:Q.coerce}),name:Q.bigint}):F.propertyAccessExpression({expression:i.placeholder,name:Q.number})}),!r&&t.type===`integer`&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:Q.gte}),parameters:[$({isBigInt:r,value:t.minimum})]})):n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:Q.gt}),parameters:[$({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:Q.lte}),parameters:[$({isBigInt:r,value:t.maximum})]})):n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:Q.lt}),parameters:[$({isBigInt:r,value:t.exclusiveMaximum})]}),n)},tm=({plugin:e,schema:t,state:n})=>{let r={},i=[],o=t.required??[],s=e.referenceSymbol(e.api.selector(`external`,`zod.z`));for(let s in t.properties){let c=t.properties[s],l=sm({optional:!o.includes(s),plugin:e,schema:c,state:{...n,_path:Y([...n._path.value,`properties`,s])}});l.hasLazyExpression&&(r.hasLazyExpression=!0),k.lastIndex=0;let u;u=k.test(s)?s.startsWith(`-`)?a.factory.createStringLiteral(s):a.factory.createNumericLiteral(s):s,(s.match(/^[0-9]/)&&s.match(/\D+/g)||s.match(/\W/g))&&!s.startsWith(`'`)&&!s.endsWith(`'`)&&(u=`'${s}'`),l.hasLazyExpression?i.push(F.getAccessorDeclaration({name:u,statements:[F.returnStatement({expression:l.expression})]})):i.push(F.propertyAssignment({initializer:l.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=sm({plugin:e,schema:t.additionalProperties,state:{...n,_path:Y([...n._path.value,`additionalProperties`])}});return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:s.placeholder,name:Q.record}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:s.placeholder,name:Q.string}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`ZodType`}:r}return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:s.placeholder,name:Q.object}),parameters:[a.factory.createObjectLiteralExpression(i,!0)]}),r.hasLazyExpression?{...r,typeName:`ZodType`}:r},nm=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol(e.api.selector(`external`,`zod.z`));if(typeof t.const==`string`)return n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.literal}),parameters:[F.ots.string(t.const)]}),n;n.expression=F.callExpression({functionName:F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.date})});break;case`date-time`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.datetime}),parameters:i.length>0?[F.objectExpression({obj:i})]:[]});break;case`email`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.email})});break;case`ipv4`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.ipv4})});break;case`ipv6`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.ipv6})});break;case`time`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:F.propertyAccessExpression({expression:r.placeholder,name:Q.iso}),name:Q.time})});break;case`uri`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.url})});break;case`uuid`:n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:Q.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:Q.length}),parameters:[F.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:Q.min}),parameters:[F.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:Q.max}),parameters:[F.valueToExpression({value:t.maxLength})]}))),t.pattern&&(n.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.expression,name:Q.regex}),parameters:[F.regularExpressionLiteral({text:t.pattern})]})),n},rm=({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=>F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.literal}),parameters:[F.valueToExpression({value:e})]}));return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[F.arrayLiteralExpression({elements:e})]}),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=sm({plugin:e,schema:t,state:{...n,_path:Y([...n._path.value,`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.placeholder,name:Q.tuple}),parameters:[F.arrayLiteralExpression({elements:a})]}),r},im=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.undefined})}),t},am=({plugin:e})=>{let t={},n=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return t.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:Q.void})}),t},om=({schema:e,...t})=>{switch(e.type){case`array`:return Yp({...t,schema:e});case`boolean`:return Xp({...t,schema:e});case`enum`:return Zp({...t,schema:e});case`integer`:case`number`:return em({...t,schema:e});case`never`:return Qp({...t,schema:e});case`null`:return $p({...t,schema:e});case`object`:return tm({...t,schema:e});case`string`:return nm({...t,schema:e});case`tuple`:return rm({...t,schema:e});case`undefined`:return im({...t,schema:e});case`unknown`:return Jp({...t,schema:e});case`void`:return am({...t,schema:e})}},sm=({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=F.identifier({text:o.placeholder}):(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[F.arrowFunction({returnType:F.keywordTypeNode({keyword:`any`}),statements:[F.returnStatement({expression:F.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=om({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:Q.register}),parameters:[F.propertyAccessExpression({expression:a.placeholder,name:Q.globalRegistry}),F.objectExpression({obj:[{key:`description`,value:F.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=E({schema:n}),n.items){let e=n.items.map((e,n)=>sm({plugin:t,schema:e,state:{...r,_path:Y([...r._path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=F.callExpression({functionName:F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:Q.and}),parameters:[e.hasLazyExpression?F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q.lazy}),parameters:[F.arrowFunction({statements:[F.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:Q.union}),parameters:[F.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=sm({plugin:t,schema:n,state:r});else i.expression=om({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:Q.readonly})})),e&&(i.expression=F.callExpression({functionName:F.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=F.callExpression({functionName:F.propertyAccessExpression({expression:i.expression,name:Q.default}),parameters:[e]}))}return i},cm=({$ref:e,plugin:t,schema:n,state:r})=>{let i=sm({plugin:t,schema:n,state:r}),a=I(e),o=yf(r._path.value);fp({ast:i,plugin:t,schema:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:o},name:T({config:t.config.definitions,name:a}),selector:t.api.selector(`ref`,e)}),typeInferSymbol:t.config.definitions.types.infer.enabled?t.registerSymbol({exported:!0,meta:{kind:`type`,resourceType:o},name:T({config:t.config.definitions.types.infer,name:a}),selector:t.api.selector(`type-infer-ref`,e)}):void 0})},lm=({plugin:e})=>{e.registerSymbol({external:pp({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{switch(t.type){case`operation`:mp({getAst:(t,n)=>sm({plugin:e,schema:t,state:X({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:X({_path:t._path})});break;case`parameter`:cm({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:X({_path:t._path,hasLazyExpression:!1})});break;case`requestBody`:cm({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:X({_path:t._path,hasLazyExpression:!1})});break;case`schema`:cm({$ref:t.$ref,plugin:e,schema:t.schema,state:X({_path:t._path,hasLazyExpression:!1})});break;case`webhook`:hp({getAst:(t,n)=>sm({plugin:e,schema:t,state:X({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:X({_path:t._path})});break}})},um={api:new dp({name:`zod`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return qp(e);case`mini`:return jp(e);case 4:default:return lm(e)}},name:`zod`,resolveConfig:(e,n)=>{let r=n.package.getVersion(`zod`),i=()=>r&&(r.major===4||r.major===3)?r.major:4,a=e=>{if(!e)return i();if(!r)return e;if((e===4||e===3||e===`mini`)&&!n.package.satisfies(r,`>=3.25.0 <5.0.0`)){let n=i();return console.warn(`🔌 ${t.yellow(`Warning:`)} Installed ${t.cyan(`zod`)} ${t.cyan(`v${r.version}`)} does not support compatibility version ${t.yellow(String(e))}, using ${t.yellow(String(n))}.`),n}return e};e.config.compatibilityVersion=a(e.config.compatibilityVersion),e.config.dates=n.valueToObject({defaultValue:{local:!1,offset:!1},value:e.config.dates}),e.config.types=n.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,t)=>({...e,infer:n.valueToObject({defaultValue:{...t.infer,enabled:e.infer===void 0?t.infer.enabled:!!e.infer},mappers:C,value:e.infer})})},value:e.config.types}),e.config.definitions=n.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:{...C,object:(e,t)=>({...e,types:n.valueToObject({defaultValue:t.types,mappers:{object:(e,t)=>({...e,infer:n.valueToObject({defaultValue:{...t.infer,enabled:e.infer===void 0?t.infer.enabled:!!e.infer},mappers:C,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=n.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:{...C,object:(e,t)=>({...e,types:n.valueToObject({defaultValue:t.types,mappers:{object:(e,t)=>({...e,infer:n.valueToObject({defaultValue:{...t.infer,enabled:e.infer===void 0?t.infer.enabled:!!e.infer},mappers:C,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=n.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:{...C,object:(e,t)=>({...e,types:n.valueToObject({defaultValue:t.types,mappers:{object:(e,t)=>({...e,infer:n.valueToObject({defaultValue:{...t.infer,enabled:e.infer===void 0?t.infer.enabled:!!e.infer},mappers:C,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=n.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:{...C,object:(e,t)=>({...e,types:n.valueToObject({defaultValue:t.types,mappers:{object:(e,t)=>({...e,infer:n.valueToObject({defaultValue:{...t.infer,enabled:e.infer===void 0?t.infer.enabled:!!e.infer},mappers:C,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},dm={"@angular/common":Qc,"@hey-api/client-angular":ml,"@hey-api/client-axios":gl,"@hey-api/client-fetch":vl,"@hey-api/client-next":bl,"@hey-api/client-nuxt":Sl,"@hey-api/client-ofetch":wl,"@hey-api/schemas":Wl,"@hey-api/sdk":fu,"@hey-api/transformers":zu,"@hey-api/typescript":cd,"@pinia/colada":Td,"@tanstack/angular-query-experimental":df,"@tanstack/react-query":ff,"@tanstack/solid-query":pf,"@tanstack/svelte-query":mf,"@tanstack/vue-query":hf,arktype:kf,fastify:Mf,"legacy/angular":Tl,"legacy/axios":El,"legacy/fetch":Dl,"legacy/node":Ol,"legacy/xhr":kl,valibot:ip,zod:um},fm=[`@hey-api/typescript`,`@hey-api/sdk`],pm=({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=dm[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:lt(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=dm[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=dm[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:ze};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}},mm=e=>typeof e==`string`?e.startsWith(`@hey-api/client`)||e.startsWith(`legacy/`):e.name.startsWith(`@hey-api/client`)||e.name.startsWith(`legacy/`)||e.tags&&e.tags.includes(`client`),hm=({dependencies:e,userConfig:t})=>{let n={},r=fm;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&mm(t.plugins[0])?[...fm,...t.plugins]:t.plugins),pm({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})},gm=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),_m=async({logger:e,userConfigs:n})=>{let i=[],a={},o=e.timeEvent(`load`);for(let r of n){let n;if(r?.configFile){let e=r.configFile.split(`.`);n=e.slice(0,e.length-1).join(`.`)}let o=e.timeEvent(`c12`),{loadConfig:s}=await import(`c12`),{config:c,configFile:l}=await s({configFile:n,name:`openapi-ts`});o.timeEnd(),Object.keys(a).length||(a=Ve(Object.keys(c).length?l:void 0));let u=c instanceof Array?c.map(e=>Ie(e,r)):[Ie(c,r)];for(let e of u){let n=Ne(e);if(e.output instanceof Array){let r=n.length,a=e.output.length;if(a>1)if(r!==a){console.warn(`⚙️ ${t.yellow(`Warning:`)} You provided ${t.cyan(String(r))} ${t.cyan(r===1?`input`:`inputs`)} and ${t.yellow(String(a))} ${t.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 t of e.output)i.push({...e,input:n,output:t})}else e.output.forEach((t,r)=>{i.push({...e,input:n[r],output:t})});else i.push({...e,input:n,output:e.output[0]??``})}else i.push({...e,input:n})}}o.timeEnd();let s=[],c=e.timeEvent(`build`);for(let e of i){let{base:n,configFile:i=``,dryRun:o=!1,experimentalParser:c=!0,exportCore:l=!0,name:u,request:d,useOptions:f=!0}=e,p=e.interactive===void 0?gm():e.interactive,m=Pe(e),h=Ne(e),g=Be(e),_=Ue(e),v=[];h.length||v.push(new re(`missing input - which OpenAPI specification should we use to generate your output?`)),g.path||v.push(new re(`missing output - where should we generate your output?`)),!f&&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=r.resolve(process.cwd(),g.path);let ee;try{ee=hm({dependencies:a,userConfig:e})}catch(e){v.push(e),ee={pluginOrder:[],plugins:{}}}let y=pe({...ee,base:n,configFile:i,dryRun:o,experimentalParser:c,exportCore:!1,input:h,interactive:p,logs:m,name:u,output:g,parser:_,request:d,useOptions:f});y.exportCore=S(y)?l:!1;let te=s.length;if(m.level===`debug`){let e=t.gray(`[Job ${te+1}] `);console.warn(`${e}${t.cyan(`config:`)}`,y)}s.push({config:y,errors:v,jobIndex:te})}return c.timeEnd(),{dependencies:a,results:s}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const vm=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},ym=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},bm=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},xm=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(ym(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=vm(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Sm({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Sm=({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)}`},Cm=({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=bm(r),s=Object.entries(i).map(([t,i])=>Sm({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},wm=({allowReserved:e,array:t,object:n}={})=>r=>{let i=[];if(r&&typeof r==`object`)for(let a in r){let o=r[a];if(o!=null)if(Array.isArray(o)){let n=xm({allowReserved:e,explode:!0,name:a,style:`form`,value:o,...t});n&&i.push(n)}else if(typeof o==`object`){let t=Cm({allowReserved:e,explode:!0,name:a,style:`deepObject`,value:o,...n});t&&i.push(t)}else{let t=Sm({allowReserved:e,name:a,value:o});t&&i.push(t)}}return i.join(`&`)},Tm=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Em=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?Tm(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};wm({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}});const Dm=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=f({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await p({fetchOptions:{method:`HEAD`,...e,headers:Em(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 p({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}};export{se as A,x as C,re as D,b as E,te as F,_ as I,le as M,ue as N,ie as O,y as P,Pe as S,me as T,Hn as _,fl as a,We as b,el as c,ls as d,ds as f,lr as g,ni as h,Bl as i,ce as j,ae as k,Sc as l,Ko as m,_m as n,cl as o,Qo as p,fm as r,$c as s,Dm as t,Cc as u,F as v,S as w,He as x,w as y};
|
|
24
|
-
//# sourceMappingURL=getSpec-54k1Qp12.js.map
|