@hey-api/openapi-ts 0.87.1 → 0.87.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/README.md +2 -0
- package/dist/clients/ky/client.ts +339 -0
- package/dist/clients/ky/index.ts +24 -0
- package/dist/clients/ky/types.ts +271 -0
- package/dist/clients/ky/utils.ts +328 -0
- package/dist/{config-PWeoedFF.d.cts → config-CQeoZYf_.d.cts} +59 -22
- package/dist/{config-CNi83ZTD.d.ts → config-U5JEpxGS.d.ts} +59 -22
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/internal.cjs +1 -1
- package/dist/internal.d.cts +1 -1
- package/dist/internal.d.ts +1 -1
- package/dist/internal.js +1 -1
- package/dist/openApi-CT-iM-D8.cjs +19 -0
- package/dist/openApi-CT-iM-D8.cjs.map +1 -0
- package/dist/openApi-HKXoyF4o.js +19 -0
- package/dist/openApi-HKXoyF4o.js.map +1 -0
- package/dist/run.cjs +1 -1
- package/dist/run.cjs.map +1 -1
- package/dist/run.js +1 -1
- package/dist/run.js.map +1 -1
- package/dist/{src-CZCpIWy7.js → src-Ba-zyEiS.js} +2 -2
- package/dist/{src-CZCpIWy7.js.map → src-Ba-zyEiS.js.map} +1 -1
- package/dist/{src-Cvd6zAsc.cjs → src-CNO_U6s-.cjs} +2 -2
- package/dist/{src-Cvd6zAsc.cjs.map → src-CNO_U6s-.cjs.map} +1 -1
- package/package.json +4 -3
- package/dist/openApi-CCTdD3hW.cjs +0 -19
- package/dist/openApi-CCTdD3hW.cjs.map +0 -1
- package/dist/openApi-D7xrG_wR.js +0 -19
- package/dist/openApi-D7xrG_wR.js.map +0 -1
|
@@ -1,19 +0,0 @@
|
|
|
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(`@hey-api/codegen-core`);l=c(l);let u=require(`ansi-colors`);u=c(u);let d=require(`node:fs`);d=c(d);let f=require(`node:path`);f=c(f);let p=require(`node:url`);p=c(p);let m=require(`typescript`);m=c(m);let h=require(`node:os`);h=c(h);let g=require(`semver`);g=c(g);let ee=require(`@hey-api/json-schema-ref-parser`);ee=c(ee);const te=(0,p.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),ne=f.default.dirname(te),re=()=>{let e=ne;for(;e!==f.default.dirname(e);){let t=d.default.readdirSync(e).filter(e=>e===`package.json`);if(t[0]){let n=f.default.join(e,t[0]);return JSON.parse(d.default.readFileSync(n,{encoding:`utf8`}))}e=f.default.dirname(e)}},ie=()=>{let e=re(),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},ae=e=>{if(e===null)return null;if(e){let t=f.default.isAbsolute(e)?e:f.default.resolve(ne,e);return d.default.existsSync(t)?t:null}let t=ne;for(;t!==f.default.dirname(t);){let e=d.default.readdirSync(t).filter(e=>e.startsWith(`tsconfig`)&&e.endsWith(`.json`)).sort(e=>e===`tsconfig.json`?-1:1);if(e[0])return f.default.join(t,e[0]);t=f.default.dirname(t)}return null},oe=e=>{if(!e)return null;let t=m.default.readConfigFile(e,m.default.sys.readFile);if(t.error)throw Error(`Couldn't read tsconfig from path: ${e}`);return m.default.parseJsonConfigFileContent(t.config,m.default.sys,f.default.dirname(e))},se=e=>{d.default.existsSync(e)||d.default.mkdirSync(e,{recursive:!0})};var ce=class extends Error{constructor(e){super(e),this.name=`ConfigError`}},le=class extends Error{errors;constructor(e){super(`Found ${e.length} configuration ${e.length===1?`error`:`errors`}.`),this.name=`ConfigValidationError`,this.errors=e}},ue=class extends Error{originalError;constructor(e,t){super(e),this.name=`JobError`,this.originalError=t}},de=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 fe=(e,t)=>{if(e instanceof ce||e instanceof le)return;e instanceof ue&&(e=e.originalError.error);let n=`openapi-ts-error-${Date.now()}.log`,r=f.default.resolve(process.cwd(),t);se(r);let i=f.default.resolve(r,n),a=`[${new Date().toISOString()}] `;e instanceof de&&(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`),d.default.writeFileSync(i,a),i},pe=async e=>{let t=ie();if(!t.bugs.url)return;e instanceof ue&&(e=e.originalError.error);let n=``;e instanceof de&&(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)},me=({error:e,logPath:t})=>{if(e instanceof le&&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=u.default.gray(`[Job ${e+1}] `),r=n.length,i=u.default.red(`Found ${r} configuration ${r===1?`error`:`errors`}:`);console.error(`${t}❗️ ${i}`),n.forEach((e,n)=>{let r=` [${n+1}] `,i=u.default.red(r);console.error(`${t}${i}${u.default.white(e.message)}`)})}}else{let t=u.default.gray(`[root] `);e instanceof ue&&(t=u.default.gray(`[Job ${e.originalError.jobIndex+1}] `),e=e.originalError.error);let n=u.default.red(`Failed with the message:`);console.error(`${t}❌ ${n}`);let r=u.default.red(` `);console.error(`${t}${r}${typeof e==`string`?e:e instanceof Error?e.message:`Unknown error`}`)}if(t){let e=u.default.gray(`[root] `);console.error(`${e}${u.default.cyan(`📄 Crash log saved to:`)} ${u.default.gray(t)}`)}},he=async({error:e,isInteractive:t})=>!t||e instanceof ce||e instanceof le?!1:new Promise(e=>{let t=u.default.gray(`[root] `);console.log(`${t}${u.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`)})}),ge=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,_e=`https://get.heyapi.dev`,ve=(e,t,n)=>`${_e}/${e}/${t}${n?`?${n}`:``}`,ye=e=>{let t=e.organization,n=e.project,r;if(e.path){let i=e.path.match(ge);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}},be=e=>{let t=ye(e);return{path:ve(t.organization,t.project,t.queryParams),registry:`hey-api`}},xe=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,Se=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,Ce=`readme`,we=e=>{let t=e.match(xe);if(!t)throw Error(`Invalid ReadMe shorthand format. Expected "${Ce}:@organization/project#uuid" or "${Ce}:uuid", received: ${Ce}:${e}`);let[,,n,r,i]=t;if(!i)throw Error(`The ReadMe UUID cannot be empty.`);return{organization:n,project:r,uuid:i}},Te=e=>{let t=we(e.slice(`${Ce}:`.length));return{...t,path:Se(t.uuid),registry:`readme`}},Ee=/^(@[\w-]+)\/([\w.-]+)$/,De=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,Oe=`scalar`,ke=e=>{let t=e.match(Ee);if(!t)throw Error(`Invalid Scalar shorthand format. Expected "${Oe}:@organization/project", received: ${Oe}:${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}},Ae=e=>{let t=ke(e.slice(`${Oe}:`.length));return{...t,path:De(t.organization,t.project),registry:`scalar`}},je=e=>{if(e.path.startsWith(`readme:`)){Object.assign(e,Te(e.path));return}if(e.path.startsWith(`scalar:`)){Object.assign(e,Ae(e.path));return}if(e.path.startsWith(`.`))return;if(e.path.startsWith(_e)){e.path=e.path.slice(23),Object.assign(e,be(e));return}let t=e.path.split(`/`);if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,be(e));return}},Me={enabled:!1,interval:1e3,timeout:6e4},Ne=e=>{let t={...Me};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},Pe=e=>{let t=e.input instanceof Array?e.input:[e.input],n=[];for(let r of t){let t={path:``,watch:Me};typeof r==`string`?t.path=r:r&&(r.path!==void 0||r.organization!==void 0)?(t={...t,path:_e,...r},t.watch!==void 0&&(t.watch=Ne(t))):t={...t,path:r},typeof t.path==`string`&&je(t),e.watch!==void 0&&t.watch.enabled===Me.enabled&&t.watch.interval===Me.interval&&t.watch.timeout===Me.timeout&&(t.watch=Ne({path:t.path,watch:e.watch})),t.path&&n.push(t)}return n},Fe=e=>{let t={file:!0,level:`info`,path:process.cwd()};return typeof e?.logs==`string`?t.path=e.logs:t={...t,...e?.logs},t},Ie=(e,t)=>{let n=e||{},r=t||{};return{...n,...r}},Le=(e,t)=>{let n=e||{},r=t||{},i={...n,...r};return typeof i.logs==`object`&&(i.logs=Ie(n.logs,r.logs)),i},Re=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e!=`function`,ze=(e,t)=>{for(let[n,r]of Object.entries(t))r!==void 0&&r!==``&&(e[n]=r);return e},_=({defaultValue:e,mappers:t,value:n})=>{let r={...e};switch(typeof n){case`boolean`:if(t&&`boolean`in t){let e=t.boolean;r=ze(r,e(n))}break;case`function`:if(t&&`function`in t){let e=t.function;r=ze(r,e(n))}break;case`number`:if(t&&`number`in t){let e=t.number;r=ze(r,e(n))}break;case`string`:if(t&&`string`in t){let e=t.string;r=ze(r,e(n))}break;case`object`:if(Re(n))if(t&&`object`in t&&typeof t.object==`function`){let i=t.object;r=ze(r,i(n,e))}else r=ze(r,n);break}return r},Be=e=>{if(e.output instanceof Array)throw Error(`Unexpected array of outputs in user configuration. This should have been expanded already.`);let t=_({defaultValue:{clean:!0,fileName:{case:`preserve`,name:`{{name}}`,suffix:`.gen`},format:null,indexFile:!0,lint:null,path:``},mappers:{object:(e,t)=>({...e,fileName:_({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=oe(ae(t.tsConfigPath)),t.importFileExtension===void 0&&t.tsConfig?.options.moduleResolution===m.default.ModuleResolutionKind.NodeNext&&(t.importFileExtension=`.js`),t.importFileExtension&&!t.importFileExtension.startsWith(`.`)&&(t.importFileExtension=`.${t.importFileExtension}`),t},Ve=e=>{let t=e?f.default.dirname(e):process.cwd();for(;t!==f.default.dirname(t);){let e=f.default.join(t,`package.json`);if(d.default.existsSync(e))try{let t=JSON.parse(d.default.readFileSync(e,`utf8`));return{...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies}}catch{}let n=f.default.dirname(t);if(n===t)break;t=n}return{}},He=[`after`,`before`,`cursor`,`offset`,`page`,`start`],Ue=e=>_({defaultValue:{hooks:{},pagination:{keywords:He},transforms:{enums:{case:`PascalCase`,enabled:!1,mode:`root`,name:`{{name}}Enum`},propertiesRequiredByDefault:!1,readWrite:{enabled:!0,requests:{case:`preserve`,name:`{{name}}Writable`},responses:{case:`preserve`,name:`{{name}}`}}},validate_EXPERIMENTAL:!1},mappers:{object:(e,t)=>({...e,pagination:_({defaultValue:{...t.pagination},value:e.pagination}),transforms:_({defaultValue:{...t.transforms},mappers:{object:(e,t)=>({...e,enums:_({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:_({defaultValue:{...t.readWrite,enabled:e.readWrite===void 0?t.readWrite.enabled:!!e.readWrite},mappers:{boolean:e=>({enabled:e}),object:(e,t)=>({...e,requests:_({defaultValue:{...t.requests},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.requests}),responses:_({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}),v=e=>t=>({...e,config:{...e.config,...t}}),y={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},We=/[\p{Lu}]/u,Ge=/[\p{Ll}]/u,Ke=/([\p{Alpha}\p{N}_]|$)/u,qe=/[_.\- `\\[\]{}\\/]+/,Je=RegExp(`^${qe.source}`),Ye=RegExp(`${qe.source}${Ke.source}`,`gu`),Xe=RegExp(`\\d+${Ke.source}`,`gu`),Ze=({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(Ge.lastIndex=0,We.lastIndex=0,We.test(s)&&(n||l&&!u&&l!==`s`&&Ge.test(l)))t=`${t.slice(0,e)}${o}${t.slice(e)}`,e++,i=r,n=!1,r=!0;else if(r&&i&&Ge.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},b=({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=Ze({case:e,string:r})),(t||r[0]!==n[0])&&(r=r.replace(Je,``)),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(Ye,(e,n,r)=>r===0&&!t?e:`_${n}`),r[r.length-1]===`_`&&(r=r.slice(0,r.length-1))):(Ye.lastIndex=0,Xe.lastIndex=0,r=r.replaceAll(Xe,(e,t,n)=>[`_`,`-`,`.`].includes(r.charAt(n+e.length))?e:e.toLocaleUpperCase()),r=r.replaceAll(Ye,(e,r,i)=>i===0&&!t&&e[0]&&n.startsWith(e[0])?e:r.toLocaleUpperCase())),r):``},x=({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 b({case:e.case,value:t})},Qe=({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]},$e=e=>{for(let t in e)if(e[t].required)return!0;return!1},et=e=>e?!!($e(e.cookie)||$e(e.header)||$e(e.path)||$e(e.query)):!1,tt=({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:Qe({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:Qe({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:Qe({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:Qe({context:e,parameter:r})}}}},S=({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},C=({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,nt=e=>!!(et(e.parameters)||e.body?.required),w=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,rt=({context:e,operation:t})=>{let n=t.body;if(!n||!n.pagination)return tt({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}:tt({context:e,parameters:t.parameters})},it=({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`}},at=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(it({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=C({items:Object.values(n.properties),mutateSchemaOneItem:!0,schema:{}});e=S({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=C({items:Object.values(r.properties),mutateSchemaOneItem:!0,schema:{}});e=S({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.response=e)}return t},ot=e=>e.replace(/^[^\p{ID_Start}]+/u,``).replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`-`).replace(/[$+]/g,`-`),st=e=>{let t=T(e);return t.name===`@hey-api/client-axios`||t.name===`@hey-api/client-nuxt`?`baseURL`:`baseUrl`},T=e=>{for(let t of e.pluginOrder){let n=e.plugins[t];if(n?.tags?.includes(`client`))return n}return{config:{name:``},name:``}},E=e=>({value:e}),D=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=E(e[n]));return t},ct=/^[^$_\p{ID_Start}]+/u,O=/^-?\d+(\.\d+)?$/,lt=/^(document|history|location|navigator|window)$/g,ut=/^(console|Array|Date|Error|Function|JSON|Map|Math|Object|Promise|RegExp|Set|WeakMap|WeakSet)$/g,dt=/^(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,ft=/^(global|process|Buffer)$/g,pt=/^(any|as|bigint|boolean|namespace|never|null|number|string|symbol|type|undefined|unknown|void)$/g,mt=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,ht=e=>(e||e===``)&&(mt.lastIndex=0,!mt.test(e))?`'${e}'`:e,gt=e=>e&&e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,e.length-1):e,_t=e=>e.replace(/\*\//g,`*`).replace(/\/\*/g,`*`).replace(/\r?\n(.*)/g,(e,t)=>h.EOL+t.trim()),vt=m.default.createPrinter({newLine:m.default.NewLineKind.LineFeed,removeComments:!1}),yt=e=>m.default.createSourceFile(``,e,m.default.ScriptTarget.ESNext,!1,m.default.ScriptKind.TS),bt=yt(``),xt=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));function St({node:e,unescape:t=!1}){let n=vt.printNode(m.default.EmitHint.Unspecified,e,bt);if(!t)return n;try{return xt(n)}catch{return n}}const k=e=>m.default.factory.createIdentifier(typeof e==`string`?e:e.text),Ct=e=>{switch(e){case`!`:return m.default.SyntaxKind.ExclamationToken;case`-`:return m.default.SyntaxKind.MinusToken}},wt=({expression:e,prefix:t})=>{let n=typeof e==`string`?k(e):e,r=typeof t==`string`?Ct(t):t;return m.default.factory.createPrefixUnaryExpression(r,n)},Tt=()=>m.default.factory.createThis(),A=({keyword:e})=>{let t=It({keyword:e});return m.default.factory.createModifier(t)},Et=({initializer:e,modifiers:t,name:n,type:r})=>{let i=Array.isArray(t)?t:[t];return m.default.factory.createPropertyDeclaration(t?i.map(e=>A({keyword:e})):void 0,n,void 0,r,e)},Dt={boolean:e=>e?m.default.factory.createTrue():m.default.factory.createFalse(),export:({alias:e,asType:t=!1,name:n})=>{let r=k(n);if(e){let n=k(e);return m.default.factory.createExportSpecifier(t,r,n)}return m.default.factory.createExportSpecifier(t,void 0,r)},import:({alias:e,asType:t=!1,name:n})=>{let r=k(n);if(e){let n=k(e);return m.default.factory.createImportSpecifier(t,r,n)}return m.default.factory.createImportSpecifier(t,void 0,r)},number:e=>e<0?wt({expression:m.default.factory.createNumericLiteral(Math.abs(e)),prefix:`-`}):m.default.factory.createNumericLiteral(e),string:(e,t=!1)=>{let n=e;t&&(n=gt(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("`")?k(n):en({text:n})}},Ot=e=>typeof e==`object`&&!!e&&typeof e.kind==`number`&&typeof e.flags==`number`&&typeof e.pos==`number`&&typeof e.end==`number`,kt=e=>e!==void 0,At=({commentObject:e,node:t})=>{let n=e.lines.filter(e=>!!e||e===``);if(!n.length)return;if(!e.jsdoc){for(let e of n)m.default.addSyntheticLeadingComment(t,m.default.SyntaxKind.SingleLineCommentTrivia,` ${e}`,!0);return}let r=n.map((e,t)=>{let r=e;return t!==n.length&&(r=`${r}\n`),m.default.factory.createJSDocText(r)}),i=St({node:m.default.factory.createJSDocComment(m.default.factory.createNodeArray(r),void 0),unescape:!0}).replace(`/*`,``).replace(`* */`,``);m.default.addSyntheticLeadingComment(t,m.default.SyntaxKind.MultiLineCommentTrivia,i,!0)},j=({comments:e=[],node:t})=>{let n=!!e.find(e=>typeof e==`object`&&e),r=e;n||(r=[{jsdoc:!0,lines:e}]);for(let e of r)At({commentObject:e,node:t})},M=(e,t)=>m.default.isTypeNode(e)?e:typeof e==`number`?m.default.factory.createLiteralTypeNode(Dt.number(e)):an({typeArguments:t?.map(e=>M(e)),typeName:m.default.isIdentifier(e)?e.text:e}),jt=({expression:e,name:t})=>m.default.factory.createPropertyAccessChain(e,m.default.factory.createToken(m.default.SyntaxKind.QuestionDotToken),t),Mt=({expression:e,isOptional:t,name:n})=>{let r=typeof e==`string`?k({text:e}):e;if(t&&typeof n!=`number`)return jt({expression:r,name:n});if(typeof n==`string`){if(mt.lastIndex=0,!mt.test(n)){!n.startsWith(`'`)&&!n.endsWith(`'`)&&(n=`\'${n}\'`);let e=k({text:n});return m.default.factory.createElementAccessExpression(r,e)}let e=k({text:n});return m.default.factory.createPropertyAccessExpression(r,e)}if(typeof n==`number`){let e=m.default.factory.createNumericLiteral(n);return m.default.factory.createElementAccessExpression(r,e)}return m.default.factory.createPropertyAccessExpression(r,n)},Nt=()=>m.default.factory.createNull(),Pt=({identifiers:e=[],isValueAccess:t,shorthand:n,unescape:r,value:i})=>{if(i===null)return Nt();if(Array.isArray(i))return Gt({elements:i});if(typeof i==`object`)return Jt({identifiers:e,obj:i,shorthand:n});if(typeof i==`number`)return Dt.number(i);if(typeof i==`boolean`)return Dt.boolean(i);if(typeof i==`string`){if(t){let e=i.split(`.`);return Mt({expression:e[0],name:e[1]})}return Dt.string(i,r)}},Ft=e=>e.map(e=>{if(`destructure`in e)return sn({name:m.default.factory.createObjectBindingPattern(e.destructure.map(e=>{if(!(`destructure`in e))return m.default.factory.createBindingElement(void 0,void 0,k({text:e.name}),void 0)}).filter(Boolean)),type:e.type===void 0?void 0:M(e.type)});let t=e.accessLevel?[A({keyword:e.accessLevel})]:[];return e.isReadOnly&&t.push(A({keyword:`readonly`})),sn({initializer:e.default===void 0?void 0:Pt({value:e.default}),modifiers:t,name:k({text:e.name}),required:e.isRequired!==!1,type:e.type===void 0?void 0:M(e.type)})}),It=({keyword:e})=>{switch(e){case`any`:return m.default.SyntaxKind.AnyKeyword;case`async`:return m.default.SyntaxKind.AsyncKeyword;case`boolean`:return m.default.SyntaxKind.BooleanKeyword;case`export`:return m.default.SyntaxKind.ExportKeyword;case`never`:return m.default.SyntaxKind.NeverKeyword;case`number`:return m.default.SyntaxKind.NumberKeyword;case`private`:return m.default.SyntaxKind.PrivateKeyword;case`protected`:return m.default.SyntaxKind.ProtectedKeyword;case`public`:return m.default.SyntaxKind.PublicKeyword;case`readonly`:return m.default.SyntaxKind.ReadonlyKeyword;case`static`:return m.default.SyntaxKind.StaticKeyword;case`string`:return m.default.SyntaxKind.StringKeyword;case`undefined`:return m.default.SyntaxKind.UndefinedKeyword;case`unknown`:return m.default.SyntaxKind.UnknownKeyword;case`void`:return m.default.SyntaxKind.VoidKeyword;default:throw Error(`unsupported syntax kind keyword "${e}"`)}},Lt=({keyword:e})=>{let t=It({keyword:e});return m.default.factory.createKeywordTypeNode(t)},Rt=e=>e.map(e=>m.default.isTypeParameterDeclaration(e)?e:Bt({constraint:e.extends?typeof e.extends==`string`?Lt({keyword:`boolean`}):e.extends:void 0,defaultType:e.default===void 0?void 0:Ot(e.default)?e.default:m.default.factory.createLiteralTypeNode(e.default?m.default.factory.createTrue():m.default.factory.createFalse()),name:e.name})),zt=({operator:e,type:t})=>{let n=e===`keyof`?m.default.SyntaxKind.KeyOfKeyword:e===`readonly`?m.default.SyntaxKind.ReadonlyKeyword:m.default.SyntaxKind.UniqueKeyword;return m.default.factory.createTypeOperatorNode(n,t)},Bt=({constraint:e,defaultType:t,modifiers:n,name:r})=>m.default.factory.createTypeParameterDeclaration(n,r,e,t),Vt=({members:e,nameType:t,questionToken:n,readonlyToken:r,type:i,typeParameter:a})=>m.default.factory.createMappedTypeNode(r,a,t,n,i,e),Ht=({literal:e})=>m.default.factory.createLiteralTypeNode(e),Ut=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=m.default.factory.createArrowFunction(e?[A({keyword:`async`})]:void 0,o?Rt(o):void 0,Ft(r),i?M(i):void 0,void 0,Array.isArray(a)?N({multiLine:n,statements:a}):a);return j({comments:t,node:s}),s},Wt=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=m.default.factory.createFunctionExpression(e?[A({keyword:`async`})]:void 0,void 0,void 0,o?Rt(o):void 0,Ft(r),i?M(i):void 0,N({multiLine:n,statements:a}));return j({comments:t,node:s}),s},Gt=({elements:e,multiLine:t=!1})=>m.default.factory.createArrayLiteralExpression(e.map(e=>Ot(e)?e:Pt({value:e})).filter(kt),t||!Array.isArray(e[0])&&typeof e[0]==`object`),Kt=({expression:e})=>m.default.factory.createAwaitExpression(e),qt=({parameters:e=[],returnType:t,typeParameters:n})=>m.default.factory.createFunctionTypeNode(n,e,t),Jt=({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=Ot(e.spread)?e.spread:k({text:e.spread});o=m.default.factory.createSpreadAssignment(e.assertion?pn({expression:t,type:typeof e.assertion==`string`?Lt({keyword:e.assertion}):e.assertion}):t)}else if(e.shorthand||i&&r)o=m.default.factory.createShorthandPropertyAssignment(e.value);else{let r=Ot(e.value)?e.value:Array.isArray(e.value)&&(!e.value.length||typeof e.value[0]==`object`)?Jt({multiLine:n,obj:e.value,shorthand:i,unescape:a}):Pt({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)&&!m.default.isObjectLiteralExpression(r)&&(r=k({text:e.value})),o=dn({initializer:r,name:e.key})}return j({comments:e.comments,node:o}),o}).filter(kt):Object.entries(r).map(([e,n])=>{let r=Pt({identifiers:t.includes(e)?Object.keys(n):[],shorthand:i,unescape:a,value:n});if(!r)return;t.includes(e)&&!m.default.isObjectLiteralExpression(r)&&(r=k({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?m.default.factory.createShorthandPropertyAssignment(n):dn({initializer:r,name:e})}).filter(kt),s=m.default.factory.createObjectLiteralExpression(o,n);return j({comments:e,node:s}),s},Yt=({asConst:e,comments:t={},leadingComment:n,name:r,obj:i})=>{let a=Array.isArray(i)?i.map(e=>{let t=Xt({initializer:Pt({value:e.value}),name:e.key});return j({comments:e.comments,node:t}),t}):Object.entries(i).map(([e,n])=>{let r=m.default.factory.createEnumMember(e,Pt({unescape:!0,value:n}));return j({comments:t[e],node:r}),r}),o=[A({keyword:`export`})],s=e?[m.default.factory.createToken(m.default.SyntaxKind.ConstKeyword)]:[],c=[...o,...s],l=m.default.factory.createEnumDeclaration(c,typeof r==`string`?k({text:r}):r,a);return j({comments:n,node:l}),l},Xt=({initializer:e,name:t})=>{let n=t;return typeof n==`string`&&(n=n.includes(`'`)?en({isSingleQuote:!1,text:n}):ht(n)),m.default.factory.createEnumMember(n,e)},Zt=({name:e,statements:t})=>m.default.factory.createModuleDeclaration([A({keyword:`export`})],k({text:e}),m.default.factory.createModuleBlock(t),m.default.NodeFlags.Namespace),Qt=({indexType:e,objectType:t})=>m.default.factory.createIndexedAccessTypeNode(t,e),$t=({modifiers:e,name:t,returnType:n,statements:r})=>{let i=Array.isArray(e)?e:[e];return m.default.factory.createGetAccessorDeclaration(e?i.map(e=>A({keyword:e})):void 0,t,[],n?an({typeName:n}):void 0,N({statements:r}))},en=({isSingleQuote:e,text:t})=>(e===void 0&&(e=!t.includes(`'`)),m.default.factory.createStringLiteral(t,e)),tn=({condition:e,whenFalse:t,whenTrue:n})=>m.default.factory.createConditionalExpression(e,m.default.factory.createToken(m.default.SyntaxKind.QuestionToken),n,m.default.factory.createToken(m.default.SyntaxKind.ColonToken),t),nn=({text:e})=>m.default.factory.createTypeOfExpression(typeof e==`string`?k({text:e}):e),rn=({comment:e,exportType:t,name:n,type:r,typeParameters:i=[]})=>{let a=m.default.factory.createTypeAliasDeclaration(t?[A({keyword:`export`})]:void 0,typeof n==`string`?k({text:n}):n,Rt(i),M(r));return j({comments:e,node:a}),a},an=({typeArguments:e,typeName:t})=>m.default.factory.createTypeReferenceNode(t,e),on=({type:e})=>m.default.factory.createParenthesizedType(e),sn=({initializer:e,modifiers:t,name:n,required:r=!0,type:i})=>m.default.factory.createParameterDeclaration(t,void 0,n,r?void 0:m.default.factory.createToken(m.default.SyntaxKind.QuestionToken),i,e),cn=({argumentsArray:e,expression:t,typeArguments:n})=>m.default.factory.createNewExpression(t,n,e),ln=({awaitModifier:e,expression:t,initializer:n,statement:r})=>m.default.factory.createForOfStatement(e,n,t,r),un=({left:e,right:t})=>m.default.factory.createAssignment(e,t),N=({multiLine:e=!0,statements:t})=>m.default.factory.createBlock(t,e),dn=({initializer:e,name:t})=>m.default.factory.createPropertyAssignment(t,e),fn=({flags:e=[],text:t})=>{let n=`/${(t.startsWith(`/`)&&t.endsWith(`/`)?t.slice(1,-1):t).replace(/(?<!\\)\//g,`\\/`)}/`;return m.default.factory.createRegularExpressionLiteral(`${n}${e.join(``)}`)},pn=({expression:e,type:t})=>m.default.factory.createAsExpression(e,t),mn=({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?m.default.factory.createTemplateMiddle(n):m.default.factory.createTemplateTail(n),i=m.default.factory.createTemplateLiteralTypeSpan(r,e);t.push(i),n=``}return m.default.factory.createTemplateLiteralType(m.default.factory.createTemplateHead(n),t.reverse())},hn=({module:e,shouldAppendJs:t})=>m.default.factory.createExportDeclaration(void 0,!1,void 0,Dt.string(t?`${e}.js`:e)),gn=({functionName:e,parameters:t=[],types:n})=>{let r=typeof e==`string`?k({text:e}):e,i=t.filter(e=>e!==void 0).map(e=>typeof e==`string`?k({text:e}):e);return m.default.factory.createCallExpression(r,n,i)},_n=({exports:e,module:t})=>{let n=Array.isArray(e)?e:[e],r=n.some(e=>typeof e!=`object`||!e.asType),i=n.map(e=>{let t=typeof e==`string`?{name:e}:e;return Dt.export({alias:t.alias,asType:r&&t.asType,name:t.name})}),a=m.default.factory.createNamedExports(i),o=Dt.string(t);return m.default.factory.createExportDeclaration(void 0,!r,a,o)},vn=({assertion:e,comment:t,destructure:n,exportConst:r,expression:i,name:a,typeName:o})=>{let s=e?pn({expression:i,type:typeof e==`string`?an({typeName:e}):e}):i,c=typeof a==`string`?k({text:a}):a,l=m.default.factory.createVariableDeclaration(n?m.default.factory.createObjectBindingPattern([m.default.factory.createBindingElement(void 0,void 0,c,void 0)]):c,void 0,o?typeof o==`string`?an({typeName:o}):o:void 0,s),u=m.default.factory.createVariableStatement(r?[A({keyword:`export`})]:void 0,m.default.factory.createVariableDeclarationList([l],m.default.NodeFlags.Const));return j({comments:t,node:u}),u},yn=({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(Dt.import({alias:t.alias,asType:r&&t.asType,name:t.name}))});let o=i?m.default.factory.createNamespaceImport(k({text:i.alias})):m.default.factory.createNamedImports(a),s=m.default.factory.createImportClause(!r,void 0,o),c=Dt.string(t);return m.default.factory.createImportDeclaration(void 0,s,c)},bn=({accessLevel:e,comment:t,multiLine:n=!0,parameters:r=[],statements:i=[]})=>{let a=e?[A({keyword:e})]:void 0,o=m.default.factory.createConstructorDeclaration(a,Ft(r),N({multiLine:n,statements:i}));return j({comments:t,node:o}),o},xn=({accessLevel:e,comment:t,isStatic:n=!1,multiLine:r=!0,name:i,parameters:a=[],returnType:o,statements:s=[],types:c=[]})=>{let l=e?[A({keyword:e})]:[];n&&l.push(A({keyword:`static`}));let u=m.default.factory.createMethodDeclaration(l,void 0,k({text:i}),void 0,c?Rt(c):void 0,Ft(a),o?M(o):void 0,N({multiLine:r,statements:s}));return j({comments:t,node:u}),u},Sn=({decorator:e,exportClass:t,extendedClasses:n,name:r,nodes:i,typeParameters:a})=>{let o=[];t&&o.push(A({keyword:`export`})),e&&o.unshift(m.default.factory.createDecorator(gn({functionName:e.name,parameters:e.args.map(e=>Pt({value:e})).filter(kt)})));let s=[];if(n)for(let e of n)s.push(m.default.factory.createHeritageClause(m.default.SyntaxKind.ExtendsKeyword,[m.default.factory.createExpressionWithTypeArguments(k({text:e}),void 0)]));return m.default.factory.createClassDeclaration(o,k({text:r}),a,s,i)},Cn=({expression:e})=>m.default.factory.createExpressionStatement(e),wn=({expression:e})=>m.default.factory.createReturnStatement(e),Tn=({args:e=[],name:t,types:n=[]})=>{let r=n.map(e=>an({typeName:e}));return wn({expression:gn({functionName:t,parameters:e.map(e=>m.default.isExpression(e)?e:k({text:e})).filter(kt),types:r})})},En=({expression:e})=>wn({expression:typeof e==`string`?k({text:e}):e}),Dn=e=>e.slice(1).reduce((e,t)=>(mt.lastIndex=0,mt.test(t)?jt({expression:e,name:t}):m.default.factory.createElementAccessChain(e,m.default.factory.createToken(m.default.SyntaxKind.QuestionDotToken),k({text:t}))),k({text:e[0]})),On=e=>e.slice(1).reduce((e,t)=>Mt({expression:e,name:t}),k({text:e[0]})),kn=({expressions:e})=>e.reduce((e,t)=>Mt({expression:e,name:t})),An=({left:e,operator:t=`=`,right:n})=>m.default.factory.createBinaryExpression(e,t===`=`?m.default.SyntaxKind.EqualsToken:t===`===`?m.default.SyntaxKind.EqualsEqualsEqualsToken:t===`!==`?m.default.SyntaxKind.ExclamationEqualsEqualsToken:t===`??`?m.default.SyntaxKind.QuestionQuestionToken:m.default.SyntaxKind.InKeyword,typeof n==`string`?k({text:n}):n),jn=({elseStatement:e,expression:t,thenStatement:n})=>m.default.factory.createIfStatement(t,n,e),Mn=({path:e})=>{let t=Dn(e),n=On(e);return jn({expression:t,thenStatement:N({statements:[Cn({expression:An({left:n,right:cn({argumentsArray:[n],expression:k({text:`Date`})})})})]})})},Nn=({path:e,transformerName:t})=>[jn({expression:Dn(e),thenStatement:N({statements:[Cn({expression:gn({functionName:t,parameters:[On(e)]})})]})})],Pn=({path:e,transformerName:t})=>{let n=Dn(e),r=On(e);return jn({expression:gn({functionName:Mt({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:N({statements:[Cn({expression:m.default.factory.createCallChain(Mt({expression:r,name:`forEach`}),void 0,void 0,[k({text:t})])})]})})},Fn=({parameterName:e})=>{let t=k({text:`Date`});return cn({argumentsArray:[k({text:e})],expression:t})},In=({path:e,transformExpression:t})=>{let n=Dn(e),r=On(e);return jn({expression:gn({functionName:Mt({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:N({statements:[Cn({expression:An({left:r,right:m.default.factory.createCallChain(Mt({expression:r,name:`map`}),void 0,void 0,[Ut({parameters:[{name:`item`}],statements:t})])})})]})})},Ln=an({typeName:`null`}),Rn=({isNullable:e,node:t})=>e?m.default.factory.createUnionTypeNode([t,Ln]):t,zn=({indexKey:e,indexProperty:t,isNullable:n,properties:r,useLegacyResolution:i})=>{let a=[],o=r.map(e=>{let t=e.isReadOnly?[A({keyword:`readonly`})]:void 0,n=e.isRequired===!1?m.default.factory.createToken(m.default.SyntaxKind.QuestionToken):void 0,r=M(e.type);a.push(r);let o=m.default.factory.createPropertySignature(t,i||typeof e.name==`string`&&e.name.match(mt)||typeof e.name!=`string`&&m.default.isPropertyName(e.name)?e.name:en({text:e.name}),n,r);return j({comments:e.comment,node:o}),o}),s=!1;if(t)if(!r.length&&e){let n=Vt({questionToken:m.default.factory.createToken(m.default.SyntaxKind.QuestionToken),type:t.type??Lt({keyword:`string`}),typeParameter:Bt({constraint:e,name:k({text:String(t.name)})})});o.push(n),s=!0}else{let e=t.isReadOnly?[A({keyword:`readonly`})]:void 0,n=m.default.factory.createIndexSignature(e,[sn({name:k({text:String(t.name)}),type:Lt({keyword:`string`})})],M(t.type));o.push(n)}return Rn({isNullable:n,node:s?o[0]:m.default.factory.createTypeLiteralNode(o)})},Bn=({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=M(e);m.default.isUnionTypeNode(t)?n.push(...t.types):n.push(t)}return Rn({isNullable:e,node:m.default.factory.createUnionTypeNode(n)})},Vn=({isNullable:e,types:t})=>{let n=[];for(let e of t){let t=M(e);m.default.isIntersectionTypeNode(t)?n.push(...t.types):n.push(t)}return Rn({isNullable:e,node:m.default.factory.createIntersectionTypeNode(n)})},Hn=({isNullable:e=!1,types:t})=>{let n=t.map(e=>M(e));return Rn({isNullable:e,node:m.default.factory.createTupleTypeNode(n)})},Un=(e,t,n=!1,r=!0)=>{let i=Bn({types:e}),a=Bn({types:t});return Rn({isNullable:n,node:zn({properties:[{name:`[key: ${St({node:i,unescape:!0})}]`,type:a}],useLegacyResolution:r})})},Wn=(e,t=!1)=>Rn({isNullable:t,node:an({typeArguments:[Array.isArray(e)?Bn({types:e}):e],typeName:`Array`})}),P={anonymousFunction:Wt,arrayLiteralExpression:Gt,arrowFunction:Ut,asExpression:pn,assignment:un,awaitExpression:Kt,binaryExpression:An,block:N,callExpression:gn,classDeclaration:Sn,conditionalExpression:tn,constVariable:vn,constructorDeclaration:bn,enumDeclaration:Yt,exportAllDeclaration:hn,exportNamedDeclaration:_n,expressionToStatement:Cn,forOfStatement:ln,functionTypeNode:qt,getAccessorDeclaration:$t,identifier:k,ifStatement:jn,indexedAccessTypeNode:Qt,isTsNode:Ot,keywordTypeNode:Lt,literalTypeNode:Ht,mappedTypeNode:Vt,methodDeclaration:xn,namedImportDeclarations:yn,namespaceDeclaration:Zt,newExpression:cn,nodeToString:St,null:Nt,objectExpression:Jt,ots:Dt,parameterDeclaration:sn,prefixUnaryExpression:wt,propertyAccessExpression:Mt,propertyAccessExpressions:kn,propertyAssignment:dn,propertyDeclaration:Et,regularExpressionLiteral:fn,returnFunctionCall:Tn,returnStatement:wn,returnVariable:En,safeAccessExpression:Dn,stringLiteral:en,templateLiteralType:mn,this:Tt,transformArrayMap:In,transformArrayMutation:Pn,transformDateMutation:Mn,transformFunctionMutation:Nn,transformNewDate:Fn,typeAliasDeclaration:rn,typeArrayNode:Wn,typeInterfaceNode:zn,typeIntersectionNode:Vn,typeNode:M,typeOfExpression:nn,typeOperatorNode:zt,typeParameterDeclaration:Bt,typeParenthesizedNode:on,typeRecordNode:Un,typeReferenceNode:an,typeTupleNode:Hn,typeUnionNode:Bn,valueToExpression:Pt},Gn=P,Kn=({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},qn=({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}},Jn=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return[];let n=[];for(let t of e.security){let e=qn({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},Yn=`TComposable`,Xn=`DefaultT`,Zn=`ResT`,Qn=/~1/g,$n=/~0/g,F=e=>{let t=tr(e),n=t[t.length-1];return decodeURI(n)},er=e=>String(e).replace(/~/g,`~0`).replace(/\//g,`~1`),tr=e=>{let t=e.trim();return t.startsWith(`#`)&&(t=t.slice(1)),t.startsWith(`/`)&&(t=t.slice(1)),t?t.split(`/`).map(e=>e.replace(Qn,`/`).replace($n,`~`)):[]},nr=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},rr=e=>{let t=e.map(er).join(`/`);return`#`+(t?`/${t}`:``)},ir=({$ref:e,spec:t})=>{let n=tr(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},ar=({operation:e})=>{let t=[`header`,`path`,`query`],n={},r=(e,t)=>{n[e]||(n[e]=new Set),n[e].add(t)};for(let n of t){let t=e.parameters?.[n];if(t)for(let e in t){let i=t[e];r(i.name,n)}}if(e.body)if(!e.body.schema.logicalOperator&&e.body.schema.type===`object`&&e.body.schema.properties){let t=e.body.schema.properties;for(let e in t)r(e,`body`)}else e.body.schema.$ref?r(b({case:`camelCase`,value:F(e.body.schema.$ref)}),`body`):r(`body`,`body`);let i=new Set;for(let e in n)n[e].size>1&&i.add(e);let a={},o=[];for(let n of t){let t=e.parameters?.[n];if(t)for(let e in t){let r=t[e],s=r.name,c=i.has(s)?`${n}_${s}`:s,l={isRequired:r.required??!1,name:c,schema:r.schema};c!==s&&(l.originalName=s),a[c]=l,o.push({in:n===`header`?`headers`:n,key:c,...c===s?{}:{map:s}})}}if(e.body){let t=`body`;if(!e.body.schema.logicalOperator&&e.body.schema.type===`object`&&e.body.schema.properties){let n=e.body.schema.properties;for(let e in n){let r=n[e],s=i.has(e)?`${t}_${e}`:e,c={isRequired:r.required?.includes(e)??!1,name:s,schema:r};s!==e&&(c.originalName=e),a[s]=c,o.push({in:t,key:s,...s===e?{}:{map:e}})}}else if(e.body.schema.$ref){let n=b({case:`camelCase`,value:F(e.body.schema.$ref)}),r=i.has(n)?`${t}_${n}`:n,s={isRequired:e.body.required??!1,name:r,schema:e.body.schema};r!==n&&(s.originalName=n),a[r]=s,o.push({key:r,map:`body`})}else a.body={isRequired:e.body.required??!1,name:`body`,schema:e.body.schema},o.push({in:`body`})}if(Object.keys(a).length)return{fields:o,parameters:a}},or=({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})},sr=({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})},cr=({context:e,value:t})=>{let n=b({case:`PascalCase`,value:ot(t)});return Kn({config:e.config,name:n})},lr=({operation:e,plugin:t})=>t.config.methodNameBuilder?t.config.methodNameBuilder(e):!t.config.asClass&&e.id.match(dt)?`${e.id}_`:e.id,ur=({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=b({case:`camelCase`,value:ot(o.pop())}),i=o.pop()));let s=n.config.instance?[n.config.instance]:t.tags??[`default`];for(let c of s){let s=cr({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||lr({operation:t,plugin:n}),path:l.map(t=>cr({context:e,value:t}))})}return r},dr=({isDataAllowed:e=!0,operation:t,plugin:n,throwOnError:r})=>{let i=T(n.context.config).name===`@hey-api/client-nuxt`,a=e?n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`data`,tool:`typescript`}):void 0,o=n.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`});if(i){let r=n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`response`}),i=e?a?.placeholder||`unknown`:`never`,s=r?.placeholder||`unknown`;return`${o.placeholder}<${Yn}, ${i}, ${s}, ${Xn}>`}if(r){let t=e?a?.placeholder||`unknown`:`never`;return`${o.placeholder}<${t}, ${r}>`}let s=e?a?.placeholder:`never`;return s?`${o.placeholder}<${s}>`:o.placeholder},fr=({isRequiredOptions:e,operation:t,plugin:n})=>{let r={argNames:[],fields:[],parameters:[]},i=n.getPluginOrThrow(`@hey-api/typescript`),a=T(n.context.config).name===`@hey-api/client-nuxt`;if(n.config.paramsStructure===`flat`){let e=ar({operation:t,plugin:n}),a=[];if(e){let t=!1;for(let n in e.parameters){let r=e.parameters[n];r.isRequired&&(t=!0),a.push({isRequired:r.isRequired,name:r.name,type:i.api.schemaToType({plugin:i,schema:r.schema,state:D({path:[]})})})}r.argNames.push(`parameters`);for(let t of e.fields)r.fields.push(t);r.parameters.push({isRequired:t,name:`parameters`,type:P.typeInterfaceNode({properties:a,useLegacyResolution:!1})})}}return r.parameters.push({isRequired:e,name:`options`,type:dr({isDataAllowed:n.config.paramsStructure===`grouped`,operation:t,plugin:n,throwOnError:a?void 0:`ThrowOnError`})}),r},pr=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`}},mr=({isRequiredOptions:e,opParameters:t,operation:n,plugin:r})=>{let i=T(r.context.config),a=i.name===`@hey-api/client-nuxt`,o=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:a?`response`:`responses`})?.placeholder||`unknown`,s=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:a?`error`:`errors`})?.placeholder||`unknown`,c=[];if(n.body)switch(n.body.type){case`form-data`:{let e=r.referenceSymbol({category:`external`,resource:`client.formDataBodySerializer`});c.push({spread:e.placeholder});break}case`json`:break;case`text`:case`octet-stream`:c.push({key:`bodySerializer`,value:null});break;case`url-search-params`:{let e=r.referenceSymbol({category:`external`,resource:`client.urlSearchParamsBodySerializer`});c.push({spread:e.placeholder});break}}let l=[];for(let e in n.parameters?.query){let t=n.parameters.query[e];t.schema.type===`array`||t.schema.type===`tuple`?(t.style!==`form`||!t.explode)&&l.push({key:t.name,value:[{key:`array`,value:[{key:`explode`,value:t.explode===!0?void 0:t.explode},{key:`style`,value:t.style===`form`?void 0:t.style}].filter(({value:e})=>e!==void 0)}]}):t.schema.type===`object`&&(t.style!==`deepObject`||!t.explode)&&l.push({key:t.name,value:[{key:`object`,value:[{key:`explode`,value:t.explode===!0?void 0:t.explode},{key:`style`,value:t.style===`deepObject`?void 0:t.style}].filter(({value:e})=>e!==void 0)}]})}l.length&&c.push({key:`querySerializer`,value:[{key:`parameters`,value:l}]});let u=or({operation:n,plugin:r});if(u&&c.push({key:`requestValidator`,value:u}),r.config.transformer){let e={category:`transform`,resource:`operation`,resourceId:n.id,role:`response`};if(r.isSymbolRegistered(e)){let t=r.referenceSymbol(e);c.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`&&it({statusCode:e})===`2XX`&&(f=pr(t.mediaType),f&&c.push({key:`responseType`,value:f})),t.mediaType===`text/event-stream`&&(d=!0)}let p=sr({operation:n,plugin:r});p&&c.push({key:`responseValidator`,value:p}),r.config.responseStyle===`data`&&c.push({key:`responseStyle`,value:r.config.responseStyle});let m=Jn({context:r.context,operation:n,plugin:r});m.length&&c.push({key:`security`,value:P.arrayLiteralExpression({elements:m})}),c.push({key:`url`,value:n.path}),c.push({spread:`options`});let h=[],g=t.argNames.length;if(g){let e=[],n=[];for(let n of t.argNames)e.push(P.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(P.objectExpression({obj:t}))}let i=r.referenceSymbol({category:`external`,resource:`client.buildClientParams`});h.push(P.constVariable({expression:P.callExpression({functionName:i.placeholder,parameters:[P.arrayLiteralExpression({elements:e}),P.arrayLiteralExpression({elements:n})]}),name:`params`})),c.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:P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!e,name:`headers`})}];g&&r.push({spread:P.propertyAccessExpression({expression:P.identifier({text:`params`}),name:`headers`})}),c.push({key:`headers`,value:r})}}let ee=r.config.client?r.getSymbol({category:`client`}):void 0,te=P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!e,name:`client`}),ne;ne=r.config.instance?P.binaryExpression({left:te,operator:`??`,right:P.propertyAccessExpression({expression:P.this(),name:`client`})}):ee?P.binaryExpression({left:te,operator:`??`,right:ee.placeholder}):te;let re=[];a?re.push(Yn,`${o} | ${Xn}`,s,Xn):re.push(o,s,`ThrowOnError`),r.config.responseStyle===`data`&&re.push(P.stringLiteral({text:r.config.responseStyle}));let ie=d?P.propertyAccessExpression({expression:ne,name:P.identifier({text:`sse`})}):ne;return ie=P.propertyAccessExpression({expression:ie,name:P.identifier({text:n.method})}),h.push(P.returnFunctionCall({args:[P.objectExpression({identifiers:[`responseTransformer`],obj:c})],name:ie,types:re})),h},I=({operation:e})=>{let t=[];if(e.summary&&t.push(_t(e.summary)),e.description&&(t.length&&t.push(``),t.push(_t(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length)return t},hr=({context:e,operation:t})=>{let n=T(e.config).name===`@hey-api/client-nuxt`,r=e.config.plugins[`@hey-api/sdk`];if(r){if(!r.config.client&&!r.config.instance)return!0;if(r.config.paramsStructure===`flat`)return!1}return n||nt(t)},gr=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType===`text/event-stream`)return!0;return!1},_r=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=hr({context:e.context,operation:n}),a=ur({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=br({isRequiredOptions:i,methodName:l,operation:n,plugin:e});c.nodes.length?c.nodes.push(P.identifier({text:`
|
|
3
|
-
`}),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(P.propertyDeclaration({initializer:P.newExpression({argumentsArray:[],expression:P.identifier({text:x({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:a.className})})}),name:b({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol({category:`external`,resource:`@angular/core.Injectable`}),o=e.registerSymbol({exported:!0,meta:{category:`utility`,resource:`class`,resourceId:r.className,tool:`angular`},name:x({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:r.className})}),s=P.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)},vr=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=hr({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,meta:{category:`utility`,resource:`operation`,resourceId:t.id,role:`data`,tool:`angular`},name:e.config.httpRequests.methodNameBuilder(t)}),i=xr({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},yr=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`client`}),r=P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!0,name:`client`}),i;return i=n?P.binaryExpression({left:r,operator:`??`,right:n.placeholder}):r,P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:`requestOptions`}),parameters:[P.objectExpression({obj:[{key:`responseStyle`,value:P.identifier({text:`'data'`})},{key:`method`,value:P.identifier({text:`'${e.method.toUpperCase()}'`})},{key:`url`,value:P.identifier({text:`'${e.path}'`})},{spread:`options`}]})]})},br=({isRequiredOptions:e,methodName:t,operation:n,plugin:r})=>{let i=r.referenceSymbol({category:`external`,resource:`@angular/common/http.HttpRequest`}),a=r.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),o=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return P.methodDeclaration({accessLevel:`public`,comment:I({operation:n}),name:t,parameters:[{isRequired:e,name:`options`,type:`${a.placeholder}<${o}, ThrowOnError>`}],returnType:`${i.placeholder}<unknown>`,statements:[P.returnStatement({expression:yr({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},xr=({isRequiredOptions:e,operation:t,plugin:n,symbol:r})=>{let i=n.referenceSymbol({category:`external`,resource:`@angular/common/http.HttpRequest`}),a=n.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),o=n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return P.constVariable({comment:I({operation:t}),exportConst:r.exported,expression:P.arrowFunction({parameters:[{isRequired:e,name:`options`,type:`${a.placeholder}<${o}, ThrowOnError>`}],returnType:`${i.placeholder}<unknown>`,statements:[P.returnStatement({expression:yr({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},Sr=({plugin:e})=>{e.config.httpRequests.asClass?_r({plugin:e}):vr({plugin:e})},Cr=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=hr({context:e.context,operation:n}),a=ur({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=Er({isRequiredOptions:i,methodName:l,operation:n,plugin:e});c.nodes.length?c.nodes.push(P.identifier({text:`
|
|
4
|
-
`}),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(P.propertyDeclaration({initializer:P.newExpression({argumentsArray:[],expression:P.identifier({text:x({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:a.className})})}),name:b({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol({category:`external`,resource:`@angular/core.Injectable`}),o=e.registerSymbol({exported:!0,name:x({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:r.className})}),s=P.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)},wr=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=hr({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,name:e.config.httpResources.methodNameBuilder(t)}),i=Dr({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},Tr=({operation:e,plugin:t})=>{let n=t.getPluginOrThrow(`@hey-api/sdk`),r=t.referenceSymbol({category:`external`,resource:`@angular/common/http.httpResource`}),i=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`;if(t.config.httpRequests.asClass){let a=ur({context:t.context,operation:e,plugin:n}),o=Array.from(a.values())[0];if(o){let n=o.path[0],a=t.referenceSymbol({category:`utility`,resource:`class`,resourceId:n,tool:`angular`}),s=t.referenceSymbol({category:`external`,resource:`@angular/core.inject`}),c=P.callExpression({functionName:s.placeholder,parameters:[P.identifier({text:a.placeholder})]});for(let e=1;e<o.path.length;e++){let t=o.path[e];t&&(c=P.propertyAccessExpression({expression:c,name:b({case:`camelCase`,value:t})}))}return c=P.propertyAccessExpression({expression:c,name:t.config.httpRequests.methodNameBuilder(e)}),P.callExpression({functionName:r.placeholder,parameters:[P.arrowFunction({parameters:[],statements:[P.constVariable({expression:P.conditionalExpression({condition:P.identifier({text:`options`}),whenFalse:P.identifier({text:`undefined`}),whenTrue:P.callExpression({functionName:`options`,parameters:[]})}),name:`opts`}),P.returnStatement({expression:P.conditionalExpression({condition:P.identifier({text:`opts`}),whenFalse:P.identifier({text:`undefined`}),whenTrue:P.callExpression({functionName:c,parameters:[P.identifier({text:`opts`})]})})})]})],types:[P.typeNode(i)]})}}else{let n=t.referenceSymbol({category:`utility`,resource:`operation`,resourceId:e.id,role:`data`,tool:`angular`});return P.callExpression({functionName:r.placeholder,parameters:[P.arrowFunction({parameters:[],statements:[P.constVariable({expression:P.conditionalExpression({condition:P.identifier({text:`options`}),whenFalse:P.identifier({text:`undefined`}),whenTrue:P.callExpression({functionName:`options`,parameters:[]})}),name:`opts`}),P.returnStatement({expression:P.conditionalExpression({condition:P.identifier({text:`opts`}),whenFalse:P.identifier({text:`undefined`}),whenTrue:P.callExpression({functionName:n.placeholder,parameters:[P.identifier({text:`opts`})]})})})]})],types:[P.typeNode(i)]})}return P.callExpression({functionName:r.placeholder,parameters:[P.arrowFunction({parameters:[],statements:[P.returnStatement({expression:P.identifier({text:`undefined`})})]})],types:[P.typeNode(i)]})},Er=({isRequiredOptions:e,methodName:t,operation:n,plugin:r})=>{let i=r.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),a=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return P.methodDeclaration({accessLevel:`public`,comment:I({operation:n}),name:t,parameters:[{isRequired:e,name:`options`,type:`() => ${i.placeholder}<${a}, ThrowOnError> | undefined`}],returnType:void 0,statements:[P.returnStatement({expression:Tr({operation:n,plugin:r})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]})},Dr=({isRequiredOptions:e,operation:t,plugin:n,symbol:r})=>{let i=n.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),a=n.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`data`,tool:`typescript`})?.placeholder||`unknown`;return P.constVariable({comment:I({operation:t}),exportConst:r.exported,expression:P.arrowFunction({parameters:[{isRequired:e,name:`options`,type:`() => ${i.placeholder}<${a}, ThrowOnError> | undefined`}],statements:[P.returnStatement({expression:Tr({operation:t,plugin:n})})],types:[{default:!1,extends:`boolean`,name:`ThrowOnError`}]}),name:r.placeholder})},Or=({plugin:e})=>{e.config.httpResources.asClass?Cr({plugin:e}):wr({plugin:e})},kr=({plugin:e})=>{e.registerSymbol({external:`@angular/common/http`,kind:`type`,meta:{category:`external`,resource:`@angular/common/http.HttpRequest`},name:`HttpRequest`}),e.registerSymbol({external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.inject`},name:`inject`}),e.registerSymbol({external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.Injectable`},name:`Injectable`}),e.registerSymbol({external:`@angular/common/http`,meta:{category:`external`,resource:`@angular/common/http.httpResource`},name:`httpResource`}),e.config.httpRequests.enabled&&Sr({plugin:e}),e.config.httpResources.enabled&&Or({plugin:e})},Ar={config:{exportFromIndex:!1},dependencies:[`@hey-api/client-angular`,`@hey-api/sdk`],handler:kr,name:`@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`}}},jr=v(Ar),Mr={baseUrl:!0,bundle:!0,exportFromIndex:!1},Nr={dependencies:[`@hey-api/typescript`],tags:[`client`]},Pr=(0,p.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),Fr=f.default.dirname(Pr),Ir=e=>{let t=T(e);if(`bundle`in t.config&&t.config.bundle){let t=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return f.default.resolve(e.output.path,`client`,`${t?.get(`index`)??`index`}.ts`)}return t.name},Lr=(e,t)=>{if(d.default.statSync(e).isDirectory()){d.default.existsSync(t)||d.default.mkdirSync(t,{recursive:!0});let n=d.default.readdirSync(e);for(let r of n)Lr(f.default.join(e,r),f.default.join(t,r))}else{let n=d.default.readFileSync(e);d.default.writeFileSync(t,n)}},Rr=({filePath:e,project:t,renamed:n})=>{let r=f.default.extname(e),i=f.default.basename(e,r),a=t.fileName?.(i)||i;if(a!==i){let t=f.default.dirname(e);d.default.renameSync(e,f.default.resolve(t,`${a}${r}`)),n.set(i,a)}},zr=({filePath:e,meta:t,renamed:n})=>{let r=d.default.readFileSync(e,`utf8`);r=r.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g,(e,r)=>{let i=e.indexOf(r),a=f.default.extname(r),o=f.default.basename(r,a),s=f.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
|
|
5
|
-
|
|
6
|
-
${r}`,d.default.writeFileSync(e,r,`utf8`)},Br=({meta:e,outputPath:t,plugin:n,project:r})=>{let i=new Map;if(n.name.startsWith(`@hey-api/client-`)){let a=f.default.resolve(t,`core`);se(a),Lr(f.default.resolve(Fr,`clients`,`core`),a);let o=f.default.resolve(t,`client`);se(o);let s=n.name.slice(16);if(Lr(f.default.resolve(Fr,`clients`,s),o),r){let e=d.default.readdirSync(a);for(let t of e)Rr({filePath:f.default.resolve(a,t),project:r,renamed:i});let t=d.default.readdirSync(o);for(let e of t)Rr({filePath:f.default.resolve(o,e),project:r,renamed:i})}let c=d.default.readdirSync(a);for(let t of c)zr({filePath:f.default.resolve(a,t),meta:e,renamed:i});let l=d.default.readdirSync(o);for(let t of l)zr({filePath:f.default.resolve(o,t),meta:e,renamed:i});return i}let a=f.default.isAbsolute(n.name)?f.default.dirname(n.name):void 0;if(a){let e=f.default.resolve(t,`client`);se(e),Lr(a,e);return}let o=f.default.normalize(require.resolve(n.name)).split(f.default.sep),s=o.slice(0,o.indexOf(`dist`)+1).join(f.default.sep),c=[o[o.length-1],`index.d.ts`,`index.d.cts`],l=f.default.resolve(t,`client`);se(l);for(let e of c)d.default.copyFileSync(f.default.resolve(s,e),f.default.resolve(l,e))},Vr=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,Hr=e=>{let t={host:``,path:``,port:``,protocol:``};Vr.lastIndex=0;let n=e.match(Vr);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}},Ur=({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},Wr=({plugin:e})=>{let t=Ir(e.context.config),n=e.registerSymbol({external:t,name:`createClient`}),r=e.registerSymbol({external:t,name:`createConfig`}),i=e.referenceSymbol({category:`type`,resource:`client`,role:`options`}),{runtimeConfigPath:a}=e.config,o=a?e.registerSymbol({external:a,name:`createClientConfig`}):void 0,s=[],c=Ur({plugin:e});if(c){let t=Hr(c);if(t.protocol&&t.host&&!c.includes(`{`))s.push({key:st(e.context.config),value:c});else if(c!==`/`&&c.startsWith(`/`)){let t=c.endsWith(`/`)?c.slice(0,-1):c;s.push({key:st(e.context.config),value:t})}}`throwOnError`in e.config&&e.config.throwOnError&&s.push({key:`throwOnError`,value:!0});let l=[P.callExpression({functionName:r.placeholder,parameters:s.length?[P.objectExpression({obj:s})]:void 0,types:[P.typeReferenceNode({typeName:i.placeholder})]})],u=e.registerSymbol({meta:{category:`client`},name:`client`}),d=P.constVariable({exportConst:!0,expression:P.callExpression({functionName:n.placeholder,parameters:o?[P.callExpression({functionName:o.placeholder,parameters:l})]:l}),name:u.placeholder});e.setSymbolValue(u,d)},Gr=({plugin:e})=>{let t=Ir(e.context.config),n=e.referenceSymbol({category:`type`,resource:`client`,role:`options`}),r=e.registerSymbol({external:t,kind:`type`,name:`Config`}),i=e.registerSymbol({external:t,kind:`type`,name:`ClientOptions`}),a=e.registerSymbol({exported:!0,kind:`type`,name:`CreateClientConfig`}),o=P.typeReferenceNode({typeName:i.placeholder}),s=P.typeReferenceNode({typeName:`T`}),c=P.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:a.exported,name:a.placeholder,type:P.functionTypeNode({parameters:[P.parameterDeclaration({name:`override`,required:!1,type:P.typeReferenceNode({typeArguments:[P.typeIntersectionNode({types:[o,s]})],typeName:r.placeholder})})],returnType:P.typeReferenceNode({typeArguments:[P.typeIntersectionNode({types:[P.typeReferenceNode({typeArguments:[o],typeName:`Required`}),s]})],typeName:r.placeholder})}),typeParameters:[{default:P.typeReferenceNode({typeName:n.placeholder}),extends:o,name:`T`}]});e.setSymbolValue(a,c)},Kr=({plugin:e})=>{Gr({plugin:e}),Wr({plugin:e})},qr={...Nr,config:{...Mr,throwOnError:!1},handler:Kr,name:`@hey-api/client-angular`},Jr=v(qr),Yr={...Nr,config:{...Mr,throwOnError:!1},handler:Kr,name:`@hey-api/client-axios`},Xr=v(Yr),Zr={...Nr,config:{...Mr,throwOnError:!1},handler:Kr,name:`@hey-api/client-fetch`},Qr=v(Zr),$r={...Nr,config:{...Mr,throwOnError:!1},handler:Kr,name:`@hey-api/client-next`},ei=v($r),ti={...Nr,config:Mr,handler:Kr,name:`@hey-api/client-nuxt`},ni=v(ti),ri={...Nr,config:{...Mr,throwOnError:!1},handler:Kr,name:`@hey-api/client-ofetch`},ii=v(ri),ai=(...e)=>g.satisfies(...e),oi=e=>({getVersion:t=>{let n=e[t];if(n)try{let e=g.parse(n);if(e)return e;let t=g.minVersion(n);if(t)return t;if(e=g.coerce(n),e)return e}catch{}},isInstalled:t=>!!e[t],satisfies:(t,n,r)=>{let i=typeof t==`string`?e[t]:t;return i?ai(i,n,r):!1}}),si=[dt,pt,ut,ft,lt],ci=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`);if(ct.lastIndex=0,ct.test(t))return`_${t}`;for(let e of si){if(t.startsWith(`_`))return t;t=t.replace(e,`_$1`)}return t},li=({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)},ui=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>ui({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(r.$ref)return r.$ref=decodeURI(r.$ref),r;if(li({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=ui({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>ui({context:e,plugin:t,schema:n})),r.items&&=ui({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]=ui({context:e,plugin:t,schema:i}))}return r},di=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>di({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(`$ref`in r)return r.$ref=decodeURI(r.$ref),r;if(li({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=di({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>di({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>di({context:e,plugin:t,schema:n})),r.items&&=di({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>di({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]=di({context:e,plugin:t,schema:i}))}return r},fi=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>fi({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(li({plugin:t,schema:r}),r.$ref&&=decodeURI(r.$ref),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=fi({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>fi({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>fi({context:e,plugin:t,schema:n})),r.items&&=fi({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>fi({context:e,plugin:t,schema:n})),r.prefixItems&&=r.prefixItems.map(n=>fi({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]=fi({context:e,plugin:t,schema:i}))}return r},pi=({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`,ci(r)},mi=({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,meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`},name:pi({name:n,plugin:t,schema:r})}),a=ui({context:e,plugin:t,schema:r}),o=P.constVariable({assertion:`const`,exportConst:i.exported,expression:P.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},hi=({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,meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`},name:pi({name:n,plugin:t,schema:r})}),a=di({context:e,plugin:t,schema:r}),o=P.constVariable({assertion:`const`,exportConst:i.exported,expression:P.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},gi=({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,meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`},name:pi({name:n,plugin:t,schema:r})}),a=fi({context:e,plugin:t,schema:r}),o=P.constVariable({assertion:`const`,exportConst:i.exported,expression:P.objectExpression({obj:a}),name:i.placeholder});t.setSymbolValue(i,o)}},_i=({plugin:e})=>{if(`swagger`in e.context.spec){mi({context:e.context,plugin:e});return}if(ai(e.context.spec.openapi,`>=3.0.0 <3.1.0`)){hi({context:e.context,plugin:e});return}if(ai(e.context.spec.openapi,`>=3.1.0`)){gi({context:e.context,plugin:e});return}throw Error(`Unsupported OpenAPI specification`)},vi={config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:_i,name:`@hey-api/schemas`},yi=v(vi);var L=class e{$expr(e){return typeof e==`string`?m.default.factory.createIdentifier(e):e}$if(e,t,n){return e?t(this,e)??this:n?n(this,e)??this:this}$node(e){if(e!==void 0)return typeof e==`string`?this.$expr(e):e instanceof Array?e.map(e=>this._render(e)):this._render(e)}$stmt(e){return(e instanceof Array?e:[e]).map(e=>{let t=typeof e==`string`?m.default.factory.createIdentifier(e):this._render(e);return m.default.isExpression(t)?m.default.factory.createExpressionStatement(t):t})}$type(e){if(e!==void 0){if(typeof e==`string`)return m.default.factory.createTypeReferenceNode(e);if(typeof e==`boolean`){let t=e?m.default.factory.createTrue():m.default.factory.createFalse();return m.default.factory.createLiteralTypeNode(t)}return this._render(e)}}_render(t){return t instanceof e?t.$render():t}},bi=class extends L{callee;callArgs=[];constructor(e,...t){super(),this.callee=e,t.length&&(this.callArgs=t)}args(...e){return this.callArgs=e,this}$render(){let e=this.$node(this.callee),t=this.$node(this.callArgs).map(e=>this.$expr(e));return m.default.factory.createCallExpression(e,void 0,t)}},xi=class{attr(e){return new Ti(this,e)}call(...e){return new bi(this,...e)}};function R(e,...t){let n=e.prototype;for(let r of t){let[t,i]=r instanceof Array?r:[r],a=t;if(typeof t==`function`)try{let n=t(e);n?.prototype&&(a=n)}catch{}let o=a.prototype;if(o)for(let[e,t]of Object.entries(Object.getOwnPropertyDescriptors(o)))e!==`constructor`&&(e===`$render`&&!i?.overrideRender||Object.defineProperty(n,e,t))}}var z=class extends L{left;operator;right;constructor(e,t,n){super(),this.left=e,this.operator=t,this.right=n}$render(){let e=this.$node(this.left),t=this.$node(this.right),n=typeof this.operator==`string`?this.mapOperator(this.operator):this.operator;return m.default.factory.createBinaryExpression(e,n,t)}mapOperator(e){let t={"!=":m.default.SyntaxKind.ExclamationEqualsToken,"!==":m.default.SyntaxKind.ExclamationEqualsEqualsToken,"&&":m.default.SyntaxKind.AmpersandAmpersandToken,"*":m.default.SyntaxKind.AsteriskToken,"+":m.default.SyntaxKind.PlusToken,"-":m.default.SyntaxKind.MinusToken,"/":m.default.SyntaxKind.SlashToken,"<":m.default.SyntaxKind.LessThanToken,"<=":m.default.SyntaxKind.LessThanEqualsToken,"=":m.default.SyntaxKind.EqualsToken,"==":m.default.SyntaxKind.EqualsEqualsToken,"===":m.default.SyntaxKind.EqualsEqualsEqualsToken,">":m.default.SyntaxKind.GreaterThanToken,">=":m.default.SyntaxKind.GreaterThanEqualsToken,"??":m.default.SyntaxKind.QuestionQuestionToken,"||":m.default.SyntaxKind.BarBarToken}[e];if(!t)throw Error(`Unsupported operator: ${e}`);return t}},Si=class{assign(e){return new z(this,`=`,e)}},Ci=class{and(e){return new z(this,`&&`,e)}coalesce(e){return new z(this,`??`,e)}div(e){return new z(this,`/`,e)}eq(e){return new z(this,`===`,e)}gt(e){return new z(this,`>`,e)}gte(e){return new z(this,`>=`,e)}looseEq(e){return new z(this,`==`,e)}looseNeq(e){return new z(this,`!=`,e)}lt(e){return new z(this,`<`,e)}lte(e){return new z(this,`<=`,e)}minus(e){return new z(this,`-`,e)}neq(e){return new z(this,`!==`,e)}or(e){return new z(this,`||`,e)}plus(e){return new z(this,`+`,e)}times(e){return new z(this,`*`,e)}},wi=class{isOptional;questionToken;optional(e=!0){return e&&(this.isOptional=!0,this.questionToken=m.default.factory.createToken(m.default.SyntaxKind.QuestionToken)),this}},Ti=class extends L{left;right;constructor(e,t){super(),this.left=e,this.right=t}$render(){let e=this.$node(this.left);return this.isOptional?m.default.factory.createPropertyAccessChain(e,m.default.factory.createToken(m.default.SyntaxKind.QuestionDotToken),m.default.factory.createIdentifier(this.right)):m.default.factory.createPropertyAccessExpression(e,m.default.factory.createIdentifier(this.right))}};R(Ti,xi,Si,Ci,wi);var Ei=class extends L{input;constructor(e){super(),this.input=e}$render(){return this.$node(this.input)}};R(Ei,xi,Ci);var Di=class extends L{props=[];layout=3;constructor(e){super(),e&&e(this)}auto(e=3){return this.layout=e,this}inline(){return this.layout=!1,this}pretty(){return this.layout=!0,this}prop(e,t){let n=t(e=>new Ei(e));return this.props.push({expr:n,name:e}),this}$render(){let e=this.props.map(({expr:e,name:t})=>m.default.factory.createPropertyAssignment(t,e.$render())),t=typeof this.layout==`number`?this.props.length>=this.layout:this.layout;return m.default.factory.createObjectLiteralExpression(e,t)}},Oi=class extends L{decorators;decorator(e,t){if(!e)return this;let n=this.$expr(e),r=n;if(t){let e=new Di(t);r=m.default.factory.createCallExpression(n,void 0,[e.$render()])}return(this.decorators??=[]).push(m.default.factory.createDecorator(r)),this}$render(){throw Error(`noop`)}},ki=class extends L{_lines=[];constructor(e,t){super(),e&&(typeof e==`string`?this.add(e):this.add(...e)),t&&t(this)}add(...e){return this._lines.push(...e),this}apply(e){let t=this._lines.filter(e=>!!e||e===``);if(!t.length)return e;let n=t.map((e,n)=>{let r=e;return n!==t.length&&(r=`${r}\n`),m.default.factory.createJSDocText(r)}),r=m.default.factory.createJSDocComment(m.default.factory.createNodeArray(n),void 0),i=m.default.createPrinter().printNode(m.default.EmitHint.Unspecified,r,e.getSourceFile?.()??m.default.createSourceFile(``,``,m.default.ScriptTarget.Latest)).replace(`/*`,``).replace(`* */`,``);return m.default.addSyntheticLeadingComment(e,m.default.SyntaxKind.MultiLineCommentTrivia,i,!0),e}$render(){return m.default.factory.createIdentifier(``)}};function Ai(e){let t=class extends e{_desc;describe(e,t){return this._desc=new ki(e,t),this}},n=e.prototype.$render;return t.prototype.$render=function(...e){let t=n.apply(this,e);return this._desc?this._desc.apply(t):t},t}function ji(e){let t=[];function n(n,r=!0){return r&&t.push(m.default.factory.createModifier(n)),e}Object.assign(e,{_m:n});function r(){return t}return{list:r}}var Mi=class{abstract(e=!0){return this._m(m.default.SyntaxKind.AbstractKeyword,e)}},Ni=class{async(e=!0){return this._m(m.default.SyntaxKind.AsyncKeyword,e)}},Pi=class{default(e=!0){return this._m(m.default.SyntaxKind.DefaultKeyword,e)}},Fi=class{export(e=!0){return this._m(m.default.SyntaxKind.ExportKeyword,e)}},Ii=class{private(e=!0){return this._m(m.default.SyntaxKind.PrivateKeyword,e)}},Li=class{protected(e=!0){return this._m(m.default.SyntaxKind.ProtectedKeyword,e)}},Ri=class{public(e=!0){return this._m(m.default.SyntaxKind.PublicKeyword,e)}},zi=class{readonly(e=!0){return this._m(m.default.SyntaxKind.ReadonlyKeyword,e)}},Bi=class{static(e=!0){return this._m(m.default.SyntaxKind.StaticKeyword,e)}},Vi=class extends L{value;constructor(e){super(),this.value=e}$render(){switch(typeof this.value){case`boolean`:return this.value?m.default.factory.createTrue():m.default.factory.createFalse();case`number`:return m.default.factory.createNumericLiteral(this.value);case`string`:return m.default.factory.createStringLiteral(this.value);default:throw Error(`Unsupported literal: ${String(this.value)}`)}}},Hi=class extends L{_generics;generic(e,t){let n=new Gi(e,t);return this._generics||=[],this._generics.push(n),this}generics(...e){return this._generics=[...e],this}$generics(){return this._generics?.map(e=>typeof e==`string`?m.default.factory.createTypeParameterDeclaration(void 0,m.default.factory.createIdentifier(e),void 0,void 0):this.$node(e))}$render(){throw Error(`noop`)}},Ui=class extends L{base;constraint;defaultValue;constructor(e){super(),e&&(this.base=this.$expr(e))}default(e){return this.defaultValue=e,this}extends(e){return this.constraint=e,this}},Wi=class extends Ui{objectBuilder;constructor(e,t){super(e),t&&t(this)}object(e){return this.objectBuilder=new qi(e),this}$render(){if(this.objectBuilder)return m.default.factory.createTypeLiteralNode(this.objectBuilder.$render());if(!this.base)throw Error(`Missing base type`);let e=this._generics?.map(e=>this.$type(e));return m.default.factory.createTypeReferenceNode(this.base,e)}};R(Wi,Hi);var Gi=class extends Ui{constructor(e,t){super(e),t&&t(this)}$render(){if(!this.base)throw Error(`Missing type name`);return m.default.factory.createTypeParameterDeclaration(void 0,this.base,this.$type(this.constraint),this.$type(this.defaultValue))}};R(Gi,Hi);var Ki=class extends L{literal;constructor(e){super(),this.literal=new Vi(e)}$render(){let e=this.literal.$render();return m.default.factory.createLiteralTypeNode(e)}},qi=class{props=[];constructor(e){e(this)}prop(e,t){let n=new Ji(e,t);return this.props.push(n),this}$render(){return this.props.map(e=>e.$render())}},Ji=class{name;typeInput;constructor(e,t){this.name=e,t(this)}type(e){return this.typeInput=e,this}$render(){if(!this.typeInput)throw Error(`Type not specified for property '${this.name}'`);let e=typeof this.typeInput==`string`?m.default.factory.createTypeReferenceNode(this.typeInput):this.typeInput;return m.default.factory.createPropertySignature(void 0,m.default.factory.createIdentifier(this.name),this.questionToken,e)}};R(Ji,wi);const Yi=Object.assign((...e)=>new Wi(...e),{literal:(...e)=>new Ki(...e),object:(...e)=>new qi(...e),param:(...e)=>new Gi(...e),ref:(...e)=>new Wi(...e)});function Xi(e){let t=e.$type.bind(e),n,r;function i(){return n?n.$render():t(r)}function a(t){return t===void 0?(n||=Yi(),n):(r=t,e)}return{$render:i,method:a}}var Zi=class{initializer;assign(e){return this.initializer=e,this}},Qi=class extends L{modifiers=ji(this);name;_type=Xi(this);constructor(e,t){super(),this.name=e,t&&t(this)}type=this._type.method;$render(){return m.default.factory.createPropertyDeclaration([...this.decorators??[],...this.modifiers.list()],m.default.factory.createIdentifier(this.name),void 0,this._type.$render(),this.$node(this.initializer))}};R(Qi,Oi,[Ai,{overrideRender:!0}],Ii,Li,Ri,zi,Bi,Zi);var $i=class extends L{name;_type=Xi(this);constructor(e,t){super(),this.name=e,t&&t(this)}type=this._type.method;$render(){return m.default.factory.createParameterDeclaration(this.decorators,void 0,m.default.factory.createIdentifier(this.name),this.questionToken,this._type.$render(),this.$node(this.initializer))}};R($i,Oi,wi,Zi);var ea=class{_params;param(e,t){let n=new $i(e,t);return this._params||=[],this._params.push(n),this}params(...e){return this._params||=[],this._params.push(...e),this}},ta=class extends L{body=[];modifiers=ji(this);constructor(e){super(),e&&e(this)}do(...e){return this.body.push(...e),this}$render(){let e=this.$node(this._params??[]),t=this.$stmt(this.body);return m.default.factory.createConstructorDeclaration([...this.decorators??[],...this.modifiers.list()],e,m.default.factory.createBlock(t,!0))}};R(ta,Oi,[Ai,{overrideRender:!0}],ea,Ii,Li,Ri);var na=class extends L{body=[];modifiers=ji(this);name;_returns=Xi(this);constructor(e,t){super(),this.name=e,t&&t(this)}returns=this._returns.method;do(...e){return this.body.push(...e),this}$render(){let e=this.$node(this._params??[]),t=this.$stmt(this.body);return m.default.factory.createMethodDeclaration([...this.decorators??[],...this.modifiers.list()],void 0,m.default.factory.createIdentifier(this.name),this.questionToken,this.$generics(),e,this._returns.$render(),m.default.factory.createBlock(t,!0))}};R(na,Mi,Ni,Oi,[Ai,{overrideRender:!0}],Hi,wi,ea,Ii,Li,Ri,Bi);var ra=class extends L{$render(){return m.default.factory.createIdentifier(`
|
|
7
|
-
`)}},ia=class extends L{heritageClauses=[];body=[];modifiers=ji(this);name;constructor(e){super(),this.name=e}init(e){let t=new ta(e);return this.body.push(t),this}extends(e){return e&&this.heritageClauses.push(m.default.factory.createHeritageClause(m.default.SyntaxKind.ExtendsKeyword,[m.default.factory.createExpressionWithTypeArguments(this.$expr(e),void 0)])),this}field(e,t){let n=new Qi(e,t);return this.body.push(n),this}method(e,t){let n=new na(e,t);return this.body.push(n),this}do(...e){return this.body.push(...e),this}newline(){return this.body.push(new ra),this}$render(){let e=this.$node(this.body);return m.default.factory.createClassDeclaration([...this.decorators??[],...this.modifiers.list()],m.default.factory.createIdentifier(this.name),this.$generics(),this.heritageClauses,e)}};R(ia,Mi,Oi,[Ai,{overrideRender:!0}],Pi,Fi,Hi);var aa=class extends L{modifiers=ji(this);name;constructor(e){super(),this.name=e}$render(){return m.default.factory.createVariableStatement(this.modifiers.list(),m.default.factory.createVariableDeclarationList([m.default.factory.createVariableDeclaration(m.default.factory.createIdentifier(this.name),void 0,void 0,this.$node(this.initializer))],m.default.NodeFlags.Const))}};R(aa,Pi,[Ai,{overrideRender:!0}],Fi,Zi);var oa=class extends L{body=[];modifiers=ji(this);name;constructor(e,t){super(),this.name=e,t&&t(this)}do(...e){return this.body.push(...e),this}$render(){let e=this.$node(this._params??[]),t=this.$stmt(this.body);return m.default.factory.createGetAccessorDeclaration([...this.decorators??[],...this.modifiers.list()],this.name,e,void 0,m.default.factory.createBlock(t,!0))}};R(oa,Mi,Oi,[Ai,{overrideRender:!0}],ea,Ii,Li,Ri,Bi);var sa=class extends L{conditionInput;thenInput;elseInput;constructor(e){super(),e&&this.condition(e)}condition(e){return this.conditionInput=e,this}do(...e){return this.thenInput=e,this}otherwise(...e){return this.elseInput=e,this}$render(){if(!this.conditionInput)throw Error(`Missing condition in if`);if(!this.thenInput)throw Error(`Missing then block in if`);let e=this.$node(this.conditionInput),t=this.$node(this.thenInput),n=t.length===1?t[0]:m.default.factory.createBlock(t,!0),r=m.default.isBlock(n)?n:m.default.factory.createBlock([n],!0),i;if(this.elseInput){let e=this.$node(this.elseInput),t=e.length===1?e[0]:m.default.factory.createBlock(e,!0);i=m.default.isBlock(t)?t:m.default.factory.createBlock([t],!0)}return m.default.factory.createIfStatement(e,r,i)}},ca=class extends L{classExpr;argList=[];constructor(e,...t){super(),this.classExpr=e,t.length&&(this.argList=[...t])}args(...e){return this.argList=[...e],this}$render(){let e=this.$node(this.classExpr),t=this.$node(this.argList).map(e=>this.$expr(e)),n=this._generics?.map(e=>this.$type(e));return m.default.factory.createNewExpression(e,n,t)}};R(ca,Hi);var la=class extends L{exprInput;constructor(e){super(),this.exprInput=e}$render(){let e=this.$node(this.exprInput);return m.default.factory.createPrefixUnaryExpression(m.default.SyntaxKind.ExclamationToken,e)}},ua=class extends L{expr;constructor(e){super(),this.expr=e}$render(){let e=this.$node(this.expr);return m.default.factory.createReturnStatement(e)}},da=class extends L{body=[];modifiers=ji(this);name;constructor(e,t){super(),this.name=e,t&&t(this)}do(...e){return this.body.push(...e),this}$render(){let e=this.$node(this._params??[]),t=this.$stmt(this.body);return m.default.factory.createSetAccessorDeclaration([...this.decorators??[],...this.modifiers.list()],this.name,e,m.default.factory.createBlock(t,!0))}};R(da,Mi,Oi,[Ai,{overrideRender:!0}],ea,Ii,Li,Ri,Bi);var fa=class extends L{parts=[];constructor(e){super(),e!==void 0&&this.add(e)}add(e){return this.parts.push(e),this}$render(){let e=this.$node(this.parts),t=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`){let i=r;for(;n+1<e.length&&typeof e[n+1]==`string`;)i+=e[n+1],n++;t.push(i)}else t.push(r)}if((t.length===0||typeof t[0]!=`string`)&&t.unshift(``),t.length===1&&typeof t[0]==`string`)return m.default.factory.createNoSubstitutionTemplateLiteral(t[0]);if(t.length===2&&typeof t[0]==`string`&&typeof t[1]!=`string`)return m.default.factory.createTemplateExpression(m.default.factory.createTemplateHead(t[0]),[m.default.factory.createTemplateSpan(t[1],m.default.factory.createTemplateTail(``))]);let n=m.default.factory.createTemplateHead(t.shift()),r=[];for(;t.length;){let e=t.shift(),n=typeof t[0]==`string`?t.shift():``,i=t.length===0;r.push(m.default.factory.createTemplateSpan(e,i?m.default.factory.createTemplateTail(n):m.default.factory.createTemplateMiddle(n)))}return m.default.factory.createTemplateExpression(n,r)}},pa=class extends L{error;msg;useNew;constructor(e,t=!0){super(),this.error=e,this.useNew=t}message(e){return this.msg=e,this}$render(){let e=this.$node(this.error),t=this.$node(this.msg?[this.msg]:[]).map(e=>typeof e==`string`?m.default.factory.createStringLiteral(e):e);if(this.useNew)return m.default.factory.createThrowStatement(m.default.factory.createNewExpression(e,void 0,t));let n=t.length?[m.default.factory.createCallExpression(e,void 0,t)]:[e];return m.default.factory.createThrowStatement(n[0])}};const ma={attr:(...e)=>new Ti(...e),binary:(...e)=>new z(...e),call:(...e)=>new bi(...e),class:(...e)=>new ia(...e),const:(...e)=>new aa(...e),describe:(...e)=>new ki(...e),expr:(...e)=>new Ei(...e),field:(...e)=>new Qi(...e),getter:(...e)=>new oa(...e),if:(...e)=>new sa(...e),init:(...e)=>new ta(...e),literal:(...e)=>new Vi(...e),method:(...e)=>new na(...e),new:(...e)=>new ca(...e),newline:(...e)=>new ra(...e),not:(...e)=>new la(...e),object:(...e)=>new Di(...e),param:(...e)=>new $i(...e),return:(...e)=>new ua(...e),setter:(...e)=>new da(...e),template:(...e)=>new fa(...e),throw:(...e)=>new pa(...e),type:Yi},B=Object.assign((...e)=>new Ei(...e),ma),ha=`__registry`,ga=({sdkName:e,symbol:t})=>{let n=`defaultKey`,r=`instances`;return B.class(t.placeholder).export(t.exported).generic(`T`).field(n,e=>e.private().readonly().assign(B.literal(`default`))).newline().field(r,e=>e.private().readonly().type(B.type(`Map`).generics(`string`,`T`)).assign(B.new(`Map`))).newline().method(`get`,t=>t.returns(`T`).param(`key`,e=>e.type(`string`).optional()).do(B.const(`instance`).assign(B(`this`).attr(`instances`).attr(`get`).call(B(`key`).coalesce(B(`this`).attr(n)))),B.if(B.not(`instance`)).do(B.throw(`Error`).message(B.template(`No SDK client found. Create one with "new `).add(e).add(`()" to fix this error.`))),B.return(`instance`))).newline().method(`set`,e=>e.returns(`void`).param(`value`,e=>e.type(`T`)).param(`key`,e=>e.type(`string`).optional()).do(B(`this`).attr(r).attr(`set`).call(B(`key`).coalesce(B(`this`).attr(n)),`value`)))},_a=({plugin:e,symbol:t})=>{let n=e.getSymbol({category:`client`}),r=!!(e.config.client&&n),i=e.referenceSymbol({category:`external`,resource:`client.Client`});return B.class(t.placeholder).export(t.exported).field(`client`,e=>e.protected().type(i.placeholder)).newline().init(e=>e.param(`args`,e=>e.optional(r).type().object(e=>e.prop(`client`,e=>e.optional(r).type(i.placeholder)))).do(B(`this`).attr(`client`).assign(B(`args`).attr(`client`).optional(r).$if(r,e=>e.coalesce(n.placeholder)))))},va=({plugin:e})=>{let t=T(e.context.config),n=t.name===`@hey-api/client-angular`,r=t.name===`@hey-api/client-nuxt`,i=new Map,a=new Set;e.forEach(`operation`,({operation:a})=>{let o=hr({context:e.context,operation:a}),s=r?e.querySymbol({category:`type`,resource:`operation`,resourceId:a.id,role:`response`}):void 0,c=ur({context:e.context,operation:a,plugin:e});for(let l of c.values())l.path.forEach((c,u)=>{let d=e.referenceSymbol({category:`utility`,resource:`class`,resourceId:c,tool:`sdk`});i.has(d.meta.resourceId)||i.set(d.meta.resourceId,{className:d.meta.resourceId,classes:new Set,id:d.id,methods:new Set,nodes:[],root:!u});let f=l.path[u-1];if(f){let t=e.referenceSymbol({category:`utility`,resource:`class`,resourceId:f,tool:`sdk`});if(t.meta?.resourceId!==d.meta?.resourceId){let e=i.get(t.meta.resourceId);e.classes.add(d.meta.resourceId),i.set(t.meta.resourceId,e)}}if(l.path.length!==u+1)return;let p=i.get(d.meta.resourceId);if(p.methods.has(l.methodName))return;let m=fr({isRequiredOptions:o,operation:a,plugin:e}),h=mr({isRequiredOptions:o,opParameters:m,operation:a,plugin:e}),g=B.method(l.methodName,i=>i.$if(I({operation:a}),(e,t)=>e.describe(t)).public().static(!n&&!e.config.instance).$if(r,t=>t.generic(Yn,t=>t.extends(e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder).default(B.type.literal(`$fetch`))).generic(Xn,e=>e.$if(s,(e,t)=>e.extends(t.placeholder).default(t.placeholder))),e=>e.generic(`ThrowOnError`,e=>e.extends(`boolean`).default((`throwOnError`in t.config?t.config.throwOnError:!1)??!1))).params(...Ft(m.parameters)).do(...h));p.nodes.length?p.nodes.push(B.newline(),g):p.nodes.push(g),p.methods.add(l.methodName),i.set(d.meta.resourceId,p)})},{order:`declarations`});let o=e.config.instance?e.registerSymbol({exported:!1,kind:`class`,meta:{category:`utility`,resource:`class`,resourceId:`HeyApiClient`,tool:`sdk`},name:`HeyApiClient`}):void 0,s=e.config.instance?e.registerSymbol({exported:!1,kind:`class`,meta:{category:`utility`,resource:`class`,resourceId:`HeyApiRegistry`,tool:`sdk`},name:`HeyApiRegistry`}):void 0,c=t=>{if(a.has(t.className))return;let r=t.className;if(a.add(r),t.classes.size)for(let n of t.classes){let r=i.get(n);c(r);let a=e.referenceSymbol({category:`utility`,resource:`class`,resourceId:r.className,tool:`sdk`}),o=b({case:`camelCase`,value:a.meta.resourceId});if(t.methods.has(o)){let e=2,n=`${o}${e}`;for(;t.methods.has(n);)n=`${o}${e++}`;o=n}t.methods.add(o);let s;s=e.isSymbolRegistered(a.id)?B.field(o,t=>t.static(!e.config.instance).assign(e.config.instance?B.new(a.placeholder).args(B.object(e=>e.prop(`client`,()=>B(`this`).attr(`client`)))):B(a.placeholder))):B.getter(o,t=>t.$if(!e.config.instance,e=>e.public().static()).do(e.config.instance?B.return(B.new(a.placeholder).args(B.object(e=>e.prop(`client`,()=>B(`this`).attr(`client`))))):B.return(a.placeholder))),t.nodes.length?t.nodes.push(B.newline(),s):t.nodes.push(s)}if(o&&!e.gen.symbols.hasValue(o.id)){let t=_a({plugin:e,symbol:o}).$render();e.setSymbolValue(o,t)}let l=e.registerSymbol({exported:!0,kind:`class`,meta:{category:`utility`,resource:`class`,resourceId:r,tool:`sdk`},name:r});if(t.root&&s){let n=e.getSymbol({category:`client`}),r=!e.config.client||!n,i=e.referenceSymbol({category:`external`,resource:`client.Client`}),a=B.init(e=>e.param(`args`,e=>e.optional(!r).type().object(e=>e.prop(`client`,e=>e.optional(!r).type(i.placeholder)).prop(`key`,e=>e.optional().type(`string`)))).do(B(`super`).call(`args`),B(l.placeholder).attr(ha).attr(`set`).call(`this`,B(`args`).attr(`key`).optional(!r))));t.nodes.length?t.nodes.unshift(a,B.newline()):t.nodes.unshift(a);let o=ga({plugin:e,sdkName:l.placeholder,symbol:s}).$render();e.setSymbolValue(s,o);let c=B.field(ha,e=>e.public().static().readonly().assign(B.new(s.placeholder).generic(l.placeholder)));t.nodes.unshift(c,B.newline())}let u=B.class(l.placeholder).export(l.exported).extends(o?.placeholder).$if(t.root&&n,t=>t.decorator(e.referenceSymbol({category:`external`,resource:`@angular/core.Injectable`}).placeholder,e=>e.prop(`providedIn`,()=>B.literal(`root`)))).do(...t.nodes).$render();e.setSymbolValue(l,u)};for(let e of i.values())c(e)},ya=({id:e,operation:t,plugin:n})=>n.config.methodNameBuilder?n.config.methodNameBuilder(t):e.match(dt)?`${e}_`:e,ba=({plugin:e})=>{let t=T(e.context.config),n=t.name===`@hey-api/client-nuxt`;e.forEach(`operation`,r=>{let{operation:i}=r,a=hr({context:e.context,operation:i}),o=n?e.querySymbol({category:`type`,resource:`operation`,resourceId:i.id,role:`response`}):void 0,s=fr({isRequiredOptions:a,operation:i,plugin:e}),c=mr({isRequiredOptions:a,opParameters:s,operation:i,plugin:e}),l=e.registerSymbol({meta:{category:`sdk`,path:r._path,resource:`operation`,resourceId:i.id,tags:r.tags,tool:`sdk`},name:ya({id:i.id,operation:i,plugin:e})}),u=P.constVariable({comment:I({operation:i}),exportConst:!0,expression:P.arrowFunction({parameters:s.parameters,returnType:void 0,statements:c,types:n?[{default:P.ots.string(`$fetch`),extends:P.typeNode(e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder),name:Yn},{default:o?P.typeReferenceNode({typeName:o.placeholder}):P.typeNode(`undefined`),extends:o?P.typeReferenceNode({typeName:o.placeholder}):void 0,name:Xn}]:[{default:(`throwOnError`in t.config?t.config.throwOnError:!1)??!1,extends:`boolean`,name:`ThrowOnError`}]}),name:l.placeholder});e.setSymbolValue(l,u)},{order:`declarations`})},xa=({plugin:e})=>{let t=Ir(e.context.config),n=T(e.context.config),r=n.name===`@hey-api/client-nuxt`,i=e.registerSymbol({external:t,kind:`type`,name:`TDataShape`}),a=e.registerSymbol({external:t,kind:`type`,meta:{category:`external`,resource:`client.Client`,tool:n.name},name:`Client`}),o=e.registerSymbol({external:t,kind:`type`,name:`Options`}),s=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`client-options`,tool:`sdk`},name:`Options`}),c=P.typeAliasDeclaration({exportType:s.exported,name:s.placeholder,type:P.typeIntersectionNode({types:[P.typeReferenceNode({typeArguments:r?[P.typeReferenceNode({typeName:`TComposable`}),P.typeReferenceNode({typeName:`TData`}),P.typeReferenceNode({typeName:Zn}),P.typeReferenceNode({typeName:Xn})]:[P.typeReferenceNode({typeName:`TData`}),P.typeReferenceNode({typeName:`ThrowOnError`})],typeName:o.placeholder}),P.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&&!e.config.instance,name:`client`,type:P.typeReferenceNode({typeName:a.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:P.typeReferenceNode({typeArguments:[P.keywordTypeNode({keyword:`string`}),P.keywordTypeNode({keyword:`unknown`})],typeName:`Record`})}],useLegacyResolution:!1})]}),typeParameters:r?[P.typeParameterDeclaration({constraint:P.typeReferenceNode({typeName:e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder}),defaultType:P.typeNode(`'$fetch'`),name:`TComposable`}),P.typeParameterDeclaration({constraint:P.typeReferenceNode({typeName:i.placeholder}),defaultType:P.typeReferenceNode({typeName:i.placeholder}),name:`TData`}),P.typeParameterDeclaration({defaultType:P.keywordTypeNode({keyword:`unknown`}),name:Zn}),P.typeParameterDeclaration({defaultType:P.keywordTypeNode({keyword:`undefined`}),name:Xn})]:[P.typeParameterDeclaration({constraint:P.typeReferenceNode({typeName:i.placeholder}),defaultType:P.typeReferenceNode({typeName:i.placeholder}),name:`TData`}),P.typeParameterDeclaration({constraint:P.keywordTypeNode({keyword:`boolean`}),defaultType:P.keywordTypeNode({keyword:`boolean`}),name:`ThrowOnError`})]});e.setSymbolValue(s,c)},Sa=({plugin:e})=>{let t=Ir(e.context.config),n=T(e.context.config),r=n.name===`@hey-api/client-angular`,i=n.name===`@hey-api/client-nuxt`;e.registerSymbol({external:t,meta:{category:`external`,resource:`client.formDataBodySerializer`,tool:n.name},name:`formDataBodySerializer`}),e.registerSymbol({external:t,meta:{category:`external`,resource:`client.urlSearchParamsBodySerializer`,tool:n.name},name:`urlSearchParamsBodySerializer`}),e.registerSymbol({external:t,meta:{category:`external`,resource:`client.buildClientParams`,tool:n.name},name:`buildClientParams`}),i&&e.registerSymbol({external:t,kind:`type`,meta:{category:`external`,resource:`client.Composable`,tool:n.name},name:`Composable`}),r&&e.config.asClass&&e.registerSymbol({external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.Injectable`},name:`Injectable`}),xa({plugin:e}),e.config.asClass?va({plugin:e}):ba({plugin:e})},Ca=e=>Sa(e),wa={config:{asClass:!1,auth:!0,classNameBuilder:`{{name}}`,classStructure:`auto`,client:!0,exportFromIndex:!0,instance:!1,operationId:!0,paramsStructure:`grouped`,response:`body`,responseStyle:`fields`,transformer:!1,validator:!1},dependencies:[`@hey-api/typescript`],handler:Ca,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`)}},Ta=v(wa),Ea=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:P.callExpression({functionName:`BigInt`,parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:e,name:`toString`})})]});if(n){if(typeof e==`string`)return[n];if(e)return[P.assignment({left:e,right:n})]}},Da=({dataExpression:e,schema:t})=>{if(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))return;let n=P.identifier({text:`Date`});if(typeof e==`string`)return[P.newExpression({argumentsArray:[P.identifier({text:e})],expression:n})];if(e)return[P.assignment({left:e,right:P.newExpression({argumentsArray:[e],expression:n})})]},Oa=`data`,ka=new Set,Aa=e=>e.map(e=>m.default.isStatement(e)?e:P.expressionToStatement({expression:e})),ja=({node:e})=>e.kind===m.default.SyntaxKind.ReturnStatement,Ma=({plugin:e,schema:t})=>{let n=P.identifier({text:Oa}),r=Na({dataExpression:n,plugin:e,schema:t});return r.length&&!ja({node:r[r.length-1]})&&r.push(P.returnStatement({expression:n})),r},Na=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r={category:`transform`,resource:`definition`,resourceId:n.$ref},i=t.getSymbol(r);if(i||(i=t.registerSymbol({meta:r,name:x({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:F(n.$ref)})}),t.setSymbolValue(i,null)),!t.gen.symbols.getValue(i.id)&&!ka.has(i.id)){ka.add(i.id);try{let e=Ma({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(e.length){let n=P.constVariable({expression:P.arrowFunction({async:!1,multiLine:!0,parameters:[{name:Oa,type:P.keywordTypeNode({keyword:`any`})}],statements:Aa(e)}),name:i.placeholder});t.setSymbolValue(i,n)}}finally{ka.delete(i.id)}}if(t.gen.symbols.getValue(i.id)||ka.has(i.id)){let n=t.referenceSymbol(r),i=P.callExpression({functionName:n.placeholder,parameters:[e]});if(e)return typeof e==`string`&&e===`item`?[P.returnStatement({expression:i})]:[typeof e==`string`?i:P.assignment({left:e,right:i})]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?Na({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=Aa(r);return i.some(e=>ja({node:e}))||i.push(P.returnStatement({expression:P.identifier({text:`item`})})),[P.assignment({left:e,right:P.callExpression({functionName:P.propertyAccessExpression({expression:e,name:`map`}),parameters:[P.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=P.propertyAccessExpression({expression:e||Oa,name:a}),c=Na({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(P.ifStatement({expression:s,thenStatement:P.block({statements:Aa(c)})}))}return r}if(n.items){if(n.items.length===1)return Na({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=Na({dataExpression:e||`item`,plugin:t,schema:i});if(n.length)if(e)r=r.concat(n);else{let e=P.identifier({text:`item`});r.push(P.ifStatement({expression:e,thenStatement:P.block({statements:Aa(n)})}),P.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[]},Pa=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=at(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${w(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.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`response`});if(!r)return;let i=Ma({plugin:e,schema:n});if(!i.length)return;let a=e.registerSymbol({exported:!0,meta:{category:`transform`,resource:`operation`,resourceId:t.id,role:`response`},name:x({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id})}),o=P.constVariable({exportConst:a.exported,expression:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:Oa,type:P.keywordTypeNode({keyword:`any`})}],returnType:P.typeReferenceNode({typeArguments:[P.typeReferenceNode({typeName:r.placeholder})],typeName:`Promise`}),statements:Aa(i)}),name:a.placeholder});e.setSymbolValue(a,o)},{order:`declarations`})},Fa={config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:Pa,name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,Da]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,Ea])},tags:[`transformer`]},Ia=v(Fa),La=P.keywordTypeNode({keyword:`string`}),Ra=({server:e})=>{let t=Hr(e.url);return t.protocol&&t.host?P.literalTypeNode({literal:P.stringLiteral({text:e.url})}):P.templateLiteralType({value:[t.protocol||La,`://`,t.host||La,t.port?`:${t.port}`:``,t.path||``]})},za=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=T(e.context.config),i=t.map(e=>Ra({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(P.typeIntersectionNode({types:[La,m.default.factory.createTypeLiteralNode([])]})):i.push(La);let a=P.typeInterfaceNode({properties:[{name:st(e.context.config),type:P.typeUnionNode({types:i})}],useLegacyResolution:!1}),o=P.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:a});e.setSymbolValue(n,o)},V=({schema:e})=>{let t=[];return e.title&&t.push(_t(e.title)),e.description&&(t.length&&t.push(``),t.push(_t(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Ba=({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=b({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),O.lastIndex=0,O.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{comments:V({schema:t}),key:a,value:t.const}}),typeofItems:n}},Va=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=Ba({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=P.constVariable({assertion:`const`,comment:V({schema:t}),exportConst:!0,expression:P.objectExpression({multiLine:!0,obj:r.obj}),name:n.placeholder}),a=P.typeOfExpression({text:n.placeholder}),o=P.typeAliasDeclaration({comment:V({schema:t}),exportType:!0,name:n.placeholder,type:P.indexedAccessTypeNode({indexType:P.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=P.enumDeclaration({asConst:e.config.enums.mode===`typescript-const`,leadingComment:V({schema:t}),name:n.placeholder,obj:r.obj});e.setSymbolValue(n,i);return}}let i=P.typeAliasDeclaration({comment:V({schema:t}),exportType:n.exported,name:n.placeholder,type:r});e.setSymbolValue(n,i)},Ha=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=S({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},Ua=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];r.properties||={},e.body?(r.properties.body=e.body.schema,e.body.required&&i.push(`body`)):r.properties.body={type:`never`},e.parameters?.header&&(r.properties.headers=Ha({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=Ha({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=Ha({parameters:e.parameters.query}),r.properties.query.required&&i.push(`query`)):r.properties.query={type:`never`},r.properties.url={const:e.path,type:`string`},i.push(`url`),r.required=i;let a=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`data`,tags:n.tags?.value,tool:`typescript`},name:x({config:t.config.requests,name:e.id})}),o=H({plugin:t,schema:r,state:n}),s=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s)},Wa=({operation:e,plugin:t,state:n})=>{Ua({operation:e,plugin:t,state:n});let{error:r,errors:i,response:a,responses:o}=at(e);if(i){let a=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`errors`,tags:n.tags?.value,tool:`typescript`},name:x({config:t.config.errors,name:e.id})}),o=H({plugin:t,schema:i,state:n}),s=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});if(t.setSymbolValue(a,s),r){let r=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`error`,tags:n.tags?.value,tool:`typescript`},name:x({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id})}),i=P.indexedAccessTypeNode({indexType:P.typeOperatorNode({operator:`keyof`,type:P.typeReferenceNode({typeName:a.placeholder})}),objectType:P.typeReferenceNode({typeName:a.placeholder})}),o=P.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});t.setSymbolValue(r,o)}}if(o){let r=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`responses`,tags:n.tags?.value,tool:`typescript`},name:x({config:t.config.responses,name:e.id})}),i=H({plugin:t,schema:o,state:n}),s=P.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:i});if(t.setSymbolValue(r,s),a){let i=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`operation`,resourceId:e.id,role:`response`,tags:n.tags?.value,tool:`typescript`},name:x({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id})}),a=P.indexedAccessTypeNode({indexType:P.typeOperatorNode({operator:`keyof`,type:P.typeReferenceNode({typeName:r.placeholder})}),objectType:P.typeReferenceNode({typeName:r.placeholder})}),o=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:a});t.setSymbolValue(i,o)}}},Ga=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];if(r.properties||={},e.body){let a=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`webhook`,resourceId:e.id,role:`data`,tags:n.tags?.value,tool:`typescript`},name:x({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id})}),o=H({plugin:t,schema:e.body.schema,state:n}),s=P.typeAliasDeclaration({comment:V({schema:e.body.schema}),exportType:a.exported,name:a.placeholder,type:o});t.setSymbolValue(a,s),t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:a.placeholder,tags:n.tags?.value,tool:`typescript`},name:a.name,placeholder:a.placeholder}),r.properties.body={$ref:a.placeholder},i.push(`body`)}else r.properties.body={type:`never`};r.properties.key={const:e.path,type:`string`},i.push(`key`),r.properties.path={type:`never`},r.properties.query={type:`never`},r.required=i;let a=t.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`webhook`,resourceId:e.id,role:`data`,tags:n.tags?.value,tool:`typescript`},name:x({config:t.config.webhooks,name:e.id})}),o=H({plugin:t,schema:r,state:n}),s=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:o});return t.setSymbolValue(a,s),a.placeholder},Ka=({operation:e,plugin:t,state:n})=>Ga({operation:e,plugin:t,state:n}),qa=({plugin:e,symbolWebhooks:t,webhookNames:n})=>{if(!n.length)return;let r=P.typeUnionNode({types:n.map(e=>P.typeReferenceNode({typeName:e}))}),i=P.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:r});e.setSymbolValue(t,i)},Ja=({plugin:e,schema:t,state:n})=>{if(!t.items)return P.typeArrayNode(P.keywordTypeNode({keyword:e.config.topType}));t=S({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=H({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});r.push(a)}),r.length===1?P.typeArrayNode(r[0]):t.logicalOperator===`and`?P.typeArrayNode(P.typeIntersectionNode({types:r})):P.typeArrayNode(P.typeUnionNode({types:r}))},Ya=({schema:e})=>e.const===void 0?P.keywordTypeNode({keyword:`boolean`}):P.literalTypeNode({literal:P.ots.boolean(e.const)}),Xa=({plugin:e,schema:t,state:n})=>H({plugin:e,schema:{...t,type:void 0},state:n}),Za=e=>P.keywordTypeNode({keyword:`never`}),Qa=e=>P.literalTypeNode({literal:P.null()}),$a=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?P.typeReferenceNode({typeName:`bigint`}):P.keywordTypeNode({keyword:`number`}):P.literalTypeNode({literal:P.ots.number(t.const)}),eo=({context:e,name:t})=>(O.lastIndex=0,O.test(t)?t.startsWith(`-`)?m.default.factory.createStringLiteral(t):m.default.factory.createNumericLiteral(t):b({case:e.config.output.case,value:t})),to=({plugin:e,schema:t,state:n})=>{let r,i,a=[],o=[],s=t.required??[],c=!1;for(let r in t.properties){let i=t.properties[r],l=H({plugin:e,schema:i,state:{...n,path:E([...n.path.value,`properties`,r])}}),u=s.includes(r);a.push({comment:V({schema:i}),isReadOnly:i.accessScope===`read`,isRequired:u,name:eo({context:e.context,name:r}),type:l}),o.push(i),u||(c=!0)}if(t.patternProperties)for(let e in t.patternProperties){let n=t.patternProperties[e];o.unshift(n)}let l=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,u=t.additionalProperties,d=u!==!1&&u?u:void 0;if(l||d&&(d.type!==`never`||!o.length)){let a=d;a&&a.type!==`never`?o.unshift(a):!l&&!o.length&&a&&a.type===`never`&&(o=[a]),c&&o.push({type:`undefined`}),i={isRequired:!t.propertyNames,name:`key`,type:o.length===1?H({plugin:e,schema:o[0],state:n}):H({plugin:e,schema:{items:o,logicalOperator:`or`},state:n})},t.propertyNames?.$ref&&(r=H({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n}))}return P.typeInterfaceNode({indexKey:r,indexProperty:i,properties:a,useLegacyResolution:!1})},no=({plugin:e,schema:t})=>{if(t.const!==void 0)return P.literalTypeNode({literal:P.stringLiteral({text:t.const})});if(t.format){if(t.format===`binary`)return P.typeUnionNode({types:[P.typeReferenceNode({typeName:`Blob`}),P.typeReferenceNode({typeName:`File`})]});if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return P.typeReferenceNode({typeName:`Date`});if(t.format===`typeid`&&typeof t.example==`string`){let n=String(t.example).split(`_`);n.pop();let r=n.join(`_`),i={category:`type`,resource:`type-id`,resourceId:r,tool:`typescript`};if(!e.getSymbol(i)){let t={category:`type`,resource:`type-id`,tool:`typescript`,variant:`container`};if(!e.getSymbol(t)){let n=e.registerSymbol({exported:!0,kind:`type`,meta:t,name:`TypeID`}),r=P.typeAliasDeclaration({exportType:n.exported,name:n.placeholder,type:P.templateLiteralType({value:[P.typeReferenceNode({typeName:`T`}),`_`,P.keywordTypeNode({keyword:`string`})]}),typeParameters:[P.typeParameterDeclaration({constraint:P.keywordTypeNode({keyword:`string`}),name:`T`})]});e.setSymbolValue(n,r)}let n=e.referenceSymbol(t),a=e.registerSymbol({exported:!0,kind:`type`,meta:i,name:b({case:e.config.case,value:`${r}_id`})}),o=P.typeAliasDeclaration({exportType:a.exported,name:a.placeholder,type:P.typeReferenceNode({typeArguments:[P.literalTypeNode({literal:P.stringLiteral({text:r})})],typeName:n.placeholder})});e.setSymbolValue(a,o)}let a=e.referenceSymbol(i);return P.typeReferenceNode({typeName:a.placeholder})}}return P.keywordTypeNode({keyword:`string`})},ro=({plugin:e,schema:t,state:n})=>{let r=[];return t.const&&Array.isArray(t.const)?r=t.const.map(t=>P.valueToExpression({value:t})??P.identifier({text:e.config.topType})):t.items&&t.items.forEach((t,i)=>{let a=H({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});r.push(a)}),P.typeTupleNode({types:r})},io=e=>P.keywordTypeNode({keyword:`undefined`}),ao=({plugin:e})=>P.keywordTypeNode({keyword:e.config.topType}),oo=e=>P.keywordTypeNode({keyword:`void`}),so=({schema:e,...t})=>{let n=t.plugin.getPlugin(`@hey-api/transformers`);if(n?.config.typeTransformers)for(let t of n.config.typeTransformers){let n=t({schema:e});if(n)return n}switch(e.type){case`array`:return Ja({...t,schema:e});case`boolean`:return Ya({...t,schema:e});case`enum`:return Xa({...t,schema:e});case`integer`:case`number`:return $a({...t,schema:e});case`never`:return Za({...t,schema:e});case`null`:return Qa({...t,schema:e});case`object`:return to({...t,schema:e});case`string`:return no({...t,schema:e});case`tuple`:return ro({...t,schema:e});case`undefined`:return io({...t,schema:e});case`unknown`:return ao({...t,schema:e});case`void`:return oo({...t,schema:e})}},H=({plugin:e,schema:t,state:n})=>{if(t.$ref){let n=e.referenceSymbol({category:`type`,resource:`definition`,resourceId:t.$ref});return P.typeReferenceNode({typeName:n.placeholder})}if(t.type)return so({plugin:e,schema:t,state:n});if(t.items){if(t=S({detectFormat:!1,schema:t}),t.items){let r=[];for(let i of t.items){let t=H({plugin:e,schema:i,state:n});r.push(t)}return t.logicalOperator===`and`?P.typeIntersectionNode({types:r}):P.typeUnionNode({types:r})}return H({plugin:e,schema:t,state:n})}return so({plugin:e,schema:{type:`unknown`},state:n})},co=({plugin:e,schema:t,state:n})=>{let r=H({plugin:e,schema:t,state:n}),i=t.type===`enum`&&e.config.enums.enabled,a=rr(n.path.value);Va({plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,kind:i?void 0:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:a,tags:n.tags?.value,tool:`typescript`},name:x({config:e.config.definitions,name:F(a)})}),type:r})},lo=({plugin:e})=>{let t=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`client`,role:`options`,tool:`typescript`},name:x({config:{case:e.config.case},name:`ClientOptions`})}),n=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`webhook`,tool:`typescript`,variant:`container`},name:x({config:{case:e.config.case},name:`Webhooks`})}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=D({path:t._path,tags:t.tags});switch(t.type){case`operation`:Wa({operation:t.operation,plugin:e,state:n});break;case`parameter`:co({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:co({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:co({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(Ka({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),za({plugin:e,servers:r,symbolClientOptions:t}),qa({plugin:e,symbolWebhooks:n,webhookNames:i})};var uo=class{schemaToType(e){return H(e)}};const fo=e=>lo(e),po={api:new uo,config:{case:`PascalCase`,exportFromIndex:!0,topType:`unknown`},handler:fo,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})}},mo=v(po),ho=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return P.valueToExpression({value:i})},go=({operation:e,plugin:t})=>dr({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),_o=({operation:e,plugin:t})=>{let n=T(t.context.config),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`error`})?.placeholder;return r||=`Error`,n.name===`@hey-api/client-axios`&&(r=`${t.referenceSymbol({category:`external`,resource:`axios.AxiosError`}).placeholder}<${r}>`),r},vo=({operation:e,plugin:t})=>t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`,yo=({plugin:e,typeData:t})=>{let n=T(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},bo=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol({category:`external`,resource:`${t.name}.UseMutationOptions`}),i=go({operation:e,plugin:t}),a=_o({operation:e,plugin:t}),o=vo({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=yo({plugin:t,typeData:i}),l=s?`${r.placeholder}<${o}, ${c}, ${a}>`:`${r.placeholder}<${o}, ${i}, ${a}>`,u=`fnOptions`,d=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:u},{key:`throwOnError`,value:!0}]})]})}),f=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?f.push(P.returnVariable({expression:d})):f.push(P.constVariable({destructure:!0,expression:d,name:`data`}),P.returnVariable({expression:`data`}));let p=[{key:`mutation`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[s?{name:u,type:`Partial<${c}>`}:{name:u}],statements:f})}],m=ho(t,e,`mutationOptions`);m&&p.push({key:`meta`,value:m});let h=t.registerSymbol({exported:!0,name:x({config:t.config.mutationOptions,name:e.id})}),g=P.constVariable({comment:t.config.comments?I({operation:e}):void 0,exportConst:h.exported,expression:P.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${c}>`}],returnType:l,statements:[P.returnStatement({expression:P.objectExpression({obj:p})})]}),name:h.placeholder});t.setSymbolValue(h,g)},xo=`TOptions`,So=P.identifier({text:`options`}),Co=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createQueryKey`,tool:e.name},name:x({config:{case:e.config.case},name:`createQueryKey`})}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),i=P.indexedAccessTypeNode({indexType:P.literalTypeNode({literal:P.ots.number(0)}),objectType:P.typeReferenceNode({typeArguments:[P.typeReferenceNode({typeName:xo})],typeName:n.placeholder})}),a=st(e.context.config),o=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),s=e.getSymbol({category:`client`}),c=Ir(e.context.config),l=e.registerSymbol({external:c,meta:{category:`external`,resource:`${c}.serializeQueryKeyValue`},name:`serializeQueryKeyValue`}),u=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:P.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:P.typeReferenceNode({typeName:xo})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:P.typeTupleNode({types:[i]}),statements:[P.constVariable({assertion:i,expression:P.objectExpression({multiLine:!1,obj:[{key:`_id`,value:P.identifier({text:`id`})},{key:a,value:P.identifier({text:`options?.${a} || (options?.client ?? ${s?.placeholder}).getConfig().${a}`})}]}),name:`params`,typeName:i}),P.ifStatement({expression:P.identifier({text:`tags`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`tags`}),right:P.asExpression({expression:P.asExpression({expression:P.identifier({text:`tags`}),type:P.keywordTypeNode({keyword:`unknown`})}),type:P.typeReferenceNode({typeName:r.placeholder})})})})]})}),P.ifStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:So,isOptional:!0,name:P.identifier({text:`body`})}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.constVariable({expression:P.callExpression({functionName:l.placeholder,parameters:[P.propertyAccessExpression({expression:`options`,name:`body`})]}),name:`normalizedBody`}),P.ifStatement({expression:P.binaryExpression({left:P.identifier({text:`normalizedBody`}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.identifier({text:`normalizedBody`})})})]})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:So,isOptional:!0,name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),P.ifStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:So,isOptional:!0,name:P.identifier({text:`query`})}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.constVariable({expression:P.callExpression({functionName:l.placeholder,parameters:[P.propertyAccessExpression({expression:`options`,name:`query`})]}),name:`normalizedQuery`}),P.ifStatement({expression:P.binaryExpression({left:P.identifier({text:`normalizedQuery`}),operator:`!==`,right:`undefined`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.identifier({text:`normalizedQuery`})})})]})})]})}),P.returnStatement({expression:P.arrayLiteralExpression({elements:[P.identifier({text:`params`})]})})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:o.placeholder})}),name:xo}]}),name:t.placeholder});e.setSymbolValue(t,u)},wo=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;r.tags&&t.tags&&t.tags.length>0&&(i=P.arrayLiteralExpression({elements:t.tags.map(e=>P.stringLiteral({text:e}))}));let a=n.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:n.name});return P.callExpression({functionName:a.placeholder,parameters:[P.ots.string(e),`options`,i]})},To=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),n=[{name:`_id`,type:P.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:st(e.context.config),type:P.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`body`,type:P.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`query`,type:P.typeReferenceNode({typeName:t.placeholder})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:t.placeholder})}],r=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),i=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`QueryKey`,tool:e.name},name:`QueryKey`}),a=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:P.typeTupleNode({types:[P.typeIntersectionNode({types:[P.typeReferenceNode({typeName:`Pick<${xo}, 'path'>`}),P.typeInterfaceNode({properties:n,useLegacyResolution:!0})]})]}),typeParameters:[{extends:P.typeReferenceNode({typeName:P.identifier({text:r.placeholder})}),name:xo}]});e.setSymbolValue(i,a)},Eo=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=yo({plugin:t,typeData:go({operation:e,plugin:t})});return P.constVariable({exportConst:n.exported,expression:P.arrowFunction({parameters:[{isRequired:nt(e),name:`options`,type:r}],statements:wo({id:e.id,operation:e,plugin:t})}),name:n.placeholder})},Do=`options`,Oo=`context`,ko=({operation:e,plugin:t,queryFn:n})=>{if(gr({operation:e}))return;let r=hr({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(To({plugin:t}),Co({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:x({config:t.config.queryKeys,name:e.id})}),r=Eo({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=P.callExpression({functionName:n.placeholder,parameters:[Do]})}else{let n=t.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name}),r;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(r=P.arrayLiteralExpression({elements:e.tags.map(e=>P.stringLiteral({text:e}))})),i=P.callExpression({functionName:n.placeholder,parameters:[P.ots.string(e.id),Do,r]})}let{strippedTypeData:a}=yo({plugin:t,typeData:go({operation:e,plugin:t})}),o=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:Do},{spread:Oo},{key:`throwOnError`,value:!0}]})]})}),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(P.returnVariable({expression:o})):s.push(P.constVariable({destructure:!0,expression:o,name:`data`}),P.returnVariable({expression:`data`}));let c=[{key:`key`,value:i},{key:`query`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:Oo}],statements:s})}],l=ho(t,e,`queryOptions`);l&&c.push({key:`meta`,value:l});let u=t.registerSymbol({exported:!0,meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name},name:x({config:t.config.queryOptions,name:e.id})}),d=t.referenceSymbol({category:`external`,resource:`${t.name}.defineQueryOptions`}),f=P.constVariable({comment:t.config.comments?I({operation:e}):void 0,exportConst:u.exported,expression:P.callExpression({functionName:d.placeholder,parameters:[P.arrowFunction({parameters:[{isRequired:r,name:Do,type:a}],statements:P.objectExpression({obj:c})})]}),name:u.placeholder});t.setSymbolValue(u,f)},Ao=({plugin:e})=>{e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.defineQueryOptions`},name:`defineQueryOptions`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.UseMutationOptions`},name:`UseMutationOptions`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.UseQueryOptions`},name:`UseQueryOptions`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}._JSONValue`},name:`_JSONValue`}),e.registerSymbol({external:`axios`,kind:`type`,meta:{category:`external`,resource:`axios.AxiosError`},name:`AxiosError`});let t=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let r=t.config.asClass?ur({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol({category:`utility`,resource:`class`,resourceId:i.path[0],tool:`sdk`}).placeholder,...i.path.slice(1).map(e=>b({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:n.id}).placeholder;e.hooks.operation.isQuery(n)&&e.config.queryOptions.enabled&&ko({operation:n,plugin:e,queryFn:a}),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&bo({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},jo=e=>Ao(e),Mo={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:jo,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})}},No=v(Mo),Po=({operation:e,plugin:t})=>dr({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Fo=({operation:e,plugin:t})=>{let n=T(t.context.config),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`error`})?.placeholder;return r||=t.referenceSymbol({category:`external`,resource:`${t.name}.DefaultError`}).placeholder,n.name===`@hey-api/client-axios`&&(r=`${t.referenceSymbol({category:`external`,resource:`axios.AxiosError`}).placeholder}<${r}>`),r},Io=({operation:e,plugin:t})=>t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`,Lo=`TOptions`,Ro=P.identifier({text:`infinite`}),zo=P.identifier({text:`options`}),Bo=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createQueryKey`,tool:e.name},name:x({config:{case:e.config.case},name:`createQueryKey`})}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=P.indexedAccessTypeNode({indexType:P.literalTypeNode({literal:P.ots.number(0)}),objectType:P.typeReferenceNode({typeArguments:[P.typeReferenceNode({typeName:Lo})],typeName:n.placeholder})}),i=st(e.context.config),a=e.getSymbol({category:`client`}),o=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),s=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`id`,type:P.typeReferenceNode({typeName:`string`})},{isRequired:!1,name:`options`,type:P.typeReferenceNode({typeName:Lo})},{isRequired:!1,name:`infinite`,type:P.typeReferenceNode({typeName:`boolean`})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],returnType:P.typeTupleNode({types:[r]}),statements:[P.constVariable({assertion:r,expression:P.objectExpression({multiLine:!1,obj:[{key:`_id`,value:P.identifier({text:`id`})},{key:i,value:P.identifier({text:`options?.${i} || (options?.client ?? ${a?.placeholder}).getConfig().${i}`})}]}),name:`params`,typeName:r}),P.ifStatement({expression:Ro,thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:Ro})})]})}),P.ifStatement({expression:P.identifier({text:`tags`}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`tags`}),right:P.identifier({text:`tags`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:zo,isOptional:!0,name:P.identifier({text:`body`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.propertyAccessExpression({expression:`options`,name:`body`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:zo,isOptional:!0,name:P.identifier({text:`headers`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`headers`}),right:P.propertyAccessExpression({expression:`options`,name:`headers`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:zo,isOptional:!0,name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.propertyAccessExpression({expression:`options`,name:`path`})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:zo,isOptional:!0,name:P.identifier({text:`query`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.propertyAccessExpression({expression:`options`,name:`query`})})})]})}),P.returnStatement({expression:P.arrayLiteralExpression({elements:[P.identifier({text:`params`})]})})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:o.placeholder})}),name:Lo}]}),name:t.placeholder});e.setSymbolValue(t,s)},Vo=({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=P.arrayLiteralExpression({elements:n.tags.map(e=>P.stringLiteral({text:e}))}));let o=r.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:r.name});return P.callExpression({functionName:o.placeholder,parameters:[P.ots.string(e),`options`,t||a?P.ots.boolean(!!t):void 0,a]})},Ho=({plugin:e})=>{let t=[{name:`_id`,type:P.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:`_infinite`,type:P.keywordTypeNode({keyword:`boolean`})},{isRequired:!1,name:`tags`,type:P.typeReferenceNode({typeName:`ReadonlyArray<string>`})}],n=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),r=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`QueryKey`,tool:e.name},name:`QueryKey`}),i=P.typeAliasDeclaration({exportType:r.exported,name:r.placeholder,type:P.typeTupleNode({types:[P.typeIntersectionNode({types:[P.typeReferenceNode({typeName:`Pick<${Lo}, '${st(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),P.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:P.typeReferenceNode({typeName:P.identifier({text:n.placeholder})}),name:Lo}]});e.setSymbolValue(r,i)},Uo=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=Po({operation:t,plugin:n});return P.constVariable({exportConst:r.exported,expression:P.arrowFunction({parameters:[{isRequired:nt(t),name:`options`,type:a}],returnType:e?i:void 0,statements:Vo({id:t.id,isInfinite:e,operation:t,plugin:n})}),name:r.placeholder})},Wo=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return P.valueToExpression({value:i})},Go=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createInfiniteParams`,tool:e.name},name:x({config:{case:e.config.case},name:`createInfiniteParams`})}),n=P.constVariable({expression:P.arrowFunction({multiLine:!0,parameters:[{name:`queryKey`,type:P.typeReferenceNode({typeName:`QueryKey<Options>`})},{name:`page`,type:P.typeReferenceNode({typeName:`K`})}],statements:[P.constVariable({expression:P.objectExpression({obj:[{spread:P.propertyAccessExpression({expression:`queryKey`,name:0})}]}),name:`params`}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`body`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`body`}),right:P.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].body`},{assertion:`any`,spread:`page.body`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`headers`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`headers`}),right:P.objectExpression({multiLine:!0,obj:[{spread:`queryKey[0].headers`},{spread:`page.headers`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`path`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`path`}),right:P.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].path`},{assertion:`any`,spread:`page.path`}]})})})]})}),P.ifStatement({expression:P.propertyAccessExpression({expression:P.identifier({text:`page`}),name:P.identifier({text:`query`})}),thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`query`}),right:P.objectExpression({multiLine:!0,obj:[{assertion:`any`,spread:`queryKey[0].query`},{assertion:`any`,spread:`page.query`}]})})})]})}),P.returnVariable({expression:P.asExpression({expression:P.asExpression({expression:P.identifier({text:`params`}),type:P.keywordTypeNode({keyword:`unknown`})}),type:m.default.factory.createTypeQueryNode(P.identifier({text:`page`}))})})],types:[{extends:P.typeReferenceNode({typeName:P.identifier({text:`Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>`})}),name:`K`}]}),name:t.placeholder});e.setSymbolValue(t,n)},Ko=({operation:e,plugin:t,queryFn:n})=>{let r=rt({context:t.context,operation:e});if(!r)return;let i=hr({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(Ho({plugin:t}),Bo({plugin:t})),t.getSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name})||Go({plugin:t});let a=t.referenceSymbol({category:`external`,resource:`${t.name}.infiniteQueryOptions`}),o=t.referenceSymbol({category:`external`,resource:`${t.name}.InfiniteData`}),s=Po({operation:e,plugin:t}),c=Fo({operation:e,plugin:t}),l=Io({operation:e,plugin:t}),u=`${t.referenceSymbol({category:`type`,resource:`QueryKey`,tool:t.name}).placeholder}<${s}>`,d=`Pick<${u}[0], 'body' | 'headers' | 'path' | 'query'>`,f=t.getPluginOrThrow(`@hey-api/typescript`),p=`${St({node:f.api.schemaToType({plugin:f,schema:r.schema,state:{path:{value:[]}}}),unescape:!0})} | ${d}`,m=t.registerSymbol({exported:!0,name:x({config:t.config.infiniteQueryKeys,name:e.id})}),h=Uo({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.setSymbolValue(m,h);let g=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:`params`},{key:`signal`,shorthand:!0,value:P.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),ee=t.referenceSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name}),te=[P.constVariable({comment:[{jsdoc:!1,lines:[`@ts-ignore`]}],expression:P.conditionalExpression({condition:P.binaryExpression({left:P.typeOfExpression({text:`pageParam`}),operator:`===`,right:P.ots.string(`object`)}),whenFalse:P.objectExpression({multiLine:!0,obj:[{key:r.in,value:P.objectExpression({multiLine:!0,obj:[{key:r.name,value:P.identifier({text:`pageParam`})}]})}]}),whenTrue:P.identifier({text:`pageParam`})}),name:`page`,typeName:d}),P.constVariable({expression:P.callExpression({functionName:ee.placeholder,parameters:[`queryKey`,`page`]}),name:`params`})];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?te.push(P.returnVariable({expression:g})):te.push(P.constVariable({destructure:!0,expression:g,name:`data`}),P.returnVariable({expression:`data`}));let ne=[{key:`queryFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:te})},{key:`queryKey`,value:P.callExpression({functionName:m.placeholder,parameters:[`options`]})}],re=Wo(t,e,`infiniteQueryOptions`);re&&ne.push({key:`meta`,value:re});let ie=t.registerSymbol({exported:!0,name:x({config:t.config.infiniteQueryOptions,name:e.id})}),ae=P.constVariable({comment:t.config.comments?I({operation:e}):void 0,exportConst:ie.exported,expression:P.arrowFunction({parameters:[{isRequired:i,name:`options`,type:s}],statements:[P.returnFunctionCall({args:[P.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:ne})],name:a.placeholder,types:[l,c||`unknown`,`${o.placeholder}<${l}>`,u,p]})]}),name:ie.placeholder});t.setSymbolValue(ie,ae)},qo=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol({category:`external`,resource:`${t.name}.MutationOptions`}),i=Po({operation:e,plugin:t}),a=Fo({operation:e,plugin:t}),o=Io({operation:e,plugin:t}),s=`${r.placeholder}<${o}, ${a}, ${i}>`,c=`fnOptions`,l=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:`options`},{spread:c},{key:`throwOnError`,value:!0}]})]})}),u=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?u.push(P.returnVariable({expression:l})):u.push(P.constVariable({destructure:!0,expression:l,name:`data`}),P.returnVariable({expression:`data`}));let d=[{key:`mutationFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:c}],statements:u})}],f=Wo(t,e,`mutationOptions`);f&&d.push({key:`meta`,value:f});let p=`mutationOptions`,m=P.arrowFunction({parameters:[{isRequired:!1,name:`options`,type:`Partial<${i}>`}],returnType:s,statements:[P.constVariable({expression:P.objectExpression({obj:d}),name:p,typeName:s}),P.returnVariable({expression:p})]}),h=t.registerSymbol({exported:!0,name:x({config:t.config.mutationOptions,name:e.id})}),g=P.constVariable({comment:t.config.comments?I({operation:e}):void 0,exportConst:h.exported,expression:m,name:h.placeholder});t.setSymbolValue(h,g)},Jo=`options`,Yo=({operation:e,plugin:t,queryFn:n})=>{if(gr({operation:e}))return;let r=hr({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(Ho({plugin:t}),Bo({plugin:t}));let i=t.referenceSymbol({category:`external`,resource:`${t.name}.queryOptions`}),a=t.registerSymbol({exported:!0,name:x({config:t.config.queryKeys,name:e.id})}),o=Uo({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=Po({operation:e,plugin:t}),c=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:Jo},{spread:`queryKey[0]`},{key:`signal`,shorthand:!0,value:P.identifier({text:`signal`})},{key:`throwOnError`,value:!0}]})]})}),l=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?l.push(P.returnVariable({expression:c})):l.push(P.constVariable({destructure:!0,expression:c,name:`data`}),P.returnVariable({expression:`data`}));let u=[{key:`queryFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`queryKey`},{name:`signal`}]}],statements:l})},{key:`queryKey`,value:P.callExpression({functionName:a.placeholder,parameters:[Jo]})}],d=Wo(t,e,`queryOptions`);d&&u.push({key:`meta`,value:d});let f=t.registerSymbol({exported:t.config.queryOptions.exported,meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name},name:x({config:t.config.queryOptions,name:e.id})}),p=P.constVariable({comment:t.config.comments?I({operation:e}):void 0,exportConst:f.exported,expression:P.arrowFunction({parameters:[{isRequired:r,name:Jo,type:s}],statements:[P.returnFunctionCall({args:[P.objectExpression({obj:u})],name:i.placeholder})]}),name:f.placeholder});t.setSymbolValue(f,p)},Xo=`options`,Zo=({operation:e,plugin:t})=>{if(gr({operation:e})||!(`useQuery`in t.config))return;let n=t.registerSymbol({exported:!0,name:x({config:t.config.useQuery,name:e.id})}),r=t.referenceSymbol({category:`external`,resource:`${t.name}.useQuery`}),i=hr({context:t.context,operation:e}),a=Po({operation:e,plugin:t}),o=t.referenceSymbol({category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}),s=P.constVariable({comment:t.config.comments?I({operation:e}):void 0,exportConst:n.exported,expression:P.arrowFunction({parameters:[{isRequired:i,name:Xo,type:a}],statements:[P.returnStatement({expression:P.callExpression({functionName:r.placeholder,parameters:[P.callExpression({functionName:o.placeholder,parameters:[Xo]})]})})]}),name:n.placeholder});t.setSymbolValue(n,s)},Qo=({plugin:e})=>{e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.DefaultError`},name:`DefaultError`}),e.registerSymbol({external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.InfiniteData`},name:`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,kind:`type`,meta:{category:`external`,resource:`${e.name}.MutationOptions`},name:t}),e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.infiniteQueryOptions`},name:`infiniteQueryOptions`}),e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.queryOptions`},name:`queryOptions`}),e.registerSymbol({external:e.name,meta:{category:`external`,resource:`${e.name}.useQuery`},name:`useQuery`}),e.registerSymbol({external:`axios`,kind:`type`,meta:{category:`external`,resource:`axios.AxiosError`},name:`AxiosError`});let n=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:t})=>{let r=n.config.asClass?ur({context:e.context,operation:t,plugin:n}):void 0,i=r?r.values().next().value:void 0,a;a=i?[e.referenceSymbol({category:`utility`,resource:`class`,resourceId:i.path[0],tool:`sdk`}).placeholder,...n.config.instance?[ha,`get()`]:[],...i.path.slice(1).map(e=>b({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:t.id}).placeholder,e.hooks.operation.isQuery(t)&&(e.config.queryOptions.enabled&&Yo({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&Ko({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&Zo({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&qo({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},$o=e=>Qo(e),es={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:$o,name:`@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})}},ts=v(es),ns={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:$o,name:`@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))}},rs=v(ns),is={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:$o,name:`@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})}},as=v(is),os={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:$o,name:`@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})}},ss=v(os),cs={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:$o,name:`@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})}},ls=v(cs),us=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`arktype`});if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[P.identifier({text:r})]})})})]})},ds=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`arktype`});if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:`parseAsync`}),parameters:[P.identifier({text:r})]})})})]})};var fs=class{createRequestValidator(e){return us(e)}createResponseValidator(e){return ds(e)}};const U={keywords:{false:P.identifier({text:`false`}),true:P.identifier({text:`true`})},number:{Infinity:P.identifier({text:`Infinity`}),NaN:P.identifier({text:`NaN`}),NegativeInfinity:P.identifier({text:`NegativeInfinity`}),epoch:P.identifier({text:`epoch`}),integer:P.identifier({text:`integer`}),safe:P.identifier({text:`safe`})},primitives:{bigint:P.identifier({text:`bigint`}),boolean:P.identifier({text:`boolean`}),keywords:P.identifier({text:`keywords`}),null:`null`,number:P.identifier({text:`number`}),string:`string`,symbol:P.identifier({text:`symbol`}),undefined:P.identifier({text:`undefined`}),unit:P.identifier({text:`unit`})},string:{NFC:P.identifier({text:`NFC`}),NFD:P.identifier({text:`NFD`}),NFKC:P.identifier({text:`NFKC`}),NFKD:P.identifier({text:`NFKD`}),alpha:P.identifier({text:`alpha`}),alphanumeric:P.identifier({text:`alphanumeric`}),base64:P.identifier({text:`base64`}),capitalize:P.identifier({text:`capitalize`}),creditCard:P.identifier({text:`creditCard`}),date:`date`,digits:P.identifier({text:`digits`}),email:`email`,epoch:P.identifier({text:`epoch`}),hex:P.identifier({text:`hex`}),integer:P.identifier({text:`integer`}),ip:`ip`,iso:`iso`,json:P.identifier({text:`json`}),lower:P.identifier({text:`lower`}),normalize:P.identifier({text:`normalize`}),numeric:P.identifier({text:`numeric`}),parse:P.identifier({text:`parse`}),preformatted:P.identifier({text:`preformatted`}),regex:P.identifier({text:`regex`}),semver:P.identifier({text:`semver`}),trim:P.identifier({text:`trim`}),upper:P.identifier({text:`upper`}),url:`url`,uuid:`uuid`,v1:`v1`,v2:`v2`,v3:`v3`,v4:`v4`,v5:`v5`,v6:`v6`,v7:`v7`,v8:`v8`},type:{$:P.identifier({text:`$`}),allows:P.identifier({text:`allows`}),and:P.identifier({text:`and`}),array:P.identifier({text:`array`}),as:P.identifier({text:`as`}),assert:P.identifier({text:`assert`}),brand:P.identifier({text:`brand`}),configure:P.identifier({text:`configure`}),default:P.identifier({text:`default`}),describe:P.identifier({text:`describe`}),description:P.identifier({text:`description`}),equals:P.identifier({text:`equals`}),exclude:P.identifier({text:`exclude`}),expression:P.identifier({text:`expression`}),extends:P.identifier({text:`extends`}),extract:P.identifier({text:`extract`}),filter:P.identifier({text:`filter`}),from:P.identifier({text:`from`}),ifEquals:P.identifier({text:`ifEquals`}),ifExtends:P.identifier({text:`ifExtends`}),infer:P.identifier({text:`infer`}),inferIn:P.identifier({text:`inferIn`}),intersect:P.identifier({text:`intersect`}),json:P.identifier({text:`json`}),meta:P.identifier({text:`meta`}),narrow:P.identifier({text:`narrow`}),onDeepUndeclaredKey:P.identifier({text:`onDeepUndeclaredKey`}),onUndeclaredKey:P.identifier({text:`onUndeclaredKey`}),optional:P.identifier({text:`optional`}),or:P.identifier({text:`or`}),overlaps:P.identifier({text:`overlaps`}),pipe:P.identifier({text:`pipe`}),select:P.identifier({text:`select`}),to:P.identifier({text:`to`}),toJsonSchema:P.identifier({text:`toJsonSchema`})}},ps=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`arktype.type`}),o=P.constVariable({comment:t.config.comments?V({schema:n}):void 0,exportConst:r.exported,expression:P.callExpression({functionName:a.placeholder,parameters:[e.def?P.stringLiteral({text:e.def}):e.expression]}),name:r.placeholder});if(t.setSymbolValue(r,o),i){let e=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:m.default.factory.createTypeQueryNode(m.default.factory.createQualifiedName(m.default.factory.createIdentifier(r.placeholder),U.type.infer))});t.setSymbolValue(i,e)}},ms=e=>{let t={};return t.def=U.primitives.null,t},hs=({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=vs({optional:!c,plugin:e,schema:s,state:{...n,path:E([...n.path.value,`properties`,o])}});l.hasLazyExpression&&(r.hasLazyExpression=!0);let u=c?o:`${o}?`;u.endsWith(`?`)?u=m.default.factory.createComputedPropertyName(P.stringLiteral({text:u})):((u.match(/^[0-9]/)&&u.match(/\D+/g)||u.match(/\W/g))&&!u.startsWith(`'`)&&!u.endsWith(`'`)&&(u=`'${u}'`),O.lastIndex=0,u=O.test(u)?u.startsWith(`-`)?P.stringLiteral({text:o}):m.default.factory.createNumericLiteral(o):o),i.push(P.propertyAssignment({initializer:l.expression,name:u}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=vs({plugin:e,schema:t.additionalProperties,state:{...n,path:E([...n.path.value,`additionalProperties`])}});return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:`TODO`,name:`record`}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:`TODO`,name:`string`}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r}return r.expression=m.default.factory.createObjectLiteralExpression(i,!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r},gs=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=U.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${U.string.date}.${U.string.iso}`;break;case`email`:n=`${n}.${U.string.email}`;break;case`ipv4`:n=`${n}.${U.string.ip}.${U.string.v4}`;break;case`ipv6`:n=`${n}.${U.string.ip}.${U.string.v6}`;break;case`uri`:n=`${n}.${U.string.url}`;break;case`uuid`:n=`${n}.${U.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},_s=({schema:e,...t})=>{switch(e.type){case`null`:return ms({...t,schema:e});case`object`:return hs({...t,schema:e});case`string`:return gs({...t,schema:e})}let n=t.plugin.referenceSymbol({category:`external`,resource:`arktype.type`});return{def:``,expression:m.default.factory.createCallExpression(m.default.factory.createIdentifier(n.placeholder),void 0,[m.default.factory.createObjectLiteralExpression([m.default.factory.createPropertyAssignment(`name`,m.default.factory.createStringLiteral(`string`)),m.default.factory.createPropertyAssignment(`platform`,m.default.factory.createStringLiteral(`'android' | 'ios'`)),m.default.factory.createPropertyAssignment(m.default.factory.createComputedPropertyName(m.default.factory.createStringLiteral(`versions?`)),m.default.factory.createStringLiteral(`(number | string)[]`))],!0)]),hasLazyExpression:!1}},vs=({plugin:e,schema:t,state:n})=>{let r={};if(t.$ref){let i={category:`schema`,resource:`definition`,resourceId:t.$ref,tool:`arktype`},a=e.referenceSymbol(i);e.isSymbolRegistered(i)?r.expression=P.identifier({text:a.placeholder}):(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:`TODO`,name:`TODO`}),parameters:[P.arrowFunction({returnType:P.keywordTypeNode({keyword:`any`}),statements:[P.returnStatement({expression:P.identifier({text:a.placeholder})})]})]}),r.hasLazyExpression=!0,n.hasLazyExpression.value=!0)}else if(t.type){let i=_s({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=S({schema:t}),t.items||(r=vs({plugin:e,schema:t,state:n}));else{let t=_s({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=_s({plugin:e,schema:{type:`unknown`},state:n}).expression,r},ys=({plugin:e,schema:t,state:n})=>{let r=rr(n.path.value),i=vs({plugin:e,schema:t,state:n}),a=F(r);ps({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`arktype`},name:x({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tool:`arktype`,variant:`infer`},name:x({config:e.config.definitions.types.infer,name:a})}):void 0})},bs=({plugin:e})=>{e.registerSymbol({external:`arktype`,meta:{category:`external`,resource:`arktype.type`},name:`type`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=D({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:ys({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:ys({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:ys({plugin:e,schema:t.schema,state:n});break}})},xs=e=>bs(e),Ss={api:new fs,config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:xs,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:y,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:{...y,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:y,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:{...y,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:y,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:{...y,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:y,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:{...y,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:y,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},Cs=v(Ss),ws=({operation:e,plugin:t})=>{let n=[],r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`data`,tool:`typescript`});r&&(e.body&&n.push({isRequired:e.body.required,name:`Body`,type:`${r.placeholder}['body']`}),e.parameters&&(e.parameters.header&&n.push({isRequired:$e(e.parameters.header),name:`Headers`,type:`${r.placeholder}['headers']`}),e.parameters.path&&n.push({isRequired:$e(e.parameters.path),name:`Params`,type:`${r.placeholder}['path']`}),e.parameters.query&&n.push({isRequired:$e(e.parameters.query),name:`Querystring`,type:`${r.placeholder}['query']`})));let{errors:i,responses:a}=at(e),o,s=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`errors`});if(s&&i&&i.properties){let e=Object.keys(i.properties);if(e.length){if(!e.includes(`default`))o=P.typeReferenceNode({typeName:s.placeholder});else if(e.length>1){let e=P.typeReferenceNode({typeName:s.placeholder}),t=P.literalTypeNode({literal:P.stringLiteral({text:`default`})});o=P.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let c,l=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`responses`});if(l&&a&&a.properties){let e=Object.keys(a.properties);if(e.length){if(!e.includes(`default`))c=P.typeReferenceNode({typeName:l.placeholder});else if(e.length>1){let e=P.typeReferenceNode({typeName:l.placeholder}),t=P.literalTypeNode({literal:P.stringLiteral({text:`default`})});c=P.typeReferenceNode({typeArguments:[e,t],typeName:`Omit`})}}}let u=[o,c].filter(Boolean);if(u.length&&n.push({name:`Reply`,type:P.typeIntersectionNode({types:u})}),!n.length)return;let d=t.referenceSymbol({category:`type`,resource:`route-handler`,tool:`fastify`});return{name:e.id,type:P.typeReferenceNode({typeArguments:[P.typeInterfaceNode({properties:n,useLegacyResolution:!1})],typeName:d.placeholder})}},Ts=({plugin:e})=>{e.registerSymbol({external:`fastify`,kind:`type`,meta:{category:`type`,resource:`route-handler`,tool:`fastify`},name:`RouteHandler`});let t=e.registerSymbol({exported:!0,kind:`type`,name:`RouteHandlers`}),n=[];e.forEach(`operation`,({operation:t})=>{let r=ws({operation:t,plugin:e});r&&n.push(r)},{order:`declarations`});let r=P.typeAliasDeclaration({exportType:t.exported,name:t.placeholder,type:P.typeInterfaceNode({properties:n,useLegacyResolution:!1})});e.setSymbolValue(t,r)},Es={config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:Ts,name:`fastify`},Ds=v(Es),Os=({operation:e,plugin:t,queryFn:n})=>{if(gr({operation:e}))return;let r=t.referenceSymbol({category:`external`,resource:`swr`}),i=t.registerSymbol({exported:!0,name:x({config:t.config.useSwr,name:e.id})}),a=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{key:`throwOnError`,value:!0}]})]})}),o=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?o.push(P.returnVariable({expression:a})):o.push(P.constVariable({destructure:!0,expression:a,name:`data`}),P.returnVariable({expression:`data`}));let s=P.constVariable({comment:t.config.comments?I({operation:e}):void 0,exportConst:i.exported,expression:P.arrowFunction({parameters:[],statements:[P.returnStatement({expression:P.callExpression({functionName:r.placeholder,parameters:[P.stringLiteral({text:e.path}),P.arrowFunction({async:!0,statements:o})]})})]}),name:i.placeholder});t.setSymbolValue(i,s)},ks=({plugin:e})=>{e.registerSymbol({external:`swr`,importKind:`default`,kind:`function`,meta:{category:`external`,resource:`swr`},name:`useSWR`});let t=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let r=t.config.asClass?ur({context:e.context,operation:n,plugin:t}):void 0,i=r?r.values().next().value:void 0,a=i?[e.referenceSymbol({category:`utility`,resource:`class`,resourceId:i.path[0],tool:`sdk`}).placeholder,...i.path.slice(1).map(e=>b({case:`camelCase`,value:e})),i.methodName].filter(Boolean).join(`.`):e.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:n.id}).placeholder;e.hooks.operation.isQuery(n)&&e.config.useSwr.enabled&&Os({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},As=e=>ks(e),js={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:As,name:`swr`,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.useSwr=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`use{{name}}`},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.useSwr}),e.config.useSwr.enabled&&(e.config.queryOptions.enabled||(e.config.queryOptions.enabled=!0,e.config.queryOptions.exported=!1))}},Ms=v(js),W={actions:{args:P.identifier({text:`args`}),base64:P.identifier({text:`base64`}),bic:P.identifier({text:`bic`}),brand:P.identifier({text:`brand`}),bytes:P.identifier({text:`bytes`}),check:P.identifier({text:`check`}),checkItems:P.identifier({text:`checkItems`}),creditCard:P.identifier({text:`creditCard`}),cuid2:P.identifier({text:`cuid2`}),decimal:P.identifier({text:`decimal`}),description:P.identifier({text:`description`}),digits:P.identifier({text:`digits`}),email:P.identifier({text:`email`}),emoji:P.identifier({text:`emoji`}),empty:P.identifier({text:`empty`}),endsWith:P.identifier({text:`endsWith`}),entries:P.identifier({text:`entries`}),everyItem:P.identifier({text:`everyItem`}),excludes:P.identifier({text:`excludes`}),filterItems:P.identifier({text:`filterItems`}),findItem:P.identifier({text:`findItem`}),finite:P.identifier({text:`finite`}),flavor:P.identifier({text:`flavor`}),graphemes:P.identifier({text:`graphemes`}),gtValue:P.identifier({text:`gtValue`}),hash:P.identifier({text:`hash`}),hexColor:P.identifier({text:`hexColor`}),hexadecimal:P.identifier({text:`hexadecimal`}),imei:P.identifier({text:`imei`}),includes:P.identifier({text:`includes`}),integer:P.identifier({text:`integer`}),ip:P.identifier({text:`ip`}),ipv4:P.identifier({text:`ipv4`}),ipv6:P.identifier({text:`ipv6`}),isoDate:P.identifier({text:`isoDate`}),isoDateTime:P.identifier({text:`isoDateTime`}),isoTime:P.identifier({text:`isoTime`}),isoTimeSecond:P.identifier({text:`isoTimeSecond`}),isoTimestamp:P.identifier({text:`isoTimestamp`}),isoWeek:P.identifier({text:`isoWeek`}),length:P.identifier({text:`length`}),ltValue:P.identifier({text:`ltValue`}),mac:P.identifier({text:`mac`}),mac48:P.identifier({text:`mac48`}),mac64:P.identifier({text:`mac64`}),mapItems:P.identifier({text:`mapItems`}),maxBytes:P.identifier({text:`maxBytes`}),maxEntries:P.identifier({text:`maxEntries`}),maxGraphemes:P.identifier({text:`maxGraphemes`}),maxLength:P.identifier({text:`maxLength`}),maxSize:P.identifier({text:`maxSize`}),maxValue:P.identifier({text:`maxValue`}),maxWords:P.identifier({text:`maxWords`}),metadata:P.identifier({text:`metadata`}),mimeType:P.identifier({text:`mimeType`}),minBytes:P.identifier({text:`minBytes`}),minEntries:P.identifier({text:`minEntries`}),minGraphemes:P.identifier({text:`minGraphemes`}),minLength:P.identifier({text:`minLength`}),minSize:P.identifier({text:`minSize`}),minValue:P.identifier({text:`minValue`}),minWords:P.identifier({text:`minWords`}),multipleOf:P.identifier({text:`multipleOf`}),nanoid:P.identifier({text:`nanoid`}),nonEmpty:P.identifier({text:`nonEmpty`}),normalize:P.identifier({text:`normalize`}),notBytes:P.identifier({text:`notBytes`}),notEntries:P.identifier({text:`notEntries`}),notGraphemes:P.identifier({text:`notGraphemes`}),notLength:P.identifier({text:`notLength`}),notSize:P.identifier({text:`notSize`}),notValue:P.identifier({text:`notValue`}),notValues:P.identifier({text:`notValues`}),notWords:P.identifier({text:`notWords`}),octal:P.identifier({text:`octal`}),parseJson:P.identifier({text:`parseJson`}),partialCheck:P.identifier({text:`partialCheck`}),rawCheck:P.identifier({text:`rawCheck`}),rawTransform:P.identifier({text:`rawTransform`}),readonly:P.identifier({text:`readonly`}),reduceItems:P.identifier({text:`reduceItems`}),regex:P.identifier({text:`regex`}),returns:P.identifier({text:`returns`}),rfcEmail:P.identifier({text:`rfcEmail`}),safeInteger:P.identifier({text:`safeInteger`}),size:P.identifier({text:`size`}),slug:P.identifier({text:`slug`}),someItem:P.identifier({text:`someItem`}),sortItems:P.identifier({text:`sortItems`}),startsWith:P.identifier({text:`startsWith`}),stringifyJson:P.identifier({text:`stringifyJson`}),title:P.identifier({text:`title`}),toLowerCase:P.identifier({text:`toLowerCase`}),toMaxValue:P.identifier({text:`toMaxValue`}),toMinValue:P.identifier({text:`toMinValue`}),toUpperCase:P.identifier({text:`toUpperCase`}),transform:P.identifier({text:`transform`}),trim:P.identifier({text:`trim`}),trimEnd:P.identifier({text:`trimEnd`}),trimStart:P.identifier({text:`trimStart`}),ulid:P.identifier({text:`ulid`}),url:P.identifier({text:`url`}),uuid:P.identifier({text:`uuid`}),value:P.identifier({text:`value`}),values:P.identifier({text:`values`}),words:P.identifier({text:`words`})},async:{argsAsync:P.identifier({text:`argsAsync`}),arrayAsync:P.identifier({text:`arrayAsync`}),awaitAsync:P.identifier({text:`awaitAsync`}),checkAsync:P.identifier({text:`checkAsync`}),checkItemsAsync:P.identifier({text:`checkItemsAsync`}),customAsync:P.identifier({text:`customAsync`}),exactOptionalAsync:P.identifier({text:`exactOptionalAsync`}),fallbackAsync:P.identifier({text:`fallbackAsync`}),forwardAsync:P.identifier({text:`forwardAsync`}),getDefaultsAsync:P.identifier({text:`getDefaultsAsync`}),getFallbacksAsync:P.identifier({text:`getFallbacksAsync`}),intersectAsync:P.identifier({text:`intersectAsync`}),lazyAsync:P.identifier({text:`lazyAsync`}),looseObjectAsync:P.identifier({text:`looseObjectAsync`}),looseTupleAsync:P.identifier({text:`looseTupleAsync`}),mapAsync:P.identifier({text:`mapAsync`}),nonNullableAsync:P.identifier({text:`nonNullableAsync`}),nonNullishAsync:P.identifier({text:`nonNullishAsync`}),nonOptionalAsync:P.identifier({text:`nonOptionalAsync`}),nullableAsync:P.identifier({text:`nullableAsync`}),nullishAsync:P.identifier({text:`nullishAsync`}),objectAsync:P.identifier({text:`objectAsync`}),objectWithRestAsync:P.identifier({text:`objectWithRestAsync`}),optionalAsync:P.identifier({text:`optionalAsync`}),parseAsync:P.identifier({text:`parseAsync`}),parserAsync:P.identifier({text:`parserAsync`}),partialAsync:P.identifier({text:`partialAsync`}),partialCheckAsync:P.identifier({text:`partialCheckAsync`}),pipeAsync:P.identifier({text:`pipeAsync`}),rawCheckAsync:P.identifier({text:`rawCheckAsync`}),rawTransformAsync:P.identifier({text:`rawTransformAsync`}),recordAsync:P.identifier({text:`recordAsync`}),requiredAsync:P.identifier({text:`requiredAsync`}),returnsAsync:P.identifier({text:`returnsAsync`}),safeParseAsync:P.identifier({text:`safeParseAsync`}),safeParserAsync:P.identifier({text:`safeParserAsync`}),setAsync:P.identifier({text:`setAsync`}),strictObjectAsync:P.identifier({text:`strictObjectAsync`}),strictTupleAsync:P.identifier({text:`strictTupleAsync`}),transformAsync:P.identifier({text:`transformAsync`}),tupleAsync:P.identifier({text:`tupleAsync`}),tupleWithRestAsync:P.identifier({text:`tupleWithRestAsync`}),undefinedableAsync:P.identifier({text:`undefinedableAsync`}),unionAsync:P.identifier({text:`unionAsync`}),variantAsync:P.identifier({text:`variantAsync`})},methods:{assert:P.identifier({text:`assert`}),config:P.identifier({text:`config`}),fallback:P.identifier({text:`fallback`}),flatten:P.identifier({text:`flatten`}),forward:P.identifier({text:`forward`}),getDefault:P.identifier({text:`getDefault`}),getDefaults:P.identifier({text:`getDefaults`}),getDescription:P.identifier({text:`getDescription`}),getFallback:P.identifier({text:`getFallback`}),getFallbacks:P.identifier({text:`getFallbacks`}),getMetadata:P.identifier({text:`getMetadata`}),getTitle:P.identifier({text:`getTitle`}),is:P.identifier({text:`is`}),keyof:P.identifier({text:`keyof`}),message:P.identifier({text:`message`}),omit:P.identifier({text:`omit`}),parse:P.identifier({text:`parse`}),parser:P.identifier({text:`parser`}),partial:P.identifier({text:`partial`}),pick:P.identifier({text:`pick`}),pipe:P.identifier({text:`pipe`}),required:P.identifier({text:`required`}),safeParse:P.identifier({text:`safeParse`}),safeParser:P.identifier({text:`safeParser`}),summarize:P.identifier({text:`summarize`}),unwrap:P.identifier({text:`unwrap`})},schemas:{any:P.identifier({text:`any`}),array:P.identifier({text:`array`}),bigInt:P.identifier({text:`bigint`}),blob:P.identifier({text:`blob`}),boolean:P.identifier({text:`boolean`}),custom:P.identifier({text:`custom`}),date:P.identifier({text:`date`}),enum:P.identifier({text:`enum`}),exactOptional:P.identifier({text:`exactOptional`}),file:P.identifier({text:`file`}),function:P.identifier({text:`function`}),instance:P.identifier({text:`instance`}),intersect:P.identifier({text:`intersect`}),lazy:P.identifier({text:`lazy`}),literal:P.identifier({text:`literal`}),looseObject:P.identifier({text:`looseObject`}),looseTuple:P.identifier({text:`looseTuple`}),map:P.identifier({text:`map`}),nan:P.identifier({text:`nan`}),never:P.identifier({text:`never`}),nonNullable:P.identifier({text:`nonNullable`}),nonNullish:P.identifier({text:`nonNullish`}),nonOptional:P.identifier({text:`nonOptional`}),null:P.identifier({text:`null`}),nullable:P.identifier({text:`nullable`}),nullish:P.identifier({text:`nullish`}),number:P.identifier({text:`number`}),object:P.identifier({text:`object`}),objectWithRest:P.identifier({text:`objectWithRest`}),optional:P.identifier({text:`optional`}),picklist:P.identifier({text:`picklist`}),promise:P.identifier({text:`promise`}),record:P.identifier({text:`record`}),set:P.identifier({text:`set`}),strictObject:P.identifier({text:`strictObject`}),strictTuple:P.identifier({text:`strictTuple`}),string:P.identifier({text:`string`}),symbol:P.identifier({text:`symbol`}),tuple:P.identifier({text:`tuple`}),tupleWithRest:P.identifier({text:`tupleWithRest`}),undefined:P.identifier({text:`undefined`}),undefinedable:P.identifier({text:`undefinedable`}),union:P.identifier({text:`union`}),unknown:P.identifier({text:`unknown`}),variant:P.identifier({text:`variant`}),void:P.identifier({text:`void`})},storages:{},types:{GenericSchema:P.identifier({text:`GenericSchema`})},utils:{}},Ns=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`valibot`});if(!n)return;let r=t.referenceSymbol({category:`external`,resource:`valibot.v`}),i=`data`;return P.arrowFunction({async:!0,parameters:[{name:i}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:W.async.parseAsync}),parameters:[P.identifier({text:n.placeholder}),P.identifier({text:i})]})})})]})},Ps=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`valibot`});if(!n)return;let r=t.referenceSymbol({category:`external`,resource:`valibot.v`}),i=`data`;return P.arrowFunction({async:!0,parameters:[{name:i}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:W.async.parseAsync}),parameters:[P.identifier({text:n.placeholder}),P.identifier({text:i})]})})})]})};var Fs=class{createRequestValidator(e){return Ns(e)}createResponseValidator(e){return Ps(e)}};const G=({pipes:e,plugin:t})=>{if(e.length===1)return e[0];let n=t.referenceSymbol({category:`external`,resource:`valibot.v`});return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.methods.pipe}),parameters:e})},Is=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`valibot.v`}),o=P.constVariable({comment:t.config.comments?V({schema:n}):void 0,exportConst:i.exported,expression:G({pipes:e.pipes,plugin:t}),name:i.placeholder,typeName:r.hasLazyExpression.value?P.propertyAccessExpression({expression:a.placeholder,name:e.typeName||W.types.GenericSchema.text}):void 0});t.setSymbolValue(i,o)},Ls={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}},Rs=e=>e!==void 0&&e in Ls,zs=e=>Rs(e)&&Ls[e].needsBigInt,Bs=({isBigInt:e,value:t})=>{let n=P.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?P.callExpression({functionName:`BigInt`,parameters:[n]}):n},Vs=({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],Is({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`operation`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`valibot`},name:x({config:n.config.requests,name:t.id})})})}if(n.config.responses.enabled&&t.responses){let{response:i}=at(t);if(i){let a=[...r.path.value,`responses`];Is({ast:e(i,a),plugin:n,schema:i,state:r,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:r.tags?.value,tool:`valibot`},name:x({config:n.config.responses,name:t.id})})})}}},Hs=({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],Is({ast:e(a,r.path.value),plugin:n,schema:a,state:r,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`webhook`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`valibot`},name:x({config:n.config.webhooks,name:t.id})})})}},Us=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:W.schemas.unknown})})},Ws=({plugin:e,schema:t,state:n})=>{let r={pipes:[]},i=e.referenceSymbol({category:`external`,resource:`valibot.v`}),a=P.propertyAccessExpression({expression:i.placeholder,name:W.schemas.array});if(t.items){t=S({schema:t});let i=t.items.map((t,i)=>{let a=nc({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),G({pipes:a.pipes,plugin:e})});if(i.length===1){let e=P.callExpression({functionName:a,parameters:i});r.pipes.push(e)}else{t.logicalOperator;let i=P.callExpression({functionName:a,parameters:[Us({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(i)}}else{let t=P.callExpression({functionName:a,parameters:[Us({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:W.actions.length}),parameters:[P.valueToExpression({value:t.minItems})]});r.pipes.push(e)}else{if(t.minItems!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:W.actions.minLength}),parameters:[P.valueToExpression({value:t.minItems})]});r.pipes.push(e)}if(t.maxItems!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:W.actions.maxLength}),parameters:[P.valueToExpression({value:t.maxItems})]});r.pipes.push(e)}}return r},Gs=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`valibot.v`});return typeof t.const==`boolean`?P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.schemas.literal}),parameters:[P.ots.boolean(t.const)]}):P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.schemas.boolean})})},Ks=({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(P.stringLiteral({text:e.const})):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return Us({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol({category:`external`,resource:`valibot.v`}),o=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:W.schemas.picklist}),parameters:[P.arrayLiteralExpression({elements:r,multiLine:!1})]});return i&&(o=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:W.schemas.nullable}),parameters:[o]})),o},qs=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:W.schemas.never})})},Js=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:W.schemas.null})})},Ys=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=zs(n),a=Rs(n)?Ls[n]:null,o=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(t.const!==void 0&&t.const!==null){let e=t.const,r;if(typeof e==`number`&&!n)r=P.ots.number(e);else if(typeof e==`number`&&n)r=i?P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(e.toString())]}):P.ots.number(e);else if(typeof e==`string`&&i){let t=e.endsWith(`n`)?e.slice(0,-1):e;r=P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(t)]})}else if(typeof e==`bigint`){let t=e.toString(),n=t.endsWith(`n`)?t.slice(0,-1):t;r=P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(n)]})}else r=P.valueToExpression({value:e});return P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.schemas.literal}),parameters:[r]})}let s=[];if(i){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.schemas.union}),parameters:[P.arrayLiteralExpression({elements:[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.schemas.number})}),P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.schemas.string})}),P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.schemas.bigInt})})],multiLine:!1})]});s.push(e);let t=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.actions.transform}),parameters:[P.arrowFunction({parameters:[{name:`x`}],statements:P.callExpression({functionName:`BigInt`,parameters:[P.identifier({text:`x`})]})})]});s.push(t)}else{let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.schemas.number})});s.push(e)}if(!i&&r){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.actions.integer})});s.push(e)}if(a){let e=a.min,t=a.max,n=a.minError,r=a.maxError,c=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.actions.minValue}),parameters:[i?P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(e.toString())]}):P.ots.number(e),P.ots.string(n)]});s.push(c);let l=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.actions.maxValue}),parameters:[i?P.callExpression({functionName:`BigInt`,parameters:[P.ots.string(t.toString())]}):P.ots.number(t),P.ots.string(r)]});s.push(l)}if(t.exclusiveMinimum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.actions.gtValue}),parameters:[Bs({isBigInt:i,value:t.exclusiveMinimum})]});s.push(e)}else if(t.minimum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.actions.minValue}),parameters:[Bs({isBigInt:i,value:t.minimum})]});s.push(e)}if(t.exclusiveMaximum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.actions.ltValue}),parameters:[Bs({isBigInt:i,value:t.exclusiveMaximum})]});s.push(e)}else if(t.maximum!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.actions.maxValue}),parameters:[Bs({isBigInt:i,value:t.maximum})]});s.push(e)}return G({pipes:s,plugin:e})},Xs=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=nc({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:E([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),O.lastIndex=0;let l;l=O.test(o)?o.startsWith(`-`)?m.default.factory.createStringLiteral(o):m.default.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(l=`'${o}'`),i.push(P.propertyAssignment({initializer:G({pipes:c.pipes,plugin:e}),name:l}))}let o=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(t.additionalProperties&&typeof t.additionalProperties==`object`&&t.additionalProperties.type!==void 0){let a=nc({plugin:e,schema:t.additionalProperties,state:{...n,path:E([...n.path.value,`additionalProperties`])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),Object.keys(i).length?(r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.schemas.objectWithRest}),parameters:[m.default.factory.createObjectLiteralExpression(i,!0),G({pipes:a.pipes,plugin:e})]})],r):(r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.schemas.record}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.schemas.string}),parameters:[]}),G({pipes:a.pipes,plugin:e})]})],r)}return r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.schemas.object}),parameters:[m.default.factory.createObjectLiteralExpression(i,!0)]})],r},Zs=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(typeof t.const==`string`)return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.schemas.literal}),parameters:[P.ots.string(t.const)]});let r=[],i=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.schemas.string})});if(r.push(i),t.format)switch(t.format){case`date`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.actions.isoDate})}));break;case`date-time`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.actions.isoTimestamp})}));break;case`ipv4`:case`ipv6`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.actions.ip})}));break;case`time`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.actions.isoTimeSecond})}));break;case`uri`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.actions.url})}));break;case`email`:case`uuid`:r.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:P.identifier({text:t.format})})}));break}if(t.minLength===t.maxLength&&t.minLength!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.actions.length}),parameters:[P.valueToExpression({value:t.minLength})]});r.push(e)}else{if(t.minLength!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.actions.minLength}),parameters:[P.valueToExpression({value:t.minLength})]});r.push(e)}if(t.maxLength!==void 0){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.actions.maxLength}),parameters:[P.valueToExpression({value:t.maxLength})]});r.push(e)}}if(t.pattern){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:W.actions.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]});r.push(e)}return G({pipes:r,plugin:e})},Qs=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:W.schemas.literal}),parameters:[P.valueToExpression({value:e})]}));return r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:W.schemas.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]})],r}if(t.items){let a=t.items.map((t,i)=>{let a=nc({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),G({pipes:a.pipes,plugin:e})});return r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:W.schemas.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]})],r}return{pipes:[Us({plugin:e,schema:{type:`unknown`},state:n})]}},$s=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:W.schemas.undefined})})},ec=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:W.schemas.void})})},tc=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:G({pipes:Ws({...t,schema:e}).pipes,plugin:t.plugin})};case`boolean`:return{expression:Gs({...t,schema:e})};case`enum`:return{expression:Ks({...t,schema:e})};case`integer`:case`number`:return{expression:Ys({...t,schema:e})};case`never`:return{expression:qs({...t,schema:e})};case`null`:return{expression:Js({...t,schema:e})};case`object`:return{expression:G({pipes:Xs({...t,schema:e}).pipes,plugin:t.plugin})};case`string`:return e.format===`int64`||e.format===`uint64`?{expression:Ys({...t,schema:e})}:{expression:Zs({...t,schema:e})};case`tuple`:return{expression:G({pipes:Qs({...t,schema:e}).pipes,plugin:t.plugin})};case`undefined`:return{expression:$s({...t,schema:e})};case`unknown`:return{expression:Us({...t,schema:e})};case`void`:return{expression:ec({...t,schema:e})}}},nc=({optional:e,plugin:t,schema:n,state:r})=>{let i={pipes:[]},a=t.referenceSymbol({category:`external`,resource:`valibot.v`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`valibot`},o=t.referenceSymbol(e);if(t.isSymbolRegistered(e)){let e=P.identifier({text:o.placeholder});i.pipes.push(e)}else{let e=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:W.schemas.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]});i.pipes.push(e),r.hasLazyExpression.value=!0}}else if(n.type){let e=tc({plugin:t,schema:n,state:r});if(i.typeName=e.anyType,i.pipes.push(e.expression),t.config.metadata&&n.description){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:W.actions.metadata}),parameters:[P.objectExpression({obj:[{key:`description`,value:P.stringLiteral({text:n.description})}]})]});i.pipes.push(e)}}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>G({pipes:nc({plugin:t,schema:e,state:{...r,path:E([...r.path.value,`items`,n])}}).pipes,plugin:t}));if(n.logicalOperator===`and`){let t=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:W.schemas.intersect}),parameters:[P.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}else{let t=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:W.schemas.union}),parameters:[P.arrayLiteralExpression({elements:e})]});i.pipes.push(t)}}else{let e=nc({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=tc({plugin:t,schema:{type:`unknown`},state:r});i.typeName=e.anyType,i.pipes.push(e.expression)}if(i.pipes.length){if(n.accessScope===`read`){let e=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:W.actions.readonly})});i.pipes.push(e)}let r;n.default!==void 0&&(r=Bs({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default}),r&&(i.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:W.schemas.optional}),parameters:[G({pipes:i.pipes,plugin:t}),r]})])),e&&!r&&(i.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:W.schemas.optional}),parameters:[G({pipes:i.pipes,plugin:t})]})])}return i},rc=({plugin:e,schema:t,state:n})=>{let r=rr(n.path.value),i=nc({plugin:e,schema:t,state:n}),a=F(r);Is({ast:i,plugin:e,schema:t,state:n,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`valibot`},name:x({config:e.config.definitions,name:a})})})},ic=({plugin:e})=>{e.registerSymbol({external:`valibot`,importKind:`namespace`,meta:{category:`external`,resource:`valibot.v`},name:`v`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=D({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Vs({getAst:(n,r)=>nc({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:rc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:rc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:rc({plugin:e,schema:t.schema,state:n});break;case`webhook`:Hs({getAst:(n,r)=>nc({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},ac=e=>ic(e),oc={api:new Fs,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:ac,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`]},sc=v(oc),K={ZodMiniOptional:P.identifier({text:`ZodMiniOptional`}),ZodOptional:P.identifier({text:`ZodOptional`}),_default:P.identifier({text:`_default`}),and:P.identifier({text:`and`}),array:P.identifier({text:`array`}),bigint:P.identifier({text:`bigint`}),boolean:P.identifier({text:`boolean`}),check:P.identifier({text:`check`}),coerce:P.identifier({text:`coerce`}),date:P.identifier({text:`date`}),datetime:P.identifier({text:`datetime`}),default:P.identifier({text:`default`}),describe:P.identifier({text:`describe`}),email:P.identifier({text:`email`}),enum:P.identifier({text:`enum`}),globalRegistry:P.identifier({text:`globalRegistry`}),gt:P.identifier({text:`gt`}),gte:P.identifier({text:`gte`}),infer:P.identifier({text:`infer`}),int:P.identifier({text:`int`}),intersection:P.identifier({text:`intersection`}),ip:P.identifier({text:`ip`}),ipv4:P.identifier({text:`ipv4`}),ipv6:P.identifier({text:`ipv6`}),iso:P.identifier({text:`iso`}),lazy:P.identifier({text:`lazy`}),length:P.identifier({text:`length`}),literal:P.identifier({text:`literal`}),lt:P.identifier({text:`lt`}),lte:P.identifier({text:`lte`}),max:P.identifier({text:`max`}),maxLength:P.identifier({text:`maxLength`}),min:P.identifier({text:`min`}),minLength:P.identifier({text:`minLength`}),never:P.identifier({text:`never`}),null:P.identifier({text:`null`}),nullable:P.identifier({text:`nullable`}),number:P.identifier({text:`number`}),object:P.identifier({text:`object`}),optional:P.identifier({text:`optional`}),parseAsync:P.identifier({text:`parseAsync`}),readonly:P.identifier({text:`readonly`}),record:P.identifier({text:`record`}),regex:P.identifier({text:`regex`}),register:P.identifier({text:`register`}),string:P.identifier({text:`string`}),time:P.identifier({text:`time`}),tuple:P.identifier({text:`tuple`}),undefined:P.identifier({text:`undefined`}),union:P.identifier({text:`union`}),unknown:P.identifier({text:`unknown`}),url:P.identifier({text:`url`}),uuid:P.identifier({text:`uuid`}),void:P.identifier({text:`void`})},cc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},lc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},uc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},dc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},fc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[P.identifier({text:r})]})})})]})},pc=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=`data`;return P.arrowFunction({async:!0,parameters:[{name:r}],statements:[P.returnStatement({expression:P.awaitExpression({expression:P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.parseAsync}),parameters:[P.identifier({text:r})]})})})]})};var mc=class{createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return uc(e);case`mini`:return cc(e);case 4:default:return fc(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return dc(e);case`mini`:return lc(e);case 4:default:return pc(e)}}};const hc=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`zod.z`}),o=P.constVariable({comment:t.config.comments?V({schema:n}):void 0,exportConst:r.exported,expression:e.expression,name:r.placeholder,typeName:e.typeName?P.propertyAccessExpression({expression:a.placeholder,name:e.typeName}):void 0});if(t.setSymbolValue(r,o),i){let e=P.typeAliasDeclaration({exportType:i.exported,name:i.placeholder,type:P.typeReferenceNode({typeArguments:[P.typeOfExpression({text:r.placeholder})],typeName:P.propertyAccessExpression({expression:a.placeholder,name:K.infer})})});t.setSymbolValue(i,e)}},gc=({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`}},q=({isBigInt:e,value:t})=>{let n=P.valueToExpression({value:t});return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?P.callExpression({functionName:`BigInt`,parameters:[n]}):n},_c=({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],hc({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`operation`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`},name:x({config:n.config.requests,name:t.id})}),typeInferSymbol:n.config.requests.types.infer.enabled?n.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:r.path.value,resource:`operation`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`,variant:`infer`},name:x({config:n.config.requests.types.infer,name:t.id})}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=at(t);if(i){let a=[...r.path.value,`responses`];hc({ast:e(i,a),plugin:n,schema:i,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:r.tags?.value,tool:`zod`},name:x({config:n.config.responses,name:t.id})}),typeInferSymbol:n.config.responses.types.infer.enabled?n.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:r.tags?.value,tool:`zod`,variant:`infer`},name:x({config:n.config.responses.types.infer,name:t.id})}):void 0})}}},vc=({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],hc({ast:e(a,r.path.value),plugin:n,schema:a,symbol:n.registerSymbol({exported:!0,meta:{category:`schema`,path:r.path.value,resource:`webhook`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`},name:x({config:n.config.webhooks,name:t.id})}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:r.path.value,resource:`webhook`,resourceId:t.id,role:`data`,tags:r.tags?.value,tool:`zod`,variant:`infer`},name:x({config:n.config.webhooks.types.infer,name:t.id})}):void 0})}},yc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.unknown})}),n},bc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={},a=P.propertyAccessExpression({expression:r.placeholder,name:K.array});if(!t.items)i.expression=P.callExpression({functionName:a,parameters:[yc({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=S({schema:t});let o=t.items.map((t,r)=>{let a=Mc({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,r])}});return a.hasLazyExpression&&(i.hasLazyExpression=!0),a.expression});if(o.length===1)i.expression=P.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=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.intersection}),parameters:[n,o[e]]})}i.expression=P.callExpression({functionName:a,parameters:[n]})}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.array}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.union}),parameters:[P.arrayLiteralExpression({elements:o})]})]})}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.length}),parameters:[P.valueToExpression({value:t.minItems})]})):(t.minItems!==void 0&&o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.minLength}),parameters:[P.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.maxLength}),parameters:[P.valueToExpression({value:t.maxItems})]}))),o.length&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:K.check}),parameters:o})),i},xc=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`}),r={};return typeof t.const==`boolean`?(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[P.ots.boolean(t.const)]}),r):(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.boolean})}),r)},Sc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`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=P.stringLiteral({text:e.const});a.push(t),o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=P.ots.number(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=P.ots.boolean(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.enum}),parameters:[P.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?i.expression=o[0]:i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.union}),parameters:[P.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.nullable}),parameters:[i.expression]})),i):yc({plugin:e,schema:{type:`unknown`},state:n})},Cc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.never})}),n},wc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.null})}),n},Tc=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`}),r={},i=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[P.ots.number(t.const)]}),r;r.expression=P.callExpression({functionName:i?P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:K.coerce}),name:K.bigint}):P.propertyAccessExpression({expression:n.placeholder,name:K.number})}),!i&&t.type===`integer`&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.int})}));let a=[];return t.exclusiveMinimum===void 0?t.minimum!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.gte}),parameters:[q({isBigInt:i,value:t.minimum})]})):a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.gt}),parameters:[q({isBigInt:i,value:t.exclusiveMinimum})]})),t.exclusiveMaximum===void 0?t.maximum!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.lte}),parameters:[q({isBigInt:i,value:t.maximum})]})):a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.lt}),parameters:[q({isBigInt:i,value:t.exclusiveMaximum})]})),a.length&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:K.check}),parameters:a})),r},Ec=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={},a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=Mc({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:E([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i.hasLazyExpression=!0),O.lastIndex=0;let l;l=O.test(r)?r.startsWith(`-`)?m.default.factory.createStringLiteral(r):m.default.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(l=`'${r}'`),c.hasLazyExpression?a.push(P.getAccessorDeclaration({name:l,statements:[P.returnStatement({expression:c.expression})]})):a.push(P.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let a=Mc({plugin:e,schema:t.additionalProperties,state:{...n,path:E([...n.path.value,`additionalProperties`])}});return i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.record}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.string}),parameters:[]}),a.expression]}),a.hasLazyExpression&&(i.hasLazyExpression=!0),i}return i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.object}),parameters:[m.default.factory.createObjectLiteralExpression(a,!0)]}),i},Dc=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`}),r={};if(typeof t.const==`string`)return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[P.ots.string(t.const)]}),r;r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.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=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:K.iso}),name:K.date})});break;case`date-time`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:K.iso}),name:K.datetime}),parameters:i.length>0?[P.objectExpression({obj:i})]:[]});break;case`email`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.email})});break;case`ipv4`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.ipv4})});break;case`ipv6`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.ipv6})});break;case`time`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:K.iso}),name:K.time})});break;case`uri`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.url})});break;case`uuid`:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.uuid})});break}let a=[];return t.minLength===t.maxLength&&t.minLength!==void 0?a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.length}),parameters:[P.valueToExpression({value:t.minLength})]})):(t.minLength!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.minLength}),parameters:[P.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.maxLength}),parameters:[P.valueToExpression({value:t.maxLength})]}))),t.pattern&&a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]})),a.length&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:K.check}),parameters:a})),r},Oc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={};if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[P.valueToExpression({value:e})]}));return i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]}),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=Mc({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]}),i},kc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.undefined})}),n},Ac=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.void})}),n},jc=({schema:e,...t})=>{switch(e.type){case`array`:return bc({...t,schema:e});case`boolean`:return xc({...t,schema:e});case`enum`:return Sc({...t,schema:e});case`integer`:case`number`:return Tc({...t,schema:e});case`never`:return Cc({...t,schema:e});case`null`:return wc({...t,schema:e});case`object`:return Ec({...t,schema:e});case`string`:return Dc({...t,schema:e});case`tuple`:return Oc({...t,schema:e});case`undefined`:return kc({...t,schema:e});case`unknown`:return yc({...t,schema:e});case`void`:return Ac({...t,schema:e})}},Mc=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=P.identifier({text:o.placeholder}):(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.lazy}),parameters:[P.arrowFunction({returnType:P.keywordTypeNode({keyword:`any`}),statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=jc({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:K.register}),parameters:[P.propertyAccessExpression({expression:a.placeholder,name:K.globalRegistry}),P.objectExpression({obj:[{key:`description`,value:P.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>Mc({plugin:t,schema:e,state:{...r,path:E([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.intersection}),parameters:[i.expression,e.hasLazyExpression?P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.union}),parameters:[P.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=Mc({plugin:t,schema:n,state:r});else i.expression=jc({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.readonly}),parameters:[i.expression]})),e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.optional}),parameters:[i.expression]}),i.typeName=K.ZodMiniOptional),n.default!==void 0)){let e=q({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K._default}),parameters:[i.expression,e]}))}return i},Nc=({plugin:e,schema:t,state:n})=>{let r=rr(n.path.value),i=Mc({plugin:e,schema:t,state:n}),a=F(r);hc({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`},name:x({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`,variant:`infer`},name:x({config:e.config.definitions.types.infer,name:a})}):void 0})},Pc=({plugin:e})=>{e.registerSymbol({external:gc({plugin:e}),importKind:`namespace`,meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=D({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:_c({getAst:(n,r)=>Mc({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Nc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Nc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Nc({plugin:e,schema:t.schema,state:n});break;case`webhook`:vc({getAst:(n,r)=>Mc({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Fc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.unknown})})},Ic=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=P.propertyAccessExpression({expression:r.placeholder,name:K.array}),a,o=!1;if(!t.items)a=P.callExpression({functionName:i,parameters:[Fc({plugin:e,schema:{type:`unknown`},state:n})]});else{t=S({schema:t});let s=t.items.map((t,r)=>{let i=Jc({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,r])}});return i.hasLazyExpression&&(o=!0),i.expression});if(s.length===1)a=P.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=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.intersection}),parameters:s});else{n=s[0];for(let e=1;e<s.length;e++)n=P.callExpression({functionName:P.propertyAccessExpression({expression:n,name:K.and}),parameters:[s[e]]})}a=P.callExpression({functionName:i,parameters:[n]})}else a=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.array}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.union}),parameters:[P.arrayLiteralExpression({elements:s})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?a=P.callExpression({functionName:P.propertyAccessExpression({expression:a,name:K.length}),parameters:[P.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(a=P.callExpression({functionName:P.propertyAccessExpression({expression:a,name:K.min}),parameters:[P.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(a=P.callExpression({functionName:P.propertyAccessExpression({expression:a,name:K.max}),parameters:[P.valueToExpression({value:t.maxItems})]}))),{expression:a,hasLazyExpression:o}},Lc=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[P.ots.boolean(t.const)]}):P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.boolean})})},Rc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=[],a=[],o=!1,s=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=P.stringLiteral({text:e.const});i.push(t),a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){s=!1;let t=P.ots.number(e.const);a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=P.ots.boolean(e.const);a.push(P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return Fc({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.enum}),parameters:[P.arrayLiteralExpression({elements:i,multiLine:!1})]}):a.length===1?a[0]:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.union}),parameters:[P.arrayLiteralExpression({elements:a,multiLine:a.length>3})]}),o&&(c=P.callExpression({functionName:P.propertyAccessExpression({expression:c,name:K.nullable})})),c},zc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.never})})},Bc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.null})})},Vc=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`}),r=t.type===`integer`&&t.format===`int64`;if(typeof t.const==`number`)return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[P.ots.number(t.const)]});let i=P.callExpression({functionName:r?P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:n.placeholder,name:K.coerce}),name:K.bigint}):P.propertyAccessExpression({expression:n.placeholder,name:K.number})});return!r&&t.type===`integer`&&(i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:K.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:K.gte}),parameters:[q({isBigInt:r,value:t.minimum})]})):i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:K.gt}),parameters:[q({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:K.lte}),parameters:[q({isBigInt:r,value:t.maximum})]})):i=P.callExpression({functionName:P.propertyAccessExpression({expression:i,name:K.lt}),parameters:[q({isBigInt:r,value:t.exclusiveMaximum})]}),i},Hc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=!1,a=[],o=t.required??[];for(let r in t.properties){let s=t.properties[r],c=Jc({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:E([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i=!0),O.lastIndex=0;let l;l=O.test(r)?r.startsWith(`-`)?m.default.factory.createStringLiteral(r):m.default.factory.createNumericLiteral(r):r,(r.match(/^[0-9]/)&&r.match(/\D+/g)||r.match(/\W/g))&&!r.startsWith(`'`)&&!r.endsWith(`'`)&&(l=`'${r}'`),a.push(P.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Jc({plugin:e,schema:t.additionalProperties,state:{...n,path:E([...n.path.value,`additionalProperties`])}});return{anyType:`AnyZodObject`,expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.record}),parameters:[i.expression]}),hasLazyExpression:i.hasLazyExpression}}return{anyType:`AnyZodObject`,expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.object}),parameters:[m.default.factory.createObjectLiteralExpression(a,!0)]}),hasLazyExpression:i}},Uc=({plugin:e,schema:t})=>{let n=e.referenceSymbol({category:`external`,resource:`zod.z`});if(typeof t.const==`string`)return P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.literal}),parameters:[P.ots.string(t.const)]});let r=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.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=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:K.date})});break;case`date-time`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:K.datetime}),parameters:i.length>0?[P.objectExpression({obj:i})]:[]});break;case`email`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:K.email})});break;case`ipv4`:case`ipv6`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:K.ip})});break;case`time`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:K.time})});break;case`uri`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:K.url})});break;case`uuid`:r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:K.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:K.length}),parameters:[P.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:K.min}),parameters:[P.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:K.max}),parameters:[P.valueToExpression({value:t.maxLength})]}))),t.pattern&&(r=P.callExpression({functionName:P.propertyAccessExpression({expression:r,name:K.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]})),r},Wc=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=!1;if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[P.valueToExpression({value:e})]}));return{expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]}),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=Jc({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]}),hasLazyExpression:i}},Gc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.undefined})})},Kc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.void})})},qc=({schema:e,...t})=>{switch(e.type){case`array`:return Ic({...t,schema:e});case`boolean`:return{expression:Lc({...t,schema:e})};case`enum`:return{expression:Rc({...t,schema:e})};case`integer`:case`number`:return{expression:Vc({...t,schema:e})};case`never`:return{expression:zc({...t,schema:e})};case`null`:return{expression:Bc({...t,schema:e})};case`object`:return Hc({...t,schema:e});case`string`:return{expression:Uc({...t,schema:e})};case`tuple`:return Wc({...t,schema:e});case`undefined`:return{expression:Gc({...t,schema:e})};case`unknown`:return{expression:Fc({...t,schema:e})};case`void`:return{expression:Kc({...t,schema:e})}}},Jc=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=P.identifier({text:o.placeholder}):(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=qc({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:K.describe}),parameters:[P.stringLiteral({text:n.description})]}))}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>Jc({plugin:t,schema:e,state:{...r,path:E([...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=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.intersection}),parameters:e}):(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:K.and}),parameters:[e]})}))}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.union}),parameters:[P.arrayLiteralExpression({elements:e})]})}else i=Jc({plugin:t,schema:n,state:r});else{let e=qc({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}if(i.expression&&(n.accessScope===`read`&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:K.readonly})})),e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:K.optional})})),n.default!==void 0)){let e=q({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:K.default}),parameters:[e]}))}return r.hasLazyExpression.value?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},Yc=({plugin:e,schema:t,state:n})=>{let r=rr(n.path.value),i=Jc({plugin:e,schema:t,state:n}),a=F(r);hc({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`},name:x({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`,variant:`infer`},name:x({config:e.config.definitions.types.infer,name:a})}):void 0})},Xc=({plugin:e})=>{e.registerSymbol({external:gc({plugin:e}),meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=D({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:_c({getAst:(n,r)=>Jc({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Yc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Yc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Yc({plugin:e,schema:t.schema,state:n});break;case`webhook`:vc({getAst:(n,r)=>Jc({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Zc=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.unknown})}),t},Qc=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a=P.propertyAccessExpression({expression:i.placeholder,name:K.array});if(!t.items)r.expression=P.callExpression({functionName:a,parameters:[Zc({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=S({schema:t});let o=t.items.map((t,i)=>{let a=ul({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),a.expression});if(o.length===1)r.expression=P.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=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.intersection}),parameters:o});else{n=o[0];for(let e=1;e<o.length;e++)n=P.callExpression({functionName:P.propertyAccessExpression({expression:n,name:K.and}),parameters:[o[e]]})}r.expression=P.callExpression({functionName:a,parameters:[n]})}else r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.array}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.union}),parameters:[P.arrayLiteralExpression({elements:o})]})]})}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:K.length}),parameters:[P.valueToExpression({value:t.minItems})]}):(t.minItems!==void 0&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:K.min}),parameters:[P.valueToExpression({value:t.minItems})]})),t.maxItems!==void 0&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.expression,name:K.max}),parameters:[P.valueToExpression({value:t.maxItems})]}))),r},$c=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[P.ots.boolean(t.const)]}),n):(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.boolean})}),n)},el=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a=[],o=[],s=!1,c=!0;for(let e of t.items??[])if(e.type===`string`&&typeof e.const==`string`){let t=P.stringLiteral({text:e.const});a.push(t),o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.literal}),parameters:[t]}))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=P.ots.number(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.literal}),parameters:[t]}))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=P.ots.boolean(e.const);o.push(P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.literal}),parameters:[t]}))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.enum}),parameters:[P.arrayLiteralExpression({elements:a,multiLine:!1})]}):o.length===1?r.expression=o[0]:r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.union}),parameters:[P.arrayLiteralExpression({elements:o,multiLine:o.length>3})]}),s&&(r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.nullable}),parameters:[r.expression]})),r):Zc({plugin:e,schema:{type:`unknown`},state:n})},tl=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.never})}),t},nl=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.null})}),t},rl=({plugin:e,schema:t})=>{let n={},r=t.type===`integer`&&t.format===`int64`,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`number`?(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.literal}),parameters:[P.ots.number(t.const)]}),n):(n.expression=P.callExpression({functionName:r?P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:i.placeholder,name:K.coerce}),name:K.bigint}):P.propertyAccessExpression({expression:i.placeholder,name:K.number})}),!r&&t.type===`integer`&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.int})})),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:K.gte}),parameters:[q({isBigInt:r,value:t.minimum})]})):n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:K.gt}),parameters:[q({isBigInt:r,value:t.exclusiveMinimum})]}),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:K.lte}),parameters:[q({isBigInt:r,value:t.maximum})]})):n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:K.lt}),parameters:[q({isBigInt:r,value:t.exclusiveMaximum})]}),n)},il=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[],o=e.referenceSymbol({category:`external`,resource:`zod.z`});for(let o in t.properties){let s=t.properties[o],c=ul({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:E([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),O.lastIndex=0;let l;l=O.test(o)?o.startsWith(`-`)?m.default.factory.createStringLiteral(o):m.default.factory.createNumericLiteral(o):o,(o.match(/^[0-9]/)&&o.match(/\D+/g)||o.match(/\W/g))&&!o.startsWith(`'`)&&!o.endsWith(`'`)&&(l=`'${o}'`),c.hasLazyExpression?i.push(P.getAccessorDeclaration({name:l,statements:[P.returnStatement({expression:c.expression})]})):i.push(P.propertyAssignment({initializer:c.expression,name:l}))}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=ul({plugin:e,schema:t.additionalProperties,state:{...n,path:E([...n.path.value,`additionalProperties`])}});return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:K.record}),parameters:[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:K.string}),parameters:[]}),i.expression]}),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`ZodType`}:r}return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:K.object}),parameters:[m.default.factory.createObjectLiteralExpression(i,!0)]}),r.hasLazyExpression?{...r,typeName:`ZodType`}:r},al=({plugin:e,schema:t})=>{let n={},r=e.referenceSymbol({category:`external`,resource:`zod.z`});if(typeof t.const==`string`)return n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.literal}),parameters:[P.ots.string(t.const)]}),n;n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.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=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:r.placeholder,name:K.iso}),name:K.date})});break;case`date-time`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:r.placeholder,name:K.iso}),name:K.datetime}),parameters:i.length>0?[P.objectExpression({obj:i})]:[]});break;case`email`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.email})});break;case`ipv4`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.ipv4})});break;case`ipv6`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.ipv6})});break;case`time`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:P.propertyAccessExpression({expression:r.placeholder,name:K.iso}),name:K.time})});break;case`uri`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.url})});break;case`uuid`:n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:r.placeholder,name:K.uuid})});break}return t.minLength===t.maxLength&&t.minLength!==void 0?n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:K.length}),parameters:[P.valueToExpression({value:t.minLength})]}):(t.minLength!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:K.min}),parameters:[P.valueToExpression({value:t.minLength})]})),t.maxLength!==void 0&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:K.max}),parameters:[P.valueToExpression({value:t.maxLength})]}))),t.pattern&&(n.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.expression,name:K.regex}),parameters:[P.regularExpressionLiteral({text:t.pattern})]})),n},ol=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`});if(t.const&&Array.isArray(t.const)){let e=t.const.map(e=>P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.literal}),parameters:[P.valueToExpression({value:e})]}));return r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.tuple}),parameters:[P.arrayLiteralExpression({elements:e})]}),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=ul({plugin:e,schema:t,state:{...n,path:E([...n.path.value,`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.placeholder,name:K.tuple}),parameters:[P.arrayLiteralExpression({elements:a})]}),r},sl=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.undefined})}),t},cl=({plugin:e})=>{let t={},n=e.referenceSymbol({category:`external`,resource:`zod.z`});return t.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:n.placeholder,name:K.void})}),t},ll=({schema:e,...t})=>{switch(e.type){case`array`:return Qc({...t,schema:e});case`boolean`:return $c({...t,schema:e});case`enum`:return el({...t,schema:e});case`integer`:case`number`:return rl({...t,schema:e});case`never`:return tl({...t,schema:e});case`null`:return nl({...t,schema:e});case`object`:return il({...t,schema:e});case`string`:return al({...t,schema:e});case`tuple`:return ol({...t,schema:e});case`undefined`:return sl({...t,schema:e});case`unknown`:return Zc({...t,schema:e});case`void`:return cl({...t,schema:e})}},ul=({optional:e,plugin:t,schema:n,state:r})=>{let i={},a=t.referenceSymbol({category:`external`,resource:`zod.z`});if(n.$ref){let e={category:`schema`,resource:`definition`,resourceId:n.$ref,tool:`zod`},o=t.referenceSymbol(e);t.isSymbolRegistered(e)?i.expression=P.identifier({text:o.placeholder}):(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.lazy}),parameters:[P.arrowFunction({returnType:P.keywordTypeNode({keyword:`any`}),statements:[P.returnStatement({expression:P.identifier({text:o.placeholder})})]})]}),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=ll({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:K.register}),parameters:[P.propertyAccessExpression({expression:a.placeholder,name:K.globalRegistry}),P.objectExpression({obj:[{key:`description`,value:P.stringLiteral({text:n.description})}]})]}))}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>ul({plugin:t,schema:e,state:{...r,path:E([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.intersection}),parameters:e.map(e=>e.expression)}):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:K.and}),parameters:[e.hasLazyExpression?P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.lazy}),parameters:[P.arrowFunction({statements:[P.returnStatement({expression:e.expression})]})]}):e.expression]})}))}else i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.union}),parameters:[P.arrayLiteralExpression({elements:e.map(e=>e.expression)})]})}else i=ul({plugin:t,schema:n,state:r});else i.expression=ll({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:K.readonly})})),e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:a.placeholder,name:K.optional}),parameters:[i.expression]}),i.typeName=K.ZodOptional),n.default!==void 0)){let e=q({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default});e&&(i.expression=P.callExpression({functionName:P.propertyAccessExpression({expression:i.expression,name:K.default}),parameters:[e]}))}return i},dl=({plugin:e,schema:t,state:n})=>{let r=rr(n.path.value),i=ul({plugin:e,schema:t,state:n}),a=F(r);hc({ast:i,plugin:e,schema:t,symbol:e.registerSymbol({exported:!0,meta:{category:`schema`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`},name:x({config:e.config.definitions,name:a})}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,path:n.path.value,resource:`definition`,resourceId:r,tags:n.tags?.value,tool:`zod`,variant:`infer`},name:x({config:e.config.definitions.types.infer,name:a})}):void 0})},fl=({plugin:e})=>{e.registerSymbol({external:gc({plugin:e}),meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=D({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:_c({getAst:(n,r)=>ul({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:dl({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:dl({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:dl({plugin:e,schema:t.schema,state:n});break;case`webhook`:vc({getAst:(n,r)=>ul({plugin:e,schema:n,state:D({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},pl=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Xc(e);case`mini`:return Pc(e);case 4:default:return fl(e)}},ml={api:new mc,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:pl,name:`zod`,resolveConfig:(e,t)=>{let n=t.package.getVersion(`zod`),r=()=>n&&(n.major===4||n.major===3)?n.major:4,i=e=>{if(!e)return r();if(!n)return e;if((e===4||e===3||e===`mini`)&&!t.package.satisfies(n,`>=3.25.0 <5.0.0`)){let t=r();return console.warn(`🔌 ${u.default.yellow(`Warning:`)} Installed ${u.default.cyan(`zod`)} ${u.default.cyan(`v${n.version}`)} does not support compatibility version ${u.default.yellow(String(e))}, using ${u.default.yellow(String(t))}.`),t}return e};e.config.compatibilityVersion=i(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{local:!1,offset:!1},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:y,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:{...y,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:y,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:{...y,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:y,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:{...y,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:y,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:{...y,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:y,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},hl=v(ml),gl={"@angular/common":Ar,"@hey-api/client-angular":qr,"@hey-api/client-axios":Yr,"@hey-api/client-fetch":Zr,"@hey-api/client-next":$r,"@hey-api/client-nuxt":ti,"@hey-api/client-ofetch":ri,"@hey-api/schemas":vi,"@hey-api/sdk":wa,"@hey-api/transformers":Fa,"@hey-api/typescript":po,"@pinia/colada":Mo,"@tanstack/angular-query-experimental":es,"@tanstack/react-query":ns,"@tanstack/solid-query":is,"@tanstack/svelte-query":os,"@tanstack/vue-query":cs,arktype:Ss,fastify:Es,swr:js,valibot:oc,zod:ml},_l=[`@hey-api/typescript`,`@hey-api/sdk`],vl=({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=gl[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:oi(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=gl[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=gl[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:_};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}},yl=e=>typeof e==`string`?e.startsWith(`@hey-api/client`):e.name.startsWith(`@hey-api/client`)||e.tags&&e.tags.includes(`client`),bl=({dependencies:e,userConfig:t})=>{let n={},r=_l;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&yl(t.plugins[0])?[..._l,...t.plugins]:t.plugins),vl({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})},xl=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),Sl=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=Ve(Object.keys(s).length?c:void 0));let l=s instanceof Array?s.map(e=>Le(e,i)):[Le(s,i)];for(let e of l){let t=Pe(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${u.default.yellow(`Warning:`)} You provided ${u.default.cyan(String(r))} ${u.default.cyan(r===1?`input`:`inputs`)} and ${u.default.yellow(String(i))} ${u.default.yellow(`outputs`)}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let r of e.output)n.push({...e,input:t,output:r})}else e.output.forEach((r,i)=>{n.push({...e,input:t[i],output:r})});else n.push({...e,input:t,output:e.output[0]??``})}else n.push({...e,input:t})}}i.timeEnd();let a=[],o=e.timeEvent(`build`);for(let e of n){let t=Fe(e),n=Pe(e),i=Be(e),o=Ue(e),s=[];n.length||s.push(new ce(`missing input - which OpenAPI specification should we use to generate your output?`)),i.path||s.push(new ce(`missing output - where should we generate your output?`)),i.path=f.default.resolve(process.cwd(),i.path);let c;try{c=bl({dependencies:r,userConfig:e})}catch(e){s.push(e),c={pluginOrder:[],plugins:{}}}let l={configFile:e.configFile??``,dryRun:e.dryRun??!1,input:n,interactive:e.interactive??xl(),logs:t,output:i,parser:o,pluginOrder:c.pluginOrder,plugins:c.plugins},d=a.length;if(t.level===`debug`){let e=u.default.gray(`[Job ${d+1}] `);console.warn(`${e}${u.default.cyan(`config:`)}`,l)}a.push({config:l,errors:s,jobIndex:d})}return o.timeEnd(),{dependencies:r,results:a}},Cl=Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`}),wl=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Tl=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},El=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Dl=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(Tl(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=wl(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Ol({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Ol=({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)}`},kl=({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=El(r),s=Object.entries(i).map(([t,i])=>Ol({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Al=({parameters:e={},...t}={})=>n=>{let r=[];if(n&&typeof n==`object`)for(let i in n){let a=n[i];if(a==null)continue;let o=e[i]||t;if(Array.isArray(a)){let e=Dl({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=kl({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=Ol({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},jl=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Ml=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?jl(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},Nl=Al({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),Pl=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=(0,ee.getResolvedInput)({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await(0,ee.sendRequest)({fetchOptions:{method:`HEAD`,...e,headers:Ml(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,ee.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}},Fl=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 Il=class{renderFile(e,t,n,r){let i=new Map;if(e=(0,l.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(`
|
|
8
|
-
`)}${o.length?`
|
|
9
|
-
|
|
10
|
-
`:``}`;let s=this.getImportLines(i,t,n);return a+=`${s.join(`
|
|
11
|
-
`)}${s.length?`
|
|
12
|
-
|
|
13
|
-
`:``}`,`${a}${e}`}renderSymbols(e,t,n){let r=new Map,i=``,a=this.getBodyLines(e,t);i+=`${a.join(`
|
|
14
|
-
|
|
15
|
-
`)}${a.length?`
|
|
16
|
-
`:``}`,i=(0,l.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(`
|
|
17
|
-
`)}${o.length?`
|
|
18
|
-
`:``}`,i}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||t===a)return;let o=this.getBindingPath(t,a,n),s=e.get(o),c=(0,l.createBinding)({file:t,modulePath:o,symbol:i,symbolFile:a});s?((0,l.mergeBindings)(s,c),e.set(o,s)):e.set(o,c)}getBindingPath(e,t,n){if(!e.path||!t.path)return``;if(t.external&&!f.default.isAbsolute(t.path))return t.path;let r=f.default.posix.relative(f.default.posix.dirname(e.path.split(f.default.sep).join(f.default.posix.sep)),t.path.split(f.default.sep).join(f.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(St({node:t,unescape:!0}));else e!=null&&n.push(St({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,l.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,l.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,l.renderIds)(c,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),c===o&&(c=void 0));let u=m.default.factory.createExportSpecifier(s?!1:a.typeNames?.includes(r)??!1,c?P.identifier({text:c}):void 0,P.identifier({text:o}));e.push(u)}}let c=o?m.default.factory.createNamespaceExport(P.identifier({text:o})):e.length?m.default.factory.createNamedExports(e):void 0,u=m.default.factory.createExportDeclaration(void 0,s,c,P.stringLiteral({isSingleQuote:!0,text:i}));r.push(St({node:u,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]:Fl.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,l.renderIds)(e.defaultBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})});o=P.identifier({text:r}),e.typeDefaultBinding&&(c=!0)}else if(typeof e.namespaceBinding==`string`)s=(0,l.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,l.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,l.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?P.identifier({text:s}):void 0})}a=r.sort((e,t)=>e.name.localeCompare(t.name)).map(({isTypeOnly:e,name:t,propertyName:n})=>m.default.factory.createImportSpecifier(e,n,P.identifier({text:t})))}let u=m.default.factory.createImportClause(c,o,s?m.default.factory.createNamespaceImport(P.identifier({text:s})):a.length?m.default.factory.createNamedImports(a):void 0),d=m.default.factory.createImportDeclaration(void 0,u,P.stringLiteral({isSingleQuote:!0,text:e.from}));i!==-1&&e.k[0]!==i&&r.push(``),r.push(St({node:d,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}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=ci(a??n.name),s=e.resolvedNames.getKey(o);if(s!==void 0){let r=t.symbols.get(s);if(r){let t=[r.kind,n.kind];(t.every(e=>e===`type`)||t.every(e=>e!==`type`)||t.includes(`class`)&&t.includes(`type`))&&(o=this.getUniqueName(o,e.resolvedNames))}}return e.resolvedNames.set(n.id,o),o}},Ll=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 Rl=(e,t,n)=>{let r=Array.from(e.nodes.keys());if(n?.preferGroups&&n.preferGroups.length>0){let i=new Set;if(n.matchPointerToGroup)for(let a of n.preferGroups)for(let o of r){let r=n.matchPointerToGroup(o);r.matched&&r.kind===a&&(i.add(o),t(o,e.nodes.get(o)))}for(let n of r)i.has(n)||t(n,e.nodes.get(n));return}for(let n of r)t(n,e.nodes.get(n))},zl=(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;for(let e of r){let t=(n?.getPointerPriority?.(e)??10)*1e6+(i.get(e)??0);a.set(e,t)}let o=new Map;for(let t of r){let n=e.subtreeDependencies?.get(t)??new Set,r=new Set;for(let i of n)i!==t&&e.nodes.has(i)&&r.add(i);o.set(t,r)}let s=new Map,c=new Map;for(let e of r)s.set(e,0);for(let[e,t]of o){s.set(e,t.size);for(let n of t)c.has(n)||c.set(n,new Set),c.get(n).add(e)}let l=e=>e.sort((e,t)=>a.get(e)-a.get(t)),u=new Ll(a);for(let e of r)(s.get(e)??0)===0&&u.push(e);let d=new Set,f=[];for(;!u.isEmpty();){let e=u.pop();if(d.has(e))continue;d.add(e),f.push(e);let t=c.get(e);if(t)for(let e of t){let t=(s.get(e)??0)-1;s.set(e,t),t===0&&u.push(e)}}let p=r.filter(e=>!d.has(e));l(p);for(let e of p)d.add(e),f.push(e);let m=f;if(n?.preferGroups&&n.preferGroups.length>0){let e=new Map;for(let t=0;t<n.preferGroups.length;t++){let r=n.preferGroups[t];r&&e.set(r,t)}let t=t=>{if(n.matchPointerToGroup){let r=n.matchPointerToGroup(t);if(r.matched)return e.has(r.kind)?e.get(r.kind):n.preferGroups.length}return n.preferGroups.length},r=[...f].sort((e,n)=>{let r=t(e),i=t(n);return r===i?f.indexOf(e)-f.indexOf(n):r-i}),i=new Map;for(let e=0;e<r.length;e++)i.set(r[e],e);(()=>{for(let[e,n]of o)for(let r of n)if(!(t(r)<=t(e))&&i.get(r)>=i.get(e))return!0;return!1})()||(m=r)}for(let n of m)t(n,e.nodes.get(n))},Bl=(e,t,n)=>n?.order===`topological`?zl(e,t,n):Rl(e,t,n),Vl=[`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`],Hl=(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}},Ul=[`server`,`schema`,`parameter`,`requestBody`,`operation`,`webhook`],Wl=(()=>{let e={};for(let t=0;t<Ul.length;t++){let n=Ul[t];n&&(e[n]=t)}for(let t of Vl)e[t]===void 0&&(e[t]=Ul.length);return e})(),Gl=10,Kl=e=>{let t=Hl(e);return t.matched?Wl[t.kind]??10:10},ql=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},Jl=e=>{switch(e.method){case`delete`:case`patch`:case`post`:case`put`:return[`mutation`];case`get`:return[`query`];default:return}};var Yl=class{api;config;context;dependencies=[];eventHooks;gen;handler;name;package;constructor(e){this.api=e.api??{},this.config=e.config,this.context=e.context,this.dependencies=e.dependencies,this.eventHooks=this.buildEventHooks(),this.gen=e.gen,this.handler=e.handler,this.name=e.name,this.package=e.context.package}forEach(...e){if(!this.context.graph)throw Error(`No graph available in context`);let t,n,r={getPointerPriority:Kl,matchPointerToGroup:Hl,order:`topological`,preferGroups:Ul};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:Vl);Bl(this.context.graph,(e,n)=>{let r=Hl(e);if(!r.matched||!i.has(r.kind))return;let a,o={_path:tr(e),pointer:e,tags:n.tags?Array.from(n.tags):void 0};switch(r.kind){case`operation`:a={...o,method:n.key,operation:n.node,path:o._path[1],type:r.kind};break;case`parameter`:a={...o,name:n.key,parameter:n.node,type:r.kind};break;case`requestBody`:a={...o,name:n.key,requestBody:n.node,type:r.kind};break;case`schema`:a={...o,name:n.key,schema:n.node,type:r.kind};break;case`server`:a={...o,server:n.node,type:r.kind};break;case`webhook`:a={...o,key:o._path[1],method:n.key,operation:n.node,type:r.kind};break}if(a)try{t(a)}catch(e){this.forEachError(e,a)}},r)}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)}hooks={operation:{isMutation:e=>this.isOperationKind(e,`mutation`),isQuery:e=>this.isOperationKind(e,`query`)}};isSymbolRegistered(e){return this.gen.symbols.isRegistered(e)}querySymbol(e){return this.gen.symbols.query(e)[0]}referenceSymbol(e){return this.gen.symbols.reference(e)}registerSymbol(e){let t={...e,exportFrom:e.exportFrom??(!e.external&&this.context.config.output.indexFile&&this.config.exportFromIndex?[`index`]:void 0),getFilePath:e.getFilePath??this.getSymbolFilePath.bind(this),meta:{pluginName:f.default.isAbsolute(this.name)?`custom`:this.name,...e.meta}};for(let e of this.eventHooks[`symbol:register:before`])e({plugin:this,symbol:t});let n=this.gen.symbols.register(t);for(let e of this.eventHooks[`symbol:register:after`])e({plugin:this,symbol:n});return n}async run(){for(let e of this.eventHooks[`plugin:handler:before`])e({plugin:this});await this.handler({plugin:this});for(let e of this.eventHooks[`plugin:handler:after`])e({plugin:this})}setSymbolValue(e,t){for(let n of this.eventHooks[`symbol:setValue:before`])n({plugin:this,symbol:e,value:t});this.gen.symbols.setValue(e.id,t);for(let n of this.eventHooks[`symbol:setValue:after`])n({plugin:this,symbol:e,value:t})}buildEventHooks(){let e={"plugin:handler:after":[],"plugin:handler:before":[],"symbol:register:after":[],"symbol:register:before":[],"symbol:setValue:after":[],"symbol:setValue:before":[]},t=[this.config[`~hooks`]?.events,this.context.config.parser.hooks.events];for(let n of t)if(n)for(let[t,r]of Object.entries(n))r&&e[t].push(r.bind(n));return e}forEachError(e,t){let n=e instanceof Error?e:Error(String(e));throw new de({args:[t],error:n,event:t.type,name:`Error`,pluginName:this.name})}getSymbolFilePath(e){let t=[this.config[`~hooks`]?.symbols,this.context.config.parser.hooks.symbols];for(let n of t){let t=n?.getFilePath?.(e);if(t!==void 0)return t}return ql(e)}isOperationKind(e,t){let n=t===`query`?`isQuery`:`isMutation`,r=[this.config[`~hooks`]?.operations?.[n],this.config[`~hooks`]?.operations?.getKind,this.context.config.parser.hooks.operations?.[n],this.context.config.parser.hooks.operations?.getKind,Jl];for(let n of r)if(n){let r=n(e);if(r!==void 0)return typeof r==`boolean`?r:r.includes(t)}return!1}},Xl=class{config;gen;graph;ir={};logger;package;plugins={};spec;constructor({config:e,dependencies:t,logger:n,spec:r}){this.config=e,this.gen=new l.Project({defaultFileName:`index`,fileName:t=>{let n=x({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 Il},root:e.output.path}),this.logger=n,this.package=oi(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 Yl({api:t.api,config:t.config,context:this,dependencies:t.dependencies??[],gen:this.gen,handler:t.handler,name:t.name});return this.plugins[n.name]=n,n}registerPlugins(){return this.config.pluginOrder.map(e=>this.registerPlugin(e))}resolveIrRef(e){return ir({$ref:e,spec:this.ir})}resolveRef(e){return ir({$ref:e,spec:this.spec})}};const Zl=[`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`],Ql=({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)?b({case:c,value:ot(n)}):b({case:c,value:`${r}-${i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`)}`}),t>1&&(o=`${o}${t}`),a.ids.has(o)?Ql({context:e,count:t+1,id:n,method:r,path:i,state:a}):(a.ids.set(o,w({method:r,path:i})),o)},$l=`/`,J=(e,t=``)=>`${e}/${t}`,Y=e=>{let t=e.indexOf(`/`);return{name:e.slice(t+1),namespace:e.slice(0,t)}},eu=e=>{switch(e){case`parameters`:return`parameter`;case`requestBodies`:return`body`;case`responses`:return`response`;case`definitions`:case`schemas`:return`schema`;default:return`unknown`}},tu=(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(J(e,i));return{regexps:r,set:new Set(n)}},nu=({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 Zl){if(!i[t])continue;let a=w({method:t,path:r});e.regexps.some(e=>e.test(a))&&e.set.add(J(`operation`,a)),n.regexps.some(e=>e.test(a))&&n.set.add(J(`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(J(`schema`,e)),r.regexps.some(t=>t.test(e))&&r.set.add(J(`schema`,e))},ru=({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 Zl){if(!r[t])continue;let i=w({method:t,path:n});e.regexps.some(e=>e.test(i))&&e.set.add(J(`operation`,i)),a.regexps.some(e=>e.test(i))&&a.set.add(J(`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(J(`parameter`,e)),o.regexps.some(t=>t.test(e))&&o.set.add(J(`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(J(`body`,e)),s.regexps.some(t=>t.test(e))&&s.set.add(J(`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(J(`response`,e)),c.regexps.some(t=>t.test(e))&&c.set.add(J(`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(J(`schema`,e)),l.regexps.some(t=>t.test(e))&&l.set.add(J(`schema`,e))}},iu=({spec:e,...t})=>{`swagger`in e?nu({...t,spec:e}):ru({...t,spec:e})},au=(e,t,n)=>{let r=n.timeEvent(`create-filters`),i=tu(`operation`,e?.operations?.exclude),a=tu(`operation`,e?.operations?.include),o=tu(`parameter`,e?.parameters?.exclude),s=tu(`parameter`,e?.parameters?.include),c=tu(`body`,e?.requestBodies?.exclude),l=tu(`body`,e?.requestBodies?.include),u=tu(`response`,e?.responses?.exclude),d=tu(`response`,e?.responses?.include),f=tu(`schema`,e?.schemas?.exclude),p=tu(`schema`,e?.schemas?.include);iu({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},ou=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,su=({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}=Y(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}},cu=({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}=Y(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}},lu=({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}=Y(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}},uu=({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}=Y(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}},du=({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}=Y(t);switch(i){case`schema`:!n.has(t)&&!e.schemas.exclude.has(t)&&r.push(t);break}}}return{schemas:n}},fu=({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}}}},pu=({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}}}},mu=({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}}}},hu=({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}}}},gu=({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)},_u=({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}=Y(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}},vu=({filters:e,logger:t,resourceMetadata:n})=>{let r=t.timeEvent(`create-filtered-dependencies`),{schemas:i}=du({filters:e,resourceMetadata:n}),{parameters:a}=cu({filters:e,resourceMetadata:n,schemas:i}),{requestBodies:o}=lu({filters:e,resourceMetadata:n,schemas:i}),{responses:s}=uu({filters:e,resourceMetadata:n,schemas:i});hu({filters:e,resourceMetadata:n,schemas:i}),fu({filters:e,parameters:a,resourceMetadata:n}),pu({filters:e,requestBodies:o,resourceMetadata:n}),mu({filters:e,resourceMetadata:n,responses:s});let{operations:c}=su({filters:e,parameters:a,requestBodies:o,resourceMetadata:n,responses:s,schemas:i});if(!e.orphans&&c.size){let{operationDependencies:e}=_u({operations:c,resourceMetadata:n});gu({operationDependencies:e,parameters:a,requestBodies:o,responses:s,schemas:i})}return r.timeEnd(),{operations:c,parameters:a,requestBodies:o,responses:s,schemas:i}},yu=(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=tr(e),r=t[t.length-2],i=t[t.length-1];if(r&&i){let e=eu(r);e===`unknown`&&console.warn(`unsupported type: ${r}`),n.add(J(e,i))}}return n};for(let[t,n]of e.nodes){let e=tr(t);if(e[0]===`components`){if(e.length===3){if(e[1]===`schemas`){let a=e[e.length-1];r.schemas.set(J(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`parameters`){let a=e[e.length-1];r.parameters.set(J(`parameter`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`requestBodies`){let a=e[e.length-1];r.requestBodies.set(J(`body`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`responses`){let a=e[e.length-1];r.responses.set(J(`response`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}}continue}if(e[0]===`paths`){if(e.length===3&&Zl.includes(e[2])){let a=e[e.length-1],o=w({method:a,path:e.slice(1,-1).join(`/`)});r.operations.set(J(`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(J(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}continue}}return n.timeEnd(),{resourceMetadata:r}},bu=e=>JSON.parse(JSON.stringify(e)),xu=[[`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`]],Su=e=>{if(Cu(e))return e.components.schemas;if(wu(e))return e.definitions},Cu=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,wu=e=>typeof e==`object`&&!!e&&`definitions`in e&&typeof e.definitions==`object`&&e.definitions!==null,Tu=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,Eu=({base:e,components:t,extraComponents:n})=>{let r=2,i=e;for(;Tu(t,i)||n&&Tu(n,i);)i=`${e}${r}`,r+=1;return i},Du=e=>e.length===3&&e[0]===`components`&&e[1]===`schemas`||e.length===2&&e[0]===`definitions`,Ou=e=>{if(e&&typeof e==`object`){if(`swagger`in e)return`#/definitions/`;if(`openapi`in e)return`#/components/schemas/`}return``},ku=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})},Au=({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||xu.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)=>Au({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):Au({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},ju=({spec:e})=>{let t=Su(e);if(!t)return;let n=Ou(e),r={};for(let[e,i]of Object.entries(t))ku(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,bu(r[n])),delete e.$ref):i(n)};i(e);for(let e of Object.keys(r)){let n=tr(e),r=n[n.length-1];r&&delete t[r]}},Mu=({config:e,spec:t})=>{let n=Su(t);if(!n)return;let r={};for(let[e,t]of Object.entries(n)){let n=ku(t);n&&(r[n]=e)}let i=[];Au({key:null,node:t,parent:null,path:[],visitor:e=>{if(!Du(e.path)){let t=ku(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]=Eu({base:x({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=Ou(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}`})}},Nu=({config:e,spec:t})=>{if(e.mode===`inline`){ju({spec:t});return}if(e.mode===`root`){Mu({config:e,spec:t});return}},Pu=({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||xu.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)=>Pu({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):Pu({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Fu=({spec:e})=>{Pu({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)}}})},Iu=(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(!Iu(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(!Iu(r[e],i[e]))return!1;return!0};var Lu=Iu;const Ru=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))}},zu=({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=zu({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=zu({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}},Bu=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&&Vu(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 xu){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&&Vu(r,a)&&n(i,a)}if(a.parentPointer){let t=e.nodes.get(a.parentPointer);t&&Vu(a,t)&&n(a.parentPointer,t)}}},Vu=(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},Hu=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`])))}},Uu=(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=rr(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=nr(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);Hu(r.nodes),Bu(r),Ru(r.nodes);for(let e of r.nodes.keys()){let t=zu({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}},Wu=new Set([`additionalProperties`,`allOf`,`anyOf`,`items`,`not`,`oneOf`,`patternProperties`,`properties`,`schema`]),Gu=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`}},Ku=(e,t)=>{let n=t.timeEvent(`capture-original-schemas`),r={};if(Cu(e))for(let[t,n]of Object.entries(e.components.schemas))r[`#/components/schemas/${t}`]=n;else if(wu(e))for(let[t,n]of Object.entries(e.definitions))r[`#/definitions/${t}`]=n;return n.timeEnd(),r},qu=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`insert-split-schemas-into-spec`);Cu(t)?Object.assign(t.components.schemas,n.schemas):wu(t)&&Object.assign(t.definitions,n.schemas),r.timeEnd()},Ju=(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,!xu.some(([e])=>e in t)))return!0}for(let[r,i]of xu){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||Ju(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||Ju(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||Ju(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||Ju(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else typeof a==`object`&&a&&(a[n]===!0||Ju(e,a,n))&&delete t[r]}if(t.type===`object`&&!xu.some(([e])=>e in t))return!0}return!1},Yu=({logger:e,originalSchemas:t,spec:n,split:r})=>{let i=e.timeEvent(`remove-original-split-schemas`),a=Su(n);for(let e of Object.keys(r.mapping)){let n=tr(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()},Xu=({config:e,graph:t,logger:n,spec:r})=>{let i=n.timeEvent(`split-schemas`),a=new Set,o={mapping:{},reverseMapping:{},schemas:{}},s=Ou(r),c=s.split(`/`).length-1,l=e=>{if(e.startsWith(s)){let t=tr(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=bu(r.node);Ju(t,c,`writeOnly`);let u=x({config:e.responses,name:i}),d=u===i?u:Eu({base:u,components:a});a.add(d),o.schemas[d]=c;let f=`${s}${d}`,p=bu(r.node);Ju(t,p,`readOnly`);let m=t.transitiveDependencies.get(n)||new Set;if(!Array.from(m).some(e=>{let n=t.nodes.get(e);return n?.scopes?.has(`normal`)&&(n.scopes.has(`read`)||n.scopes.has(`write`))})&&Lu(c,p)&&Lu(c,r.node))continue;let h=x({config:e.requests,name:i}),g=h===i&&h!==d?h:Eu({base:h,components:a});a.add(g),o.schemas[g]=p;let ee=`${s}${g}`;o.mapping[n]={read:f,write:ee},o.reverseMapping[f]=n,o.reverseMapping[ee]=n}return i.timeEnd(),o},Zu=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`update-refs-in-spec`),i=Ou(t),a=({context:e,currentPointer:t,inSchema:r,node:o,path:s,visited:c=new Set})=>{if(o instanceof Array)o.forEach((n,i)=>a({context:e,currentPointer:t,inSchema:r,node:n,path:[...s,i],visited:c}));else if(o&&typeof o==`object`){let l=t,u=e;if(Du(s)){l=`${i}${s[s.length-1]}`;let e=n.reverseMapping[l];if(e){let t=n.mapping[e];t?.read===l?u=`read`:t?.write===l&&(u=`write`)}}let d=Gu(s);if(d!==void 0){for(let e in o)Object.prototype.hasOwnProperty.call(o,e)&&a({context:d,currentPointer:l,inSchema:!1,node:o[e],path:[...s,e],visited:c});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:l,inSchema:!1,node:t,path:[...s,e],visited:c});continue}if(e===`responses`){a({context:`read`,currentPointer:l,inSchema:!1,node:t,path:[...s,e],visited:c});continue}if(e===`parameters`&&Array.isArray(t)){t.forEach((t,n)=>{t&&typeof t==`object`&&`schema`in t&&a({context:`write`,currentPointer:l,inSchema:!0,node:t.schema,path:[...s,e,n,`schema`],visited:c}),t&&typeof t==`object`&&`content`in t&&a({context:`write`,currentPointer:l,inSchema:!1,node:t.content,path:[...s,e,n,`content`],visited:c})});continue}if(e===`headers`&&typeof t==`object`&&t){for(let n in t)Object.prototype.hasOwnProperty.call(t,n)&&a({context:`read`,currentPointer:l,inSchema:!1,node:t[n],path:[...s,e,n],visited:c});continue}}if(Wu.has(e))a({context:u,currentPointer:l,inSchema:!0,node:t,path:[...s,e],visited:c});else if(e===`$ref`&&typeof t==`string`){let r=n.mapping[t];r&&(u===`read`&&r.read?o[e]=r.read:u===`write`&&r.write?o[e]=r.write:!u&&r.read&&(o[e]=r.read))}else a({context:u,currentPointer:l,inSchema:r,node:t,path:[...s,e],visited:c})}}};a({context:null,currentPointer:null,inSchema:!1,node:t,path:[]}),r.timeEnd()},Qu=({config:e,logger:t,spec:n})=>{let{graph:r}=Uu(n,t),i=Ku(n,t),a=Xu({config:e,graph:r,logger:t,spec:n});qu({logger:t,spec:n,split:a}),Zu({logger:t,spec:n,split:a}),Yu({logger:t,originalSchemas:i,spec:n,split:a})},$u=({context:e})=>{let{logger:t}=e,n=t.timeEvent(`transform-openapi-spec`);e.config.parser.transforms.enums.enabled&&Nu({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&Fu({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&Qu({config:e.config.parser.transforms.readWrite,logger:t,spec:e.spec}),n.timeEnd()},X=({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},ed=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),td=e=>e.map((e,t)=>typeof e==`number`?`[${e}]`:t===0?e:ed(e)?`.${e}`:`['${e.replace(/"/g,`\\'`)}']`).join(``),nd=e=>{let t=td(e.path),n=e.severity===`error`?u.default.bold.red:u.default.bold.yellow,r=e.message.replace(/`([^`]+)`/g,(e,t)=>u.default.yellow(`\`${t}\``));return`${n(`[${e.severity.toUpperCase()}]`)} ${u.default.cyan(t)}: ${r}`},rd=({context:e,issue:t})=>e.config.logs.level===`silent`?!1:t.severity===`error`?e.config.logs.level!==`warn`:!0,id=({context:e,result:t})=>{for(let n of t.issues)rd({context:e,issue:n})&&console.log(nd(n));t.valid||process.exit(1)},ad=({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(J(`schema`,t))&&(e[t]=n);else for(let t of r){let{name:n}=Y(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 Zl){if(!r[e])continue;let i=J(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete i.paths[n]}a.timeEnd()},od=/^(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,sd=/^application\/(.*\+)?json(;.*)?$/i,cd=/^multipart\/form-data(;.*)?$/i,ld=/^text\/[a-z0-9.+-]+(;.*)?$/i,ud=/^application\/x-www-form-urlencoded(;.*)?$/i,dd=/^application\/octet-stream(;.*)?$/i,fd=({mediaType:e})=>(od.lastIndex=0,od.test(e)),pd=({mediaType:e})=>{if(sd.lastIndex=0,sd.test(e))return`json`;if(cd.lastIndex=0,cd.test(e))return`form-data`;if(ld.lastIndex=0,ld.test(e))return`text`;if(ud.lastIndex=0,ud.test(e))return`url-search-params`;if(dd.lastIndex=0,dd.test(e))return`octet-stream`},md=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&fd({mediaType:t})?{...n,format:`binary`}:n:fd({mediaType:t})?{format:`binary`,type:`string`}:void 0},hd=({mimeTypes:e,response:t})=>{let n=[];for(let r of e??[])n.push({mediaType:r,schema:t.schema,type:pd({mediaType:r})});return n};function gd(e){let t=`^(${e.keywords.join(`|`)})$`;return new RegExp(t)}const _d=(e,t,n)=>{let r=[];for(let n in t)t[n]===e&&r.push(n);return!r.length&&(!n||n())?[F(e)]:r},vd=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},yd=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},bd=({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`)},xd=({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=Pd({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=C({items:i,schema:t}),t},Sd=({irSchema:e={}})=>(e.type=`boolean`,e),Cd=({irSchema:e={},schema:t})=>(e.type=t.type,e),wd=({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]=Pd({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=Pd({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},Td=({irSchema:e={}})=>(e.type=`string`,e),Ed=({schema:e})=>{let t={};return yd({irSchema:t,schema:e}),t},Dd=({context:e,schema:t,state:n})=>{let r=Ed({schema:t}),i=[],a=vd({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=Pd({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=_d(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=Md({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(vd({schema:a})===`object`){let i=Md({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({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},Od=({context:e,schema:t,state:n})=>{let r=Ed({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=Md({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=C({items:i,schema:r}),r},kd=({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=Pd({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,Pd({context:e,schema:r,state:n}),n.$ref=i}return r},Ad=({context:e,irSchema:t,schema:n,state:r})=>{t||=Ed({schema:n});let i={};return bd({irSchema:i,schema:n}),i.default===null&&delete i.default,t=C({items:[Md({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},jd=({context:e,schema:t,state:n})=>{let r=Ed({schema:t});bd({irSchema:r,schema:t});let i=vd({schema:t});return i?t[`x-nullable`]?Ad({context:e,irSchema:r,schema:{...t,type:i},state:n}):Md({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},Md=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Ed({schema:n}),bd({irSchema:t,schema:n})),n.type){case`array`:return xd({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Sd({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Cd({context:e,irSchema:t,schema:n,state:r});case`object`:return wd({context:e,irSchema:t,schema:n,state:r});case`string`:return Td({context:e,irSchema:t,schema:n,state:r});default:return Nd({context:e,irSchema:t,schema:n})}},Nd=({irSchema:e,schema:t})=>(e||=Ed({schema:t}),e.type=`unknown`,bd({irSchema:e,schema:t}),e),Pd=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?kd({context:e,schema:t,state:n}):t.enum?Od({context:e,schema:t,state:n}):t.allOf?Dd({context:e,schema:t,state:n}):t.type||t.properties?jd({context:e,schema:t,state:n}):Nd({context:e,schema:t})),Fd=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[F(e)]=Pd({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Id=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,Ld=({context:e,name:t,schema:n})=>{if(gd(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref??``);return`in`in r&&r.in?Ld({context:e,name:t,schema:`schema`in r?r.schema:{...r,in:void 0}}):Ld({context:e,name:t,schema:r})}if(`in`in n)return n.in?Ld({context:e,name:t,schema:`schema`in n?n.schema:{...n,in:void 0}}):!1;for(let t in n.properties)if(gd(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&Id(vd({schema:e})))return t}for(let r of n.allOf??[]){let n=Ld({context:e,name:t,schema:r});if(n)return n}return!1},Rd=({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)},zd=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:Ql({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Rd({irOperation:a,operation:n}),a},Bd=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=zd({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=[],u=n.requestBody?.some(t=>(`$ref`in t?e.resolveRef(t.$ref):t).in===`body`);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=n.consumes;!a&&u&&r.in===`body`&&(a=[`application/json`]);let o=hd({mimeTypes:a,response:{schema:i}}),d=o.find(e=>e.type===`json`)||o[0];if(d){let t=Ld({context:e,name:``,schema:d.schema&&`$ref`in d.schema?{allOf:[{...d.schema}],description:r.description}:{description:r.description,...d.schema}}),n=Pd({context:e,schema:`$ref`in r?{allOf:[{...r,$ref:r.$ref,required:[],type:`string`}],description:r.description}:d.schema&&`$ref`in d.schema?{allOf:[{...d.schema}],description:r.description}:{description:r.description,...d.schema},state:void 0});c.mediaType=d.mediaType,r.in===`body`?c.schema=n:(c.schema.properties[r.name]=n,r.required&&l.push(r.name)),t&&(c.pagination=t),d.type&&(c.type=d.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=hd({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:Pd({context:e,schema:{description:i.description,...md({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},Vd=({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]=Bd({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},Hd=e=>{switch(e){case`multi`:return!0;case`csv`:case`pipes`:case`ssv`:case`tsv`:default:return!1}},Ud=e=>{switch(e){case`header`:case`path`:return`simple`;case`query`:default:return`form`}},Wd=({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()]=Gd({$ref:`#/todo/real/path/to/parameter/${n.name}`,context:e,parameter:n})}return r},Gd=({$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=Ld({context:t,name:n.name,schema:i}),o=Ud(n.in),s={allowReserved:!1,explode:Hd(n.collectionFormat),location:n.in,name:n.name,schema:Pd({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},Kd=({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=Hr(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})))},qd=(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 Zl){if(t===`trace`)continue;let a=n[t];if(!a)continue;let o=w({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`)}},Jd=e=>{if(e.config.parser.validate_EXPERIMENTAL&&id({context:e,result:qd(e.spec,e.logger)}),ou(e.config.parser.filters)){let t=au(e.config.parser.filters,e.spec,e.logger),{graph:n}=Uu(e.spec,e.logger),{resourceMetadata:r}=yu(n,e.logger);ad({...vu({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}$u({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];Fd({$ref:n,context:e,schema:r})}for(let r in Kd({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:Wd({context:e,operation:o,parameters:a.parameters})},path:r,securitySchemesMap:n,state:t};if(a.delete){let t=X({source:Wd({context:e,operation:a.delete,parameters:a.delete.parameters}),target:s.operation.parameters});Vd({...s,method:`delete`,operation:{...s.operation,...a.delete,parameters:t}})}if(a.get){let t=X({source:Wd({context:e,operation:a.get,parameters:a.get.parameters}),target:s.operation.parameters});Vd({...s,method:`get`,operation:{...s.operation,...a.get,parameters:t}})}if(a.head){let t=X({source:Wd({context:e,operation:a.head,parameters:a.head.parameters}),target:s.operation.parameters});Vd({...s,method:`head`,operation:{...s.operation,...a.head,parameters:t}})}if(a.options){let t=X({source:Wd({context:e,operation:a.options,parameters:a.options.parameters}),target:s.operation.parameters});Vd({...s,method:`options`,operation:{...s.operation,...a.options,parameters:t}})}if(a.patch){let t=X({source:Wd({context:e,operation:a.patch,parameters:a.patch.parameters}),target:s.operation.parameters});Vd({...s,method:`patch`,operation:{...s.operation,...a.patch,parameters:t}})}if(a.post){let t=X({source:Wd({context:e,operation:a.post,parameters:a.post.parameters}),target:s.operation.parameters});Vd({...s,method:`post`,operation:{...s.operation,...a.post,parameters:t}})}if(a.put){let t=X({source:Wd({context:e,operation:a.put,parameters:a.put.parameters}),target:s.operation.parameters});Vd({...s,method:`put`,operation:{...s.operation,...a.put,parameters:t}})}}},Yd=({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(J(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=Y(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(J(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=Y(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(J(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=Y(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(J(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=Y(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 Zl){if(!r[e])continue;let i=J(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},Xd=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&fd({mediaType:t})?{...n,format:`binary`}:n:fd({mediaType:t})?{format:`binary`,type:`string`}:void 0},Zd=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:pd({mediaType:n})});return t},Qd=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},$d=({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)},ef=({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`)},tf=({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=Z({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=C({items:i,schema:t}),t},nf=({irSchema:e={}})=>(e.type=`boolean`,e),rf=({irSchema:e={},schema:t})=>(e.type=t.type,e),af=({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]=Z({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=Z({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},of=({irSchema:e={}})=>(e.type=`string`,e),sf=({schema:e})=>{let t={};return $d({irSchema:t,schema:e}),t},cf=({context:e,schema:t,state:n})=>{let r=sf({schema:t}),i=[],a=Qd({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=Z({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=_d(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=hf({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(Qd({schema:a})===`object`){let i=hf({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({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},lf=({context:e,schema:t,state:n})=>{let r=sf({schema:t}),i=[],a=Qd({schema:t}),o=t.anyOf;for(let r of o){let a=Z({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=_d(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=C({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=hf({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},uf=({context:e,schema:t,state:n})=>{let r=sf({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=hf({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=C({items:i,schema:r}),r},df=({context:e,schema:t,state:n})=>{let r=sf({schema:t}),i=[],a=Qd({schema:t}),o=t.oneOf;for(let r of o){let a=Z({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=_d(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=C({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=hf({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},ff=({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=Z({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,Z({context:e,schema:r,state:n}),n.$ref=i}return r},pf=({context:e,irSchema:t,schema:n,state:r})=>{t||=sf({schema:n});let i={};return ef({irSchema:i,schema:n}),i.default===null&&delete i.default,t=C({items:[hf({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},mf=({context:e,schema:t,state:n})=>{let r=sf({schema:t});ef({irSchema:r,schema:t});let i=Qd({schema:t});return i?t.nullable?pf({context:e,irSchema:r,schema:{...t,type:i},state:n}):hf({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},hf=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=sf({schema:n}),ef({irSchema:t,schema:n})),n.type){case`array`:return tf({context:e,irSchema:t,schema:n,state:r});case`boolean`:return nf({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return rf({context:e,irSchema:t,schema:n,state:r});case`object`:return af({context:e,irSchema:t,schema:n,state:r});case`string`:return of({context:e,irSchema:t,schema:n,state:r});default:return gf({context:e,irSchema:t,schema:n})}},gf=({irSchema:e,schema:t})=>(e||=sf({schema:t}),e.type=`unknown`,ef({irSchema:e,schema:t}),e),Z=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),`$ref`in t?ff({context:e,schema:t,state:n}):t.enum?uf({context:e,schema:t,state:n}):t.allOf?cf({context:e,schema:t,state:n}):t.anyOf?lf({context:e,schema:t,state:n}):t.oneOf?df({context:e,schema:t,state:n}):t.type||t.properties?mf({context:e,schema:t,state:n}):gf({context:e,schema:t})),_f=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[F(e)]=Z({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},vf=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,yf=({context:e,name:t,schema:n})=>{if(gd(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=Zd({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?yf({context:e,name:t,schema:n}):!1}return yf({context:e,name:t,schema:r})}for(let t in n.properties)if(gd(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&vf(Qd({schema:e})))return t}for(let r of n.allOf??[]){let n=yf({context:e,name:t,schema:r});if(n)return n}return!1},bf=({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)},xf=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:Ql({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),bf({irOperation:a,operation:n}),a},Sf=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=xf({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=Zd({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=yf({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:Z({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=Zd({content:i.content}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:Z({context:e,schema:{description:i.description,...Xd({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},Cf=({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]=Sf({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},wf=e=>{switch(e){case`query`:return!1;default:return}},Tf=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},Ef=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},Df=({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()]=Of({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Of=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=Zd({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=yf({context:t,name:n.name,schema:i}),o=n.style||Ef(n.in),s=n.explode===void 0?Tf(o):n.explode,c={allowReserved:n.allowReserved===void 0?wf(n.in):n.allowReserved,explode:s,location:n.in,name:n.name,schema:Z({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},kf=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[F(e)]=Of({$ref:e,context:t,parameter:n})},Af=({$ref:e,context:t,requestBody:n})=>{let r=Zd({content:n.content}),i=r.find(e=>e.type===`json`)||r[0],a=i?i.schema:void 0,o={schema:Z({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},jf=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[F(e)]=Af({$ref:e,context:t,requestBody:n})},Mf=({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=Hr(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},Nf=(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 Zl){let a=n[t];if(!a)continue;let o=w({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`)}},Pf=e=>{if(e.config.parser.validate_EXPERIMENTAL&&id({context:e,result:Nf(e.spec,e.logger)}),ou(e.config.parser.filters)){let t=au(e.config.parser.filters,e.spec,e.logger),{graph:n}=Uu(e.spec,e.logger),{resourceMetadata:r}=yu(n,e.logger);Yd({...vu({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}$u({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];kf({$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];jf({$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];_f({$ref:n,context:e,schema:r})}}for(let r in Mf({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:Df({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&Cf({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:X({source:Df({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Cf({...o,method:`get`,operation:{...o.operation,...a.get,parameters:X({source:Df({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Cf({...o,method:`head`,operation:{...o.operation,...a.head,parameters:X({source:Df({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Cf({...o,method:`options`,operation:{...o.operation,...a.options,parameters:X({source:Df({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Cf({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:X({source:Df({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Cf({...o,method:`post`,operation:{...o.operation,...a.post,parameters:X({source:Df({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Cf({...o,method:`put`,operation:{...o.operation,...a.put,parameters:X({source:Df({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Cf({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:X({source:Df({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},Ff=({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(J(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=Y(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(J(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=Y(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(J(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=Y(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(J(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=Y(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 Zl){if(!r[e])continue;let i=J(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},If=({content:e})=>{let{mediaType:t,schema:n}=e;return n?n.type===`string`&&!n.format&&fd({mediaType:t})?{...n,format:`binary`}:n:fd({mediaType:t})?{format:`binary`,type:`string`}:void 0},Lf=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:pd({mediaType:n})});return t},Rf=({schema:e})=>typeof e.type==`string`?[e.type]:e.type?e.type:e.properties?[`object`]:[],zf=({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)},Bf=({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`)},Vf=({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=Q({context:e,schema:t,state:r});i.push(n)}if(n.items){let a=Q({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&&!Rf({schema:n.items}).includes(`null`)?t={...t,...a}:i.push(a)}}return t=C({items:i,schema:t}),t},Hf=({irSchema:e={}})=>(e.type=`boolean`,e),Uf=({irSchema:e={}})=>(e.type=`null`,e),Wf=({irSchema:e={},schema:t})=>(e.type=t.type,e),Gf=({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]=Q({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=Q({context:e,schema:n.additionalProperties,state:r}),n.patternProperties){let i={};for(let t in n.patternProperties){let a=n.patternProperties[t];i[t]=Q({context:e,schema:a,state:r})}Object.keys(i).length&&(t.patternProperties=i)}return n.propertyNames&&(t.propertyNames=Q({context:e,schema:n.propertyNames,state:r})),n.required&&(t.required=n.required),t},Kf=({irSchema:e={}})=>(e.type=`string`,e),qf=({schema:e})=>{let t={};return zf({irSchema:t,schema:e}),t},Jf=({context:e,schema:t,state:n})=>{let r=qf({schema:t}),i=[],a=Rf({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=Q({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=_d(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=$f({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(Rf({schema:a}).includes(`object`)){let i=$f({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({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},Yf=({context:e,schema:t,state:n})=>{let r=qf({schema:t}),i=[],a=Rf({schema:t}),o=t.anyOf;for(let r of o){let a=Q({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=_d(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=C({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=$f({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Xf=({context:e,schema:t,state:n})=>{let r=qf({schema:t});r.type=`enum`;let i=[],a=Rf({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=$f({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=C({items:i,schema:r}),r},Zf=({context:e,schema:t,state:n})=>{let r=qf({schema:t}),i=[],a=Rf({schema:t}),o=t.oneOf;for(let r of o){let a=Q({context:e,schema:r,state:n});if(t.discriminator&&a.$ref!=null){let e=_d(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=C({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=$f({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Qf=({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=Q({context:e,schema:r,state:n});return n.$ref=i,a}let r=qf({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,Q({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=C({items:a,mutateSchemaOneItem:!0,schema:r}),r},$f=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=qf({schema:n}),Bf({irSchema:t,schema:n})),n.type){case`array`:return Vf({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Hf({context:e,irSchema:t,schema:n});case`integer`:case`number`:return Wf({context:e,irSchema:t,schema:n});case`null`:return Uf({context:e,irSchema:t,schema:n});case`object`:return Gf({context:e,irSchema:t,schema:n,state:r});case`string`:return Kf({context:e,irSchema:t,schema:n});default:return np({context:e,irSchema:t,schema:n})}},ep=({context:e,irSchema:t,schema:n,state:r})=>{t||=qf({schema:n});let i={};Bf({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=$f({context:e,irSchema:{...i},schema:{...n,type:t},state:r});a.push(o)}return t=C({items:a,schema:t}),t},tp=({context:e,schema:t,state:n})=>{let r=qf({schema:t});Bf({irSchema:r,schema:t});let i=Rf({schema:t});return i.length===1?$f({context:e,irSchema:r,schema:{...t,type:i[0]},state:n}):ep({context:e,irSchema:r,schema:{...t,type:i},state:n})},np=({irSchema:e,schema:t})=>(e||=qf({schema:t}),e.type=`unknown`,Bf({irSchema:e,schema:t}),e),Q=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?Qf({context:e,schema:t,state:n}):t.enum?Xf({context:e,schema:t,state:n}):t.allOf?Jf({context:e,schema:t,state:n}):t.anyOf?Yf({context:e,schema:t,state:n}):t.oneOf?Zf({context:e,schema:t,state:n}):t.type||t.properties?tp({context:e,schema:t,state:n}):np({context:e,schema:t})),rp=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[F(e)]=Q({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},ip=e=>e.includes(`boolean`)||e.includes(`integer`)||e.includes(`number`)||e.includes(`string`),ap=({context:e,name:t,schema:n})=>{if(gd(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=Lf({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?ap({context:e,name:t,schema:n}):!1}return ap({context:e,name:t,schema:r})}for(let t in n.properties)if(gd(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`){let n=Rf({schema:e});if(!n.length){let n=(e.anyOf??e.oneOf??[]).filter(e=>e.type!==`null`);if(n.length===1&&ip(Rf({schema:n[0]})))return t}if(ip(n))return t}}for(let r of n.allOf??[]){let n=ap({context:e,name:t,schema:r});if(n)return n}return!1},op=({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)},sp=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:Ql({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),op({irOperation:a,operation:n}),a},cp=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=sp({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=Lf({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=ap({context:e,name:``,schema:{description:t.description,...i.schema}});o.body={mediaType:i.mediaType,schema:Q({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=Lf({content:i.content}),s=a.find(e=>e.type===`json`)||a[0];s?o.responses[t]={mediaType:s.mediaType,schema:Q({context:e,schema:{description:i.description,...If({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},lp=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>(n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),{parsed:cp({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})}),up=({context:e,method:t,path:n,...r})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={});let{parsed:i}=lp({context:e,method:t,path:n,...r});e.ir.paths[n][t]=i},dp=({context:e,key:t,method:n,...r})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:i}=lp({context:e,method:n,path:t,...r});e.ir.webhooks[t][n]=i},fp=e=>{switch(e){case`query`:return!1;default:return}},pp=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},mp=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},$=({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()]=hp({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},hp=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=Lf({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=ap({context:t,name:n.name,schema:i}),o=n.style||mp(n.in),s=n.explode===void 0?pp(o):n.explode,c={allowReserved:n.allowReserved===void 0?fp(n.in):n.allowReserved,explode:s,location:n.in,name:n.name,schema:Q({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},gp=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[F(e)]=hp({$ref:e,context:t,parameter:n})},_p=({$ref:e,context:t,requestBody:n})=>{let r=Lf({content:n.content}),i=r.find(e=>e.type===`json`)||r[0],a=i?i.schema:void 0,o={schema:Q({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},vp=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[F(e)]=_p({$ref:e,context:t,requestBody:n})},yp=({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=Hr(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},bp=(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 Zl){let a=n[t];if(!a)continue;let o=w({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`)}},xp=({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:$({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},securitySchemesMap:t,state:n};a.delete&&dp({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:X({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&dp({...o,method:`get`,operation:{...o.operation,...a.get,parameters:X({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&dp({...o,method:`head`,operation:{...o.operation,...a.head,parameters:X({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&dp({...o,method:`options`,operation:{...o.operation,...a.options,parameters:X({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&dp({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:X({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&dp({...o,method:`post`,operation:{...o.operation,...a.post,parameters:X({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&dp({...o,method:`put`,operation:{...o.operation,...a.put,parameters:X({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&dp({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:X({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},Sp=e=>{if(e.config.parser.validate_EXPERIMENTAL&&id({context:e,result:bp(e.spec,e.logger)}),ou(e.config.parser.filters)){let t=au(e.config.parser.filters,e.spec,e.logger),{graph:n}=Uu(e.spec,e.logger),{resourceMetadata:r}=yu(n,e.logger);Ff({...vu({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}$u({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];gp({$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];vp({$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];rp({$ref:n,context:e,schema:r})}}for(let r in yp({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:$({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&up({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:X({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&up({...o,method:`get`,operation:{...o.operation,...a.get,parameters:X({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&up({...o,method:`head`,operation:{...o.operation,...a.head,parameters:X({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&up({...o,method:`options`,operation:{...o.operation,...a.options,parameters:X({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&up({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:X({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&up({...o,method:`post`,operation:{...o.operation,...a.post,parameters:X({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&up({...o,method:`put`,operation:{...o.operation,...a.put,parameters:X({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&up({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:X({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}xp({context:e,securitySchemesMap:n})},Cp=({config:e,dependencies:t,logger:n,spec:r})=>{let i=new Xl({config:e,dependencies:t,logger:n,spec:r});if(`swagger`in i.spec)return Jd(i),i;if(ai(i.spec.openapi,`>=3.0.0 <3.1.0`))return Pf(i),i;if(ai(i.spec.openapi,`>=3.1.0`))return Sp(i),i;throw Error(`Unsupported OpenAPI specification`)};Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return _l}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return Mr}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return P}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return Fe}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return He}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return Sl}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return Nr}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return Uu}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Kr}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Pl}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return Br}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Cp}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return Gn}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return ie}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return ue}});
|
|
19
|
-
//# sourceMappingURL=openApi-CCTdD3hW.cjs.map
|