@hey-api/openapi-ts 0.86.1 → 0.86.2
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-54k1Qp12.js +24 -0
- package/dist/getSpec-54k1Qp12.js.map +1 -0
- package/dist/getSpec-BFMqYPd3.cjs +24 -0
- package/dist/getSpec-BFMqYPd3.cjs.map +1 -0
- package/dist/index.cjs +4 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +47 -47
- package/dist/index.js.map +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-C7EJ2jAV.d.cts → types-BT1ededZ.d.cts} +1137 -385
- package/dist/{types-k8CRHWYM.d.ts → types-DGAzCzMG.d.ts} +1140 -390
- package/package.json +3 -3
- package/dist/getSpec-BlRTbnm6.js +0 -24
- package/dist/getSpec-BlRTbnm6.js.map +0 -1
- package/dist/getSpec-D8vjI0RE.cjs +0 -24
- package/dist/getSpec-D8vjI0RE.cjs.map +0 -1
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`ansi-colors`);l=c(l);let u=require(`node:fs`);u=c(u);let d=require(`node:path`);d=c(d);let f=require(`node:url`);f=c(f);let p=require(`typescript`);p=c(p);let m=require(`semver`);m=c(m);let h=require(`@hey-api/codegen-core`);h=c(h);let g=require(`node:os`);g=c(g);let _=require(`@hey-api/json-schema-ref-parser`);_=c(_);const v=(0,f.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),y=d.default.dirname(v),ee=()=>{let e=y;for(;e!==d.default.dirname(e);){let t=u.default.readdirSync(e).filter(e=>e===`package.json`);if(t[0]){let n=d.default.join(e,t[0]);return JSON.parse(u.default.readFileSync(n,{encoding:`utf8`}))}e=d.default.dirname(e)}},te=()=>{let e=ee(),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},ne=e=>{if(e===null)return null;if(e){let t=d.default.isAbsolute(e)?e:d.default.resolve(y,e);return u.default.existsSync(t)?t:null}let t=y;for(;t!==d.default.dirname(t);){let e=u.default.readdirSync(t).filter(e=>e.startsWith(`tsconfig`)&&e.endsWith(`.json`)).sort(e=>e===`tsconfig.json`?-1:1);if(e[0])return d.default.join(t,e[0]);t=d.default.dirname(t)}return null},re=e=>{if(!e)return null;let t=p.default.readConfigFile(e,p.default.sys.readFile);if(t.error)throw Error(`Couldn't read tsconfig from path: ${e}`);return p.default.parseJsonConfigFileContent(t.config,p.default.sys,d.default.dirname(e))},ie=e=>{u.default.existsSync(e)||u.default.mkdirSync(e,{recursive:!0})},ae=e=>{u.default.existsSync(e)&&u.default.rmSync(e,{force:!0,recursive:!0})},oe=({moduleOutput:e,sourceOutput:t})=>{let n=t.split(`/`);return`${Array.from({length:n.length}).fill(``).join(`../`)||`./`}${e}`};var se=class extends Error{constructor(e){super(e),this.name=`ConfigError`}},ce=class extends Error{errors;constructor(e){super(`Found ${e.length} configuration ${e.length===1?`error`:`errors`}.`),this.name=`ConfigValidationError`,this.errors=e}},le=class extends Error{originalError;constructor(e,t){super(e),this.name=`JobError`,this.originalError=t}},ue=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 de=(e,t)=>{if(e instanceof se||e instanceof ce)return;e instanceof le&&(e=e.originalError.error);let n=`openapi-ts-error-${Date.now()}.log`,r=d.default.resolve(process.cwd(),t);ie(r);let i=d.default.resolve(r,n),a=`[${new Date().toISOString()}] `;e instanceof ue&&(a+=`${e.name} during event "${e.event}"\n`,e.pluginName&&(a+=`Plugin: ${e.pluginName}\n`),a+=`Arguments: ${JSON.stringify(e.args,null,2)}\n\n`);let o=e instanceof Error?e.message:String(e),s=e instanceof Error?e.stack:void 0;return a+=`Error: ${o}\n`,s&&(a+=`Stack:\n${s}\n`),u.default.writeFileSync(i,a),i},fe=async e=>{let t=te();if(!t.bugs.url)return;e instanceof le&&(e=e.originalError.error);let n=``;e instanceof ue&&(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)},pe=({error:e,logPath:t})=>{if(e instanceof ce&&e.errors.length){let t=new Map;for(let{error:n,jobIndex:r}of e.errors)t.has(r)||t.set(r,[]),t.get(r).push(n);for(let[e,n]of t.entries()){let t=l.default.gray(`[Job ${e+1}] `),r=n.length,i=l.default.red(`Found ${r} configuration ${r===1?`error`:`errors`}:`);console.error(`${t}❗️ ${i}`),n.forEach((e,n)=>{let r=` [${n+1}] `,i=l.default.red(r);console.error(`${t}${i}${l.default.white(e.message)}`)})}}else{let t=l.default.gray(`[root] `);e instanceof le&&(t=l.default.gray(`[Job ${e.originalError.jobIndex+1}] `),e=e.originalError.error);let n=l.default.red(`Failed with the message:`);console.error(`${t}❌ ${n}`);let r=l.default.red(` `);console.error(`${t}${r}${typeof e==`string`?e:e instanceof Error?e.message:`Unknown error`}`)}if(t){let e=l.default.gray(`[root] `);console.error(`${e}${l.default.cyan(`📄 Crash log saved to:`)} ${l.default.gray(t)}`)}},me=async({error:e,isInteractive:t})=>!t||e instanceof se||e instanceof ce?!1:new Promise(e=>{let t=l.default.gray(`[root] `);console.log(`${t}${l.default.yellow(`📢 Open a GitHub issue with crash details? (y/N):`)}`),process.stdin.setEncoding(`utf8`),process.stdin.once(`data`,t=>{e(t.trim().toLowerCase()===`y`)})}),he=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 ge;const x=()=>{let e=ge;return e.client=b(e),e},_e=e=>(ge=e,x()),S=e=>b(e).name.startsWith(`legacy/`),ve=e=>{if(S(e))return e.name},ye=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,be=`https://get.heyapi.dev`,xe=(e,t,n)=>`${be}/${e}/${t}${n?`?${n}`:``}`,Se=e=>{let t=e.organization,n=e.project,r;if(e.path){let i=e.path.match(ye);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}},Ce=e=>{let t=Se(e);return{path:xe(t.organization,t.project,t.queryParams),registry:`hey-api`}},we=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,Te=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,Ee=`readme`,De=e=>{let t=e.match(we);if(!t)throw Error(`Invalid ReadMe shorthand format. Expected "${Ee}:@organization/project#uuid" or "${Ee}:uuid", received: ${Ee}:${e}`);let[,,n,r,i]=t;if(!i)throw Error(`The ReadMe UUID cannot be empty.`);return{organization:n,project:r,uuid:i}},Oe=e=>{let t=De(e.slice(`${Ee}:`.length));return{...t,path:Te(t.uuid),registry:`readme`}},ke=/^(@[\w-]+)\/([\w.-]+)$/,Ae=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,je=`scalar`,Me=e=>{let t=e.match(ke);if(!t)throw Error(`Invalid Scalar shorthand format. Expected "${je}:@organization/project", received: ${je}:${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}},Ne=e=>{let t=Me(e.slice(`${je}:`.length));return{...t,path:Ae(t.organization,t.project),registry:`scalar`}},Pe=e=>{if(e.path.startsWith(`readme:`)){Object.assign(e,Oe(e.path));return}if(e.path.startsWith(`scalar:`)){Object.assign(e,Ne(e.path));return}if(e.path.startsWith(`.`))return;if(e.path.startsWith(be)){e.path=e.path.slice(23),Object.assign(e,Ce(e));return}let t=e.path.split(`/`);if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,Ce(e));return}},Fe={enabled:!1,interval:1e3,timeout:6e4},Ie=e=>{let t={...Fe};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},Le=e=>{let t=e.input instanceof Array?e.input:[e.input],n=[];for(let r of t){let t={path:``,watch:Fe};typeof r==`string`?t.path=r:r&&(r.path!==void 0||r.organization!==void 0)?(t={...t,path:be,...r},t.watch!==void 0&&(t.watch=Ie(t))):t={...t,path:r},typeof t.path==`string`&&Pe(t),e.watch!==void 0&&t.watch.enabled===Fe.enabled&&t.watch.interval===Fe.interval&&t.watch.timeout===Fe.timeout&&(t.watch=Ie({path:t.path,watch:e.watch})),t.path&&n.push(t)}return n},Re=e=>{let t={file:!0,level:`info`,path:process.cwd()};return typeof e?.logs==`string`?t.path=e.logs:t={...t,...e?.logs},t},ze=(e,t)=>{let n=e||{},r=t||{};return{...n,...r}},Be=(e,t)=>{let n=e||{},r=t||{},i={...n,...r};return typeof i.logs==`object`&&(i.logs=ze(n.logs,r.logs)),i},Ve=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e!=`function`,He=(e,t)=>{for(let[n,r]of Object.entries(t))r!==void 0&&r!==``&&(e[n]=r);return e},Ue=({defaultValue:e,mappers:t,value:n})=>{let r={...e};switch(typeof n){case`boolean`:if(t&&`boolean`in t){let e=t.boolean;r=He(r,e(n))}break;case`function`:if(t&&`function`in t){let e=t.function;r=He(r,e(n))}break;case`number`:if(t&&`number`in t){let e=t.number;r=He(r,e(n))}break;case`string`:if(t&&`string`in t){let e=t.string;r=He(r,e(n))}break;case`object`:if(Ve(n))if(t&&`object`in t&&typeof t.object==`function`){let i=t.object;r=He(r,i(n,e))}else r=He(r,n);break}return r},We=e=>{if(e.output instanceof Array)throw Error(`Unexpected array of outputs in user configuration. This should have been expanded already.`);let t=Ue({defaultValue:{clean:!0,fileName:{case:`preserve`,name:`{{name}}`,suffix:`.gen`},format:null,indexFile:!0,lint:null,path:``},mappers:{object:(e,t)=>({...e,fileName:Ue({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=re(ne(t.tsConfigPath)),t.importFileExtension===void 0&&t.tsConfig?.options.moduleResolution===p.default.ModuleResolutionKind.NodeNext&&(t.importFileExtension=`.js`),t.importFileExtension&&!t.importFileExtension.startsWith(`.`)&&(t.importFileExtension=`.${t.importFileExtension}`),t},Ge=e=>{let t=e?d.default.dirname(e):process.cwd();for(;t!==d.default.dirname(t);){let e=d.default.join(t,`package.json`);if(u.default.existsSync(e))try{let t=JSON.parse(u.default.readFileSync(e,`utf8`));return{...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies}}catch{}let n=d.default.dirname(t);if(n===t)break;t=n}return{}},Ke=[`after`,`before`,`cursor`,`offset`,`page`,`start`],qe=e=>Ue({defaultValue:{hooks:{},pagination:{keywords:Ke},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:Ue({defaultValue:{...t.pagination},value:e.pagination}),transforms:Ue({defaultValue:{...t.transforms},mappers:{object:(e,t)=>({...e,enums:Ue({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:Ue({defaultValue:{...t.readWrite,enabled:e.readWrite===void 0?t.readWrite.enabled:!!e.readWrite},mappers:{boolean:e=>({enabled:e}),object:(e,t)=>({...e,requests:Ue({defaultValue:{...t.requests},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.requests}),responses:Ue({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}),C=e=>t=>({...e,config:{...e.config,...t}}),w={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})};var Je=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Ye=/[\p{Lu}]/u,Xe=/[\p{Ll}]/u,Ze=/([\p{Alpha}\p{N}_]|$)/u,Qe=/[_.\- `\\[\]{}\\/]+/,$e=RegExp(`^${Qe.source}`),et=RegExp(`${Qe.source}${Ze.source}`,`gu`),tt=RegExp(`\\d+${Ze.source}`,`gu`),nt=({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(Qe.lastIndex=0;l&&Qe.test(l);)c+=1,l=t[c];let u=c!==e+1;if(Xe.lastIndex=0,Ye.lastIndex=0,Ye.test(s)&&(n||l&&!u&&l!==`s`&&Xe.test(l)))t=`${t.slice(0,e)}${o}${t.slice(e)}`,e++,i=r,n=!1,r=!0;else if(r&&i&&Xe.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},T=({case:e,stripLeadingSeparators:t=!0,value:n})=>{let r=n.trim();return r.length?!e||e===`preserve`?r:r.length===1?(Qe.lastIndex=0,Qe.test(r)?``:e===`PascalCase`||e===`SCREAMING_SNAKE_CASE`?r.toLocaleUpperCase():r.toLocaleLowerCase()):(r!==r.toLocaleLowerCase()&&(r=nt({case:e,string:r})),(t||r[0]!==n[0])&&(r=r.replace($e,``)),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(et,(e,n,r)=>r===0&&!t?e:`_${n}`),r[r.length-1]===`_`&&(r=r.slice(0,r.length-1))):(et.lastIndex=0,tt.lastIndex=0,r=r.replaceAll(tt,(e,t,n)=>[`_`,`-`,`.`].includes(r.charAt(n+e.length))?e:e.toLocaleUpperCase()),r=r.replaceAll(et,(e,r,i)=>i===0&&!t&&e[0]&&n.startsWith(e[0])?e:r.toLocaleUpperCase())),r):``},E=({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 T({case:e.case,value:t})},rt=({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]},it=e=>{for(let t in e)if(e[t].required)return!0;return!1},at=e=>e?!!(it(e.cookie)||it(e.header)||it(e.path)||it(e.query)):!1,ot=({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:rt({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:rt({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:rt({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:rt({context:e,parameter:r})}}}},D=({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},O=({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,st=e=>!!(at(e.parameters)||e.body?.required),k=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,ct=({context:e,operation:t})=>{let n=t.body;if(!n||!n.pagination)return ot({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}:ot({context:e,parameters:t.parameters})},lt=({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`}},ut=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(lt({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=O({items:Object.values(n.properties),mutateSchemaOneItem:!0,schema:{}});e=D({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=O({items:Object.values(r.properties),mutateSchemaOneItem:!0,schema:{}});e=D({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.response=e)}return t},dt=(...e)=>m.satisfies(...e),ft=e=>({getVersion:t=>{let n=e[t];if(n)try{let e=m.parse(n);if(e)return e;let t=m.minVersion(n);if(t)return t;if(e=m.coerce(n),e)return e}catch{}},isInstalled:t=>!!e[t],satisfies:(t,n,r)=>{let i=typeof t==`string`?e[t]:t;return i?dt(i,n,r):!1}}),pt=/^[^$_\p{ID_Start}]+/u,A=/^-?\d+(\.\d+)?$/,mt=/^(document|history|location|navigator|window)$/g,ht=/^(console|Array|Date|Error|Function|JSON|Map|Math|Object|Promise|RegExp|Set|WeakMap|WeakSet)$/g,gt=/^(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,_t=/^(global|process|Buffer)$/g,vt=/^(any|as|bigint|boolean|namespace|never|null|number|string|symbol|type|undefined|unknown|void)$/g,yt=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,bt=[gt,vt,ht,_t,mt],xt=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`);if(pt.lastIndex=0,pt.test(t))return`_${t}`;for(let e of bt){if(t.startsWith(`_`))return t;t=t.replace(e,`_$1`)}return t},St=e=>(e||e===``)&&(yt.lastIndex=0,!yt.test(e))?`'${e}'`:e,Ct=e=>e&&e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,e.length-1):e,j=e=>e.replace(/\*\//g,`*`).replace(/\/\*/g,`*`).replace(/\r?\n(.*)/g,(e,t)=>g.EOL+t.trim()),wt=p.default.createPrinter({newLine:p.default.NewLineKind.LineFeed,removeComments:!1}),Tt=e=>p.default.createSourceFile(``,e,p.default.ScriptTarget.ESNext,!1,p.default.ScriptKind.TS),Et=Tt(``),Dt=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));function Ot({node:e,unescape:t=!1}){let n=wt.printNode(p.default.EmitHint.Unspecified,e,Et);if(!t)return n;try{return Dt(n)}catch{return x().logs.level===`debug`&&console.warn(`Could not decode value:`,n),n}}const M=({text:e})=>p.default.factory.createIdentifier(e),kt=()=>p.default.factory.createThis(),N=({keyword:e})=>{let t=Vt({keyword:e});return p.default.factory.createModifier(t)},At=({initializer:e,modifier:t,name:n,type:r})=>p.default.factory.createPropertyDeclaration(t?[N({keyword:t})]:void 0,n,void 0,r,e),jt={boolean:e=>e?p.default.factory.createTrue():p.default.factory.createFalse(),export:({alias:e,asType:t=!1,name:n})=>{let r=M({text:n});if(e){let n=M({text:e});return p.default.factory.createExportSpecifier(t,r,n)}return p.default.factory.createExportSpecifier(t,void 0,r)},import:({alias:e,asType:t=!1,name:n})=>{let r=M({text:n});if(e){let n=M({text:e});return p.default.factory.createImportSpecifier(t,r,n)}return p.default.factory.createImportSpecifier(t,void 0,r)},number:e=>e<0?p.default.factory.createPrefixUnaryExpression(p.default.SyntaxKind.MinusToken,p.default.factory.createNumericLiteral(Math.abs(e))):p.default.factory.createNumericLiteral(e),string:(e,t=!1)=>{let n=e;t&&(n=Ct(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("`")?M({text:n}):on({text:n})}},Mt=e=>typeof e==`object`&&!!e&&typeof e.kind==`number`&&typeof e.flags==`number`&&typeof e.pos==`number`&&typeof e.end==`number`,Nt=e=>e!==void 0,Pt=({commentObject:e,node:t})=>{let n=e.lines.filter(e=>!!e||e===``);if(!n.length)return;if(!e.jsdoc){for(let e of n)p.default.addSyntheticLeadingComment(t,p.default.SyntaxKind.SingleLineCommentTrivia,` ${e}`,!0);return}let r=n.map((e,t)=>{let r=e;return t!==n.length&&(r=`${r}\n`),p.default.factory.createJSDocText(r)}),i=Ot({node:p.default.factory.createJSDocComment(p.default.factory.createNodeArray(r),void 0),unescape:!0}).replace(`/*`,``).replace(`* */`,``);p.default.addSyntheticLeadingComment(t,p.default.SyntaxKind.MultiLineCommentTrivia,i,!0)},Ft=({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)Pt({commentObject:e,node:t})},P=(e,t)=>p.default.isTypeNode(e)?e:typeof e==`number`?p.default.factory.createLiteralTypeNode(jt.number(e)):un({typeArguments:t?.map(e=>P(e)),typeName:p.default.isIdentifier(e)?e.text:e}),It=({expression:e,name:t})=>p.default.factory.createPropertyAccessChain(e,p.default.factory.createToken(p.default.SyntaxKind.QuestionDotToken),t),Lt=({expression:e,isOptional:t,name:n})=>{let r=typeof e==`string`?M({text:e}):e;if(t&&typeof n!=`number`)return It({expression:r,name:n});if(typeof n==`string`){if(yt.lastIndex=0,!yt.test(n)){!n.startsWith(`'`)&&!n.endsWith(`'`)&&(n=`\'${n}\'`);let e=M({text:n});return p.default.factory.createElementAccessExpression(r,e)}let e=M({text:n});return p.default.factory.createPropertyAccessExpression(r,e)}if(typeof n==`number`){let e=p.default.factory.createNumericLiteral(n);return p.default.factory.createElementAccessExpression(r,e)}return p.default.factory.createPropertyAccessExpression(r,n)},Rt=()=>p.default.factory.createNull(),zt=({identifiers:e=[],isValueAccess:t,shorthand:n,unescape:r,value:i})=>{if(i===null)return Rt();if(Array.isArray(i))return Xt({elements:i});if(typeof i==`object`)return $t({identifiers:e,obj:i,shorthand:n});if(typeof i==`number`)return jt.number(i);if(typeof i==`boolean`)return jt.boolean(i);if(typeof i==`string`){if(t){let e=i.split(`.`);return Lt({expression:e[0],name:e[1]})}return jt.string(i,r)}},Bt=e=>e.map(e=>{if(`destructure`in e)return fn({name:p.default.factory.createObjectBindingPattern(e.destructure.map(e=>{if(!(`destructure`in e))return p.default.factory.createBindingElement(void 0,void 0,M({text:e.name}),void 0)}).filter(Boolean)),type:e.type===void 0?void 0:P(e.type)});let t=e.accessLevel?[N({keyword:e.accessLevel})]:[];return e.isReadOnly&&t.push(N({keyword:`readonly`})),fn({initializer:e.default===void 0?void 0:zt({value:e.default}),modifiers:t,name:M({text:e.name}),required:e.isRequired!==!1,type:e.type===void 0?void 0:P(e.type)})}),Vt=({keyword:e})=>{switch(e){case`any`:return p.default.SyntaxKind.AnyKeyword;case`async`:return p.default.SyntaxKind.AsyncKeyword;case`boolean`:return p.default.SyntaxKind.BooleanKeyword;case`export`:return p.default.SyntaxKind.ExportKeyword;case`never`:return p.default.SyntaxKind.NeverKeyword;case`number`:return p.default.SyntaxKind.NumberKeyword;case`private`:return p.default.SyntaxKind.PrivateKeyword;case`protected`:return p.default.SyntaxKind.ProtectedKeyword;case`public`:return p.default.SyntaxKind.PublicKeyword;case`readonly`:return p.default.SyntaxKind.ReadonlyKeyword;case`static`:return p.default.SyntaxKind.StaticKeyword;case`string`:return p.default.SyntaxKind.StringKeyword;case`undefined`:return p.default.SyntaxKind.UndefinedKeyword;case`unknown`:return p.default.SyntaxKind.UnknownKeyword;case`void`:return p.default.SyntaxKind.VoidKeyword;default:throw Error(`unsupported syntax kind keyword "${e}"`)}},Ht=({keyword:e})=>{let t=Vt({keyword:e});return p.default.factory.createKeywordTypeNode(t)},Ut=e=>e.map(e=>p.default.isTypeParameterDeclaration(e)?e:Gt({constraint:e.extends?typeof e.extends==`string`?Ht({keyword:`boolean`}):e.extends:void 0,defaultType:e.default===void 0?void 0:Mt(e.default)?e.default:p.default.factory.createLiteralTypeNode(e.default?p.default.factory.createTrue():p.default.factory.createFalse()),name:e.name})),Wt=({operator:e,type:t})=>{let n=e===`keyof`?p.default.SyntaxKind.KeyOfKeyword:e===`readonly`?p.default.SyntaxKind.ReadonlyKeyword:p.default.SyntaxKind.UniqueKeyword;return p.default.factory.createTypeOperatorNode(n,t)},Gt=({constraint:e,defaultType:t,modifiers:n,name:r})=>p.default.factory.createTypeParameterDeclaration(n,r,e,t),Kt=({members:e,nameType:t,questionToken:n,readonlyToken:r,type:i,typeParameter:a})=>p.default.factory.createMappedTypeNode(r,a,t,n,i,e),qt=({literal:e})=>p.default.factory.createLiteralTypeNode(e),Jt=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=p.default.factory.createArrowFunction(e?[N({keyword:`async`})]:void 0,o?Ut(o):void 0,Bt(r),i?P(i):void 0,void 0,Array.isArray(a)?gn({multiLine:n,statements:a}):a);return Ft({comments:t,node:s}),s},Yt=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=p.default.factory.createFunctionExpression(e?[N({keyword:`async`})]:void 0,void 0,void 0,o?Ut(o):void 0,Bt(r),i?P(i):void 0,gn({multiLine:n,statements:a}));return Ft({comments:t,node:s}),s},Xt=({elements:e,multiLine:t=!1})=>p.default.factory.createArrayLiteralExpression(e.map(e=>Mt(e)?e:zt({value:e})).filter(Nt),t||!Array.isArray(e[0])&&typeof e[0]==`object`),Zt=({expression:e})=>p.default.factory.createAwaitExpression(e),Qt=({parameters:e=[],returnType:t,typeParameters:n})=>p.default.factory.createFunctionTypeNode(n,e,t),$t=({comments:e,identifiers:t=[],multiLine:n=!0,obj:r,shorthand:i,unescape:a=!1})=>{let o=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 o;if(`spread`in e){let t=Mt(e.spread)?e.spread:M({text:e.spread});o=p.default.factory.createSpreadAssignment(e.assertion?yn({expression:t,type:typeof e.assertion==`string`?Ht({keyword:e.assertion}):e.assertion}):t)}else if(e.shorthand||i&&r)o=p.default.factory.createShorthandPropertyAssignment(e.value);else{let r=Mt(e.value)?e.value:Array.isArray(e.value)&&(!e.value.length||typeof e.value[0]==`object`)?$t({multiLine:n,obj:e.value,shorthand:i,unescape:a}):zt({identifiers:t.includes(e.key)?Object.keys(e.value):[],isValueAccess:e.isValueAccess,shorthand:i,unescape:a,value:e.value});if(!r)return;t.includes(e.key)&&!p.default.isObjectLiteralExpression(r)&&(r=M({text:e.value})),o=_n({initializer:r,name:e.key})}return Ft({comments:e.comments,node:o}),o}).filter(Nt):Object.entries(r).map(([e,n])=>{let r=zt({identifiers:t.includes(e)?Object.keys(n):[],shorthand:i,unescape:a,value:n});if(!r)return;t.includes(e)&&!p.default.isObjectLiteralExpression(r)&&(r=M({text:n}));let o=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&&o?p.default.factory.createShorthandPropertyAssignment(n):_n({initializer:r,name:e})}).filter(Nt),s=p.default.factory.createObjectLiteralExpression(o,n);return Ft({comments:e,node:s}),s},en=({asConst:e,comments:t={},leadingComment:n,name:r,obj:i})=>{let a=Array.isArray(i)?i.map(e=>{let t=tn({initializer:zt({value:e.value}),name:e.key});return Ft({comments:e.comments,node:t}),t}):Object.entries(i).map(([e,n])=>{let r=p.default.factory.createEnumMember(e,zt({unescape:!0,value:n}));return Ft({comments:t[e],node:r}),r}),o=[N({keyword:`export`})],s=e?[p.default.factory.createToken(p.default.SyntaxKind.ConstKeyword)]:[],c=[...o,...s],l=p.default.factory.createEnumDeclaration(c,typeof r==`string`?M({text:r}):r,a);return Ft({comments:n,node:l}),l},tn=({initializer:e,name:t})=>{let n=t;return typeof n==`string`&&(n=n.includes(`'`)?on({isSingleQuote:!1,text:n}):St(n)),p.default.factory.createEnumMember(n,e)},nn=({name:e,statements:t})=>p.default.factory.createModuleDeclaration([N({keyword:`export`})],M({text:e}),p.default.factory.createModuleBlock(t),p.default.NodeFlags.Namespace),rn=({indexType:e,objectType:t})=>p.default.factory.createIndexedAccessTypeNode(t,e),an=({name:e,returnType:t,statements:n})=>p.default.factory.createGetAccessorDeclaration(void 0,e,[],t?un({typeName:t}):void 0,gn({statements:n})),on=({isSingleQuote:e,text:t})=>(e===void 0&&(e=!t.includes(`'`)),p.default.factory.createStringLiteral(t,e)),sn=({condition:e,whenFalse:t,whenTrue:n})=>p.default.factory.createConditionalExpression(e,p.default.factory.createToken(p.default.SyntaxKind.QuestionToken),n,p.default.factory.createToken(p.default.SyntaxKind.ColonToken),t),cn=({text:e})=>p.default.factory.createTypeOfExpression(typeof e==`string`?M({text:e}):e),ln=({comment:e,exportType:t,name:n,type:r,typeParameters:i=[]})=>{let a=p.default.factory.createTypeAliasDeclaration(t?[N({keyword:`export`})]:void 0,typeof n==`string`?M({text:n}):n,Ut(i),P(r));return Ft({comments:e,node:a}),a},un=({typeArguments:e,typeName:t})=>p.default.factory.createTypeReferenceNode(t,e),dn=({type:e})=>p.default.factory.createParenthesizedType(e),fn=({initializer:e,modifiers:t,name:n,required:r=!0,type:i})=>p.default.factory.createParameterDeclaration(t,void 0,n,r?void 0:p.default.factory.createToken(p.default.SyntaxKind.QuestionToken),i,e),pn=({argumentsArray:e,expression:t,typeArguments:n})=>p.default.factory.createNewExpression(t,n,e),mn=({awaitModifier:e,expression:t,initializer:n,statement:r})=>p.default.factory.createForOfStatement(e,n,t,r),hn=({left:e,right:t})=>p.default.factory.createAssignment(e,t),gn=({multiLine:e=!0,statements:t})=>p.default.factory.createBlock(t,e),_n=({initializer:e,name:t})=>p.default.factory.createPropertyAssignment(t,e),vn=({flags:e=[],text:t})=>{let n=`/${(t.startsWith(`/`)&&t.endsWith(`/`)?t.slice(1,-1):t).replace(/(?<!\\)\//g,`\\/`)}/`;return p.default.factory.createRegularExpressionLiteral(`${n}${e.join(``)}`)},yn=({expression:e,type:t})=>p.default.factory.createAsExpression(e,t),bn=({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?p.default.factory.createTemplateMiddle(n):p.default.factory.createTemplateTail(n),i=p.default.factory.createTemplateLiteralTypeSpan(r,e);t.push(i),n=``}return p.default.factory.createTemplateLiteralType(p.default.factory.createTemplateHead(n),t.reverse())},xn=({module:e,shouldAppendJs:t})=>p.default.factory.createExportDeclaration(void 0,!1,void 0,jt.string(t?`${e}.js`:e)),Sn=({functionName:e,parameters:t=[],types:n})=>{let r=typeof e==`string`?M({text:e}):e,i=t.filter(e=>e!==void 0).map(e=>typeof e==`string`?M({text:e}):e);return p.default.factory.createCallExpression(r,n,i)},Cn=({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 jt.export({alias:t.alias,asType:r&&t.asType,name:t.name})}),a=p.default.factory.createNamedExports(i),o=jt.string(t);return p.default.factory.createExportDeclaration(void 0,!r,a,o)},wn=({assertion:e,comment:t,destructure:n,exportConst:r,expression:i,name:a,typeName:o})=>{let s=e?yn({expression:i,type:typeof e==`string`?un({typeName:e}):e}):i,c=typeof a==`string`?M({text:a}):a,l=p.default.factory.createVariableDeclaration(n?p.default.factory.createObjectBindingPattern([p.default.factory.createBindingElement(void 0,void 0,c,void 0)]):c,void 0,o?typeof o==`string`?un({typeName:o}):o:void 0,s),u=p.default.factory.createVariableStatement(r?[N({keyword:`export`})]:void 0,p.default.factory.createVariableDeclarationList([l],p.default.NodeFlags.Const));return Ft({comments:t,node:u}),u},Tn=({imports:e,module:t})=>{let n=Array.isArray(e)?e:[e],r=n.some(e=>typeof e!=`object`||!e.asType),i,a=[];n.forEach(e=>{let t=typeof e==`string`?{name:e}:e;t.name===`*`&&t.alias?i=t:a.push(jt.import({alias:t.alias,asType:r&&t.asType,name:t.name}))});let o=i?p.default.factory.createNamespaceImport(M({text:i.alias})):p.default.factory.createNamedImports(a),s=p.default.factory.createImportClause(!r,void 0,o),c=jt.string(t);return p.default.factory.createImportDeclaration(void 0,s,c)},En=({accessLevel:e,comment:t,multiLine:n=!0,parameters:r=[],statements:i=[]})=>{let a=e?[N({keyword:e})]:void 0,o=p.default.factory.createConstructorDeclaration(a,Bt(r),gn({multiLine:n,statements:i}));return Ft({comments:t,node:o}),o},Dn=({accessLevel:e,comment:t,isStatic:n=!1,multiLine:r=!0,name:i,parameters:a=[],returnType:o,statements:s=[],types:c=[]})=>{let l=e?[N({keyword:e})]:[];n&&l.push(N({keyword:`static`}));let u=p.default.factory.createMethodDeclaration(l,void 0,M({text:i}),void 0,c?Ut(c):void 0,Bt(a),o?P(o):void 0,gn({multiLine:r,statements:s}));return Ft({comments:t,node:u}),u},On=({decorator:e,exportClass:t,extendedClasses:n,name:r,nodes:i})=>{let a=[];t&&a.push(N({keyword:`export`})),e&&a.unshift(p.default.factory.createDecorator(Sn({functionName:e.name,parameters:e.args.map(e=>zt({value:e})).filter(Nt)})));let o=[];if(n)for(let e of n)o.push(p.default.factory.createHeritageClause(p.default.SyntaxKind.ExtendsKeyword,[p.default.factory.createExpressionWithTypeArguments(M({text:e}),void 0)]));return p.default.factory.createClassDeclaration(a,M({text:r}),void 0,o,i)},kn=({expression:e})=>p.default.factory.createExpressionStatement(e),An=({expression:e})=>p.default.factory.createReturnStatement(e),jn=({args:e=[],name:t,types:n=[]})=>{let r=n.map(e=>un({typeName:e}));return An({expression:Sn({functionName:t,parameters:e.map(e=>p.default.isExpression(e)?e:M({text:e})).filter(Nt),types:r})})},Mn=({expression:e})=>An({expression:typeof e==`string`?M({text:e}):e}),Nn=e=>e.slice(1).reduce((e,t)=>(yt.lastIndex=0,yt.test(t)?It({expression:e,name:t}):p.default.factory.createElementAccessChain(e,p.default.factory.createToken(p.default.SyntaxKind.QuestionDotToken),M({text:t}))),M({text:e[0]})),Pn=e=>e.slice(1).reduce((e,t)=>Lt({expression:e,name:t}),M({text:e[0]})),Fn=({expressions:e})=>e.reduce((e,t)=>Lt({expression:e,name:t})),In=({left:e,operator:t=`=`,right:n})=>p.default.factory.createBinaryExpression(e,t===`=`?p.default.SyntaxKind.EqualsToken:t===`===`?p.default.SyntaxKind.EqualsEqualsEqualsToken:t===`!==`?p.default.SyntaxKind.ExclamationEqualsEqualsToken:t===`??`?p.default.SyntaxKind.QuestionQuestionToken:p.default.SyntaxKind.InKeyword,typeof n==`string`?M({text:n}):n),Ln=({elseStatement:e,expression:t,thenStatement:n})=>p.default.factory.createIfStatement(t,n,e),Rn=({path:e})=>{let t=Nn(e),n=Pn(e);return Ln({expression:t,thenStatement:gn({statements:[kn({expression:In({left:n,right:pn({argumentsArray:[n],expression:M({text:`Date`})})})})]})})},zn=({path:e,transformerName:t})=>[Ln({expression:Nn(e),thenStatement:gn({statements:[kn({expression:Sn({functionName:t,parameters:[Pn(e)]})})]})})],Bn=({path:e,transformerName:t})=>{let n=Nn(e),r=Pn(e);return Ln({expression:Sn({functionName:Lt({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:gn({statements:[kn({expression:p.default.factory.createCallChain(Lt({expression:r,name:`forEach`}),void 0,void 0,[M({text:t})])})]})})},Vn=({parameterName:e})=>{let t=M({text:`Date`});return pn({argumentsArray:[M({text:e})],expression:t})},Hn=({path:e,transformExpression:t})=>{let n=Nn(e),r=Pn(e);return Ln({expression:Sn({functionName:Lt({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:gn({statements:[kn({expression:In({left:r,right:p.default.factory.createCallChain(Lt({expression:r,name:`map`}),void 0,void 0,[Jt({parameters:[{name:`item`}],statements:t})])})})]})})},Un=un({typeName:`null`}),Wn=({isNullable:e,node:t})=>e?p.default.factory.createUnionTypeNode([t,Un]):t,Gn=({indexKey:e,indexProperty:t,isNullable:n,properties:r,useLegacyResolution:i})=>{let a=[],o=r.map(e=>{let t=e.isReadOnly?[N({keyword:`readonly`})]:void 0,n=e.isRequired===!1?p.default.factory.createToken(p.default.SyntaxKind.QuestionToken):void 0,r=P(e.type);a.push(r);let o=p.default.factory.createPropertySignature(t,i||typeof e.name==`string`&&e.name.match(yt)||typeof e.name!=`string`&&p.default.isPropertyName(e.name)?e.name:on({text:e.name}),n,r);return Ft({comments:e.comment,node:o}),o}),s=!1;if(t)if(!r.length&&e){let n=Kt({questionToken:p.default.factory.createToken(p.default.SyntaxKind.QuestionToken),type:t.type??Ht({keyword:`string`}),typeParameter:Gt({constraint:e,name:M({text:String(t.name)})})});o.push(n),s=!0}else{let e=t.isReadOnly?[N({keyword:`readonly`})]:void 0,n=p.default.factory.createIndexSignature(e,[fn({name:M({text:String(t.name)}),type:Ht({keyword:`string`})})],P(t.type));o.push(n)}return Wn({isNullable:n,node:s?o[0]:p.default.factory.createTypeLiteralNode(o)})},Kn=({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=P(e);p.default.isUnionTypeNode(t)?n.push(...t.types):n.push(t)}return Wn({isNullable:e,node:p.default.factory.createUnionTypeNode(n)})},qn=({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=P(e);p.default.isIntersectionTypeNode(t)?n.push(...t.types):n.push(t)}return Wn({isNullable:e,node:p.default.factory.createIntersectionTypeNode(n)})},Jn=({isNullable:e=!1,types:t})=>{let n=t.map(e=>P(e));return Wn({isNullable:e,node:p.default.factory.createTupleTypeNode(n)})},Yn=(e,t,n=!1,r=!0)=>{let i=Kn({types:e}),a=Kn({types:t});return Wn({isNullable:n,node:Gn({properties:[{name:`[key: ${Ot({node:i,unescape:!0})}]`,type:a}],useLegacyResolution:r})})},Xn=(e,t=!1)=>Wn({isNullable:t,node:un({typeArguments:[Array.isArray(e)?Kn({types:e}):e],typeName:`Array`})}),F={anonymousFunction:Yt,arrayLiteralExpression:Xt,arrowFunction:Jt,asExpression:yn,assignment:hn,awaitExpression:Zt,binaryExpression:In,block:gn,callExpression:Sn,classDeclaration:On,conditionalExpression:sn,constVariable:wn,constructorDeclaration:En,enumDeclaration:en,exportAllDeclaration:xn,exportNamedDeclaration:Cn,expressionToStatement:kn,forOfStatement:mn,functionTypeNode:Qt,getAccessorDeclaration:an,identifier:M,ifStatement:Ln,indexedAccessTypeNode:rn,isTsNode:Mt,keywordTypeNode:Ht,literalTypeNode:qt,mappedTypeNode:Kt,methodDeclaration:Dn,namedImportDeclarations:Tn,namespaceDeclaration:nn,newExpression:pn,nodeToString:Ot,null:Rt,objectExpression:$t,ots:jt,parameterDeclaration:fn,propertyAccessExpression:Lt,propertyAccessExpressions:Fn,propertyAssignment:_n,propertyDeclaration:At,regularExpressionLiteral:vn,returnFunctionCall:jn,returnStatement:An,returnVariable:Mn,safeAccessExpression:Nn,stringLiteral:on,templateLiteralType:bn,this:kt,transformArrayMap:Hn,transformArrayMutation:Bn,transformDateMutation:Rn,transformFunctionMutation:zn,transformNewDate:Vn,typeAliasDeclaration:ln,typeArrayNode:Xn,typeInterfaceNode:Gn,typeIntersectionNode:qn,typeNode:P,typeOfExpression:cn,typeOperatorNode:Wt,typeParameterDeclaration:Gt,typeParenthesizedNode:dn,typeRecordNode:Yn,typeReferenceNode:un,typeTupleNode:Jn,typeUnionNode:Kn,valueToExpression:zt},Zn=F,Qn=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 $n=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),c=(0,h.createBinding)({file:t,modulePath:o,symbol:i,symbolFile:a});s?((0,h.mergeBindings)(s,c),e.set(o,s)):e.set(o,c)}getBindingPath(e,t,n){if(!e.path||!t.path)return``;if(t.external&&!d.default.isAbsolute(t.path))return t.path;let r=d.default.posix.relative(d.default.posix.dirname(e.path.split(d.default.sep).join(d.default.posix.sep)),t.path.split(d.default.sep).join(d.default.posix.sep));return!r.startsWith(`.`)&&r!==``&&(r=`./${r}`),t.extension===`.ts`&&(r.endsWith(t.extension)&&(r=r.slice(0,-t.extension.length)),n?.importFileExtension?r+=n.importFileExtension:r.endsWith(`/index`)&&(r=r.slice(0,-6))),r}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(Ot({node:t,unescape:!0}));else e!=null&&n.push(Ot({node:e,unescape:!0}))}return n}getExportLines(e,t,n){let r=[];for(let[i,a]of e.entries()){let e=[],o,s=!1;if(a.namespaceBinding!==void 0)typeof a.namespaceBinding==`string`&&(o=(0,h.renderIds)(a.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})})),a.typeNamespaceBinding&&(s=!0);else if(a.names&&a.names.length>0){a.names.every(e=>(a.typeNames??[]).includes(e))&&(s=!0);for(let r of a.names){let i=a.aliases?.[r],o=r,c;i&&i!==o&&(c=o,o=i),o=(0,h.renderIds)(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&&(c||=o),i}),c&&(c=(0,h.renderIds)(c,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),c===o&&(c=void 0));let l=p.default.factory.createExportSpecifier(s?!1:a.typeNames?.includes(r)??!1,c?F.identifier({text:c}):void 0,F.identifier({text:o}));e.push(l)}}let c=o?p.default.factory.createNamespaceExport(F.identifier({text:o})):e.length?p.default.factory.createNamedExports(e):void 0,l=p.default.factory.createExportDeclaration(void 0,s,c,F.stringLiteral({isSingleQuote:!0,text:i}));r.push(Ot({node:l,unescape:!0}))}return r}getHeaderLines(){return[`// This file is auto-generated by @hey-api/openapi-ts`]}getImportLines(e,t,n){let r=[],i=-1,a=e=>{let t=e.from;return t.startsWith(`.`)?t.startsWith(`./`)?[2,0,t]:[2,t.match(/\.\.\//g)?.length??0,t]:Qn.has(t.split(`/`)[0])?[0,0,t]:[1,0,t]},o=Array.from(e.values()).map(e=>({...e,k:a(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 o){let a=[],o,s,c=!1;if(e.defaultBinding){let r=(0,h.renderIds)(e.defaultBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})});o=F.identifier({text:r}),e.typeDefaultBinding&&(c=!0)}else if(typeof e.namespaceBinding==`string`)s=(0,h.renderIds)(e.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),e.typeNamespaceBinding&&(c=!0);else if(e.names&&e.names.length>0){e.names.every(t=>e.typeNames?.includes(t))&&(c=!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=(0,h.renderIds)(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=(0,h.renderIds)(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:c?!1:e.typeNames?.includes(i)??!1,name:o,propertyName:s?F.identifier({text:s}):void 0})}a=r.sort((e,t)=>e.name.localeCompare(t.name)).map(({isTypeOnly:e,name:t,propertyName:n})=>p.default.factory.createImportSpecifier(e,n,F.identifier({text:t})))}let l=p.default.factory.createImportClause(c,o,s?p.default.factory.createNamespaceImport(F.identifier({text:s})):a.length?p.default.factory.createNamedImports(a):void 0),u=p.default.factory.createImportDeclaration(void 0,l,F.stringLiteral({isSingleQuote:!0,text:e.from}));i!==-1&&e.k[0]!==i&&r.push(``),r.push(Ot({node:u,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=(0,h.renderIds)(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=(0,h.renderIds)(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=xt(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}},er=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 tr=(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??or;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 er(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??ir;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=rr(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))},nr=[`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`],rr=(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}},ir=[`schema`,`parameter`,`requestBody`,`operation`,`server`,`webhook`],ar=(()=>{let e={};for(let t=0;t<ir.length;t++){let n=ir[t];n&&(e[n]=t)}for(let t of nr)e[t]===void 0&&(e[t]=ir.length);return e})(),or=e=>{let t=rr(e);return t.matched?ar[t.kind]??10:10},sr=/~1/g,cr=/~0/g,I=e=>{let t=L(e),n=t[t.length-1];return decodeURI(n)},lr=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(sr,`/`).replace(cr,`~`)):[]},ur=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},dr=e=>{let t=e.map(lr).join(`/`);return`#`+(t?`/${t}`:``)},fr=({$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},pr=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},mr=e=>{switch(e.method){case`delete`:case`patch`:case`post`:case`put`:return[`mutation`];case`get`:return[`query`];default:return}};var hr=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:nr);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&&tr(this.context.graph,(e,n)=>{let r=rr(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 ue({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?pr(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?(mr(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:d.default.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}},gr=class{config;gen;graph;ir={};logger;package;plugins={};spec;constructor({config:e,dependencies:t,logger:n,spec:r}){this.config=e,this.gen=new h.Project({defaultFileName:`index`,fileName:t=>{let n=E({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 $n},root:e.output.path}),this.logger=n,this.package=ft(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 hr({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 fr({$ref:e,spec:this.ir})}resolveRef(e){return fr({$ref:e,spec:this.spec})}};const _r=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`);return pt.lastIndex=0,pt.test(t)?`_${t}`:t},vr=e=>e.replace(/^[^\p{ID_Start}]+/u,``).replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`-`).replace(/[$+]/g,`-`),yr=e=>vr(e.replace(`[]`,`Array`)),br=[`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`],xr=({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)?T({case:c,value:vr(n)}):T({case:c,value:`${r}-${i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`)}`}),t>1&&(o=`${o}${t}`),a.ids.has(o)?xr({context:e,count:t+1,id:n,method:r,path:i,state:a}):(a.ids.set(o,k({method:r,path:i})),o)},Sr=`/`,R=(e,t=``)=>`${e}/${t}`,z=e=>{let t=e.indexOf(`/`);return{name:e.slice(t+1),namespace:e.slice(0,t)}},Cr=e=>{switch(e){case`parameters`:return`parameter`;case`requestBodies`:return`body`;case`responses`:return`response`;case`definitions`:case`schemas`:return`schema`;default:return`unknown`}},wr=(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)}},Tr=({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 br){if(!i[t])continue;let a=k({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))},Er=({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 br){if(!r[t])continue;let i=k({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))}},Dr=({spec:e,...t})=>{`swagger`in e?Tr({...t,spec:e}):Er({...t,spec:e})},Or=(e,t,n)=>{let r=n.timeEvent(`create-filters`),i=wr(`operation`,e?.operations?.exclude),a=wr(`operation`,e?.operations?.include),o=wr(`parameter`,e?.parameters?.exclude),s=wr(`parameter`,e?.parameters?.include),c=wr(`body`,e?.requestBodies?.exclude),l=wr(`body`,e?.requestBodies?.include),u=wr(`response`,e?.responses?.exclude),d=wr(`response`,e?.responses?.include),f=wr(`schema`,e?.schemas?.exclude),p=wr(`schema`,e?.schemas?.include);Dr({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},kr=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,Ar=({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}},jr=({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}},Mr=({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}},Nr=({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}},Pr=({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}},Fr=({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}}}},Ir=({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}}}},Lr=({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}}}},Rr=({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}}}},zr=({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)},Br=({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}},Vr=({filters:e,logger:t,resourceMetadata:n})=>{let r=t.timeEvent(`create-filtered-dependencies`),{schemas:i}=Pr({filters:e,resourceMetadata:n}),{parameters:a}=jr({filters:e,resourceMetadata:n,schemas:i}),{requestBodies:o}=Mr({filters:e,resourceMetadata:n,schemas:i}),{responses:s}=Nr({filters:e,resourceMetadata:n,schemas:i});Rr({filters:e,resourceMetadata:n,schemas:i}),Fr({filters:e,parameters:a,resourceMetadata:n}),Ir({filters:e,requestBodies:o,resourceMetadata:n}),Lr({filters:e,resourceMetadata:n,responses:s});let{operations:c}=Ar({filters:e,parameters:a,requestBodies:o,resourceMetadata:n,responses:s,schemas:i});if(!e.orphans&&c.size){let{operationDependencies:e}=Br({operations:c,resourceMetadata:n});zr({operationDependencies:e,parameters:a,requestBodies:o,responses:s,schemas:i})}return r.timeEnd(),{operations:c,parameters:a,requestBodies:o,responses:s,schemas:i}},Hr=(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=Cr(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&&br.includes(e[2])){let a=e[e.length-1],o=k({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}},Ur=e=>JSON.parse(JSON.stringify(e)),Wr=[[`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`]],Gr=e=>{if(Kr(e))return e.components.schemas;if(qr(e))return e.definitions},Kr=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,qr=e=>typeof e==`object`&&!!e&&`definitions`in e&&typeof e.definitions==`object`&&e.definitions!==null,Jr=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,Yr=({base:e,components:t,extraComponents:n})=>{let r=2,i=e;for(;Jr(t,i)||n&&Jr(n,i);)i=`${e}${r}`,r+=1;return i},Xr=e=>e.length===3&&e[0]===`components`&&e[1]===`schemas`||e.length===2&&e[0]===`definitions`,Zr=e=>{if(e&&typeof e==`object`){if(`swagger`in e)return`#/definitions/`;if(`openapi`in e)return`#/components/schemas/`}return``},Qr=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})},$r=({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||Wr.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)=>$r({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):$r({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},ei=({spec:e})=>{let t=Gr(e);if(!t)return;let n=Zr(e),r={};for(let[e,i]of Object.entries(t))Qr(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,Ur(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]}},ti=({config:e,spec:t})=>{let n=Gr(t);if(!n)return;let r={};for(let[e,t]of Object.entries(n)){let n=Qr(t);n&&(r[n]=e)}let i=[];$r({key:null,node:t,parent:null,path:[],visitor:e=>{if(!Xr(e.path)){let t=Qr(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]=Yr({base:E({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=Zr(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}`})}},ni=({config:e,spec:t})=>{if(e.mode===`inline`){ei({spec:t});return}if(e.mode===`root`){ti({config:e,spec:t});return}},ri=({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||Wr.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)=>ri({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):ri({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},ii=({spec:e})=>{ri({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)}}})},ai=(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(!ai(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(!ai(r[e],i[e]))return!1;return!0};var oi=ai;const si=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))}},ci=({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=ci({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=ci({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}},li=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&&ui(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 Wr){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&&ui(r,a)&&n(i,a)}if(a.parentPointer){let t=e.nodes.get(a.parentPointer);t&&ui(a,t)&&n(a.parentPointer,t)}}},ui=(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},di=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`])))}},fi=(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=dr(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=ur(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);di(r.nodes),li(r),si(r.nodes);for(let e of r.nodes.keys()){let t=ci({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}},pi=new Set([`additionalProperties`,`allOf`,`anyOf`,`items`,`not`,`oneOf`,`patternProperties`,`properties`,`schema`]),mi=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`}},hi=(e,t)=>{let n=t.timeEvent(`capture-original-schemas`),r={};if(Kr(e))for(let[t,n]of Object.entries(e.components.schemas))r[`#/components/schemas/${t}`]=n;else if(qr(e))for(let[t,n]of Object.entries(e.definitions))r[`#/definitions/${t}`]=n;return n.timeEnd(),r},gi=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`insert-split-schemas-into-spec`);Kr(t)?Object.assign(t.components.schemas,n.schemas):qr(t)&&Object.assign(t.definitions,n.schemas),r.timeEnd()},_i=(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,!Wr.some(([e])=>e in t)))return!0}for(let[r,i]of Wr){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||_i(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||_i(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||_i(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||_i(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else typeof a==`object`&&a&&(a[n]===!0||_i(e,a,n))&&delete t[r]}if(t.type===`object`&&!Wr.some(([e])=>e in t))return!0}return!1},vi=({logger:e,originalSchemas:t,spec:n,split:r})=>{let i=e.timeEvent(`remove-original-split-schemas`),a=Gr(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()},yi=({config:e,graph:t,logger:n,spec:r})=>{let i=n.timeEvent(`split-schemas`),a=new Set,o={mapping:{},reverseMapping:{},schemas:{}},s=Zr(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=Ur(r.node);_i(t,c,`writeOnly`);let u=E({config:e.responses,name:i}),d=u===i?u:Yr({base:u,components:a});a.add(d),o.schemas[d]=c;let f=`${s}${d}`,p=Ur(r.node);if(_i(t,p,`readOnly`),oi(c,p)&&oi(c,r.node))continue;let m=E({config:e.requests,name:i}),h=m===i&&m!==d?m:Yr({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},bi=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`update-refs-in-spec`),i=Zr(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(Xr(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=mi(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(pi.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()},xi=({config:e,logger:t,spec:n})=>{let{graph:r}=fi(n,t),i=hi(n,t),a=yi({config:e,graph:r,logger:t,spec:n});gi({logger:t,spec:n,split:a}),bi({logger:t,spec:n,split:a}),vi({logger:t,originalSchemas:i,spec:n,split:a})},Si=({context:e})=>{let{logger:t}=e,n=t.timeEvent(`transform-openapi-spec`);e.config.parser.transforms.enums.enabled&&ni({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&ii({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&xi({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},Ci=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),wi=e=>e.map((e,t)=>typeof e==`number`?`[${e}]`:t===0?e:Ci(e)?`.${e}`:`['${e.replace(/"/g,`\\'`)}']`).join(``),Ti=e=>{let t=wi(e.path),n=e.severity===`error`?l.default.bold.red:l.default.bold.yellow,r=e.message.replace(/`([^`]+)`/g,(e,t)=>l.default.yellow(`\`${t}\``));return`${n(`[${e.severity.toUpperCase()}]`)} ${l.default.cyan(t)}: ${r}`},Ei=({context:e,issue:t})=>e.config.logs.level===`silent`?!1:t.severity===`error`?e.config.logs.level!==`warn`:!0,Di=({context:e,result:t})=>{for(let n of t.issues)Ei({context:e,issue:n})&&console.log(Ti(n));t.valid||process.exit(1)},Oi=({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 br){if(!r[e])continue;let i=R(`operation`,k({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete i.paths[n]}a.timeEnd()},ki=/^(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,Ai=/^application\/(.*\+)?json(;.*)?$/i,ji=/^multipart\/form-data(;.*)?$/i,Mi=/^text\/[a-z0-9.+-]+(;.*)?$/i,Ni=/^application\/x-www-form-urlencoded(;.*)?$/i,Pi=/^application\/octet-stream(;.*)?$/i,Fi=({mediaType:e})=>(ki.lastIndex=0,ki.test(e)),Ii=({mediaType:e})=>{if(Ai.lastIndex=0,Ai.test(e))return`json`;if(ji.lastIndex=0,ji.test(e))return`form-data`;if(Mi.lastIndex=0,Mi.test(e))return`text`;if(Ni.lastIndex=0,Ni.test(e))return`url-search-params`;if(Pi.lastIndex=0,Pi.test(e))return`octet-stream`},Li=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Fi({mediaType:t})?{...n,format:`binary`}:n:Fi({mediaType:t})?{format:`binary`,type:`string`}:void 0},Ri=({mimeTypes:e,response:t})=>{let n=[];for(let r of e??[])n.push({mediaType:r,schema:t.schema,type:Ii({mediaType:r})});return n};function zi(e){let t=`^(${e.keywords.join(`|`)})$`;return new RegExp(t)}const Bi=(e,t,n)=>{let r=[];for(let n in t)t[n]===e&&r.push(n);return!r.length&&(!n||n())?[I(e)]:r},Vi=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},Hi=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},Ui=({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`)},Wi=({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=ra({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=O({items:i,schema:t}),t},Gi=({irSchema:e={}})=>(e.type=`boolean`,e),Ki=({irSchema:e={},schema:t})=>(e.type=t.type,e),qi=({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]=ra({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=ra({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},Ji=({irSchema:e={}})=>(e.type=`string`,e),Yi=({schema:e})=>{let t={};return Hi({irSchema:t,schema:e}),t},Xi=({context:e,schema:t,state:n})=>{let r=Yi({schema:t}),i=[],a=Vi({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=ra({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=Bi(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=ta({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(Vi({schema:a})===`object`){let i=ta({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=O({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},Zi=({context:e,schema:t,state:n})=>{let r=Yi({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=ta({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=O({items:i,schema:r}),r},Qi=({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=ra({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,ra({context:e,schema:r,state:n}),n.$ref=i}return r},$i=({context:e,irSchema:t,schema:n,state:r})=>{t||=Yi({schema:n});let i={};return Ui({irSchema:i,schema:n}),i.default===null&&delete i.default,t=O({items:[ta({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},ea=({context:e,schema:t,state:n})=>{let r=Yi({schema:t});Ui({irSchema:r,schema:t});let i=Vi({schema:t});return i?t[`x-nullable`]?$i({context:e,irSchema:r,schema:{...t,type:i},state:n}):ta({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},ta=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Yi({schema:n}),Ui({irSchema:t,schema:n})),n.type){case`array`:return Wi({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Gi({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Ki({context:e,irSchema:t,schema:n,state:r});case`object`:return qi({context:e,irSchema:t,schema:n,state:r});case`string`:return Ji({context:e,irSchema:t,schema:n,state:r});default:return na({context:e,irSchema:t,schema:n})}},na=({irSchema:e,schema:t})=>(e||=Yi({schema:t}),e.type=`unknown`,Ui({irSchema:e,schema:t}),e),ra=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?Qi({context:e,schema:t,state:n}):t.enum?Zi({context:e,schema:t,state:n}):t.allOf?Xi({context:e,schema:t,state:n}):t.type||t.properties?ea({context:e,schema:t,state:n}):na({context:e,schema:t})),ia=({$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)]=ra({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},aa=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,oa=({context:e,name:t,schema:n})=>{if(zi(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref??``);return`in`in r&&r.in?oa({context:e,name:t,schema:`schema`in r?r.schema:{...r,in:void 0}}):oa({context:e,name:t,schema:r})}if(`in`in n)return n.in?oa({context:e,name:t,schema:`schema`in n?n.schema:{...n,in:void 0}}):!1;for(let t in n.properties)if(zi(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&aa(Vi({schema:e})))return t}for(let r of n.allOf??[]){let n=oa({context:e,name:t,schema:r});if(n)return n}return!1},sa=({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)},ca=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:xr({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),sa({irOperation:a,operation:n}),a},la=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=ca({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=Ri({mimeTypes:n.consumes,response:{schema:i}}),o=a.find(e=>e.type===`json`)||a[0];if(o){let t=oa({context:e,name:``,schema:o.schema&&`$ref`in o.schema?{allOf:[{...o.schema}],description:r.description}:{description:r.description,...o.schema}}),n=ra({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=Ri({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:ra({context:e,schema:{description:i.description,...Li({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},ua=({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]=la({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},da=e=>{switch(e){case`multi`:return!0;case`csv`:case`pipes`:case`ssv`:case`tsv`:default:return!1}},fa=e=>{switch(e){case`header`:case`path`:return`simple`;case`query`:default:return`form`}},pa=({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()]=ma({$ref:`#/todo/real/path/to/parameter/${n.name}`,context:e,parameter:n})}return r},ma=({$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=oa({context:t,name:n.name,schema:i}),o=fa(n.in),s={allowReserved:!1,explode:da(n.collectionFormat),location:n.in,name:n.name,schema:ra({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},ha=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,ga=e=>{let t={host:``,path:``,port:``,protocol:``};ha.lastIndex=0;let n=e.match(ha);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}},_a=({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=ga(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})))},va=(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 br){if(t===`trace`)continue;let a=n[t];if(!a)continue;let o=k({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`)}},ya=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Di({context:e,result:va(e.spec,e.logger)}),kr(e.config.parser.filters)){let t=Or(e.config.parser.filters,e.spec,e.logger),{graph:n}=fi(e.spec,e.logger),{resourceMetadata:r}=Hr(n,e.logger);Oi({...Vr({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Si({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];ia({$ref:n,context:e,schema:r})}for(let r in _a({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:pa({context:e,operation:o,parameters:a.parameters})},path:r,securitySchemesMap:n,state:t};if(a.delete){let t=B({source:pa({context:e,operation:a.delete,parameters:a.delete.parameters}),target:s.operation.parameters});ua({...s,method:`delete`,operation:{...s.operation,...a.delete,parameters:t}})}if(a.get){let t=B({source:pa({context:e,operation:a.get,parameters:a.get.parameters}),target:s.operation.parameters});ua({...s,method:`get`,operation:{...s.operation,...a.get,parameters:t}})}if(a.head){let t=B({source:pa({context:e,operation:a.head,parameters:a.head.parameters}),target:s.operation.parameters});ua({...s,method:`head`,operation:{...s.operation,...a.head,parameters:t}})}if(a.options){let t=B({source:pa({context:e,operation:a.options,parameters:a.options.parameters}),target:s.operation.parameters});ua({...s,method:`options`,operation:{...s.operation,...a.options,parameters:t}})}if(a.patch){let t=B({source:pa({context:e,operation:a.patch,parameters:a.patch.parameters}),target:s.operation.parameters});ua({...s,method:`patch`,operation:{...s.operation,...a.patch,parameters:t}})}if(a.post){let t=B({source:pa({context:e,operation:a.post,parameters:a.post.parameters}),target:s.operation.parameters});ua({...s,method:`post`,operation:{...s.operation,...a.post,parameters:t}})}if(a.put){let t=B({source:pa({context:e,operation:a.put,parameters:a.put.parameters}),target:s.operation.parameters});ua({...s,method:`put`,operation:{...s.operation,...a.put,parameters:t}})}}},ba=({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 br){if(!r[e])continue;let i=R(`operation`,k({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&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Fi({mediaType:t})?{...n,format:`binary`}:n:Fi({mediaType:t})?{format:`binary`,type:`string`}:void 0},Sa=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:Ii({mediaType:n})});return t},Ca=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},wa=({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)},Ta=({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`)},Ea=({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=O({items:i,schema:t}),t},Da=({irSchema:e={}})=>(e.type=`boolean`,e),Oa=({irSchema:e={},schema:t})=>(e.type=t.type,e),ka=({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},Aa=({irSchema:e={}})=>(e.type=`string`,e),ja=({schema:e})=>{let t={};return wa({irSchema:t,schema:e}),t},Ma=({context:e,schema:t,state:n})=>{let r=ja({schema:t}),i=[],a=Ca({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=Bi(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=za({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(Ca({schema:a})===`object`){let i=za({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=O({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},Na=({context:e,schema:t,state:n})=>{let r=ja({schema:t}),i=[],a=Ca({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=Bi(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=O({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=za({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Pa=({context:e,schema:t,state:n})=>{let r=ja({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=za({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=O({items:i,schema:r}),r},Fa=({context:e,schema:t,state:n})=>{let r=ja({schema:t}),i=[],a=Ca({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=Bi(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=O({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=za({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Ia=({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},La=({context:e,irSchema:t,schema:n,state:r})=>{t||=ja({schema:n});let i={};return Ta({irSchema:i,schema:n}),i.default===null&&delete i.default,t=O({items:[za({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},Ra=({context:e,schema:t,state:n})=>{let r=ja({schema:t});Ta({irSchema:r,schema:t});let i=Ca({schema:t});return i?t.nullable?La({context:e,irSchema:r,schema:{...t,type:i},state:n}):za({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},za=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=ja({schema:n}),Ta({irSchema:t,schema:n})),n.type){case`array`:return Ea({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Da({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Oa({context:e,irSchema:t,schema:n,state:r});case`object`:return ka({context:e,irSchema:t,schema:n,state:r});case`string`:return Aa({context:e,irSchema:t,schema:n,state:r});default:return Ba({context:e,irSchema:t,schema:n})}},Ba=({irSchema:e,schema:t})=>(e||=ja({schema:t}),e.type=`unknown`,Ta({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?Ia({context:e,schema:t,state:n}):t.enum?Pa({context:e,schema:t,state:n}):t.allOf?Ma({context:e,schema:t,state:n}):t.anyOf?Na({context:e,schema:t,state:n}):t.oneOf?Fa({context:e,schema:t,state:n}):t.type||t.properties?Ra({context:e,schema:t,state:n}):Ba({context:e,schema:t})),Va=({$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}})},Ha=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,Ua=({context:e,name:t,schema:n})=>{if(zi(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=Sa({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?Ua({context:e,name:t,schema:n}):!1}return Ua({context:e,name:t,schema:r})}for(let t in n.properties)if(zi(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&Ha(Ca({schema:e})))return t}for(let r of n.allOf??[]){let n=Ua({context:e,name:t,schema:r});if(n)return n}return!1},Wa=({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)},Ga=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:xr({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Wa({irOperation:a,operation:n}),a},Ka=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Ga({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=Sa({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=Ua({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=Sa({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,...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},qa=({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]=Ka({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},Ja=e=>{switch(e){case`query`:return!1;default:return}},Ya=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},Xa=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},Za=({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()]=Qa({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Qa=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=Sa({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=Ua({context:t,name:n.name,schema:i}),o=n.style||Xa(n.in),s=n.explode===void 0?Ya(o):n.explode,c={allowReserved:n.allowReserved===void 0?Ja(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},$a=({$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)]=Qa({$ref:e,context:t,parameter:n})},eo=({$ref:e,context:t,requestBody:n})=>{let r=Sa({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},to=({$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)]=eo({$ref:e,context:t,requestBody:n})},no=({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=ga(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},ro=(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 br){let a=n[t];if(!a)continue;let o=k({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=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Di({context:e,result:ro(e.spec,e.logger)}),kr(e.config.parser.filters)){let t=Or(e.config.parser.filters,e.spec,e.logger),{graph:n}=fi(e.spec,e.logger),{resourceMetadata:r}=Hr(n,e.logger);ba({...Vr({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Si({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];$a({$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];to({$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];Va({$ref:n,context:e,schema:r})}}for(let r in no({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:Za({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&qa({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:B({source:Za({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&qa({...o,method:`get`,operation:{...o.operation,...a.get,parameters:B({source:Za({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&qa({...o,method:`head`,operation:{...o.operation,...a.head,parameters:B({source:Za({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&qa({...o,method:`options`,operation:{...o.operation,...a.options,parameters:B({source:Za({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&qa({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:B({source:Za({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&qa({...o,method:`post`,operation:{...o.operation,...a.post,parameters:B({source:Za({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&qa({...o,method:`put`,operation:{...o.operation,...a.put,parameters:B({source:Za({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&qa({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:B({source:Za({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},ao=({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 br){if(!r[e])continue;let i=R(`operation`,k({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},oo=({content:e})=>{let{mediaType:t,schema:n}=e;return n?n.type===`string`&&!n.format&&Fi({mediaType:t})?{...n,format:`binary`}:n:Fi({mediaType:t})?{format:`binary`,type:`string`}:void 0},so=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:Ii({mediaType:n})});return t},co=({schema:e})=>typeof e.type==`string`?[e.type]:e.type?e.type:e.properties?[`object`]:[],lo=({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)},uo=({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`)},fo=({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&&!co({schema:n.items}).includes(`null`)?t={...t,...a}:i.push(a)}}return t=O({items:i,schema:t}),t},po=({irSchema:e={}})=>(e.type=`boolean`,e),mo=({irSchema:e={}})=>(e.type=`null`,e),ho=({irSchema:e={},schema:t})=>(e.type=t.type,e),go=({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},_o=({irSchema:e={}})=>(e.type=`string`,e),vo=({schema:e})=>{let t={};return lo({irSchema:t,schema:e}),t},yo=({context:e,schema:t,state:n})=>{let r=vo({schema:t}),i=[],a=co({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=Bi(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=wo({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(co({schema:a}).includes(`object`)){let i=wo({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=O({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},bo=({context:e,schema:t,state:n})=>{let r=vo({schema:t}),i=[],a=co({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=Bi(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=O({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=wo({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},xo=({context:e,schema:t,state:n})=>{let r=vo({schema:t});r.type=`enum`;let i=[],a=co({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=wo({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=O({items:i,schema:r}),r},So=({context:e,schema:t,state:n})=>{let r=vo({schema:t}),i=[],a=co({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=Bi(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=O({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=wo({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Co=({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=vo({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=O({items:a,mutateSchemaOneItem:!0,schema:r}),r},wo=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=vo({schema:n}),uo({irSchema:t,schema:n})),n.type){case`array`:return fo({context:e,irSchema:t,schema:n,state:r});case`boolean`:return po({context:e,irSchema:t,schema:n});case`integer`:case`number`:return ho({context:e,irSchema:t,schema:n});case`null`:return mo({context:e,irSchema:t,schema:n});case`object`:return go({context:e,irSchema:t,schema:n,state:r});case`string`:return _o({context:e,irSchema:t,schema:n});default:return Do({context:e,irSchema:t,schema:n})}},To=({context:e,irSchema:t,schema:n,state:r})=>{t||=vo({schema:n});let i={};uo({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=wo({context:e,irSchema:{...i},schema:{...n,type:t},state:r});a.push(o)}return t=O({items:a,schema:t}),t},Eo=({context:e,schema:t,state:n})=>{let r=vo({schema:t});uo({irSchema:r,schema:t});let i=co({schema:t});return i.length===1?wo({context:e,irSchema:r,schema:{...t,type:i[0]},state:n}):To({context:e,irSchema:r,schema:{...t,type:i},state:n})},Do=({irSchema:e,schema:t})=>(e||=vo({schema:t}),e.type=`unknown`,uo({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?Co({context:e,schema:t,state:n}):t.enum?xo({context:e,schema:t,state:n}):t.allOf?yo({context:e,schema:t,state:n}):t.anyOf?bo({context:e,schema:t,state:n}):t.oneOf?So({context:e,schema:t,state:n}):t.type||t.properties?Eo({context:e,schema:t,state:n}):Do({context:e,schema:t})),Oo=({$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}})},ko=e=>e.includes(`boolean`)||e.includes(`integer`)||e.includes(`number`)||e.includes(`string`),Ao=({context:e,name:t,schema:n})=>{if(zi(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=so({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?Ao({context:e,name:t,schema:n}):!1}return Ao({context:e,name:t,schema:r})}for(let t in n.properties)if(zi(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`){let n=co({schema:e});if(!n.length){let n=(e.anyOf??e.oneOf??[]).filter(e=>e.type!==`null`);if(n.length===1&&ko(co({schema:n[0]})))return t}if(ko(n))return t}}for(let r of n.allOf??[]){let n=Ao({context:e,name:t,schema:r});if(n)return n}return!1},jo=({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)},Mo=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:xr({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),jo({irOperation:a,operation:n}),a},No=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Mo({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=so({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=Ao({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=so({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,...oo({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},Po=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>(n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),{parsed:No({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})}),Fo=({context:e,method:t,path:n,...r})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={});let{parsed:i}=Po({context:e,method:t,path:n,...r});e.ir.paths[n][t]=i},Io=({context:e,key:t,method:n,...r})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:i}=Po({context:e,method:n,path:t,...r});e.ir.webhooks[t][n]=i},Lo=e=>{switch(e){case`query`:return!1;default:return}},Ro=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},zo=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()]=Bo({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Bo=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=so({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=Ao({context:t,name:n.name,schema:i}),o=n.style||zo(n.in),s=n.explode===void 0?Ro(o):n.explode,c={allowReserved:n.allowReserved===void 0?Lo(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},Vo=({$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)]=Bo({$ref:e,context:t,parameter:n})},Ho=({$ref:e,context:t,requestBody:n})=>{let r=so({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},Uo=({$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)]=Ho({$ref:e,context:t,requestBody:n})},Wo=({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=ga(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},Go=(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 br){let a=n[t];if(!a)continue;let o=k({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`)}},Ko=({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&&Io({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:B({source:U({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Io({...o,method:`get`,operation:{...o.operation,...a.get,parameters:B({source:U({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Io({...o,method:`head`,operation:{...o.operation,...a.head,parameters:B({source:U({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Io({...o,method:`options`,operation:{...o.operation,...a.options,parameters:B({source:U({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Io({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:B({source:U({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Io({...o,method:`post`,operation:{...o.operation,...a.post,parameters:B({source:U({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Io({...o,method:`put`,operation:{...o.operation,...a.put,parameters:B({source:U({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Io({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:B({source:U({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},qo=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Di({context:e,result:Go(e.spec,e.logger)}),kr(e.config.parser.filters)){let t=Or(e.config.parser.filters,e.spec,e.logger),{graph:n}=fi(e.spec,e.logger),{resourceMetadata:r}=Hr(n,e.logger);ao({...Vr({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Si({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];Vo({$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];Uo({$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];Oo({$ref:n,context:e,schema:r})}}for(let r in Wo({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&&Fo({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:B({source:U({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Fo({...o,method:`get`,operation:{...o.operation,...a.get,parameters:B({source:U({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Fo({...o,method:`head`,operation:{...o.operation,...a.head,parameters:B({source:U({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Fo({...o,method:`options`,operation:{...o.operation,...a.options,parameters:B({source:U({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Fo({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:B({source:U({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Fo({...o,method:`post`,operation:{...o.operation,...a.post,parameters:B({source:U({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Fo({...o,method:`put`,operation:{...o.operation,...a.put,parameters:B({source:U({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Fo({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:B({source:U({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}Ko({context:e,securitySchemesMap:n})},Jo=[`connect`,`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`];function Yo(e=`1.0`){return String(e).replace(/^v/gi,``)}const Xo=(e,t)=>{if(e.enum&&!t.includes(`boolean`))return`enum`},Zo=e=>$o(e).includes(`null`),Qo=e=>e.nullable===!0||Zo(e),$o=({type:e})=>Array.isArray(e)?e:e?[e]:[],es=`#/components/parameters/`,ts=`#/components/schemas/`,ns=({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},rs=e=>x().plugins[`@hey-api/typescript`]?.config.style===`PascalCase`?T({case:`PascalCase`,value:e}):e,is=e=>_r(rs(e)).replace(gt,`_$1`),as=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\//,``),os=(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}},ss=/(?<!`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=>os(e,t)).filter(Boolean).join(` | `);return r.type=e,r.base=e,r.isNullable=Zo({type:n}),r}let i=os(n,t);if(i)return r.type=i,r.base=i,r;let a=decodeURIComponent(as(n));if(ss.lastIndex=0,ss.test(a)){let t=a.match(/(.*?)\[(.*)\]$/);if(t?.length){let n=W({debug:e,type:_r(t[1])}),i=W({debug:e,type:_r(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=rs(_r(a));return n.startsWith(es)&&(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 cs(e,t,n){return n.indexOf(e)===t}const ls=(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(cs).filter(e=>typeof e==`number`||typeof e==`string`).map((e,t)=>({customDescription:n[t],customName:r[t],description:void 0,value:e}))},us=e=>e?.replace(/\\/g,`\\\\`).replace(/'/g,`\\'`),ds=({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:St(a),pattern:us(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:St(a),pattern:us(o.pattern),properties:e.properties,template:e.template,type:e.type,uniqueItems:o.uniqueItems})}}),i},fs=/~1/g,ps=/~0/g;function ms(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(fs,`/`).replace(ps,`~`));if(r.hasOwnProperty(n))r=r[n];else throw Error(`Could not find reference: "${t.$ref}"`)}),r}return t}const hs=({definitions:e,getModel:t,openApi:n,required:r,types:i})=>e.reduce((e,r)=>{if(r.$ref){let a=ms(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})),gs=({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=hs({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=ds({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},_s=({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:us(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=ls(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=_s({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=_s({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=gs({definition:e,definitions:e.allOf,getModel:_s,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&&ds({definition:e,getModel:_s,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},vs=e=>{let t={},n=[];return Object.entries(e.definitions??{}).forEach(([r,i])=>{let a=W({type:r}).base.replace(gt,`_$1`),o={$ref:`#/definitions/${r}`,name:a};t[a]=o;let s=_s({definition:i,isDefinition:!0,meta:o,openApi:e,types:t});n=[...n,s]}),{models:n,types:t}};function ys(e,t){let n=e.toLocaleLowerCase(),r=t.toLocaleLowerCase();return n.localeCompare(r,`en`)}const bs=(e,t)=>ys(e.name,t.name);function xs(e){return e.sort(bs)}const Ss=(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()},Cs=e=>e.map(e=>ws(e.value,!0)).filter(cs).join(` | `),ws=(e,t=!1)=>typeof e==`string`?e.includes(`'`)&&t?`"${e}"`:`'${e}'`:e,Ts=e=>({key:Ss(e.value,e.customName),value:ws(e.value)}),Es=e=>{let t=e.enum.map(e=>Ts(e)).sort((e,t)=>ys(e.key,t.key)).map(e=>`${e.key}=${e.value}`).join(`&`);return{$ref:`enum/${e.name}/${t}`,name:_r(Ct(e.name))}},Ds=e=>{let t=`Parameter${W({type:e}).base.replace(gt,`_$1`)}`;return{$ref:es+e,name:t}},Os=e=>{let t=is(e);return{$ref:ts+e,name:t}},ks=e=>e.format===`date`||e.format===`date-time`,As=e=>{let t=x();return e.base===`binary`?F.typeUnionNode({types:[`Blob`,`File`]}):t.plugins[`@hey-api/transformers`]?.config.dates&&ks(e)?F.typeNode(`Date`):F.typeNode(e.base)},js=e=>{let t=e.base===`null`?!1:e.isNullable,n=As(e);if(e.export===`reference`&&e.$refs.length===1&&e.$refs[0].startsWith(ts)){let t=Os(e.base);n=F.typeNode(t.name)}return F.typeUnionNode({isNullable:t,types:[n]})},Ms=e=>{if(e.link){if(Array.isArray(e.link)){let t=e.link.map(e=>Ls(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(Ls(e.link));return F.typeTupleNode({isNullable:e.isNullable,types:t})}return F.typeArrayNode([Ls(e.link)],e.isNullable)}return F.typeArrayNode([As(e)],e.isNullable)},Ns=e=>{let t=e.enum.map(e=>ws(e.value));return F.typeUnionNode({isNullable:e.isNullable,types:t})},Ps=e=>{let t=e.link&&!Array.isArray(e.link)?Ls(e.link):As(e);return F.typeRecordNode([`string`],[t],e.isNullable,!0)},Fs=({model:e,style:t})=>{let n=e.properties.map(e=>F.nodeToString({node:Ls(e),unescape:!0})).filter(cs),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})},Is=e=>{if(!e.properties.length)return F.typeNode(`unknown`);let t=S(x()),n=e.properties.map(e=>{let n=e.isRequired?``:`?`,r=Ls(e),i=t?/^\dXX$/.test(e.name)?St(e.name):e.name:St(Ct(Bs(e.name)));return e.name===`[key: string]`&&(i=e.name,n&&(n=``,r=F.typeUnionNode({types:[r,`undefined`]}))),{comment:[e.description&&j(e.description),e.deprecated&&`@deprecated`],isReadOnly:e.isReadOnly,isRequired:n===``,name:i,type:r}});return F.typeInterfaceNode({isNullable:e.isNullable,properties:n,useLegacyResolution:!0})},Ls=e=>{switch(e.export){case`all-of`:return Fs({model:e,style:`intersection`});case`any-of`:case`one-of`:return Fs({model:e,style:`union`});case`array`:return Ms(e);case`dictionary`:return Ps(e);case`enum`:return Ns(e);case`interface`:return Is(e);case`const`:case`generic`:case`reference`:default:return js(e)}},Rs=({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}:Rs({client:e,count:t+1,create:n,meta:r,nameTransformer:i}):n&&(e.types[o]=r,a={created:!0,name:o}),a},zs=({client:e,name:t})=>{let n={deleted:!1,name:``};return e.types[t]?(delete e.types[t],n={deleted:!0,name:t},n):n},Bs=e=>S(x())?T({case:`camelCase`,value:yr(e)}).replace(gt,`_$1`):e,Vs=e=>{let t=e.find(e=>e.in===`header`);return t?t.name:null},Hs=e=>e.some(e=>e.isRequired),Us=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},Ws=(e,t)=>e.code>t.code?1:e.code<t.code?-1:0,Gs=e=>e===`3XX`||e===`4XX`||e===`5XX`||typeof e==`number`&&e>=300,Ks=e=>e===`2XX`||typeof e==`number`&&e>=200&&e<300,qs=(e,t)=>{let n=[],r=e=>{n.includes(e)||(n=[...n,e])};t.some(({code:e})=>Ks(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},Js=({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)},Ys=({config:e,method:t,operationId:n,path:r})=>{if(e.plugins[`@hey-api/sdk`]?.config.operationId&&n)return T({case:`camelCase`,value:vr(n)});let i=r;return S(e)&&(i=i.replace(/[^/]*?{api-version}.*?\//g,``)),i=i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`),T({case:`camelCase`,value:`${t}-${i}`})},Xs=e=>!S(x())||e.prop!==`api-version`,Zs=e=>S(x())?Bs(e.prop):e.prop,Qs=e=>e.map(t=>{let{code:n}=t;return n===`default`?t.responseTypes=qs(t,e):Ks(n)?t.responseTypes=[`success`]:Gs(n)&&(t.responseTypes=[`error`]),t}),G=(e,t)=>{if(e.default===void 0||e.default===null)return e.default;switch($o(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}},$s=({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:us(t.pattern),prop:t.name,properties:[],template:null,type:`unknown`,uniqueItems:t.uniqueItems},i={...r,name:Zs(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=ls(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=ms(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=_s({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},ec=[`body`,`formData`,`header`,`path`,`query`],tc=({openApi:e,parameters:t,types:n})=>{let r={$refs:[],imports:[],parameters:[],parametersBody:null,parametersCookie:[],parametersForm:[],parametersHeader:[],parametersPath:[],parametersQuery:[]};return t.forEach(t=>{let i=ms(e,t),a=$s({openApi:e,parameter:i,types:n}),o=!Xs(a);if(!(!ec.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 nc(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 rc=({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=ms(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=_s({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=us(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},ic=({openApi:e,responses:t,types:n})=>{let r=[];return Object.entries(t).forEach(([t,i])=>{let a=Us(t);if(!a)return;let o=rc({code:a,openApi:e,response:ms(e,i),types:n});r=[...r,o]}),r=Qs(r),r.sort(Ws)},ac=({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:Ys({config:x(),method:o.method,operationId:t.operationId,path:o.path})};if(t.parameters){let e=tc({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=ic({openApi:n,responses:t.responses,types:i});let e=s.responses.filter(e=>e.responseTypes.includes(`success`));s.responseHeader=Vs(e),e.forEach(e=>{s.$refs=[...s.$refs,...e.$refs],s.imports=[...s.imports,...e.imports]})}return s.parameters=nc(s.parameters),s},oc=({openApi:e,types:t})=>{let n=new Map,r=[],i=x();for(let a in e.paths){let o=e.paths[a],s=tc({openApi:e,parameters:o.parameters??[],types:t});for(let c in o){let l=c,u=k({method:l,path:a});if(Jo.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)),Js({config:i,operationKey:u})){let n=ac({method:l,op:c,openApi:e,pathParams:s,types:t,url:a});r.push(n)}}}}return r},sc=e=>{let t=e.schemes?.[0]||`http`,n=e.host,r=e.basePath||``;return(n?`${t}://${n}${r}`:r).replace(/\/$/g,``)},cc=e=>{let t=Yo(e.info.version),n=sc(e),{models:r,types:i}=vs(e);return{models:r,operations:oc({openApi:e,types:i}),server:n,types:i,version:t}},lc=e=>{let t={};for(let n in e)t[e[n]]=n;return t},uc=(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&&as(e.$ref)==t.name))return r.discriminator}}},dc=(e,t)=>{if(e.mapping){let n=lc(e.mapping),r=Object.keys(n).find(e=>as(e)==t.name);if(r&&n[r])return n[r]}return t.name},fc=({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(cs).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)},pc=({debug:e,definition:t,getModel:n,openApi:r,parent:i,types:a})=>{let o=[],s=uc(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:St(c),pattern:us(l.pattern),uniqueItems:l.uniqueItems};if(i&&s?.propertyName==c){o=[...o,{...d,$refs:[],base:`'${dc(s,i)}'`,enum:[],enums:[],export:`reference`,imports:[],isNullable:Qo(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||Qo(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||Qo(l),o=[...o,f]}),o},mc=({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=ms(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})),hc=e=>[{definitions:e.allOf,type:`all-of`},{definitions:e.anyOf,type:`any-of`},{definitions:e.oneOf,type:`one-of`}].find(e=>e.definitions?.length),gc=({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=mc({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=pc({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=hc(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},_c=({debug:e,definition:t,initialValues:n={},isDefinition:r=!1,meta:i,openApi:a,parentDefinition:o=null,types:s})=>{let c=$o(t),l=Xo(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:Qo(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:us(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=ls(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||=Es(u),u}if(c.includes(`array`)&&(t.items||t.prefixItems)){if(t.prefixItems){let e=t.prefixItems.map(e=>_c({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=hc(o);if(e&&e.definitions.some(e=>!$o(e).includes(`array`)))return _c({definition:t.items,openApi:a,parentDefinition:t,types:s})}let e=_c({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=hc(t);if(d){let n=gc({...d,debug:e,definition:t,getModel:_c,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),pc({debug:e,definition:t,getModel:_c,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=fc({debug:e,definition:t,getModel:_c,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 fc({debug:e,definition:t,getModel:_c,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},vc=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}}},yc=e=>{let t={},n=[];return e.components?(Object.entries(e.components.schemas??{}).forEach(([r,i])=>{let a=Os(r);t[a.name]=a;let o=_c({definition:i,isDefinition:!0,meta:a,openApi:e,types:t});n=[...n,o]}),Object.entries(e.components.parameters??{}).forEach(([r,i])=>{let a=vc(i);if(!a)return;let o=Ds(r);t[o.name]=o;let s=_c({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}},bc=({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:Qo(t),isReadOnly:!1,isRequired:t.required===!0,link:null,mediaType:null,prop:t.name,properties:[],template:null,type:`unknown`},i={...r,name:Zs(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=vc(t);if(a){if(a.$ref?.startsWith(es)&&(a=ms(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=_c({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:us(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=Es(i)),i.default=t.default,i}return i},xc=[`cookie`,`formData`,`header`,`path`,`query`],Sc=({openApi:e,parameters:t,types:n})=>{let r={$refs:[],imports:[],parameters:[],parametersBody:null,parametersCookie:[],parametersForm:[],parametersHeader:[],parametersPath:[],parametersQuery:[]};return t.forEach(t=>{let i=ms(e,t),a=bc({openApi:e,parameter:i,types:n}),o=!Xs(a);if(!(!xc.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},Cc=[`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`],wc=(e,t)=>{let n=Object.keys(t).filter(e=>{let t=e.split(`;`)[0].trim();return Cc.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}},Tc=({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=wc(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=_c({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=us(s.pattern),a.properties=[...a.properties,...s.properties],a.template=s.template,a.type=s.type,a.uniqueItems=s.uniqueItems,a},Ec=({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=wc(t,n.content);if(e){if(e.schema.$ref?.startsWith(`#/components/responses/`)&&(e.schema=ms(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=_c({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=us(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},Dc=({openApi:e,responses:t,types:n})=>{let r=[];return Object.entries(t).forEach(([t,i])=>{let a=Us(t);if(!a)return;let o=Ec({code:a,openApi:e,response:ms(e,i),types:n});r=[...r,o]}),r=Qs(r),r.sort(Ws)},Oc=(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},kc=({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:Ys({config:x(),method:s.method,operationId:n.operationId,path:s.path})};if(n.parameters){let e=Sc({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=Tc({body:ms(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=Dc({openApi:r,responses:n.responses,types:a});let e=c.responses.filter(e=>e.responseTypes.includes(`success`));c.responseHeader=Vs(e),e.forEach(e=>{c.$refs=[...c.$refs,...e.$refs],c.imports=[...c.imports,...e.imports]})}return c.parameters=Oc(c.parameters,i.parameters),c.parametersCookie=Oc(c.parametersCookie,i.parametersCookie),c.parametersForm=Oc(c.parametersForm,i.parametersForm),c.parametersHeader=Oc(c.parametersHeader,i.parametersHeader),c.parametersPath=Oc(c.parametersPath,i.parametersPath),c.parametersQuery=Oc(c.parametersQuery,i.parametersQuery),c.parameters=nc(c.parameters),c},Ac=({openApi:e,types:t})=>{let n=new Map,r=[],i=x();for(let a in e.paths){let o=e.paths[a],s=Sc({openApi:e,parameters:o.parameters??[],types:t});for(let c in o){let l=c,u=k({method:l,path:a});if(Jo.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)),Js({config:i,operationKey:u})){let n=kc({method:l,op:c,openApi:e,pathParams:s,types:t,url:a});r.push(n)}}}}return r},jc=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,``)},Mc=e=>{let t=Yo(e.info.version),n=jc(e),{models:r,types:i}=yc(e);return{models:r,operations:Ac({openApi:e,types:i}),server:n,types:i,version:t}};function Nc({openApi:e}){let t=e;if(`openapi`in t)return Mc(t);if(`swagger`in t)return cc(t);throw Error(`Unsupported OpenAPI specification: ${JSON.stringify(t,null,2)}`)}const Pc=({config:e,dependencies:t,logger:n,spec:r})=>{let i=new gr({config:e,dependencies:t,logger:n,spec:r});if(`swagger`in i.spec)return ya(i),i;if(dt(i.spec.openapi,`>=3.0.0 <3.1.0`))return io(i),i;if(dt(i.spec.openapi,`>=3.1.0`))return qo(i),i;throw Error(`Unsupported OpenAPI specification`)},Fc=({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}},Ic=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return[];let n=[];for(let t of e.security){let e=Fc({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},Lc=`TComposable`,Rc=`DefaultT`,zc=`ResT`,Bc=({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})},Vc=({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})},Hc=({context:e,value:t})=>{let n=T({case:`PascalCase`,value:vr(t)});return ns({config:e.config,name:n})},Uc=({operation:e,plugin:t})=>t.config.methodNameBuilder?t.config.methodNameBuilder(e):!t.config.asClass&&e.id.match(gt)?`${e.id}_`:e.id,Wc=({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=T({case:`camelCase`,value:vr(o.pop())}),i=o.pop()));let s=n.config.instance?[n.config.instance]:t.tags??[`default`];for(let c of s){let s=Hc({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||Uc({operation:t,plugin:n}),path:l.map(t=>Hc({context:e,value:t}))})}return r},Gc=({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}<${Lc}, ${o}, ${n}, ${Rc}>`}return n?`${s.placeholder}<${o}, ${n}>`:a?`${s.placeholder}<${a.placeholder}>`:s.placeholder},Kc=({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=xt(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=xt(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:Gc({operation:t,plugin:n,throwOnError:a?void 0:`ThrowOnError`})}),r},qc=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`}},Jc=({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=Bc({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`&<({statusCode:e})===`2XX`&&(f=qc(t.mediaType),f&&l.push({key:`responseType`,value:f})),t.mediaType===`text/event-stream`&&(d=!0)}let p=Vc({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=Ic({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`}),y;y=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 ee=[];a?ee.push(Lc,`${s} | ${Rc}`,c,Rc):ee.push(s,c,`ThrowOnError`),r.config.responseStyle===`data`&&ee.push(F.stringLiteral({text:r.config.responseStyle}));let te=d?F.propertyAccessExpression({expression:y,name:F.identifier({text:`sse`})}):y;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:ee})),h},Yc=({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||st(t)},Xc=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType===`text/event-stream`)return!0;return!1},Zc=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=Yc({context:e.context,operation:n}),a=Wc({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=el({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:E({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:a.className})})}),name:T({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol(e.api.selector(`Injectable`)),o=e.registerSymbol({exported:!0,name:E({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)},Qc=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=Yc({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,name:e.config.httpRequests.methodNameBuilder(t),selector:e.api.selector(`httpRequest`,t.id)}),i=tl({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},$c=({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`}]})]})},el=({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:$c({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},tl=({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:$c({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},nl=({plugin:e})=>{e.config.httpRequests.asClass?Zc({plugin:e}):Qc({plugin:e})},rl=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=Yc({context:e.context,operation:n}),a=Wc({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=ol({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:E({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:a.className})})}),name:T({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol(e.api.selector(`Injectable`)),o=e.registerSymbol({exported:!0,name:E({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)},il=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=Yc({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,name:e.config.httpResources.methodNameBuilder(t)}),i=sl({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},al=({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=Wc({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:T({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)]})},ol=({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:al({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},sl=({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:al({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},cl=({plugin:e})=>{e.config.httpResources.asClass?rl({plugin:e}):il({plugin:e})},ll=({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&&nl({plugin:e}),e.config.httpResources.enabled&&cl({plugin:e})},ul={api:new Je({name:`@angular/common`}),config:{exportFromIndex:!1},dependencies:[`@hey-api/client-angular`,`@hey-api/sdk`],handler:ll,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`}}},dl=C(ul),fl={baseUrl:!0,bundle:!0,exportFromIndex:!1},pl={dependencies:[`@hey-api/typescript`],tags:[`client`]},ml=(0,f.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),hl=d.default.dirname(ml),gl=({config:e,sourceOutput:t})=>{let n=b(e);if(`bundle`in n.config&&n.config.bundle)return oe({moduleOutput:`client`,sourceOutput:t});if(d.default.isAbsolute(n.name)){let t=d.default.dirname(n.name),r=d.default.resolve(e.output.path);return d.default.relative(r,t).replace(/\\/g,`/`)}return n.name},_l=e=>{let t=b(e);if(`bundle`in t.config&&t.config.bundle){let t=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return d.default.resolve(e.output.path,`client`,`${t?.get(`index`)??`index`}.ts`)}return t.name},vl=(e,t)=>{if(u.default.statSync(e).isDirectory()){u.default.existsSync(t)||u.default.mkdirSync(t,{recursive:!0});let n=u.default.readdirSync(e);for(let r of n)vl(d.default.join(e,r),d.default.join(t,r))}else{let n=u.default.readFileSync(e);u.default.writeFileSync(t,n)}},yl=({filePath:e,project:t,renamed:n})=>{let r=d.default.extname(e),i=d.default.basename(e,r),a=t.fileName?.(i)||i;if(a!==i){let t=d.default.dirname(e);u.default.renameSync(e,d.default.resolve(t,`${a}${r}`)),n.set(i,a)}},bl=({filePath:e,meta:t,renamed:n})=>{let r=u.default.readFileSync(e,`utf8`);r=r.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g,(e,r)=>{let i=e.indexOf(r),a=d.default.extname(r),o=d.default.basename(r,a),s=d.default.dirname(r),c=(n.get(o)??o)+(t.importFileExtension?t.importFileExtension:a);return e.slice(0,i)+[s,c].filter(Boolean).join(`/`)+e.slice(i+r.length)}),r=`// This file is auto-generated by @hey-api/openapi-ts
|
|
16
|
+
|
|
17
|
+
${r}`,u.default.writeFileSync(e,r,`utf8`)},xl=({meta:e,outputPath:t,plugin:n,project:r})=>{let i=new Map;if(n.name.startsWith(`@hey-api/client-`)){let a=d.default.resolve(t,`core`);ie(a),vl(d.default.resolve(hl,`clients`,`core`),a);let o=d.default.resolve(t,`client`);ie(o);let s=n.name.slice(16);if(vl(d.default.resolve(hl,`clients`,s),o),r){let e=u.default.readdirSync(a);for(let t of e)yl({filePath:d.default.resolve(a,t),project:r,renamed:i});let t=u.default.readdirSync(o);for(let e of t)yl({filePath:d.default.resolve(o,e),project:r,renamed:i})}let c=u.default.readdirSync(a);for(let t of c)bl({filePath:d.default.resolve(a,t),meta:e,renamed:i});let l=u.default.readdirSync(o);for(let t of l)bl({filePath:d.default.resolve(o,t),meta:e,renamed:i});return i}let a=d.default.isAbsolute(n.name)?d.default.dirname(n.name):void 0;if(a){let e=d.default.resolve(t,`client`);ie(e),vl(a,e);return}let o=d.default.normalize(require.resolve(n.name)).split(d.default.sep),s=o.slice(0,o.indexOf(`dist`)+1).join(d.default.sep),c=[o[o.length-1],`index.d.ts`,`index.d.cts`],l=d.default.resolve(t,`client`);ie(l);for(let e of c)u.default.copyFileSync(d.default.resolve(s,e),d.default.resolve(l,e))},Sl=({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},Cl=({plugin:e})=>{let t=_l(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=Sl({plugin:e});if(l){let t=ga(l);if(t.protocol&&t.host&&!l.includes(`{`))c.push({key:he(e.context.config),value:l});else if(l!==`/`&&l.startsWith(`/`)){let t=l.endsWith(`/`)?l.slice(0,-1):l;c.push({key:he(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)},wl=({plugin:e})=>{let t=_l(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)},Tl=({plugin:e})=>{wl({plugin:e}),Cl({plugin:e})};var El=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Dl={...pl,api:new El({name:`@hey-api/client-angular`}),config:{...fl,throwOnError:!1},handler:Tl,name:`@hey-api/client-angular`},Ol=C(Dl);var kl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Al={...pl,api:new kl({name:`@hey-api/client-axios`}),config:{...fl,throwOnError:!1},handler:Tl,name:`@hey-api/client-axios`},jl=C(Al);var Ml=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Nl={...pl,api:new Ml({name:`@hey-api/client-fetch`}),config:{...fl,throwOnError:!1},handler:Tl,name:`@hey-api/client-fetch`},Pl=C(Nl);var Fl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Il={...pl,api:new Fl({name:`@hey-api/client-next`}),config:{...fl,throwOnError:!1},handler:Tl,name:`@hey-api/client-next`},Ll=C(Il);var Rl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const zl={...pl,api:new Rl({name:`@hey-api/client-nuxt`}),config:fl,handler:Tl,name:`@hey-api/client-nuxt`},Bl=C(zl);var Vl=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Hl={...pl,api:new Vl({name:`@hey-api/client-ofetch`}),config:{...fl,throwOnError:!1},handler:Tl,name:`@hey-api/client-ofetch`},Ul=C(Hl),Wl={config:{},handler:()=>{},name:`legacy/angular`,output:`client`,tags:[`client`]},Gl=C(Wl),Kl={config:{},handler:()=>{},name:`legacy/axios`,output:`client`,tags:[`client`]},ql=C(Kl),Jl={config:{},handler:()=>{},name:`legacy/fetch`,output:`client`,tags:[`client`]},Yl=C(Jl),Xl={config:{},handler:()=>{},name:`legacy/node`,output:`client`,tags:[`client`]},Zl=C(Xl),Ql={config:{},handler:()=>{},name:`legacy/xhr`,output:`client`,tags:[`client`]},$l=C(Ql);var eu=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const tu=({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)},nu=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>nu({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(r.$ref)return r.$ref=decodeURI(r.$ref),r;if(tu({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=nu({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>nu({context:e,plugin:t,schema:n})),r.items&&=nu({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]=nu({context:e,plugin:t,schema:i}))}return r},ru=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>ru({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(`$ref`in r)return r.$ref=decodeURI(r.$ref),r;if(tu({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=ru({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>ru({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>ru({context:e,plugin:t,schema:n})),r.items&&=ru({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>ru({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]=ru({context:e,plugin:t,schema:i}))}return r},iu=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>iu({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(tu({plugin:t,schema:r}),r.$ref&&=decodeURI(r.$ref),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=iu({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>iu({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>iu({context:e,plugin:t,schema:n})),r.items&&=iu({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>iu({context:e,plugin:t,schema:n})),r.prefixItems&&=r.prefixItems.map(n=>iu({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]=iu({context:e,plugin:t,schema:i}))}return r},au=({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`,xt(r)},ou=({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:au({name:n,plugin:t,schema:r}),selector:t.api.selector(`ref`,n)}),a=nu({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)}},su=({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:au({name:n,plugin:t,schema:r}),selector:t.api.selector(`ref`,n)}),a=ru({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)}},cu=({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:au({name:n,plugin:t,schema:r}),selector:t.api.selector(`ref`,n)}),a=iu({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)}},lu=({plugin:e})=>{if(`swagger`in e.context.spec){ou({context:e.context,plugin:e});return}if(dt(e.context.spec.openapi,`>=3.0.0 <3.1.0`)){su({context:e.context,plugin:e});return}if(dt(e.context.spec.openapi,`>=3.1.0`)){cu({context:e.context,plugin:e});return}throw Error(`Unsupported OpenAPI specification`)};var uu=class{_exportFromIndex;_headers=[];_id;_imports=new Map;_items=[];_name;_path;constructor({dir:e,exportFromIndex:t=!1,header:n=!0,id:r,name:i}){this._exportFromIndex=t,this._id=r,this._name=this._setName(i),this._path=d.default.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}=du(this._name);return e}remove(e){u.default.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}=du(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===p.default.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(Ot({node:o}))}return i.length&&n.push(i.join(`
|
|
19
|
+
`)),n=n.concat(this._items.map(e=>typeof e==`string`?e:Ot({node:e,unescape:!0}))),n.join(e)}write(e=`
|
|
20
|
+
`,t=null){if(this.isEmpty()){this.remove({force:!0});return}let n=this._path;if(typeof this._path==`string`){let e=this._path.split(d.default.sep);n=e.slice(0,e.length-1).join(d.default.sep)}ie(n),u.default.writeFileSync(this._path,this._toString(e,t))}};const du=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))}},fu=(e,t)=>{let n=x();if(Array.isArray(e))return e.map(e=>fu(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]=fu(i,e))}),r},pu=(e,t)=>{let n=x(),r=_r(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`},mu=({files:e,openApi:t,plugin:n})=>{e.schemas=new uu({dir:x().output.path,exportFromIndex:n.config.exportFromIndex,id:`schemas`,name:`schemas.ts`});let r=(t,n)=>{let r=fu(n),i=F.objectExpression({obj:r}),a=F.constVariable({assertion:`const`,exportConst:!0,expression:i,name:pu(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)})},hu={api:new eu({name:`@hey-api/schemas`}),config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:lu,handlerLegacy:mu,name:`@hey-api/schemas`},gu=C(hu),_u=({operation:e})=>{let t=[];if(e.summary&&t.push(j(e.summary)),e.description&&(t.length&&t.push(``),t.push(j(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length)return t};var vu=class{constructor(e){this.meta=e}createOperationComment(...e){return _u(...e)}selector(...e){return[this.meta.name,...e]}};const yu=({meta:e,onImport:t,...n})=>{if(!e)return{created:!1,name:``};let{created:r,name:i}=Rs({meta:e,...n});return i&&t(i),{created:r,name:i}},bu=e=>`${e}ModelResponseTransformer`,xu=e=>`${T({case:`PascalCase`,value:e})}Data`,Su=e=>`${T({case:`PascalCase`,value:e})}Error`,Cu=e=>`${e}Transformer`,wu=e=>`${T({case:`PascalCase`,value:e})}Response`,Tu=({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}=Rs({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:xu}),i=Hs(t.parameters);if(!S(n))return[{isRequired:i,name:`options`,type:Tu({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}})},Du=(e,t)=>{let n=x(),r=F.typeNode(`void`);if(t.responses.filter(e=>e.responseTypes.includes(`success`)).length){let{name:n}=Rs({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:wu});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},Ou=e=>{let t=x();if(!S(t))return[e.deprecated&&`@deprecated`,e.summary&&j(e.summary),e.description&&j(e.description)];let n=[];e.parameters.length&&(n=t.useOptions?[`@param data The data for the request.`,...e.parameters.map(e=>`@param data.${e.name} ${e.description?j(e.description):``}`)]:e.parameters.map(e=>`@param ${e.name} ${e.description?j(e.description):``}`));let r=e.responses.filter(e=>e.responseTypes.includes(`success`));return[e.deprecated&&`@deprecated`,e.summary&&j(e.summary),e.description&&j(e.description),...n,...r.map(e=>`@returns ${e.type} ${e.description?j(e.description):``}`),`@throws ApiError`]},ku=({client:e,onClientImport:t,onImport:n,operation:r})=>{let i=x(),a=wu(r.name),{name:o}=Rs({client:e,meta:{$ref:`transformers/${a}`,name:a},nameTransformer:Cu});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(cs);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:St(n)===n?e[n]=r:e[`'${n}'`]=r,e},{}),c={method:r.method,url:r.path};r.parametersPath.length&&(c.path=s(r.parametersPath)),r.parametersCookie.length&&(c.cookies=s(r.parametersCookie)),r.parametersHeader.length&&(c.headers=s(r.parametersHeader)),r.parametersQuery.length&&(c.query=s(r.parametersQuery)),r.parametersForm.length&&(c.formData=s(r.parametersForm)),r.parametersBody&&(r.parametersBody.in===`formData`&&(i.useOptions?c.formData=`data.${r.parametersBody.name}`:c.formData=r.parametersBody.name),r.parametersBody.in===`body`&&(i.useOptions?c.body=`data.${r.parametersBody.name}`:c.body=r.parametersBody.name)),r.parametersBody?.mediaType&&(c.mediaType=r.parametersBody?.mediaType),r.responseHeader&&(c.responseHeader=r.responseHeader),o&&(c.responseTransformer=o);let l=r.responses.filter(e=>e.responseTypes.includes(`error`));if(l.length>0){let e={};l.forEach(t=>{e[t.code]=t.description??``}),c.errors=e}return F.objectExpression({identifiers:[`body`,`cookies`,`formData`,`headers`,`path`,`query`,`responseTransformer`],obj:c,shorthand:!0})},Au=({config:e,handleIllegal:t,id:n,operation:r})=>e.plugins[`@hey-api/sdk`]?.config.methodNameBuilder?e.plugins[`@hey-api/sdk`].config.methodNameBuilder(r):t&&n.match(gt)?`${n}_`:n,ju=({client:e,onClientImport:t,onImport:n,operation:r})=>{let i=x(),a=ku({client:e,onClientImport:t,onImport:n,operation:r});if(!S(i)){let t=Rs({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:Su}).name,n=r.responses.filter(e=>e.responseTypes.includes(`success`)).length?Rs({client:e,meta:{$ref:r.name,name:r.name},nameTransformer:wu}).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 ve(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`})]},Mu=({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&&yu({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:xu,onImport:n}),s||yu({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:Su,onImport:n}),t.responses.filter(e=>e.responseTypes.includes(`success`)).length&&yu({client:e,meta:{$ref:t.name,name:t.name},nameTransformer:wu,onImport:n});let c={default:(`throwOnError`in o.config?o.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`};if(!a.plugins[`@hey-api/sdk`]?.config.asClass&&!ve(a)){for(let l of i.operations){let i={parameters:Eu(e,l),returnType:s?Du(e,l):void 0,statements:ju({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:Ou(l),exportConst:!0,expression:u,name:Au({config:a,handleIllegal:!0,id:l.name,operation:l})}))}return}let l=i.operations.map(r=>F.methodDeclaration({accessLevel:`public`,comment:Ou(r),isStatic:ve(a)===void 0&&o.name!==`legacy/angular`,name:Au({config:a,id:r.name,operation:r}),parameters:Eu(e,r),returnType:s?Du(e,r):void 0,statements:ju({client:e,onClientImport:t,onImport:n,operation:r}),types:s?void 0:[c]}));if(!l.length)return;ve(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:ns({config:a,name:i.name}),nodes:u}))},Nu=({client:e,files:t,plugin:n})=>{let r=x(),i=S(r);if(t.sdk=new uu({dir:r.output.path,exportFromIndex:n.config.exportFromIndex,id:`sdk`,name:`sdk.ts`}),!i)t.sdk.import({module:gl({config:r,sourceOutput:`sdk`}),name:`createClient`}),t.sdk.import({module:gl({config:r,sourceOutput:`sdk`}),name:`createConfig`}),t.sdk.import({asType:!0,module:gl({config:r,sourceOutput:`sdk`}),name:`OptionsLegacyParser`});else if(b(r).name===`legacy/angular`?(t.sdk.import({module:`@angular/core`,name:`Injectable`}),ve(r)||t.sdk.import({module:`@angular/common/http`,name:`HttpClient`}),t.sdk.import({asType:!0,module:`rxjs`,name:`Observable`})):t.sdk.import({asType:!0,module:`./core/CancelablePromise`,name:`CancelablePromise`}),r.plugins[`@hey-api/sdk`]?.config.response===`response`&&t.sdk.import({asType:!0,module:`./core/ApiResult`,name:`ApiResult`}),ve(r)){let e=b(r);t.sdk.import({asType:e.name!==`legacy/angular`,module:`./core/BaseHttpRequest`,name:`BaseHttpRequest`})}else t.sdk.import({module:`./core/OpenAPI`,name:`OpenAPI`}),t.sdk.import({alias:`__request`,module:`./core/request`,name:`request`});if(!i){let e=b(r),n=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)Mu({client:e,onClientImport:e=>{t.sdk.import({module:gl({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})},Pu=({plugin:e})=>{let t=_l(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:zc}),F.typeReferenceNode({typeName:Rc})]:[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:zc}),F.typeParameterDeclaration({defaultType:F.keywordTypeNode({keyword:`undefined`}),name:Rc})]:[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)},Fu=({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]})]},Iu=({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?Fu({plugin:e}):[];e.forEach(`operation`,({operation:a})=>{let o=Yc({context:e.context,operation:a}),s=e.getPluginOrThrow(`@hey-api/typescript`),c=r?e.getSymbol(s.api.selector(`response`,a.id)):void 0,l=Wc({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=Kc({isRequiredOptions:o,operation:a,plugin:e}),h=Jc({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:Lc},{default:c?F.typeReferenceNode({typeName:c.placeholder}):F.typeNode(`undefined`),extends:c?F.typeReferenceNode({typeName:c.placeholder}):void 0,name:Rc}]:[{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:T({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)},Lu=({plugin:e})=>{let t=b(e.context.config),n=t.name===`@hey-api/client-nuxt`;e.forEach(`operation`,({operation:r})=>{let i=Yc({context:e.context,operation:r}),a=e.getPluginOrThrow(`@hey-api/typescript`),o=n?e.getSymbol(a.api.selector(`response`,r.id)):void 0,s=Kc({isRequiredOptions:i,operation:r,plugin:e}),c=Jc({isRequiredOptions:i,opParameters:s,operation:r,plugin:e}),l=e.registerSymbol({name:Au({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:Lc},{default:o?F.typeReferenceNode({typeName:o.placeholder}):F.typeNode(`undefined`),extends:o?F.typeReferenceNode({typeName:o.placeholder}):void 0,name:Rc}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]}),name:l.placeholder});e.setSymbolValue(l,u)},{order:`declarations`})},Ru=({plugin:e})=>{let t=_l(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`)}),Pu({plugin:e}),e.config.asClass?Iu({plugin:e}):Lu({plugin:e})},zu={api:new vu({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:Ru,handlerLegacy:Nu,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`)}},Bu=C(zu);var Vu=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Hu=({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})]}},Uu=({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})})]},Wu=`data`,Gu=e=>e.map(e=>p.default.isStatement(e)?e:F.expressionToStatement({expression:e})),Ku=({node:e})=>e.kind===p.default.SyntaxKind.ReturnStatement,qu=({plugin:e,schema:t})=>{let n=F.identifier({text:Wu}),r=Ju({dataExpression:n,plugin:e,schema:t});return r.length&&!Ku({node:r[r.length-1]})&&r.push(F.returnStatement({expression:n})),r},Ju=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r=t.api.selector(`response-ref`,n.$ref);if(!t.getSymbol(r)){let e=t.registerSymbol({name:E({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:I(n.$ref)}),selector:r}),i=qu({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(i.length){let n=F.constVariable({expression:F.arrowFunction({async:!1,multiLine:!0,parameters:[{name:Wu,type:F.keywordTypeNode({keyword:`any`})}],statements:Gu(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?Ju({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=Gu(r);return i.some(e=>Ku({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||Wu,name:a}),c=Ju({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:Gu(c)})}))}return r}if(n.items){if(n.items.length===1)return Ju({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=Ju({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:Gu(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[]},Yu=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=ut(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${k(t)} has ${n.items.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);return}let r=e.getPluginOrThrow(`@hey-api/typescript`),i=e.getSymbol(r.api.selector(`response`,t.id));if(!i)return;let a=e.registerSymbol({exported:!0,name:E({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id}),selector:e.api.selector(`response`,t.id)}),o=qu({plugin:e,schema:n});if(o.length){let t=F.constVariable({exportConst:a.exported,expression:F.arrowFunction({async:!0,multiLine:!0,parameters:[{name:Wu,type:F.keywordTypeNode({keyword:`any`})}],returnType:F.typeReferenceNode({typeArguments:[F.typeReferenceNode({typeName:i.placeholder})],typeName:`Promise`}),statements:Gu(o)}),name:a.placeholder});e.setSymbolValue(a,t)}else e.setSymbolValue(a,null)},{order:`declarations`})},Xu=`$OpenApiTs`,K={$refs:[],base:``,description:null,enum:[],enums:[],export:`interface`,imports:[],in:``,isDefinition:!1,isNullable:!1,isReadOnly:!1,isRequired:!1,link:null,name:``,properties:[],template:null,type:``},Zu=({comments:e,leadingComment:t,meta:n,obj:r,onNode:i,...a})=>{if(!n)return;let{created:o,name:s}=Rs({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}))}},Qu=({comment:e,meta:t,onCreated:n,onNode:r,type:i,...a})=>{if(!t)return{created:!1,name:``};let o=Rs({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},$u=e=>{let t=[];nd(e),e.model.enums.forEach(n=>td({...e,model:n,onNode:e=>{t.push(e)}})),t.length&&e.onNode(F.namespaceDeclaration({name:e.model.name,statements:t}))},ed=({client:e,model:t,onNode:n})=>{let r=x(),i={},a={};t.enum.forEach(e=>{let{key:t,value:n}=Ts(e);i[t]=n;let r=e.customDescription||e.description;r&&(a[t]=[j(r)])});let o=[t.description&&j(t.description),t.deprecated&&`@deprecated`],s=r.plugins[`@hey-api/typescript`];if(s?.config&&typeof s.config.enums==`object`&&s.config.enums.enabled&&(s.config.enums.mode===`typescript`||s.config.enums.mode===`typescript-const`)){Zu({asConst:s.config.enums.mode===`typescript-const`,client:e,comments:a,leadingComment:o,meta:t.meta,obj:i,onNode:n});return}Qu({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:Cs(t.enum)})},td=({model:e,onNode:t})=>{let n={},r={};e.enum.forEach(e=>{let{key:t,value:i}=Ts(e);n[t]=i;let a=e.customDescription||e.description;a&&(r[t]=[j(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&&j(e.description),e.deprecated&&`@deprecated`],name:e.meta?.name||e.name,obj:n}))},nd=({client:e,model:t,onNode:n})=>{Qu({client:e,comment:[t.description&&j(t.description),t.deprecated&&`@deprecated`],meta:t.meta,onNode:n,type:Ls(t)})},rd=e=>{switch(e.model.export){case`all-of`:case`any-of`:case`one-of`:case`interface`:return $u(e);case`enum`:return ed(e);default:return nd(e)}},id=({client:e,onNode:t})=>{let n={},r=x();if(!r.plugins[`@hey-api/sdk`]&&!r.plugins[`@hey-api/typescript`]?.config.tree)return;let i=S(r);for(let r of e.services)for(let a of r.operations){if(!a.parameters.length&&!a.responses.length)continue;n[a.path]||(n[a.path]={});let r=n[a.path];r[a.method]||(r[a.method]={});let o=r[a.method];if(o.$ref=a.name,a.responses.length>0){if(o.res||={},Array.isArray(o.res))continue;a.responses.forEach(e=>{o.res[e.code]=e})}if(a.parameters.length>0){let n={mediaType:null,...K,in:`body`,name:`body`,prop:`body`},r=a.parameters.filter(e=>e.in===`body`);r.length||(r=a.parameters.filter(e=>e.in===`formData`)),r.length===1?n={...K,...r[0],in:`body`,isRequired:r[0].isRequired,name:`body`,prop:`body`}:r.length>1&&(n={...K,in:`body`,isRequired:r.some(e=>e.isRequired),mediaType:`multipart/form-data`,name:`body`,prop:`body`,properties:r});let s={...K,in:`header`,isRequired:Hs(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(bs)},c={...K,in:`path`,isRequired:Hs(a.parameters.filter(e=>e.in===`path`)),mediaType:null,name:`path`,prop:`path`,properties:a.parameters.filter(e=>e.in===`path`).sort(bs)},l={...K,in:`query`,isRequired:Hs(a.parameters.filter(e=>e.in===`query`)),mediaType:null,name:`query`,prop:`query`,properties:a.parameters.filter(e=>e.in===`query`).sort(bs)},u=i?xs([...a.parameters]):[n,s,c,l].filter(e=>e.properties.length||e.$refs.length||e.mediaType);o.req=u,Qu({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:xu,onNode:t,type:Ls({...K,isRequired:!0,properties:u})})}let s=a.responses.filter(e=>e.responseTypes.includes(`success`));if(s.length>0){Qu({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:wu,onNode:t,type:Ls({...K,export:`any-of`,isRequired:!0,properties:s})});let n=a.responses.filter(e=>e.responseTypes.includes(`error`));i||Qu({client:e,meta:{$ref:a.name,name:a.name},nameTransformer:Su,onNode:t,type:Ls(n.length?{...K,export:`one-of`,isRequired:!0,properties:n}:{...K,base:`unknown`,isRequired:!0,type:`unknown`})})}}let a=Object.entries(n).map(([t,n])=>{let r=Object.entries(n).map(([t,n])=>{let r=t,i=[];if(n.req){let t=n.$ref,{name:r}=Rs({client:e,meta:{$ref:t,name:t},nameTransformer:xu}),a={...K,base:r,export:`reference`,isRequired:!0,name:`req`,properties:[],type:r};i=[...i,a]}if(n.res){let e=Object.entries(n.res).map(([e,t])=>({...K,...t,isRequired:!0,name:String(e)})),t={...K,isRequired:!0,name:`res`,properties:e};i=[...i,t]}return{...K,isRequired:!0,name:r.toLocaleLowerCase(),properties:i}}).filter(Boolean);return{...K,isRequired:!0,name:`'${t}'`,properties:r}});r.plugins[`@hey-api/typescript`]?.config.tree&&Qu({client:e,meta:{$ref:`@hey-api/openapi-ts`,name:`$OpenApiTs`},onNode:t,type:Ls({...K,properties:a})})},ad=({client:e,files:t,plugin:n})=>{t.types=new uu({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)rd({client:e,model:t,onNode:r});id({client:e,onNode:r})},od=`data`,sd=e=>e.base===`unknown`&&e.export===`generic`&&e.type===`unknown`,cd=({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}),ld=e=>{let t=e.model.meta.name,{name:n}=Qu({...e,meta:{$ref:`transformers/${t}`,name:t},nameTransformer:bu,onCreated:n=>{let r=fd({...e,meta:{$ref:`transformers/${t}`,name:n},path:[od]});pd({...e,async:!1,name:n,statements:r})},type:`(${od}: any) => ${t}`});return{created:!!e.client.types[n],name:n}},ud=e=>{let{model:t}=e,n=cd(e);if(n.length===1){let{created:t,name:r}=ld({...e,model:n[0]});return t?[F.transformArrayMutation({path:e.path,transformerName:r})]:[]}return ks(t)||t.link&&!Array.isArray(t.link)&&t.link.export===`any-of`&&t.link.properties.find(e=>ks(e))?[F.transformArrayMap({path:e.path,transformExpression:F.conditionalExpression({condition:F.identifier({text:`item`}),whenFalse:F.identifier({text:`item`}),whenTrue:F.transformNewDate({parameterName:`item`})})})]:[]},dd=e=>{let{model:t}=e,n=[...e.path,t.name];return t.type===`string`&&t.export!==`array`&&ks(t)?[F.transformDateMutation({path:n})]:fd({...e,model:t,path:n})},fd=e=>{let{model:t}=e;switch(t.export){case`array`:return ud(e);case`interface`:return t.properties.flatMap(t=>dd({...e,model:t}));case`reference`:{if(t.$refs.length!==1)return[];let n=cd(e),{created:r,name:i}=ld({...e,model:n[0]});return r?t.in===`response`?[F.expressionToStatement({expression:F.callExpression({functionName:i,parameters:[od]})})]:F.transformFunctionMutation({path:e.path,transformerName:i}):[]}default:return[]}},pd=({async:e,client:t,name:n,onNode:r,onRemoveNode:i,statements:a})=>{let o={created:!1,name:n};if(!a.length)return zs({client:t,name:n}),i?.(),o;let s=F.arrowFunction({async:e,multiLine:!0,parameters:[{name:od}],statements:[...a,F.returnVariable({expression:od})]});return r(F.constVariable({exportConst:!0,expression:s,name:n,typeName:n})),{created:!0,name:n}},md=({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=>!sd(e));if(!o.length)continue;if(o.length>1){n.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${k(a)} has ${o.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);continue}let s=wu(a.name);Qu({client:e,meta:{$ref:`transformers/${s}`,name:s},nameTransformer:Cu,onCreated:n=>{pd({async:!0,client:e,name:n,onNode:r,onRemoveNode:i,statements:t.length>1?t.flatMap(t=>{let n=fd({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t,onNode:r,onRemoveNode:i,path:[od]});return n.length?[F.ifStatement({expression:F.safeAccessExpression([`data`]),thenStatement:F.block({statements:n})})]:[]}):fd({client:e,meta:{$ref:`transformers/${s}`,name:s},model:t[0],onNode:r,onRemoveNode:i,path:[od]})})},onNode:r,type:`(${od}: any) => Promise<${s}>`})}},hd={api:new Vu({name:`@hey-api/transformers`}),config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:Yu,handlerLegacy:md,name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,Uu]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,Hu])},tags:[`transformer`]},gd=C(hd),_d=({context:e,name:t})=>(A.lastIndex=0,A.test(t)?t.startsWith(`-`)?p.default.factory.createStringLiteral(t):p.default.factory.createNumericLiteral(t):T({case:e.config.output.case,value:t})),vd=({schema:e})=>{let t=[];return e.title&&t.push(j(e.title)),e.description&&(t.length&&t.push(``),t.push(j(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},yd=F.keywordTypeNode({keyword:`string`}),bd=({server:e})=>{let t=ga(e.url);return t.protocol&&t.host?F.literalTypeNode({literal:F.stringLiteral({text:e.url})}):F.templateLiteralType({value:[t.protocol||yd,`://`,t.host||yd,t.port?`:${t.port}`:``,t.path||``]})},xd=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=b(e.context.config),i=t.map(e=>bd({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(F.typeIntersectionNode({types:[yd,p.default.factory.createTypeLiteralNode([])]})):i.push(yd);let a=F.typeInterfaceNode({properties:[{name:he(e.context.config),type:F.typeUnionNode({types:i})}],useLegacyResolution:!1}),o=F.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:a});e.setSymbolValue(n,o)},Sd=({plugin:e,schema:t})=>{let n=[];return{obj:(t.items??[]).map((t,r)=>{let i=typeof t.const;n.includes(i)||n.push(i);let a;return a=t.title?t.title:i===`number`||i===`string`?`${t.const}`:i===`boolean`?t.const?`true`:`false`:t.const===null?`null`:`${r}`,a&&(a=T({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),A.lastIndex=0,A.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{comments:vd({schema:t}),key:a,value:t.const}}),typeofItems:n}},Cd=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=Sd({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:vd({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:vd({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:vd({schema:t}),name:n.placeholder,obj:r.obj});e.setSymbolValue(n,i);return}}let i=F.typeAliasDeclaration({comment:vd({schema:t}),exportType:n.exported,name:n.placeholder,type:r});e.setSymbolValue(n,i)},wd=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=D({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},Td=({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=wd({parameters:e.parameters.header}),n.properties.headers.required&&r.push(`headers`)),e.parameters?.path?(n.properties.path=wd({parameters:e.parameters.path}),n.properties.path.required&&r.push(`path`)):n.properties.path={type:`never`},e.parameters?.query?(n.properties.query=wd({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:E({config:t.config.requests,name:e.id}),selector:t.api.selector(`data`,e.id)}),a=q({plugin:t,schema:n}),o=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});t.setSymbolValue(i,o)},Ed=({operation:e,plugin:t})=>{Td({operation:e,plugin:t});let{error:n,errors:r,response:i,responses:a}=ut(e);if(r){let i=t.registerSymbol({exported:!0,meta:{kind:`type`},name:E({config:t.config.errors,name:e.id}),selector:t.api.selector(`errors`,e.id)}),a=q({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:E({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:E({config:t.config.responses,name:e.id}),selector:t.api.selector(`responses`,e.id)}),r=q({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:E({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)}}},Dd=({operation:e,plugin:t})=>{let n={type:`object`},r=[];if(n.properties||={},e.body){let i=t.registerSymbol({exported:!0,meta:{kind:`type`},name:E({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id}),selector:t.api.selector(`webhook-payload`,e.id)}),a=q({plugin:t,schema:e.body.schema}),o=F.typeAliasDeclaration({comment:vd({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:E({config:t.config.webhooks,name:e.id}),selector:t.api.selector(`webhook-request`,e.id)}),a=q({plugin:t,schema:n}),o=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});return t.setSymbolValue(i,o),i.placeholder},Od=({operation:e,plugin:t})=>Dd({operation:e,plugin:t}),kd=({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)},Ad=({plugin:e,schema:t})=>{if(!t.items)return F.typeArrayNode(F.keywordTypeNode({keyword:e.config.topType}));t=D({detectFormat:!0,schema:t});let n=[];for(let r of t.items){let t=q({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}))},jd=({schema:e})=>e.const===void 0?F.keywordTypeNode({keyword:`boolean`}):F.literalTypeNode({literal:F.ots.boolean(e.const)}),Md=({plugin:e,schema:t})=>q({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)}),Pd=({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=q({plugin:e,schema:r}),l=o.includes(n);i.push({comment:vd({schema:r}),isReadOnly:r.accessScope===`read`,isRequired:l,name:_d({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?q({plugin:e,schema:a[0]}):q({plugin:e,schema:{items:a,logicalOperator:`or`}})},t.propertyNames?.$ref&&(n=q({plugin:e,schema:{$ref:t.propertyNames.$ref}}))}return F.typeInterfaceNode({indexKey:n,indexProperty:r,properties:i,useLegacyResolution:!1})},Fd=({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:T({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`})},Id=({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=q({plugin:e,schema:r});n.push(t)}return F.typeTupleNode({types:n})},Ld=({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 Ad({plugin:e,schema:t});case`boolean`:return jd({schema:t});case`enum`:return Md({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 Pd({plugin:e,schema:t});case`string`:return Fd({plugin:e,schema:t});case`tuple`:return Id({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`})}},q=({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 Ld({plugin:e,schema:t});if(t.items){if(t=D({detectFormat:!1,schema:t}),t.items){let n=[];for(let r of t.items){let t=q({plugin:e,schema:r});n.push(t)}return t.logicalOperator===`and`?F.typeIntersectionNode({types:n}):F.typeUnionNode({types:n})}return q({plugin:e,schema:t})}return Ld({plugin:e,schema:{type:`unknown`}})},Rd=({id:e,plugin:t,schema:n})=>{let r=q({plugin:t,schema:n}),i=n.type===`enum`&&t.config.enums.enabled;Cd({plugin:t,schema:n,symbol:t.registerSymbol({exported:!0,meta:{kind:i?void 0:`type`},name:E({config:t.config.definitions,name:I(e)}),selector:t.api.selector(`ref`,e)}),type:r})},zd=({plugin:e})=>{let t=e.registerSymbol({exported:!0,meta:{kind:`type`},name:E({config:{case:e.config.case},name:`ClientOptions`}),selector:e.api.selector(`ClientOptions`)}),n=e.registerSymbol({exported:!0,meta:{kind:`type`},name:E({config:{case:e.config.case},name:`Webhooks`}),selector:e.api.selector(`Webhooks`)}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{switch(t.type){case`operation`:Ed({operation:t.operation,plugin:e});break;case`parameter`:Rd({id:t.$ref,plugin:e,schema:t.parameter.schema});break;case`requestBody`:Rd({id:t.$ref,plugin:e,schema:t.requestBody.schema});break;case`schema`:Rd({id:t.$ref,plugin:e,schema:t.schema});break;case`server`:r.push(t.server);break;case`webhook`:i.push(Od({operation:t.operation,plugin:e}));break}},{order:`declarations`}),xd({plugin:e,servers:r,symbolClientOptions:t}),kd({plugin:e,symbolWebhooks:n,webhookNames:i})};var Bd=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}schemaToType(e){return q(e)}};const Vd={api:new Bd({name:`@hey-api/typescript`}),config:{case:`PascalCase`,exportFromIndex:!0,style:`preserve`,topType:`unknown`,tree:!1},handler:zd,handlerLegacy:ad,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})}},Hd=C(Vd);var Ud=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Wd=(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})},Gd=({operation:e,plugin:t})=>Gc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Kd=({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},qd=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},Jd=({plugin:e,typeData:t})=>{let n=b(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},Yd=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`UseMutationOptions`)),i=Gd({operation:e,plugin:t}),a=Kd({operation:e,plugin:t}),o=qd({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=Jd({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=Wd(t,e,`mutationOptions`);m&&p.push({key:`meta`,value:m});let h=t.getPluginOrThrow(`@hey-api/sdk`),g=t.registerSymbol({exported:!0,name:E({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,_)},Xd=`TOptions`,Zd=F.identifier({text:`options`}),Qd=({plugin:e})=>{let t=e.registerSymbol({name:E({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=e.referenceSymbol(e.api.selector(`_JSONValue`)),i=F.indexedAccessTypeNode({indexType:F.literalTypeNode({literal:F.ots.number(0)}),objectType:F.typeReferenceNode({typeArguments:[F.typeReferenceNode({typeName:Xd})],typeName:n.placeholder})}),a=he(e.context.config),o=e.getPluginOrThrow(`@hey-api/sdk`),s=e.referenceSymbol(o.api.selector(`Options`)),c=b(e.context.config),l=c.api&&`selector`in c.api?e.getSymbol(c.api.selector(`client`)):void 0,u=_l(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:Xd})},{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:Zd,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:Zd,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:Zd,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:Xd}]}),name:t.placeholder});e.setSymbolValue(t,f)},$d=({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]})},ef=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`_JSONValue`)),n=[{name:`_id`,type:F.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:he(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<${Xd}, 'path'>`}),F.typeInterfaceNode({properties:n,useLegacyResolution:!0})]})]}),typeParameters:[{extends:F.typeReferenceNode({typeName:F.identifier({text:i.placeholder})}),name:Xd}]});e.setSymbolValue(a,o)},tf=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=Jd({plugin:t,typeData:Gd({operation:e,plugin:t})});return F.constVariable({exportConst:n.exported,expression:F.arrowFunction({parameters:[{isRequired:st(e),name:`options`,type:r}],statements:$d({id:e.id,operation:e,plugin:t})}),name:n.placeholder})},nf=`options`,rf=`context`,af=({operation:e,plugin:t,queryFn:n})=>{if(Xc({operation:e}))return;let r=Yc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(ef({plugin:t}),Qd({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:E({config:t.config.queryKeys,name:e.id})}),r=tf({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=F.callExpression({functionName:n.placeholder,parameters:[nf]})}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),nf,r]})}let{strippedTypeData:a}=Jd({plugin:t,typeData:Gd({operation:e,plugin:t})}),o=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:nf},{spread:rf},{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:rf}],statements:s})}],l=Wd(t,e,`queryOptions`);l&&c.push({key:`meta`,value:l});let u=t.getPluginOrThrow(`@hey-api/sdk`),d=t.registerSymbol({exported:!0,name:E({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:nf,type:a}],statements:F.objectExpression({obj:c})})]}),name:d.placeholder});t.setSymbolValue(d,p)},of=({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?Wc({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(t.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>T({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(t.api.selector(`function`,n.id)).placeholder;e.hooks.operation.isQuery(n)&&e.config.queryOptions.enabled&&af({operation:n,plugin:e,queryFn:a}),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&Yd({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},sf={api:new Ud({name:`@pinia/colada`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:of,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})}},cf=C(sf),lf=(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})},uf=({operation:e,plugin:t})=>Gc({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),df=({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},ff=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/typescript`);return t.getSymbol(n.api.selector(`response`,e.id))?.placeholder||`unknown`},pf=`TOptions`,mf=F.identifier({text:`infinite`}),hf=F.identifier({text:`options`}),gf=({plugin:e})=>{let t=e.registerSymbol({name:E({config:{case:e.config.case},name:`createQueryKey`}),selector:e.api.selector(`createQueryKey`)}),n=e.referenceSymbol(e.api.selector(`QueryKey`)),r=F.indexedAccessTypeNode({indexType:F.literalTypeNode({literal:F.ots.number(0)}),objectType:F.typeReferenceNode({typeArguments:[F.typeReferenceNode({typeName:pf})],typeName:n.placeholder})}),i=he(e.context.config),a=b(e.context.config),o=a.api&&`selector`in a.api?e.getSymbol(a.api.selector(`client`)):void 0,s=e.getPluginOrThrow(`@hey-api/sdk`),c=e.referenceSymbol(s.api.selector(`Options`)),l=F.constVariable({expression:F.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:F.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:F.typeReferenceNode({typeName:pf})},{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:mf,thenStatement:F.block({statements:[F.expressionToStatement({expression:F.binaryExpression({left:F.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:mf})})]})}),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:hf,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:hf,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:hf,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:hf,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:pf}]}),name:t.placeholder});e.setSymbolValue(t,l)},_f=({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]})},vf=({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<${pf}, '${he(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),F.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:F.typeReferenceNode({typeName:F.identifier({text:r.placeholder})}),name:pf}]});e.setSymbolValue(i,a)},yf=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=uf({operation:t,plugin:n});return F.constVariable({exportConst:r.exported,expression:F.arrowFunction({parameters:[{isRequired:st(t),name:`options`,type:a}],returnType:e?i:void 0,statements:_f({id:t.id,isInfinite:e,operation:t,plugin:n})}),name:r.placeholder})},bf=({plugin:e})=>{let t=e.registerSymbol({name:E({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:p.default.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)},xf=({operation:e,plugin:t,queryFn:n})=>{let r=ct({context:t.context,operation:e});if(!r)return;let i=Yc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(vf({plugin:t}),gf({plugin:t})),t.getSymbol(t.api.selector(`createInfiniteParams`))||bf({plugin:t});let a=t.referenceSymbol(t.api.selector(`infiniteQueryOptions`)),o=t.referenceSymbol(t.api.selector(`InfiniteData`)),s=uf({operation:e,plugin:t}),c=df({operation:e,plugin:t}),l=ff({operation:e,plugin:t}),u=`${t.referenceSymbol(t.api.selector(`QueryKey`)).placeholder}<${s}>`,d=`Pick<${u}[0], 'body' | 'headers' | 'path' | 'query'>`,f=t.getPluginOrThrow(`@hey-api/typescript`),p=`${Ot({node:f.api.schemaToType({plugin:f,schema:r.schema}),unescape:!0})} | ${d}`,m=t.registerSymbol({exported:!0,name:E({config:t.config.infiniteQueryKeys,name:e.id})}),h=yf({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 y=[{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`]})}],ee=lf(t,e,`infiniteQueryOptions`);ee&&y.push({key:`meta`,value:ee});let te=t.getPluginOrThrow(`@hey-api/sdk`),ne=t.registerSymbol({exported:!0,name:E({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:y})],name:a.placeholder,types:[l,c||`unknown`,`${o.placeholder}<${l}>`,u,p]})]}),name:ne.placeholder});t.setSymbolValue(ne,re)},Sf=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol(t.api.selector(`MutationOptions`)),i=uf({operation:e,plugin:t}),a=df({operation:e,plugin:t}),o=ff({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=lf(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:E({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,_)},Cf=`options`,wf=({operation:e,plugin:t,queryFn:n})=>{if(Xc({operation:e}))return;let r=Yc({context:t.context,operation:e});t.getSymbol(t.api.selector(`createQueryKey`))||(vf({plugin:t}),gf({plugin:t}));let i=t.referenceSymbol(t.api.selector(`queryOptions`)),a=t.registerSymbol({exported:!0,name:E({config:t.config.queryKeys,name:e.id})}),o=yf({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=uf({operation:e,plugin:t}),c=F.awaitExpression({expression:F.callExpression({functionName:n,parameters:[F.objectExpression({multiLine:!0,obj:[{spread:Cf},{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:[Cf]})}],d=lf(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:E({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:Cf,type:s}],statements:[F.returnFunctionCall({args:[F.objectExpression({obj:u})],name:i.placeholder})]}),name:p.placeholder});t.setSymbolValue(p,m)},Tf=`options`,Ef=({operation:e,plugin:t})=>{if(Xc({operation:e})||!(`useQuery`in t.config))return;let n=t.getPluginOrThrow(`@hey-api/sdk`),r=t.registerSymbol({exported:!0,name:E({config:t.config.useQuery,name:e.id})}),i=t.referenceSymbol(t.api.selector(`useQuery`)),a=Yc({context:t.context,operation:e}),o=uf({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:Tf,type:o}],statements:[F.returnStatement({expression:F.callExpression({functionName:i.placeholder,parameters:[F.callExpression({functionName:s.placeholder,parameters:[Tf]})]})})]}),name:r.placeholder});t.setSymbolValue(r,c)},Df=({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?Wc({context:e.context,operation:t,plugin:n}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol(n.api.selector(`class`,i.path[0])).placeholder,...i.path.slice(1).map(e=>T({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol(n.api.selector(`function`,t.id)).placeholder;e.hooks.operation.isQuery(t)&&(e.config.queryOptions.enabled&&wf({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&xf({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&Ef({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&Sf({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},Of=e=>`${Au({config:x(),id:e.name,operation:e})}InfiniteOptions`,kf=e=>`${Au({config:x(),id:e.name,operation:e})}Mutation`,Af=({config:e,id:t,operation:n})=>`${Au({config:e,id:t,operation:n})}Options`,jf=({config:e,id:t,isInfinite:n,operation:r})=>`${Au({config:e,id:t,operation:r})}${n?`Infinite`:``}QueryKey`,Mf=e=>{switch(e.in){case`formData`:return`body`;case`header`:return`headers`;default:return e.in}},Nf=`createInfiniteParams`,Pf=`createQueryKey`,Ff=`infiniteQueryOptions`,If=`mutationOptions`,Lf=`QueryKey`,Rf=`queryOptions`,zf=`TOptions`,Bf=({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:p.default.factory.createAsExpression(p.default.factory.createAsExpression(F.identifier({text:`params`}),p.default.factory.createKeywordTypeNode(p.default.SyntaxKind.UnknownKeyword)),p.default.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)},Vf=({file:e})=>{let t=F.indexedAccessTypeNode({indexType:F.typeNode(0),objectType:F.typeNode(Lf,[F.typeNode(zf)])}),n=F.identifier({text:`infinite`}),r=he(x()),i=F.constVariable({expression:F.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:F.typeNode(`string`)},{isRequired:!1,name:`options`,type:F.typeNode(zf)},{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:zf}]}),name:Pf});e.add(i)},Hf=({file:e})=>{let t=[{name:`_id`,type:F.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:F.keywordTypeNode({keyword:`boolean`})}],n=F.typeAliasDeclaration({name:Lf,type:F.typeTupleNode({types:[F.typeIntersectionNode({types:[F.typeReferenceNode({typeName:`Pick<${zf}, '${he(x())}' | 'body' | 'headers' | 'path' | 'query'>`}),F.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:F.typeReferenceNode({typeName:F.identifier({text:`OptionsLegacyParser`})}),name:zf}]});e.add(n)},Uf=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=yu({client:e,meta:n.parameters.length?{$ref:n.name,name:n.name}:void 0,nameTransformer:xu,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeData:Tu({importedType:i})}},Wf=({client:e,file:t,operation:n,pluginName:r,typesModulePath:i})=>{let a=x(),{name:o}=yu({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:Su,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}},Gf=({client:e,file:t,operation:n,typesModulePath:r})=>{let{name:i}=yu({client:e,meta:{$ref:n.name,name:n.name},nameTransformer:wu,onImport:e=>{t.import({asType:!0,module:r,name:e})}});return{typeResponse:i||`void`}},Kf=({id:e,isInfinite:t})=>F.arrayLiteralExpression({elements:[F.callExpression({functionName:Pf,parameters:[F.ots.string(e),`options`,t?F.ots.boolean(!0):void 0]})],multiLine:!1}),qf=({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:gl({config:r,sourceOutput:n.output}),name:`OptionsLegacyParser`});let a=oe({moduleOutput:t.types.nameWithoutExtension(),sourceOutput:n.output}),o=n.name===`@tanstack/angular-query-experimental`||n.name===`@tanstack/svelte-query`||n.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`,s,c=!1,l=!1,u=!1,d=!1,f=!1,p=new Map;for(let m of e.services)for(let h of m.operations){let g=k(h);if(p.has(g))continue;p.set(g,!0);let _=[r.plugins[`@hey-api/sdk`]?.config.asClass&&ns({config:r,name:m.name}),Au({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||=(Hf({file:i}),Vf({file:i}),!0),i.import({module:n.name,name:Rf})),v=!0;let{typeData:t}=Uf({client:e,file:i,operation:h,typesModulePath:a}),o=Hs(h.parameters),s=F.constVariable({exportConst:!0,expression:F.arrowFunction({parameters:[{isRequired:o,name:`options`,type:t}],statements:Kf({id:h.name})}),name:jf({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:jf({config:r,id:h.name,operation:h}),parameters:[`options`]})}]})],name:Rf})]}),name:Af({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(zi(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(zi(r.parser.pagination).test(e.name))return t=e,!0})}return n.properties.find(e=>{if(zi(r.parser.pagination).test(e.name))return t=e,!0})}});if(o&&t){u||(u=!0,l||=(Hf({file:i}),Vf({file:i}),!0),c||=(Bf({file:i}),!0),i.import({module:n.name,name:Ff}),s=i.import({asType:!0,module:n.name,name:`InfiniteData`})),v=!0;let{typeData:d}=Uf({client:e,file:i,operation:h,typesModulePath:a}),{typeError:f}=Wf({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:p}=Gf({client:e,file:i,operation:h,typesModulePath:a}),m=Hs(h.parameters),g=`${Lf}<${d}>`,y=`Pick<${g}[0], 'body' | 'headers' | 'path' | 'query'>`,ee=`${t.base} | ${y}`,te=F.constVariable({exportConst:!0,expression:F.arrowFunction({parameters:[{isRequired:m,name:`options`,type:d}],returnType:g,statements:Kf({id:h.name,isInfinite:!0})}),name:jf({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:Mf(o),value:F.objectExpression({multiLine:!0,obj:[{key:t.name,value:F.identifier({text:`pageParam`})}]})}]}),whenTrue:F.identifier({text:`pageParam`})}),name:`page`,typeName:y}),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:jf({config:r,id:h.name,isInfinite:!0,operation:h}),parameters:[`options`]})}]})],name:Ff,types:[p,f.name,`${typeof s==`string`?s:s.name}<${p}>`,g,ee]})]}),name:Of(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}=Uf({client:e,file:i,operation:h,typesModulePath:a}),{typeError:r}=Wf({client:e,file:i,operation:h,pluginName:n.name,typesModulePath:a}),{typeResponse:s}=Gf({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:If,typeName:`${o}<${s}, ${r.name}, ${t}>`}),F.returnVariable({expression:If})]}),u=F.constVariable({comment:[],exportConst:!0,expression:l,name:kf(h)});i.add(u)}(f||u)&&i.import({alias:`_heyApiClient`,module:oe({moduleOutput:t.client.nameWithoutExtension(),sourceOutput:n.output}),name:`client`}),v&&i.import({module:oe({moduleOutput:t.sdk.nameWithoutExtension(),sourceOutput:n.output}),name:_.split(`.`)[0]})}};var Jf=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Yf={api:new Jf({name:`@tanstack/angular-query-experimental`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Df,handlerLegacy:qf,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})}},Xf=C(Yf);var Zf=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Qf={api:new Zf({name:`@tanstack/react-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Df,handlerLegacy:qf,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))}},$f=C(Qf);var ep=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const tp={api:new ep({name:`@tanstack/solid-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Df,handlerLegacy:qf,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})}},np=C(tp);var rp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const ip={api:new rp({name:`@tanstack/svelte-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Df,handlerLegacy:qf,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})}},ap=C(ip);var op=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const sp={api:new op({name:`@tanstack/vue-query`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Df,handlerLegacy:qf,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})}},cp=C(sp),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:`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:`parseAsync`}),parameters:[F.identifier({text:r})]})})})]})};var dp=class{constructor(e){this.meta=e}createRequestValidator(e){return lp(e)}createResponseValidator(e){return up(e)}selector(...e){return[this.meta.name,...e]}};const fp=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`}},J=e=>({value:e}),Y=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=J(e[n]));return t},pp={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`})}},mp=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol(t.api.selector(`external`,`arktype.type`)),o=F.constVariable({comment:t.config.comments?vd({schema:n}):void 0,exportConst:r.exported,expression:F.callExpression({functionName:a.placeholder,parameters:[e.def?F.stringLiteral({text:e.def}):e.expression]}),name:r.placeholder});if(t.setSymbolValue(r,o),i){let e=F.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:p.default.factory.createTypeQueryNode(p.default.factory.createQualifiedName(p.default.factory.createIdentifier(r.placeholder),pp.type.infer))});t.setSymbolValue(i,e)}},hp=e=>{let t={};return t.def=pp.primitives.null,t},gp=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=a.includes(o),l=yp({optional:!c,plugin:e,schema:s,state:{...n,_path:J([...n._path.value,`properties`,o])}});l.hasLazyExpression&&(r.hasLazyExpression=!0);let u=c?o:`${o}?`;u.endsWith(`?`)?u=p.default.factory.createComputedPropertyName(F.stringLiteral({text:u})):((u.match(/^[0-9]/)&&u.match(/\D+/g)||u.match(/\W/g))&&!u.startsWith(`'`)&&!u.endsWith(`'`)&&(u=`'${u}'`),A.lastIndex=0,u=A.test(u)?u.startsWith(`-`)?F.stringLiteral({text:o}):p.default.factory.createNumericLiteral(o):o),i.push(F.propertyAssignment({initializer:l.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=yp({plugin:e,schema:t.additionalProperties,state:{...n,_path:J([...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=p.default.factory.createObjectLiteralExpression(i,!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r},_p=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=pp.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${pp.string.date}.${pp.string.iso}`;break;case`email`:n=`${n}.${pp.string.email}`;break;case`ipv4`:n=`${n}.${pp.string.ip}.${pp.string.v4}`;break;case`ipv6`:n=`${n}.${pp.string.ip}.${pp.string.v6}`;break;case`uri`:n=`${n}.${pp.string.url}`;break;case`uuid`:n=`${n}.${pp.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},vp=({schema:e,...t})=>{switch(e.type){case`null`:return hp({...t,schema:e});case`object`:return gp({...t,schema:e});case`string`:return _p({...t,schema:e})}let n=t.plugin.referenceSymbol(t.plugin.api.selector(`external`,`arktype.type`));return{def:``,expression:p.default.factory.createCallExpression(p.default.factory.createIdentifier(n.placeholder),void 0,[p.default.factory.createObjectLiteralExpression([p.default.factory.createPropertyAssignment(`name`,p.default.factory.createStringLiteral(`string`)),p.default.factory.createPropertyAssignment(`platform`,p.default.factory.createStringLiteral(`'android' | 'ios'`)),p.default.factory.createPropertyAssignment(p.default.factory.createComputedPropertyName(p.default.factory.createStringLiteral(`versions?`)),p.default.factory.createStringLiteral(`(number | string)[]`))],!0)]),hasLazyExpression:!1}},yp=({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=vp({plugin:e,schema:t,state:n});r.def=i.def,r.expression=i.expression,r.hasLazyExpression=i.hasLazyExpression,e.config.metadata&&t.description}else if(t.items)t=D({schema:t}),t.items||(r=yp({plugin:e,schema:t,state:n}));else{let t=vp({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=vp({plugin:e,schema:{type:`unknown`},state:n}).expression,r},bp=({$ref:e,plugin:t,schema:n,state:r})=>{let i=yp({plugin:t,schema:n,state:r}),a=I(e),o=fp(r._path.value);mp({ast:i,plugin:t,schema:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:o},name:E({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:E({config:t.config.definitions.types.infer,name:a}),selector:t.api.selector(`type-infer-ref`,e)}):void 0})},xp=({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`:bp({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break;case`requestBody`:bp({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break;case`schema`:bp({$ref:t.$ref,plugin:e,schema:t.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break}})},Sp=e=>xp(e),Cp={api:new dp({name:`arktype`}),config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:Sp,name:`arktype`,resolveConfig:(e,t)=>{e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Data`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}Response`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`PascalCase`,enabled:!0,name:`{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequest`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},wp=C(Cp);var Tp=class{constructor(e){this.meta=e}selector(...e){return[this.meta.name,...e]}};const Ep=({operation:e,plugin:t})=>{let n=[],r=t.getPluginOrThrow(`@hey-api/typescript`),i=t.getSymbol(r.api.selector(`data`,e.id));i&&(e.body&&n.push({isRequired:e.body.required,name:`Body`,type:`${i.placeholder}['body']`}),e.parameters&&(e.parameters.header&&n.push({isRequired:it(e.parameters.header),name:`Headers`,type:`${i.placeholder}['headers']`}),e.parameters.path&&n.push({isRequired:it(e.parameters.path),name:`Params`,type:`${i.placeholder}['path']`}),e.parameters.query&&n.push({isRequired:it(e.parameters.query),name:`Querystring`,type:`${i.placeholder}['query']`})));let{errors:a,responses:o}=ut(e),s,c=t.getSymbol(r.api.selector(`errors`,e.id));if(c&&a&&a.properties){let e=Object.keys(a.properties);if(e.length){if(!e.includes(`default`))s=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})}},Dp=({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=Ep({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)},Op={api:new Tp({name:`fastify`}),config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:Dp,name:`fastify`},kp=C(Op),X={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:{}},Ap=({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:X.async.parseAsync}),parameters:[F.identifier({text:n.placeholder}),F.identifier({text:i})]})})})]})},jp=({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:X.async.parseAsync}),parameters:[F.identifier({text:n.placeholder}),F.identifier({text:i})]})})})]})};var Mp=class{constructor(e){this.meta=e}createRequestValidator(e){return Ap(e)}createResponseValidator(e){return jp(e)}selector(...e){return[this.meta.name,...e]}};const Np={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}},Pp=e=>e!==void 0&&e in Np,Fp=e=>Pp(e)&&Np[e].needsBigInt,Ip=({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},Lp=({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],Z({plugin:t,schema:i,state:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:fp(n._path.value)},name:E({config:t.config.requests,name:e.id}),selector:t.api.selector(`data`,e.id)})})}if(t.config.responses.enabled&&e.responses){let{response:r}=ut(e);if(r){let i=[...n._path.value,`responses`],a=t.registerSymbol({exported:!0,meta:{resourceType:fp(i)},name:E({config:t.config.responses,name:e.id}),selector:t.api.selector(`responses`,e.id)});Z({plugin:t,schema:r,state:{...n,_path:J(i)},symbol:a})}}},Rp=({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:X.methods.pipe}),parameters:e})},zp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:X.schemas.unknown})})},Bp=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`valibot.v`)),i=F.propertyAccessExpression({expression:r.placeholder,name:X.schemas.array}),a=[];if(t.items){t=D({schema:t});let r=t.items.map((t,r)=>Rp({pipes:Z({plugin:e,schema:t,state:{...n,_path:J([...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:[zp({plugin:e,schema:{type:`unknown`},state:n})]});a.push(r)}}else{let t=F.callExpression({functionName:i,parameters:[zp({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:X.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:X.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:X.actions.maxLength}),parameters:[F.valueToExpression({value:t.maxItems})]});a.push(e)}}return Rp({pipes:a,plugin:e})},Vp=({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:X.schemas.literal}),parameters:[F.ots.boolean(t.const)]}):F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:X.schemas.boolean})})},Hp=({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 zp({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:X.schemas.picklist}),parameters:[F.arrayLiteralExpression({elements:r,multiLine:!1})]});return i&&(o=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:X.schemas.nullable}),parameters:[o]})),o},Up=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:X.schemas.never})})},Wp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:X.schemas.null})})},Gp=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=Fp(n),a=Pp(n)?Np[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:X.schemas.literal}),parameters:[r]})}let s=[];if(i){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.schemas.union}),parameters:[F.arrayLiteralExpression({elements:[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.schemas.number})}),F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.schemas.string})}),F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.schemas.bigInt})})],multiLine:!1})]});s.push(e);let t=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.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:X.schemas.number})});s.push(e)}if(!i&&r){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.actions.integer})});s.push(e)}if(a){let e=a.min,t=a.max,n=a.minError,r=a.maxError,c=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.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:X.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:X.actions.gtValue}),parameters:[Ip({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:X.actions.minValue}),parameters:[Ip({isBigInt:i,value:t.minimum})]});s.push(e)}if(t.exclusiveMaximum!==void 0){let e=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.actions.ltValue}),parameters:[Ip({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:X.actions.maxValue}),parameters:[Ip({isBigInt:i,value:t.maximum})]});s.push(e)}return Rp({pipes:s,plugin:e})},Kp=({plugin:e,schema:t,state:n})=>{let r=[],i=t.required??[];for(let a in t.properties){let o=t.properties[a],s=Z({optional:!i.includes(a),plugin:e,schema:o,state:{...n,_path:J([...n._path.value,`properties`,a])}});A.lastIndex=0;let c;c=A.test(a)?a.startsWith(`-`)?p.default.factory.createStringLiteral(a):p.default.factory.createNumericLiteral(a):a,(a.match(/^[0-9]/)&&a.match(/\D+/g)||a.match(/\W/g))&&!a.startsWith(`'`)&&!a.endsWith(`'`)&&(c=`'${a}'`),r.push(F.propertyAssignment({initializer:Rp({pipes:s,plugin:e}),name:c}))}let a=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));if(t.additionalProperties&&t.additionalProperties.type===`object`&&!Object.keys(r).length){let r=Z({plugin:e,schema:t.additionalProperties,state:{...n,_path:J([...n._path.value,`additionalProperties`])}});return{anyType:`AnyZodObject`,expression:F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:X.schemas.record}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:X.schemas.string}),parameters:[]}),Rp({pipes:r,plugin:e})]})}}let o=F.callExpression({functionName:F.propertyAccessExpression({expression:a.placeholder,name:X.schemas.object}),parameters:[p.default.factory.createObjectLiteralExpression(r,!0)]});return{anyType:X.types.GenericSchema.text,expression:o}},qp=({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:X.schemas.literal}),parameters:[F.ots.string(t.const)]});let r=[],i=F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:X.schemas.string})});if(r.push(i),t.format)switch(t.format){case`date`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoDate})}));break;case`date-time`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:X.actions.isoTimestamp})}));break;case`ipv4`:case`ipv6`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:X.actions.ip})}));break;case`uri`:r.push(F.callExpression({functionName:F.propertyAccessExpression({expression:n.placeholder,name:X.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:X.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:X.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:X.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:X.actions.regex}),parameters:[F.regularExpressionLiteral({text:t.pattern})]});r.push(e)}return Rp({pipes:r,plugin:e})},Jp=({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:X.schemas.literal}),parameters:[F.valueToExpression({value:e})]}));return F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:X.schemas.tuple}),parameters:[F.arrayLiteralExpression({elements:e})]})}if(t.items){let i=t.items.map((t,r)=>Rp({pipes:Z({plugin:e,schema:t,state:{...n,_path:J([...n._path.value,`items`,r])}}),plugin:e}));return F.callExpression({functionName:F.propertyAccessExpression({expression:r.placeholder,name:X.schemas.tuple}),parameters:[F.arrayLiteralExpression({elements:i})]})}return zp({plugin:e,schema:{type:`unknown`},state:n})},Yp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:X.schemas.undefined})})},Xp=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`valibot.v`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:X.schemas.void})})},Zp=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:Bp({...t,schema:e})};case`boolean`:return{expression:Vp({...t,schema:e})};case`enum`:return{expression:Hp({...t,schema:e})};case`integer`:case`number`:return{expression:Gp({...t,schema:e})};case`never`:return{expression:Up({...t,schema:e})};case`null`:return{expression:Wp({...t,schema:e})};case`object`:return Kp({...t,schema:e});case`string`:return e.format===`int64`||e.format===`uint64`?{expression:Gp({...t,schema:e})}:{expression:qp({...t,schema:e})};case`tuple`:return{expression:Jp({...t,schema:e})};case`undefined`:return{expression:Yp({...t,schema:e})};case`unknown`:return{expression:zp({...t,schema:e})};case`void`:return{expression:Xp({...t,schema:e})}}},Qp=({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],Z({plugin:t,schema:i,state:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:fp(n._path.value)},name:E({config:t.config.webhooks,name:e.id}),selector:t.api.selector(`webhook-request`,e.id)})})}},Z=({$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:X.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=Zp({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:X.actions.metadata}),parameters:[F.objectExpression({obj:[{key:`description`,value:F.stringLiteral({text:r.description})}]})]});c.push(e)}}else if(r.items)if(r=D({schema:r}),r.items){let e=r.items.map((e,t)=>Rp({pipes:Z({plugin:n,schema:e,state:{...i,_path:J([...i._path.value,`items`,t])}}),plugin:n}));if(r.logicalOperator===`and`){let t=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.schemas.intersect}),parameters:[F.arrayLiteralExpression({elements:e})]});c.push(t)}else{let t=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.schemas.union}),parameters:[F.arrayLiteralExpression({elements:e})]});c.push(t)}}else{let e=Z({plugin:n,schema:r,state:i});c.push(...e)}else{let e=Zp({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:X.actions.readonly})});c.push(e)}let e;r.default!==void 0&&(e=Ip({isBigInt:r.type===`integer`&&r.format===`int64`,value:r.default}),e&&(c=[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.schemas.optional}),parameters:[Rp({pipes:c,plugin:n}),e]})])),t&&!e&&(c=[F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:X.schemas.optional}),parameters:[Rp({pipes:c,plugin:n})]})])}if(a){e&&(a=n.registerSymbol({exported:!0,meta:{resourceType:fp(i._path.value)},name:E({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?vd({schema:r}):void 0,exportConst:a.exported,expression:Rp({pipes:c,plugin:n}),name:a.placeholder,typeName:i.hasLazyExpression.value?F.propertyAccessExpression({expression:o.placeholder,name:s||X.types.GenericSchema.text}):void 0});return n.setSymbolValue(a,t),[]}return c},$p=({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=Y({_path:t._path,hasLazyExpression:!1,nameCase:e.config.definitions.case,nameTransformer:e.config.definitions.name});switch(t.type){case`operation`:Lp({operation:t.operation,plugin:e,state:n});break;case`parameter`:Z({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Z({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Z({$ref:t.$ref,plugin:e,schema:t.schema,state:n});break;case`webhook`:Qp({operation:t.operation,plugin:e,state:n});break}})},em=e=>$p(e),tm={api:new Mp({name:`valibot`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:em,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`]},nm=C(tm),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`})},rm=({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})]})})})]})},im=({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})]})})})]})},am=({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})]})})})]})},om=({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})]})})})]})},sm=({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})]})})})]})},cm=({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 lm=class{constructor(e){this.meta=e}createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return am(e);case`mini`:return rm(e);case 4:default:return sm(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return om(e);case`mini`:return im(e);case 4:default:return cm(e)}}selector(...e){return[this.meta.name,...e]}};const um=({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?vd({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)}},dm=({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},fm=({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=fp(o);um({ast:s,plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{resourceType:c},name:E({config:n.config.requests,name:t.id}),selector:n.api.selector(`data`,t.id)}),typeInferSymbol:n.config.requests.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,resourceType:c},name:E({config:n.config.requests.types.infer,name:t.id}),selector:n.api.selector(`type-infer-data`,t.id)}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=ut(t);if(i){let a=[...r._path?.value||[],`responses`],o=e(i,a),s=fp(a);um({ast:o,plugin:n,schema:i,symbol:n.registerSymbol({exported:!0,meta:{resourceType:s},name:E({config:n.config.responses,name:t.id}),selector:n.api.selector(`responses`,t.id)}),typeInferSymbol:n.config.responses.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,resourceType:s},name:E({config:n.config.responses.types.infer,name:t.id}),selector:n.api.selector(`type-infer-responses`,t.id)}):void 0})}}},pm=({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=fp(o);um({ast:s,plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{resourceType:c},name:E({config:n.config.webhooks,name:t.id}),selector:n.api.selector(`webhook-request`,t.id)}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.registerSymbol({exported:!0,meta:{kind:`type`,resourceType:c},name:E({config:n.config.webhooks.types.infer,name:t.id}),selector:n.api.selector(`type-infer-webhook-request`,t.id)}):void 0})}},mm=({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},hm=({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:[mm({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=D({schema:t});let o=t.items.map((t,r)=>{let a=Dm({plugin:e,schema:t,state:{...n,_path:J([...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},gm=({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)},_m=({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):mm({plugin:e,schema:{type:`unknown`},state:n})},vm=({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},ym=({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},bm=({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},xm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i={},a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=Dm({optional:!o.includes(r),plugin:e,schema:s,state:{...n,_path:J([...n._path.value,`properties`,r])}});c.hasLazyExpression&&(i.hasLazyExpression=!0),A.lastIndex=0;let l;l=A.test(r)?r.startsWith(`-`)?p.default.factory.createStringLiteral(r):p.default.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(l=`'${r}'`),c.hasLazyExpression?a.push(F.getAccessorDeclaration({name:l,statements:[F.returnStatement({expression:c.expression})]})):a.push(F.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Dm({plugin:e,schema:t.additionalProperties,state:{...n,_path:J([...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:[p.default.factory.createObjectLiteralExpression(a,!0)]}),i},Sm=({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},Cm=({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=Dm({plugin:e,schema:t,state:{...n,_path:J([...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},wm=({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},Tm=({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},Em=({schema:e,...t})=>{switch(e.type){case`array`:return hm({...t,schema:e});case`boolean`:return gm({...t,schema:e});case`enum`:return _m({...t,schema:e});case`integer`:case`number`:return bm({...t,schema:e});case`never`:return vm({...t,schema:e});case`null`:return ym({...t,schema:e});case`object`:return xm({...t,schema:e});case`string`:return Sm({...t,schema:e});case`tuple`:return Cm({...t,schema:e});case`undefined`:return wm({...t,schema:e});case`unknown`:return mm({...t,schema:e});case`void`:return Tm({...t,schema:e})}},Dm=({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=Em({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=D({schema:n}),n.items){let e=n.items.map((e,n)=>Dm({plugin:t,schema:e,state:{...r,_path:J([...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=Dm({plugin:t,schema:n,state:r});else i.expression=Em({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},Om=({$ref:e,plugin:t,schema:n,state:r})=>{let i=Dm({plugin:t,schema:n,state:r}),a=I(e),o=fp(r._path.value);um({ast:i,plugin:t,schema:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:o},name:E({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:E({config:t.config.definitions.types.infer,name:a}),selector:t.api.selector(`type-infer-ref`,e)}):void 0})},km=({plugin:e})=>{e.registerSymbol({external:dm({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`:fm({getAst:(t,n)=>Dm({plugin:e,schema:t,state:Y({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:Y({_path:t._path})});break;case`parameter`:Om({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break;case`requestBody`:Om({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break;case`schema`:Om({$ref:t.$ref,plugin:e,schema:t.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break;case`webhook`:pm({getAst:(t,n)=>Dm({plugin:e,schema:t,state:Y({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:Y({_path:t._path})});break}})},Am=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.unknown})})},jm=({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:[Am({plugin:e,schema:{type:`unknown`},state:n})]});else{t=D({schema:t});let s=t.items.map((t,r)=>{let i=Um({plugin:e,schema:t,state:{...n,_path:J([...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}},Mm=({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})})},Nm=({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 Am({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},Pm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.never})})},Fm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.null})})},Im=({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},Lm=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol(e.api.selector(`external`,`zod.z`)),i=!1,a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=Um({optional:!o.includes(r),plugin:e,schema:s,state:{...n,_path:J([...n._path.value,`properties`,r])}});c.hasLazyExpression&&(i=!0),A.lastIndex=0;let l;l=A.test(r)?r.startsWith(`-`)?p.default.factory.createStringLiteral(r):p.default.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(l=`'${r}'`),a.push(F.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Um({plugin:e,schema:t.additionalProperties,state:{...n,_path:J([...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:[p.default.factory.createObjectLiteralExpression(a,!0)]}),hasLazyExpression:i}},Rm=({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},zm=({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=Um({plugin:e,schema:t,state:{...n,_path:J([...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}},Bm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.undefined})})},Vm=({plugin:e})=>{let t=e.referenceSymbol(e.api.selector(`external`,`zod.z`));return F.callExpression({functionName:F.propertyAccessExpression({expression:t.placeholder,name:Q.void})})},Hm=({schema:e,...t})=>{switch(e.type){case`array`:return jm({...t,schema:e});case`boolean`:return{expression:Mm({...t,schema:e})};case`enum`:return{expression:Nm({...t,schema:e})};case`integer`:case`number`:return{expression:Im({...t,schema:e})};case`never`:return{expression:Pm({...t,schema:e})};case`null`:return{expression:Fm({...t,schema:e})};case`object`:return Lm({...t,schema:e});case`string`:return{expression:Rm({...t,schema:e})};case`tuple`:return zm({...t,schema:e});case`undefined`:return{expression:Bm({...t,schema:e})};case`unknown`:return{expression:Am({...t,schema:e})};case`void`:return{expression:Vm({...t,schema:e})}}},Um=({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=Hm({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=D({schema:n}),n.items){let e=n.items.map((e,n)=>Um({plugin:t,schema:e,state:{...r,_path:J([...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=Um({plugin:t,schema:n,state:r});else{let e=Hm({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},Wm=({$ref:e,plugin:t,schema:n,state:r})=>{let i=Um({plugin:t,schema:n,state:r}),a=I(e),o=fp(r._path.value);um({ast:i,plugin:t,schema:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:o},name:E({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:E({config:t.config.definitions.types.infer,name:a}),selector:t.api.selector(`type-infer-ref`,e)}):void 0})},Gm=({plugin:e})=>{e.registerSymbol({external:dm({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{switch(t.type){case`operation`:fm({getAst:(t,n)=>Um({plugin:e,schema:t,state:Y({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:Y({_path:t._path})});break;case`parameter`:Wm({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break;case`requestBody`:Wm({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break;case`schema`:Wm({$ref:t.$ref,plugin:e,schema:t.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break;case`webhook`:pm({getAst:(t,n)=>Um({plugin:e,schema:t,state:Y({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:Y({_path:t._path})});break}})},Km=({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},qm=({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:[Km({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=D({schema:t});let o=t.items.map((t,i)=>{let a=ah({plugin:e,schema:t,state:{...n,_path:J([...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},Jm=({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)},Ym=({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):Km({plugin:e,schema:{type:`unknown`},state:n})},Xm=({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},Zm=({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},Qm=({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)},$m=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[],o=e.referenceSymbol(e.api.selector(`external`,`zod.z`));for(let o in t.properties){let s=t.properties[o],c=ah({optional:!a.includes(o),plugin:e,schema:s,state:{...n,_path:J([...n._path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),A.lastIndex=0;let l;l=A.test(o)?o.startsWith(`-`)?p.default.factory.createStringLiteral(o):p.default.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(l=`'${o}'`),c.hasLazyExpression?i.push(F.getAccessorDeclaration({name:l,statements:[F.returnStatement({expression:c.expression})]})):i.push(F.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=ah({plugin:e,schema:t.additionalProperties,state:{...n,_path:J([...n._path.value,`additionalProperties`])}});return r.expression=F.callExpression({functionName:F.propertyAccessExpression({expression:o.placeholder,name:Q.record}),parameters:[F.callExpression({functionName:F.propertyAccessExpression({expression:o.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:o.placeholder,name:Q.object}),parameters:[p.default.factory.createObjectLiteralExpression(i,!0)]}),r.hasLazyExpression?{...r,typeName:`ZodType`}:r},eh=({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},th=({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=ah({plugin:e,schema:t,state:{...n,_path:J([...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},nh=({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},rh=({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},ih=({schema:e,...t})=>{switch(e.type){case`array`:return qm({...t,schema:e});case`boolean`:return Jm({...t,schema:e});case`enum`:return Ym({...t,schema:e});case`integer`:case`number`:return Qm({...t,schema:e});case`never`:return Xm({...t,schema:e});case`null`:return Zm({...t,schema:e});case`object`:return $m({...t,schema:e});case`string`:return eh({...t,schema:e});case`tuple`:return th({...t,schema:e});case`undefined`:return nh({...t,schema:e});case`unknown`:return Km({...t,schema:e});case`void`:return rh({...t,schema:e})}},ah=({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=ih({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=D({schema:n}),n.items){let e=n.items.map((e,n)=>ah({plugin:t,schema:e,state:{...r,_path:J([...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=ah({plugin:t,schema:n,state:r});else i.expression=ih({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},oh=({$ref:e,plugin:t,schema:n,state:r})=>{let i=ah({plugin:t,schema:n,state:r}),a=I(e),o=fp(r._path.value);um({ast:i,plugin:t,schema:n,symbol:t.registerSymbol({exported:!0,meta:{resourceType:o},name:E({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:E({config:t.config.definitions.types.infer,name:a}),selector:t.api.selector(`type-infer-ref`,e)}):void 0})},sh=({plugin:e})=>{e.registerSymbol({external:dm({plugin:e}),name:`z`,selector:e.api.selector(`external`,`zod.z`)}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{switch(t.type){case`operation`:fm({getAst:(t,n)=>ah({plugin:e,schema:t,state:Y({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:Y({_path:t._path})});break;case`parameter`:oh({$ref:t.$ref,plugin:e,schema:t.parameter.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break;case`requestBody`:oh({$ref:t.$ref,plugin:e,schema:t.requestBody.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break;case`schema`:oh({$ref:t.$ref,plugin:e,schema:t.schema,state:Y({_path:t._path,hasLazyExpression:!1})});break;case`webhook`:pm({getAst:(t,n)=>ah({plugin:e,schema:t,state:Y({_path:n,hasLazyExpression:!1})}),operation:t.operation,plugin:e,state:Y({_path:t._path})});break}})},ch=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Gm(e);case`mini`:return km(e);case 4:default:return sh(e)}},lh={api:new lm({name:`zod`}),config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:ch,name:`zod`,resolveConfig:(e,t)=>{let n=t.package.getVersion(`zod`),r=()=>n&&(n.major===4||n.major===3)?n.major:4,i=e=>{if(!e)return r();if(!n)return e;if((e===4||e===3||e===`mini`)&&!t.package.satisfies(n,`>=3.25.0 <5.0.0`)){let t=r();return console.warn(`🔌 ${l.default.yellow(`Warning:`)} Installed ${l.default.cyan(`zod`)} ${l.default.cyan(`v${n.version}`)} does not support compatibility version ${l.default.yellow(String(e))}, using ${l.default.yellow(String(t))}.`),t}return e};e.config.compatibilityVersion=i(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{local:!1,offset:!1},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.config.types}),e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Data`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}DataZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}Response`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}ResponseZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`z{{name}}WebhookRequest`,types:{...e.config.types,infer:{...e.config.types.infer,name:`{{name}}WebhookRequestZodType`}}},mappers:{...w,object:(e,n)=>({...e,types:t.valueToObject({defaultValue:n.types,mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:w,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},uh=C(lh),dh={"@angular/common":ul,"@hey-api/client-angular":Dl,"@hey-api/client-axios":Al,"@hey-api/client-fetch":Nl,"@hey-api/client-next":Il,"@hey-api/client-nuxt":zl,"@hey-api/client-ofetch":Hl,"@hey-api/schemas":hu,"@hey-api/sdk":zu,"@hey-api/transformers":hd,"@hey-api/typescript":Vd,"@pinia/colada":sf,"@tanstack/angular-query-experimental":Yf,"@tanstack/react-query":Qf,"@tanstack/solid-query":tp,"@tanstack/svelte-query":ip,"@tanstack/vue-query":sp,arktype:Cp,fastify:Op,"legacy/angular":Wl,"legacy/axios":Kl,"legacy/fetch":Jl,"legacy/node":Xl,"legacy/xhr":Ql,valibot:tm,zod:lh},fh=[`@hey-api/typescript`,`@hey-api/sdk`],ph=({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=dh[s],l=n[s];if(!c&&!l)throw Error(`unknown plugin dependency "${s}" - do you need to register a custom plugin with this name?`);let u={...c,...l,config:{...c?.config,...l?.config},dependencies:new Set([...c?.dependencies||[],...l?.dependencies||[]])};if(u.resolveConfig){let r={package:ft(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=dh[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=dh[i]||n[i];if(t&&t.tags?.includes(e)&&i!==s)return i}throw Error(a||`missing plugin - no plugin with tag "${e}" found`)},valueToObject:Ue};u.resolveConfig(u,r)}for(let e of u.dependencies)o(e);r.delete(s),i.add(s),a[s]=u};for(let e of t)o(e);return{pluginOrder:Array.from(i),plugins:a}},mh=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`),hh=({dependencies:e,userConfig:t})=>{let n={},r=fh;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&mh(t.plugins[0])?[...fh,...t.plugins]:t.plugins),ph({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})},gh=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),_h=async({logger:e,userConfigs:t})=>{let n=[],r={},i=e.timeEvent(`load`);for(let i of t){let t;if(i?.configFile){let e=i.configFile.split(`.`);t=e.slice(0,e.length-1).join(`.`)}let a=e.timeEvent(`c12`),{loadConfig:o}=await import(`c12`),{config:s,configFile:c}=await o({configFile:t,name:`openapi-ts`});a.timeEnd(),Object.keys(r).length||(r=Ge(Object.keys(s).length?c:void 0));let u=s instanceof Array?s.map(e=>Be(e,i)):[Be(s,i)];for(let e of u){let t=Le(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${l.default.yellow(`Warning:`)} You provided ${l.default.cyan(String(r))} ${l.default.cyan(r===1?`input`:`inputs`)} and ${l.default.yellow(String(i))} ${l.default.yellow(`outputs`)}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let r of e.output)n.push({...e,input:t,output:r})}else e.output.forEach((r,i)=>{n.push({...e,input:t[i],output:r})});else n.push({...e,input:t,output:e.output[0]??``})}else n.push({...e,input:t})}}i.timeEnd();let a=[],o=e.timeEvent(`build`);for(let e of n){let{base:t,configFile:n=``,dryRun:i=!1,experimentalParser:o=!0,exportCore:s=!0,name:c,request:u,useOptions:f=!0}=e,p=e.interactive===void 0?gh():e.interactive,m=Re(e),h=Le(e),g=We(e),_=qe(e),v=[];h.length||v.push(new se(`missing input - which OpenAPI specification should we use to generate your output?`)),g.path||v.push(new se(`missing output - where should we generate your output?`)),!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=d.default.resolve(process.cwd(),g.path);let y;try{y=hh({dependencies:r,userConfig:e})}catch(e){v.push(e),y={pluginOrder:[],plugins:{}}}let ee=_e({...y,base:t,configFile:n,dryRun:i,experimentalParser:o,exportCore:!1,input:h,interactive:p,logs:m,name:c,output:g,parser:_,request:u,useOptions:f});ee.exportCore=S(ee)?s:!1;let te=a.length;if(m.level===`debug`){let e=l.default.gray(`[Job ${te+1}] `);console.warn(`${e}${l.default.cyan(`config:`)}`,ee)}a.push({config:ee,errors:v,jobIndex:te})}return o.timeEnd(),{dependencies:r,results:a}},vh=Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`}),yh=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},bh=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},xh=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Sh=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(bh(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=yh(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Ch({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Ch=({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)}`},wh=({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=xh(r),s=Object.entries(i).map(([t,i])=>Ch({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Th=({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=Sh({allowReserved:e,explode:!0,name:a,style:`form`,value:o,...t});n&&i.push(n)}else if(typeof o==`object`){let t=wh({allowReserved:e,explode:!0,name:a,style:`deepObject`,value:o,...n});t&&i.push(t)}else{let t=Ch({allowReserved:e,name:a,value:o});t&&i.push(t)}}return i.join(`&`)},Eh=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Dh=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?Eh(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},Oh=Th({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),kh=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=(0,_.getResolvedInput)({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await(0,_.sendRequest)({fetchOptions:{method:`HEAD`,...e,headers:Dh(e?.headers,r.headers)},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok&&r.isHeadMethodSupported)return{error:`not-ok`,response:s};if(r.isHeadMethodSupported===void 0&&(r.isHeadMethodSupported=s.ok),s.status===304)return{error:`not-modified`,response:s};if(o===void 0){let e=s.headers.get(`ETag`);e&&(o=e!==r.headers.get(`If-None-Match`),o&&r.headers.set(`If-None-Match`,e))}if(o===void 0){let e=s.headers.get(`Last-Modified`);e&&(o=e!==r.headers.get(`If-Modified-Since`),o&&r.headers.set(`If-Modified-Since`,e))}if(o===!1)return{error:`not-modified`,response:s}}try{let t=await(0,_.sendRequest)({fetchOptions:{method:`GET`,...e},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok)return{error:`not-ok`,response:s};if(a=s.body?await s.arrayBuffer():new ArrayBuffer(0),o===void 0){let e=new TextDecoder().decode(a);o=e!==r.lastValue,r.lastValue=e}}else r.lastValue?o=!1:r.lastValue=i.type;return o===!1?{error:`not-modified`,response:s}:{arrayBuffer:a,resolvedInput:i}};Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`F`,{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,`I`,{enumerable:!0,get:function(){return te}}),Object.defineProperty(exports,`L`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,`P`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`R`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return Re}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return ve}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return Zn}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Tl}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return C}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return pl}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return ys}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return xs}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return vr}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return fi}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return uu}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return Nc}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return ns}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return _h}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return xl}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return cs}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return fh}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return fl}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return kh}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return Pc}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return F}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return S}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return Ke}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return T}});
|
|
24
|
+
//# sourceMappingURL=getSpec-BFMqYPd3.cjs.map
|