@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.
@@ -0,0 +1,19 @@
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 _=require(`@hey-api/json-schema-ref-parser`);_=c(_);const ee=(0,p.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),te=f.default.dirname(ee),ne=()=>{let e=te;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)}},re=()=>{let e=ne(),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},ie=e=>{if(e===null)return null;if(e){let t=f.default.isAbsolute(e)?e:f.default.resolve(te,e);return d.default.existsSync(t)?t:null}let t=te;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},ae=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))},oe=e=>{d.default.existsSync(e)||d.default.mkdirSync(e,{recursive:!0})};var se=class extends Error{constructor(e){super(e),this.name=`ConfigError`}},ce=class extends Error{errors;constructor(e){super(`Found ${e.length} configuration ${e.length===1?`error`:`errors`}.`),this.name=`ConfigValidationError`,this.errors=e}},le=class extends Error{originalError;constructor(e,t){super(e),this.name=`JobError`,this.originalError=t}},ue=class extends Error{args;event;pluginName;constructor({args:e,error:t,event:n,name:r,pluginName:i}){let a=t instanceof Error?t.message:`Unknown error`;super(a),this.args=e,this.cause=t.cause,this.event=n,this.name=r||t.name,this.pluginName=i,this.stack=t.stack}};const de=(e,t)=>{if(e instanceof se||e instanceof ce)return;e instanceof le&&(e=e.originalError.error);let n=`openapi-ts-error-${Date.now()}.log`,r=f.default.resolve(process.cwd(),t);oe(r);let i=f.default.resolve(r,n),a=`[${new Date().toISOString()}] `;e instanceof ue&&(a+=`${e.name} during event "${e.event}"\n`,e.pluginName&&(a+=`Plugin: ${e.pluginName}\n`),a+=`Arguments: ${JSON.stringify(e.args,null,2)}\n\n`);let o=e instanceof Error?e.message:String(e),s=e instanceof Error?e.stack:void 0;return a+=`Error: ${o}\n`,s&&(a+=`Stack:\n${s}\n`),d.default.writeFileSync(i,a),i},fe=async e=>{let t=re();if(!t.bugs.url)return;e instanceof le&&(e=e.originalError.error);let n=``;e instanceof ue&&(e.pluginName&&(n+=`**Plugin**: \`${e.pluginName}\`\n`),n+=`**Event**: \`${e.event}\`\n`,n+=`**Arguments**:\n\`\`\`ts\n${JSON.stringify(e.args,null,2)}\n\`\`\`\n\n`);let r=e instanceof Error?e.message:String(e),i=e instanceof Error?e.stack:void 0;n+=`**Error**: \`${r}\`\n`,i&&(n+=`\n**Stack Trace**:\n\`\`\`\n${i}\n\`\`\``);let a=new URLSearchParams({body:n,labels:`bug 🔥`,title:`Crash Report`}),o=`${t.bugs.url}new?${a.toString()}`,s=(await import(`open`)).default;await s(o)},pe=({error:e,logPath:t})=>{if(e instanceof ce&&e.errors.length){let t=new Map;for(let{error:n,jobIndex:r}of e.errors)t.has(r)||t.set(r,[]),t.get(r).push(n);for(let[e,n]of t.entries()){let t=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 le&&(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)}`)}},me=async({error:e,isInteractive:t})=>!t||e instanceof se||e instanceof ce?!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`)})}),he=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,ge=`https://get.heyapi.dev`,_e=(e,t,n)=>`${ge}/${e}/${t}${n?`?${n}`:``}`,ve=e=>{let t=e.organization,n=e.project,r;if(e.path){let i=e.path.match(he);if(!i)throw Error(`Invalid Hey API shorthand format. Expected "organization/project?queryParams" or "organization/project", received: ${e.path}`);t=i[1],n=i[2],r=i[3]}if(!t)throw Error(`The Hey API organization cannot be empty.`);if(!n)throw Error(`The Hey API project cannot be empty.`);return{organization:t,project:n,queryParams:r}},ye=e=>{let t=ve(e);return{path:_e(t.organization,t.project,t.queryParams),registry:`hey-api`}},be=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,xe=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,Se=`readme`,Ce=e=>{let t=e.match(be);if(!t)throw Error(`Invalid ReadMe shorthand format. Expected "${Se}:@organization/project#uuid" or "${Se}:uuid", received: ${Se}:${e}`);let[,,n,r,i]=t;if(!i)throw Error(`The ReadMe UUID cannot be empty.`);return{organization:n,project:r,uuid:i}},we=e=>{let t=Ce(e.slice(`${Se}:`.length));return{...t,path:xe(t.uuid),registry:`readme`}},Te=/^(@[\w-]+)\/([\w.-]+)$/,Ee=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,De=`scalar`,Oe=e=>{let t=e.match(Te);if(!t)throw Error(`Invalid Scalar shorthand format. Expected "${De}:@organization/project", received: ${De}:${e}`);let[,n,r]=t;if(!n)throw Error(`The Scalar organization cannot be empty.`);if(!r)throw Error(`The Scalar project cannot be empty.`);return{organization:n,project:r}},ke=e=>{let t=Oe(e.slice(`${De}:`.length));return{...t,path:Ee(t.organization,t.project),registry:`scalar`}},Ae=e=>{if(e.path.startsWith(`readme:`)){Object.assign(e,we(e.path));return}if(e.path.startsWith(`scalar:`)){Object.assign(e,ke(e.path));return}if(e.path.startsWith(`.`))return;if(e.path.startsWith(ge)){e.path=e.path.slice(23),Object.assign(e,ye(e));return}let t=e.path.split(`/`);if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,ye(e));return}},je={enabled:!1,interval:1e3,timeout:6e4},Me=e=>{let t={...je};return typeof e.path==`string`&&(typeof e.watch==`boolean`?t.enabled=e.watch:typeof e.watch==`number`?(t.enabled=!0,t.interval=e.watch):e.watch&&(t={...t,...e.watch})),t},Ne=e=>{let t=e.input instanceof Array?e.input:[e.input],n=[];for(let r of t){let t={path:``,watch:je};typeof r==`string`?t.path=r:r&&(r.path!==void 0||r.organization!==void 0)?(t={...t,path:ge,...r},t.watch!==void 0&&(t.watch=Me(t))):t={...t,path:r},typeof t.path==`string`&&Ae(t),e.watch!==void 0&&t.watch.enabled===je.enabled&&t.watch.interval===je.interval&&t.watch.timeout===je.timeout&&(t.watch=Me({path:t.path,watch:e.watch})),t.path&&n.push(t)}return n},Pe=e=>{let t={file:!0,level:`info`,path:process.cwd()};return typeof e?.logs==`string`?t.path=e.logs:t={...t,...e?.logs},t},Fe=(e,t)=>{let n=e||{},r=t||{};return{...n,...r}},Ie=(e,t)=>{let n=e||{},r=t||{},i={...n,...r};return typeof i.logs==`object`&&(i.logs=Fe(n.logs,r.logs)),i},Le=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e!=`function`,Re=(e,t)=>{for(let[n,r]of Object.entries(t))r!==void 0&&r!==``&&(e[n]=r);return e},v=({defaultValue:e,mappers:t,value:n})=>{let r={...e};switch(typeof n){case`boolean`:if(t&&`boolean`in t){let e=t.boolean;r=Re(r,e(n))}break;case`function`:if(t&&`function`in t){let e=t.function;r=Re(r,e(n))}break;case`number`:if(t&&`number`in t){let e=t.number;r=Re(r,e(n))}break;case`string`:if(t&&`string`in t){let e=t.string;r=Re(r,e(n))}break;case`object`:if(Le(n))if(t&&`object`in t&&typeof t.object==`function`){let i=t.object;r=Re(r,i(n,e))}else r=Re(r,n);break}return r},ze=e=>{if(e.output instanceof Array)throw Error(`Unexpected array of outputs in user configuration. This should have been expanded already.`);let t=v({defaultValue:{clean:!0,fileName:{case:`preserve`,name:`{{name}}`,suffix:`.gen`},format:null,indexFile:!0,lint:null,path:``},mappers:{object:(e,t)=>({...e,fileName:v({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=ae(ie(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},Be=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{}},Ve=[`after`,`before`,`cursor`,`offset`,`page`,`start`],He=e=>v({defaultValue:{hooks:{},pagination:{keywords:Ve},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:v({defaultValue:{...t.pagination},value:e.pagination}),transforms:v({defaultValue:{...t.transforms},mappers:{object:(e,t)=>({...e,enums:v({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:v({defaultValue:{...t.readWrite,enabled:e.readWrite===void 0?t.readWrite.enabled:!!e.readWrite},mappers:{boolean:e=>({enabled:e}),object:(e,t)=>({...e,requests:v({defaultValue:{...t.requests},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.requests}),responses:v({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}),y=e=>t=>({...e,config:{...e.config,...t}}),b={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},Ue=/[\p{Lu}]/u,We=/[\p{Ll}]/u,Ge=/([\p{Alpha}\p{N}_]|$)/u,Ke=/[_.\- `\\[\]{}\\/]+/,qe=RegExp(`^${Ke.source}`),Je=RegExp(`${Ke.source}${Ge.source}`,`gu`),Ye=RegExp(`\\d+${Ge.source}`,`gu`),Xe=({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(Ke.lastIndex=0;l&&Ke.test(l);)c+=1,l=t[c];let u=c!==e+1;if(We.lastIndex=0,Ue.lastIndex=0,Ue.test(s)&&(n||l&&!u&&l!==`s`&&We.test(l)))t=`${t.slice(0,e)}${o}${t.slice(e)}`,e++,i=r,n=!1,r=!0;else if(r&&i&&We.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},x=({case:e,stripLeadingSeparators:t=!0,value:n})=>{let r=n.trim();return r.length?!e||e===`preserve`?r:r.length===1?(Ke.lastIndex=0,Ke.test(r)?``:e===`PascalCase`||e===`SCREAMING_SNAKE_CASE`?r.toLocaleUpperCase():r.toLocaleLowerCase()):(r!==r.toLocaleLowerCase()&&(r=Xe({case:e,string:r})),(t||r[0]!==n[0])&&(r=r.replace(qe,``)),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(Je,(e,n,r)=>r===0&&!t?e:`_${n}`),r[r.length-1]===`_`&&(r=r.slice(0,r.length-1))):(Je.lastIndex=0,Ye.lastIndex=0,r=r.replaceAll(Ye,(e,t,n)=>[`_`,`-`,`.`].includes(r.charAt(n+e.length))?e:e.toLocaleUpperCase()),r=r.replaceAll(Je,(e,r,i)=>i===0&&!t&&e[0]&&n.startsWith(e[0])?e:r.toLocaleUpperCase())),r):``},S=({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 x({case:e.case,value:t})},Ze=({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]},Qe=e=>{for(let t in e)if(e[t].required)return!0;return!1},$e=e=>e?!!(Qe(e.cookie)||Qe(e.header)||Qe(e.path)||Qe(e.query)):!1,et=({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:Ze({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:Ze({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:Ze({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:Ze({context:e,parameter:r})}}}},C=({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},w=({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,tt=e=>!!($e(e.parameters)||e.body?.required),T=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,nt=({context:e,operation:t})=>{let n=t.body;if(!n||!n.pagination)return et({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}:et({context:e,parameters:t.parameters})},rt=({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`}},it=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(rt({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=w({items:Object.values(n.properties),mutateSchemaOneItem:!0,schema:{}});e=C({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=w({items:Object.values(r.properties),mutateSchemaOneItem:!0,schema:{}});e=C({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.response=e)}return t},at=e=>e.replace(/^[^\p{ID_Start}]+/u,``).replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`-`).replace(/[$+]/g,`-`),ot=e=>{let t=E(e);return t.name===`@hey-api/client-axios`||t.name===`@hey-api/client-nuxt`?`baseURL`:`baseUrl`},E=e=>{for(let t of e.pluginOrder){let n=e.plugins[t];if(n?.tags?.includes(`client`))return n}return{config:{name:``},name:``}},D=e=>({value:e}),O=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=D(e[n]));return t},st=/^[^$_\p{ID_Start}]+/u,k=/^-?\d+(\.\d+)?$/,ct=/^(document|history|location|navigator|window)$/g,lt=/^(console|Array|Date|Error|Function|JSON|Map|Math|Object|Promise|RegExp|Set|WeakMap|WeakSet)$/g,ut=/^(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,dt=/^(global|process|Buffer)$/g,ft=/^(any|as|bigint|boolean|namespace|never|null|number|string|symbol|type|undefined|unknown|void)$/g,pt=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,mt=e=>(e||e===``)&&(pt.lastIndex=0,!pt.test(e))?`'${e}'`:e,ht=e=>e&&e.startsWith(`'`)&&e.endsWith(`'`)?e.slice(1,e.length-1):e,gt=e=>e.replace(/\*\//g,`*`).replace(/\/\*/g,`*`).replace(/\r?\n(.*)/g,(e,t)=>h.EOL+t.trim()),_t=m.default.createPrinter({newLine:m.default.NewLineKind.LineFeed,removeComments:!1}),vt=e=>m.default.createSourceFile(``,e,m.default.ScriptTarget.ESNext,!1,m.default.ScriptKind.TS),yt=vt(``),bt=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));function xt({node:e,unescape:t=!1}){let n=_t.printNode(m.default.EmitHint.Unspecified,e,yt);if(!t)return n;try{return bt(n)}catch{return n}}const A=e=>m.default.factory.createIdentifier(typeof e==`string`?e:e.text),St=e=>{switch(e){case`!`:return m.default.SyntaxKind.ExclamationToken;case`-`:return m.default.SyntaxKind.MinusToken}},Ct=({expression:e,prefix:t})=>{let n=typeof e==`string`?A(e):e,r=typeof t==`string`?St(t):t;return m.default.factory.createPrefixUnaryExpression(r,n)},wt=()=>m.default.factory.createThis(),j=({keyword:e})=>{let t=Ft({keyword:e});return m.default.factory.createModifier(t)},Tt=({initializer:e,modifiers:t,name:n,type:r})=>{let i=Array.isArray(t)?t:[t];return m.default.factory.createPropertyDeclaration(t?i.map(e=>j({keyword:e})):void 0,n,void 0,r,e)},Et={boolean:e=>e?m.default.factory.createTrue():m.default.factory.createFalse(),export:({alias:e,asType:t=!1,name:n})=>{let r=A(n);if(e){let n=A(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=A(n);if(e){let n=A(e);return m.default.factory.createImportSpecifier(t,r,n)}return m.default.factory.createImportSpecifier(t,void 0,r)},number:e=>e<0?Ct({expression:m.default.factory.createNumericLiteral(Math.abs(e)),prefix:`-`}):m.default.factory.createNumericLiteral(e),string:(e,t=!1)=>{let n=e;t&&(n=ht(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("`")?A(n):$t({text:n})}},Dt=e=>typeof e==`object`&&!!e&&typeof e.kind==`number`&&typeof e.flags==`number`&&typeof e.pos==`number`&&typeof e.end==`number`,Ot=e=>e!==void 0,kt=({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=xt({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)},M=({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)kt({commentObject:e,node:t})},N=(e,t)=>m.default.isTypeNode(e)?e:typeof e==`number`?m.default.factory.createLiteralTypeNode(Et.number(e)):rn({typeArguments:t?.map(e=>N(e)),typeName:m.default.isIdentifier(e)?e.text:e}),At=({expression:e,name:t})=>m.default.factory.createPropertyAccessChain(e,m.default.factory.createToken(m.default.SyntaxKind.QuestionDotToken),t),jt=({expression:e,isOptional:t,name:n})=>{let r=typeof e==`string`?A({text:e}):e;if(t&&typeof n!=`number`)return At({expression:r,name:n});if(typeof n==`string`){if(pt.lastIndex=0,!pt.test(n)){!n.startsWith(`'`)&&!n.endsWith(`'`)&&(n=`\'${n}\'`);let e=A({text:n});return m.default.factory.createElementAccessExpression(r,e)}let e=A({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)},Mt=()=>m.default.factory.createNull(),Nt=({identifiers:e=[],isValueAccess:t,shorthand:n,unescape:r,value:i})=>{if(i===null)return Mt();if(Array.isArray(i))return Wt({elements:i});if(typeof i==`object`)return qt({identifiers:e,obj:i,shorthand:n});if(typeof i==`number`)return Et.number(i);if(typeof i==`boolean`)return Et.boolean(i);if(typeof i==`string`){if(t){let e=i.split(`.`);return jt({expression:e[0],name:e[1]})}return Et.string(i,r)}},Pt=e=>e.map(e=>{if(`destructure`in e)return on({name:m.default.factory.createObjectBindingPattern(e.destructure.map(e=>{if(!(`destructure`in e))return m.default.factory.createBindingElement(void 0,void 0,A({text:e.name}),void 0)}).filter(Boolean)),type:e.type===void 0?void 0:N(e.type)});let t=e.accessLevel?[j({keyword:e.accessLevel})]:[];return e.isReadOnly&&t.push(j({keyword:`readonly`})),on({initializer:e.default===void 0?void 0:Nt({value:e.default}),modifiers:t,name:A({text:e.name}),required:e.isRequired!==!1,type:e.type===void 0?void 0:N(e.type)})}),Ft=({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}"`)}},It=({keyword:e})=>{let t=Ft({keyword:e});return m.default.factory.createKeywordTypeNode(t)},Lt=e=>e.map(e=>m.default.isTypeParameterDeclaration(e)?e:zt({constraint:e.extends?typeof e.extends==`string`?It({keyword:`boolean`}):e.extends:void 0,defaultType:e.default===void 0?void 0:Dt(e.default)?e.default:m.default.factory.createLiteralTypeNode(e.default?m.default.factory.createTrue():m.default.factory.createFalse()),name:e.name})),Rt=({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)},zt=({constraint:e,defaultType:t,modifiers:n,name:r})=>m.default.factory.createTypeParameterDeclaration(n,r,e,t),Bt=({members:e,nameType:t,questionToken:n,readonlyToken:r,type:i,typeParameter:a})=>m.default.factory.createMappedTypeNode(r,a,t,n,i,e),Vt=({literal:e})=>m.default.factory.createLiteralTypeNode(e),Ht=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=m.default.factory.createArrowFunction(e?[j({keyword:`async`})]:void 0,o?Lt(o):void 0,Pt(r),i?N(i):void 0,void 0,Array.isArray(a)?un({multiLine:n,statements:a}):a);return M({comments:t,node:s}),s},Ut=({async:e,comment:t,multiLine:n,parameters:r=[],returnType:i,statements:a=[],types:o=[]})=>{let s=m.default.factory.createFunctionExpression(e?[j({keyword:`async`})]:void 0,void 0,void 0,o?Lt(o):void 0,Pt(r),i?N(i):void 0,un({multiLine:n,statements:a}));return M({comments:t,node:s}),s},Wt=({elements:e,multiLine:t=!1})=>m.default.factory.createArrayLiteralExpression(e.map(e=>Dt(e)?e:Nt({value:e})).filter(Ot),t||!Array.isArray(e[0])&&typeof e[0]==`object`),Gt=({expression:e})=>m.default.factory.createAwaitExpression(e),Kt=({parameters:e=[],returnType:t,typeParameters:n})=>m.default.factory.createFunctionTypeNode(n,e,t),qt=({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=Dt(e.spread)?e.spread:A({text:e.spread});o=m.default.factory.createSpreadAssignment(e.assertion?pn({expression:t,type:typeof e.assertion==`string`?It({keyword:e.assertion}):e.assertion}):t)}else if(e.shorthand||i&&r)o=m.default.factory.createShorthandPropertyAssignment(e.value);else{let r=Dt(e.value)?e.value:Array.isArray(e.value)&&(!e.value.length||typeof e.value[0]==`object`)?qt({multiLine:n,obj:e.value,shorthand:i,unescape:a}):Nt({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=A({text:e.value})),o=dn({initializer:r,name:e.key})}return M({comments:e.comments,node:o}),o}).filter(Ot):Object.entries(r).map(([e,n])=>{let r=Nt({identifiers:t.includes(e)?Object.keys(n):[],shorthand:i,unescape:a,value:n});if(!r)return;t.includes(e)&&!m.default.isObjectLiteralExpression(r)&&(r=A({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(Ot),s=m.default.factory.createObjectLiteralExpression(o,n);return M({comments:e,node:s}),s},Jt=({asConst:e,comments:t={},leadingComment:n,name:r,obj:i})=>{let a=Array.isArray(i)?i.map(e=>{let t=Yt({initializer:Nt({value:e.value}),name:e.key});return M({comments:e.comments,node:t}),t}):Object.entries(i).map(([e,n])=>{let r=m.default.factory.createEnumMember(e,Nt({unescape:!0,value:n}));return M({comments:t[e],node:r}),r}),o=[j({keyword:`export`})],s=e?[m.default.factory.createToken(m.default.SyntaxKind.ConstKeyword)]:[],c=[...o,...s],l=m.default.factory.createEnumDeclaration(c,typeof r==`string`?A({text:r}):r,a);return M({comments:n,node:l}),l},Yt=({initializer:e,name:t})=>{let n=t;return typeof n==`string`&&(n=n.includes(`'`)?$t({isSingleQuote:!1,text:n}):mt(n)),m.default.factory.createEnumMember(n,e)},Xt=({name:e,statements:t})=>m.default.factory.createModuleDeclaration([j({keyword:`export`})],A({text:e}),m.default.factory.createModuleBlock(t),m.default.NodeFlags.Namespace),Zt=({indexType:e,objectType:t})=>m.default.factory.createIndexedAccessTypeNode(t,e),Qt=({modifiers:e,name:t,returnType:n,statements:r})=>{let i=Array.isArray(e)?e:[e];return m.default.factory.createGetAccessorDeclaration(e?i.map(e=>j({keyword:e})):void 0,t,[],n?rn({typeName:n}):void 0,un({statements:r}))},$t=({isSingleQuote:e,text:t})=>(e===void 0&&(e=!t.includes(`'`)),m.default.factory.createStringLiteral(t,e)),en=({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),tn=({text:e})=>m.default.factory.createTypeOfExpression(typeof e==`string`?A({text:e}):e),nn=({comment:e,exportType:t,name:n,type:r,typeParameters:i=[]})=>{let a=m.default.factory.createTypeAliasDeclaration(t?[j({keyword:`export`})]:void 0,typeof n==`string`?A({text:n}):n,Lt(i),N(r));return M({comments:e,node:a}),a},rn=({typeArguments:e,typeName:t})=>m.default.factory.createTypeReferenceNode(t,e),an=({type:e})=>m.default.factory.createParenthesizedType(e),on=({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),sn=({argumentsArray:e,expression:t,typeArguments:n})=>m.default.factory.createNewExpression(t,n,e),cn=({awaitModifier:e,expression:t,initializer:n,statement:r})=>m.default.factory.createForOfStatement(e,n,t,r),ln=({left:e,right:t})=>m.default.factory.createAssignment(e,t),un=({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,Et.string(t?`${e}.js`:e)),gn=({functionName:e,parameters:t=[],types:n})=>{let r=typeof e==`string`?A({text:e}):e,i=t.filter(e=>e!==void 0).map(e=>typeof e==`string`?A({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 Et.export({alias:t.alias,asType:r&&t.asType,name:t.name})}),a=m.default.factory.createNamedExports(i),o=Et.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`?rn({typeName:e}):e}):i,c=typeof a==`string`?A({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`?rn({typeName:o}):o:void 0,s),u=m.default.factory.createVariableStatement(r?[j({keyword:`export`})]:void 0,m.default.factory.createVariableDeclarationList([l],m.default.NodeFlags.Const));return M({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(Et.import({alias:t.alias,asType:r&&t.asType,name:t.name}))});let o=i?m.default.factory.createNamespaceImport(A({text:i.alias})):m.default.factory.createNamedImports(a),s=m.default.factory.createImportClause(!r,void 0,o),c=Et.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?[j({keyword:e})]:void 0,o=m.default.factory.createConstructorDeclaration(a,Pt(r),un({multiLine:n,statements:i}));return M({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?[j({keyword:e})]:[];n&&l.push(j({keyword:`static`}));let u=m.default.factory.createMethodDeclaration(l,void 0,A({text:i}),void 0,c?Lt(c):void 0,Pt(a),o?N(o):void 0,un({multiLine:r,statements:s}));return M({comments:t,node:u}),u},Sn=({decorator:e,exportClass:t,extendedClasses:n,name:r,nodes:i,typeParameters:a})=>{let o=[];t&&o.push(j({keyword:`export`})),e&&o.unshift(m.default.factory.createDecorator(gn({functionName:e.name,parameters:e.args.map(e=>Nt({value:e})).filter(Ot)})));let s=[];if(n)for(let e of n)s.push(m.default.factory.createHeritageClause(m.default.SyntaxKind.ExtendsKeyword,[m.default.factory.createExpressionWithTypeArguments(A({text:e}),void 0)]));return m.default.factory.createClassDeclaration(o,A({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=>rn({typeName:e}));return wn({expression:gn({functionName:t,parameters:e.map(e=>m.default.isExpression(e)?e:A({text:e})).filter(Ot),types:r})})},En=({expression:e})=>wn({expression:typeof e==`string`?A({text:e}):e}),Dn=e=>e.slice(1).reduce((e,t)=>(pt.lastIndex=0,pt.test(t)?At({expression:e,name:t}):m.default.factory.createElementAccessChain(e,m.default.factory.createToken(m.default.SyntaxKind.QuestionDotToken),A({text:t}))),A({text:e[0]})),On=e=>e.slice(1).reduce((e,t)=>jt({expression:e,name:t}),A({text:e[0]})),kn=({expressions:e})=>e.reduce((e,t)=>jt({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`?A({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:un({statements:[Cn({expression:An({left:n,right:sn({argumentsArray:[n],expression:A({text:`Date`})})})})]})})},Nn=({path:e,transformerName:t})=>[jn({expression:Dn(e),thenStatement:un({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:jt({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:un({statements:[Cn({expression:m.default.factory.createCallChain(jt({expression:r,name:`forEach`}),void 0,void 0,[A({text:t})])})]})})},Fn=({parameterName:e})=>{let t=A({text:`Date`});return sn({argumentsArray:[A({text:e})],expression:t})},In=({path:e,transformExpression:t})=>{let n=Dn(e),r=On(e);return jn({expression:gn({functionName:jt({expression:`Array`,name:`isArray`}),parameters:[n]}),thenStatement:un({statements:[Cn({expression:An({left:r,right:m.default.factory.createCallChain(jt({expression:r,name:`map`}),void 0,void 0,[Ht({parameters:[{name:`item`}],statements:t})])})})]})})},Ln=rn({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?[j({keyword:`readonly`})]:void 0,n=e.isRequired===!1?m.default.factory.createToken(m.default.SyntaxKind.QuestionToken):void 0,r=N(e.type);a.push(r);let o=m.default.factory.createPropertySignature(t,i||typeof e.name==`string`&&e.name.match(pt)||typeof e.name!=`string`&&m.default.isPropertyName(e.name)?e.name:$t({text:e.name}),n,r);return M({comments:e.comment,node:o}),o}),s=!1;if(t)if(!r.length&&e){let n=Bt({questionToken:m.default.factory.createToken(m.default.SyntaxKind.QuestionToken),type:t.type??It({keyword:`string`}),typeParameter:zt({constraint:e,name:A({text:String(t.name)})})});o.push(n),s=!0}else{let e=t.isReadOnly?[j({keyword:`readonly`})]:void 0,n=m.default.factory.createIndexSignature(e,[on({name:A({text:String(t.name)}),type:It({keyword:`string`})})],N(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=N(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=N(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=>N(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: ${xt({node:i,unescape:!0})}]`,type:a}],useLegacyResolution:r})})},Wn=(e,t=!1)=>Rn({isNullable:t,node:rn({typeArguments:[Array.isArray(e)?Bn({types:e}):e],typeName:`Array`})}),P={anonymousFunction:Ut,arrayLiteralExpression:Wt,arrowFunction:Ht,asExpression:pn,assignment:ln,awaitExpression:Gt,binaryExpression:An,block:un,callExpression:gn,classDeclaration:Sn,conditionalExpression:en,constVariable:vn,constructorDeclaration:bn,enumDeclaration:Jt,exportAllDeclaration:hn,exportNamedDeclaration:_n,expressionToStatement:Cn,forOfStatement:cn,functionTypeNode:Kt,getAccessorDeclaration:Qt,identifier:A,ifStatement:jn,indexedAccessTypeNode:Zt,isTsNode:Dt,keywordTypeNode:It,literalTypeNode:Vt,mappedTypeNode:Bt,methodDeclaration:xn,namedImportDeclarations:yn,namespaceDeclaration:Xt,newExpression:sn,nodeToString:xt,null:Mt,objectExpression:qt,ots:Et,parameterDeclaration:on,prefixUnaryExpression:Ct,propertyAccessExpression:jt,propertyAccessExpressions:kn,propertyAssignment:dn,propertyDeclaration:Tt,regularExpressionLiteral:fn,returnFunctionCall:Tn,returnStatement:wn,returnVariable:En,safeAccessExpression:Dn,stringLiteral:$t,templateLiteralType:mn,this:wt,transformArrayMap:In,transformArrayMutation:Pn,transformDateMutation:Mn,transformFunctionMutation:Nn,transformNewDate:Fn,typeAliasDeclaration:nn,typeArrayNode:Wn,typeInterfaceNode:zn,typeIntersectionNode:Vn,typeNode:N,typeOfExpression:tn,typeOperatorNode:Rt,typeParameterDeclaration:zt,typeParenthesizedNode:an,typeRecordNode:Un,typeReferenceNode:rn,typeTupleNode:Hn,typeUnionNode:Bn,valueToExpression:Nt},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(x({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=x({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=x({case:`PascalCase`,value:at(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(ut)?`${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=x({case:`camelCase`,value:at(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=E(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=E(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:O({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=E(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}),d=sr({operation:n,plugin:r});if(u&&c.push({key:`requestValidator`,value:u.$render()}),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 f=!1,p;for(let e in n.responses){let t=n.responses[e];!p&&i.name===`@hey-api/client-axios`&&rt({statusCode:e})===`2XX`&&(p=pr(t.mediaType),p&&c.push({key:`responseType`,value:p})),t.mediaType===`text/event-stream`&&(f=!0)}d&&c.push({key:`responseValidator`,value:d.$render()}),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 _=r.config.client?r.getSymbol({category:`client`}):void 0,ee=P.propertyAccessExpression({expression:P.identifier({text:`options`}),isOptional:!e,name:`client`}),te;te=r.config.instance?P.binaryExpression({left:ee,operator:`??`,right:P.propertyAccessExpression({expression:P.this(),name:`client`})}):_?P.binaryExpression({left:ee,operator:`??`,right:_.placeholder}):ee;let ne=[];a?ne.push(Yn,`${o} | ${Xn}`,s,Xn):ne.push(o,s,`ThrowOnError`),r.config.responseStyle===`data`&&ne.push(P.stringLiteral({text:r.config.responseStyle}));let re=f?P.propertyAccessExpression({expression:te,name:P.identifier({text:`sse`})}):te;return re=P.propertyAccessExpression({expression:re,name:P.identifier({text:n.method})}),h.push(P.returnFunctionCall({args:[P.objectExpression({identifiers:[`responseTransformer`],obj:c})],name:re,types:ne})),h},I=({operation:e})=>{let t=[];if(e.summary&&t.push(gt(e.summary)),e.description&&(t.length&&t.push(``),t.push(gt(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length)return t},hr=({context:e,operation:t})=>{let n=E(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||tt(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:S({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:a.className})})}),name:x({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:S({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:S({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:a.className})})}),name:x({case:`camelCase`,value:a.className})}))}let a=e.referenceSymbol({category:`external`,resource:`@angular/core.Injectable`}),o=e.registerSymbol({exported:!0,name:S({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:x({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=y(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=E(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`);oe(a),Lr(f.default.resolve(Fr,`clients`,`core`),a);let o=f.default.resolve(t,`client`);oe(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`);oe(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`);oe(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:ot(e.context.config),value:c});else if(c!==`/`&&c.startsWith(`/`)){let t=c.endsWith(`/`)?c.slice(0,-1):c;s.push({key:ot(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=y(qr),Yr={...Nr,config:{...Mr,throwOnError:!1},handler:Kr,name:`@hey-api/client-axios`},Xr=y(Yr),Zr={...Nr,config:{...Mr,throwOnError:!1},handler:Kr,name:`@hey-api/client-fetch`},Qr=y(Zr),$r={...Nr,config:{...Mr,throwOnError:!1},handler:Kr,name:`@hey-api/client-ky`},ei=y($r),ti={...Nr,config:{...Mr,throwOnError:!1},handler:Kr,name:`@hey-api/client-next`},ni=y(ti),ri={...Nr,config:Mr,handler:Kr,name:`@hey-api/client-nuxt`},ii=y(ri),ai={...Nr,config:{...Mr,throwOnError:!1},handler:Kr,name:`@hey-api/client-ofetch`},oi=y(ai),si=(...e)=>g.satisfies(...e),ci=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?si(i,n,r):!1}}),li=[ut,ft,lt,dt,ct],ui=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`);if(st.lastIndex=0,st.test(t))return`_${t}`;for(let e of li){if(t.startsWith(`_`))return t;t=t.replace(e,`_$1`)}return t},di=({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)},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(r.$ref)return r.$ref=decodeURI(r.$ref),r;if(di({plugin:t,schema:r}),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.items&&=fi({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]=fi({context:e,plugin:t,schema:i}))}return r},pi=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>pi({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(`$ref`in r)return r.$ref=decodeURI(r.$ref),r;if(di({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=pi({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>pi({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>pi({context:e,plugin:t,schema:n})),r.items&&=pi({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>pi({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]=pi({context:e,plugin:t,schema:i}))}return r},mi=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>mi({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(di({plugin:t,schema:r}),r.$ref&&=decodeURI(r.$ref),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=mi({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>mi({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>mi({context:e,plugin:t,schema:n})),r.items&&=mi({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>mi({context:e,plugin:t,schema:n})),r.prefixItems&&=r.prefixItems.map(n=>mi({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]=mi({context:e,plugin:t,schema:i}))}return r},hi=({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`,ui(r)},gi=({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:hi({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=({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:hi({name:n,plugin:t,schema:r})}),a=pi({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)}},vi=({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:hi({name:n,plugin:t,schema:r})}),a=mi({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)}},yi=({plugin:e})=>{if(`swagger`in e.context.spec){gi({context:e.context,plugin:e});return}if(si(e.context.spec.openapi,`>=3.0.0 <3.1.0`)){_i({context:e.context,plugin:e});return}if(si(e.context.spec.openapi,`>=3.1.0`)){vi({context:e.context,plugin:e});return}throw Error(`Unsupported OpenAPI specification`)},bi={config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:yi,name:`@hey-api/schemas`},xi=y(bi);var L=class e{$expr(e){return typeof e==`string`?m.default.factory.createIdentifier(e):e}$if(e,t,n){if(e){let n;try{n=t?.(this,e)}catch{}if(n===void 0)try{n=t?.(e)}catch{}if(n===void 0)try{n=t?.()}catch{}return n??this}if(n){let t;try{t=n?.(this,e)}catch{}if(t===void 0)try{t=n?.(e)}catch{}if(t===void 0)try{t=n?.()}catch{}return t??this}return this}$node(e){if(e!==void 0)return typeof e==`string`?this.$expr(e):typeof e==`boolean`?e?m.default.factory.createTrue():m.default.factory.createFalse():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`?this.$expr(e):this._render(e);return m.default.isExpression(t)?m.default.factory.createExpressionStatement(t):t})}$type(e,t){if(e!==void 0){if(typeof e==`string`)return m.default.factory.createTypeReferenceNode(e,t);if(typeof e==`boolean`){let t=e?m.default.factory.createTrue():m.default.factory.createFalse();return m.default.factory.createLiteralTypeNode(t)}return e instanceof Array?e.map(e=>this.$type(e,t)):this._render(e)}}_render(t){return t instanceof e?t.$render():t}},R=class extends L{};let Si;function Ci(e){Si=e}let wi;function Ti(e){wi=e}let Ei;function Di(e){Ei=e}let Oi;function ki(e){Oi=e}var Ai=class{attr(e){return Si(this,e)}await(){return wi(this)}call(...e){return Ei(this,e)}return(){return Oi(this)}};function z(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 B=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}},ji=class{assign(e){return new B(this,`=`,e)}},Mi=class{and(e){return new B(this,`&&`,e)}coalesce(e){return new B(this,`??`,e)}div(e){return new B(this,`/`,e)}eq(e){return new B(this,`===`,e)}gt(e){return new B(this,`>`,e)}gte(e){return new B(this,`>=`,e)}looseEq(e){return new B(this,`==`,e)}looseNeq(e){return new B(this,`!=`,e)}lt(e){return new B(this,`<`,e)}lte(e){return new B(this,`<=`,e)}minus(e){return new B(this,`-`,e)}neq(e){return new B(this,`!==`,e)}or(e){return new B(this,`||`,e)}plus(e){return new B(this,`+`,e)}times(e){return new B(this,`*`,e)}},Ni=class{isOptional;questionToken;optional(e=!0){return e&&(this.isOptional=!0,this.questionToken=m.default.factory.createToken(m.default.SyntaxKind.QuestionToken)),this}},Pi=class extends L{left;right;constructor(e,t){super(),this.left=e,this.right=t}$render(){let e=this.$node(this.left);return typeof this.right==`number`?this.isOptional?m.default.factory.createElementAccessChain(e,m.default.factory.createToken(m.default.SyntaxKind.QuestionDotToken),m.default.factory.createNumericLiteral(this.right)):m.default.factory.createElementAccessExpression(e,m.default.factory.createNumericLiteral(this.right)):this.isOptional?m.default.factory.createPropertyAccessChain(e,m.default.factory.createToken(m.default.SyntaxKind.QuestionDotToken),this.$expr(this.right)):m.default.factory.createPropertyAccessExpression(e,this.$expr(this.right))}};z(Pi,Ai,ji,Mi,Ni),Ci((e,t)=>new Pi(e,t));var Fi=class extends L{_awaitExpr;constructor(e){super(),this._awaitExpr=e}$render(){return m.default.factory.createAwaitExpression(this.$node(this._awaitExpr))}};z(Fi,Ai),Ti(e=>new Fi(e));var Ii=class extends L{_args;arg(e){return(this._args??=[]).push(e),this}args(...e){return(this._args??=[]).push(...e),this}$args(){return this._args?this.$node(this._args).map(e=>this.$expr(e)):[]}$render(){throw Error(`noop`)}},Li=class extends L{_callee;constructor(e,...t){super(),this._callee=e,this.args(...t)}$render(){return m.default.factory.createCallExpression(this.$node(this._callee),void 0,this.$args())}};z(Li,Ai,Ii),Di((e,t)=>new Li(e,...t));var Ri=class extends L{name;constructor(e,...t){super(),this.name=e,this.args(...t)}$render(){let e=this.$args();return m.default.factory.createDecorator(e.length?m.default.factory.createCallExpression(this.$expr(this.name),void 0,e):this.$expr(this.name))}};z(Ri,Ii);var zi=class extends L{decorators;decorator(e,...t){return(this.decorators??=[]).push(new Ri(e,...t)),this}$decorators(){return this.decorators?this.$node(this.decorators):[]}$render(){throw Error(`noop`)}},Bi=class extends L{_lines=[];constructor(e,t){super(),e&&(typeof e==`string`?this.add(e):this.add(...e)),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 Vi(e){let t=class extends e{_desc;describe(e,t){return this._desc=new Bi(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 Hi(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 Ui=class{abstract(e=!0){return this._m(m.default.SyntaxKind.AbstractKeyword,e)}},Wi=class{async(e=!0){return this._m(m.default.SyntaxKind.AsyncKeyword,e)}},Gi=class{default(e=!0){return this._m(m.default.SyntaxKind.DefaultKeyword,e)}},Ki=class{export(e=!0){return this._m(m.default.SyntaxKind.ExportKeyword,e)}},qi=class{private(e=!0){return this._m(m.default.SyntaxKind.PrivateKeyword,e)}},Ji=class{protected(e=!0){return this._m(m.default.SyntaxKind.ProtectedKeyword,e)}},Yi=class{public(e=!0){return this._m(m.default.SyntaxKind.PublicKeyword,e)}},Xi=class{readonly(e=!0){return this._m(m.default.SyntaxKind.ReadonlyKeyword,e)}},Zi=class{static(e=!0){return this._m(m.default.SyntaxKind.StaticKeyword,e)}},Qi=class extends L{value;assign(e){return this.value=e,this}$value(){return this.$node(this.value)}$render(){throw Error(`noop`)}},$i=class extends R{name;constraint;defaultValue;constructor(e,t){super(),this.name=e,t?.(this)}default(e){return this.defaultValue=e,this}extends(e){return this.constraint=e,this}$render(){if(!this.name)throw Error(`Missing type name`);return m.default.factory.createTypeParameterDeclaration(void 0,this.$expr(this.name),this.$type(this.constraint),this.$type(this.defaultValue))}},ea=class extends L{_generics;generic(...e){let t=new $i(...e);return(this._generics??=[]).push(t),this}generics(...e){return this._generics=[...e],this}$generics(){return this._generics?.map(e=>typeof e==`string`?m.default.factory.createTypeParameterDeclaration(void 0,this.$expr(e),void 0,void 0):this.$node(e))}$render(){throw Error(`noop`)}},ta=class extends L{_base;right;constructor(e,t){super(),t?(this.base(e),this.right=t):(this.base(void 0),this.right=e)}base(e){return this._base=e,this}$render(){if(!this._base)throw Error(`TypeAttrTsDsl: missing base for qualified name`);let e=this.$node(this._base);if(!m.default.isEntityName(e))throw Error(`TypeAttrTsDsl: base must be an EntityName`);let t=this.$expr(this.right);return m.default.factory.createQualifiedName(e,t)}},na=class extends R{_exprInput;constructor(e,t){super(),typeof e==`string`?(this._exprInput=e,t?.(this)):e?.(this)}attr(e){return this._exprInput=e instanceof ta?e.base(this._exprInput):new ta(this._exprInput,e),this}$render(){if(!this._exprInput)throw Error(`TypeExpr must have either an expression or an object`);let e=this._generics?.map(e=>this.$type(e));return m.default.factory.createTypeReferenceNode(this.$type(this._exprInput),e)}};z(na,ea);var ra=class extends L{modifiers=Hi(this);name;_type;constructor(e,t){super(),this.name=e,t?.(this)}type(e){return this._type=e instanceof R?e:new na(e),this}$render(){return m.default.factory.createPropertyDeclaration([...this.$decorators(),...this.modifiers.list()],this.$expr(this.name),void 0,this.$type(this._type),this.$value())}};z(ra,zi,[Vi,{overrideRender:!0}],qi,Ji,Yi,Xi,Zi,Qi);var ia=class extends L{_do;do(...e){return(this._do??=[]).push(...e),this}$do(){return this._do?this.$stmt(this._do):[]}$render(){throw Error(`noop`)}},aa=class extends L{pattern;_spread;array(...e){return this.pattern={kind:`array`,values:e[0]instanceof Array?[...e[0]]:e},this}object(...e){let t={};for(let n of e)if(typeof n==`string`)t[n]=n;else if(n instanceof Array)for(let e of n)t[e]=e;else Object.assign(t,n);return this.pattern={kind:`object`,values:t},this}spread(e){return this._spread=e,this}$render(){if(!this.pattern)throw Error(`PatternTsDsl requires object() or array() pattern`);if(this.pattern.kind===`object`){let e=Object.entries(this.pattern.values).map(([e,t])=>e===t?m.default.factory.createBindingElement(void 0,void 0,e,void 0):m.default.factory.createBindingElement(void 0,e,t,void 0)),t=this.createSpread();return t&&e.push(t),m.default.factory.createObjectBindingPattern(e)}if(this.pattern.kind===`array`){let e=this.pattern.values.map(e=>m.default.factory.createBindingElement(void 0,void 0,e,void 0)),t=this.createSpread();return t&&e.push(t),m.default.factory.createArrayBindingPattern(e)}throw Error(`PatternTsDsl requires object() or array() pattern`)}createSpread(){return this._spread?m.default.factory.createBindingElement(m.default.factory.createToken(m.default.SyntaxKind.DotDotDotToken),void 0,m.default.factory.createIdentifier(this._spread)):void 0}},oa=class extends L{pattern;array(...e){return(this.pattern??=new aa).array(...e),this}object(...e){return(this.pattern??=new aa).object(...e),this}spread(e){return(this.pattern??=new aa).spread(e),this}$pattern(){return this.$node(this.pattern)}$render(){throw Error(`noop`)}},sa=class extends L{name;_type;constructor(e,t){super(),typeof e==`string`?(this.name=e,t?.(this)):e(this)}type(e){return this._type=e instanceof R?e:new na(e),this}$render(){let e=this.$pattern()??this.name;if(!e)throw Error(`Param must have either a name or a destructuring pattern`);return m.default.factory.createParameterDeclaration(this.$decorators(),void 0,e,this.questionToken,this.$type(this._type),this.$value())}};z(sa,zi,Ni,oa,Qi);var ca=class extends L{_params;param(e,t){let n=new sa(e,t);return(this._params??=[]).push(n),this}params(...e){return(this._params??=[]).push(...e),this}$params(){return this._params?this.$node(this._params):[]}$render(){throw Error(`noop`)}},la=class extends L{modifiers=Hi(this);constructor(e){super(),e?.(this)}$render(){return m.default.factory.createConstructorDeclaration([...this.$decorators(),...this.modifiers.list()],this.$params(),m.default.factory.createBlock(this.$do(),!0))}};z(la,zi,[Vi,{overrideRender:!0}],ia,ca,qi,Ji,Yi);var ua=class extends L{modifiers=Hi(this);name;_returns;constructor(e,t){super(),this.name=e,t?.(this)}returns(e){return this._returns=e instanceof R?e:new na(e),this}$render(){return m.default.factory.createMethodDeclaration([...this.$decorators(),...this.modifiers.list()],void 0,this.$expr(this.name),this.questionToken,this.$generics(),this.$params(),this.$type(this._returns),m.default.factory.createBlock(this.$do(),!0))}};z(ua,Ui,Wi,zi,[Vi,{overrideRender:!0}],ia,ea,Ni,ca,qi,Ji,Yi,Zi);var da=class extends L{$render(){return m.default.factory.createIdentifier(`
7
+ `)}},fa=class extends L{heritageClauses=[];body=[];modifiers=Hi(this);name;constructor(e){super(),this.name=e}do(...e){return this.body.push(...e),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 ra(e,t);return this.body.push(n),this}init(e){let t=new la(e);return this.body.push(t),this}method(e,t){let n=new ua(e,t);return this.body.push(n),this}newline(){return this.body.push(new da),this}$render(){let e=this.$node(this.body);return m.default.factory.createClassDeclaration([...this.$decorators(),...this.modifiers.list()],this.$expr(this.name),this.$generics(),this.heritageClauses,e)}};z(fa,Ui,zi,[Vi,{overrideRender:!0}],Gi,Ki,ea);var pa=class extends L{_exprInput;constructor(e){super(),this._exprInput=e}$render(){return this.$node(this._exprInput)}};z(pa,Ai,Mi);var ma=class extends L{mode;modifiers=Hi(this);name;_returns;constructor(e,t){super(),typeof e==`string`?(this.name=e,this.mode=`decl`,t?.(this)):(this.mode=`arrow`,e?.(this))}arrow(){return this.mode=`arrow`,this}decl(){return this.mode=`decl`,this}expr(){return this.mode=`expr`,this}returns(e){return this._returns=e instanceof R?e:new na(e),this}$render(){if(this.mode===`decl`){if(!this.name)throw Error(`Function declaration requires a name`);return m.default.factory.createFunctionDeclaration([...this.$decorators(),...this.modifiers.list()],void 0,this.name,this.$generics(),this.$params(),this.$type(this._returns),m.default.factory.createBlock(this.$do(),!0))}if(this.mode===`expr`)return m.default.factory.createFunctionExpression([...this.modifiers.list()],void 0,this.$expr(this.name),this.$generics(),this.$params(),this.$type(this._returns),m.default.factory.createBlock(this.$do(),!0));let e=this.$do(),t=e.length===1&&m.default.isReturnStatement(e[0])?e[0].expression??m.default.factory.createBlock(e,!0):m.default.factory.createBlock(e,!0);return m.default.factory.createArrowFunction([...this.modifiers.list()],this.$generics(),this.$params(),this.$type(this._returns),void 0,t)}};z(ma,Ui,Wi,zi,[Vi,{overrideRender:!0}],ia,ea,Ni,ca,qi,Ji,Yi,Zi);const ha=ma;var ga=class extends L{modifiers=Hi(this);name;constructor(e,t){super(),this.name=e,t?.(this)}$render(){return m.default.factory.createGetAccessorDeclaration([...this.$decorators(),...this.modifiers.list()],this.name,this.$params(),void 0,m.default.factory.createBlock(this.$do(),!0))}};z(ga,Ui,zi,[Vi,{overrideRender:!0}],ia,ca,qi,Ji,Yi,Zi);var _a=class extends L{conditionInput;elseInput;constructor(e){super(),e&&this.condition(e)}condition(e){return this.conditionInput=e,this}otherwise(...e){return this.elseInput=e,this}$render(){if(!this.conditionInput)throw Error(`Missing condition in if`);let e=this.$do();if(!e.length)throw Error(`Missing then block in if`);let t=this.$node(this.conditionInput),n=e.length===1?e[0]:m.default.factory.createBlock(e,!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(t,r,i)}};z(_a,ia);var va=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)}`)}}},ya=class extends L{classExpr;constructor(e,...t){super(),this.classExpr=e,this.args(...t)}$render(){let e=this._generics?.map(e=>this.$type(e));return m.default.factory.createNewExpression(this.$node(this.classExpr),e,this.$args())}};z(ya,Ai,Ii,ea);var ba=class extends L{_notExpr;constructor(e){super(),this._notExpr=e}$render(){return m.default.factory.createPrefixUnaryExpression(m.default.SyntaxKind.ExclamationToken,this.$node(this._notExpr))}},xa=class e extends L{static DEFAULT_THRESHOLD=3;layout=e.DEFAULT_THRESHOLD;props=[];auto(t=e.DEFAULT_THRESHOLD){return this.layout=t,this}inline(){return this.layout=!1,this}pretty(){return this.layout=!0,this}prop(e,t){return this.props.push({expr:t,kind:`prop`,name:e}),this}spread(e){return this.props.push({expr:e,kind:`spread`}),this}$render(){let e=this.props.map(e=>{let t=this.$node(e.expr);return e.kind===`spread`?m.default.factory.createSpreadAssignment(t):m.default.isIdentifier(t)&&t.text===e.name?m.default.factory.createShorthandPropertyAssignment(e.name):m.default.factory.createPropertyAssignment(e.name,t)}),t=typeof this.layout==`number`?this.props.length>=this.layout:this.layout;return m.default.factory.createObjectLiteralExpression(e,t)}},Sa=class extends L{_returnExpr;constructor(e){super(),this._returnExpr=e}$render(){return m.default.factory.createReturnStatement(this.$node(this._returnExpr))}};z(Sa,Ai),ki(e=>new Sa(e));var Ca=class extends L{modifiers=Hi(this);name;constructor(e,t){super(),this.name=e,t?.(this)}$render(){return m.default.factory.createSetAccessorDeclaration([...this.$decorators(),...this.modifiers.list()],this.name,this.$params(),m.default.factory.createBlock(this.$do(),!0))}};z(Ca,Ui,zi,[Vi,{overrideRender:!0}],ia,ca,qi,Ji,Yi,Zi);var wa=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)}},Ta=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])}},Ea=class extends R{value;constructor(e){super(),this.value=e}$render(){return m.default.factory.createLiteralTypeNode(this.$node(new va(this.value)))}},Da=class extends R{props=[];merges=[];prop(e,t){let n=new Oa(e,t);return this.props.push(n),this}merge(e){return this.merges.push(e),this}$render(){let e=m.default.factory.createTypeLiteralNode(this.$node(this.props));return this.merges.length>0?m.default.factory.createIntersectionTypeNode([...this.merges.map(e=>this.$type(e)),e]):e}},Oa=class extends R{name;typeInput;constructor(e,t){super(),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}'`);return m.default.factory.createPropertySignature(void 0,this.$expr(this.name),this.questionToken,this.$type(this.typeInput))}};z(Oa,Ni);var ka=class extends L{kind=m.default.NodeFlags.None;modifiers=Hi(this);name;_type;constructor(e){super(),this.name=e}const(){return this.kind=m.default.NodeFlags.Const,this}let(){return this.kind=m.default.NodeFlags.Let,this}type(e){return this._type=e instanceof R?e:new na(e),this}var(){return this.kind=m.default.NodeFlags.None,this}$render(){let e=this.$pattern()??this.name;if(!e)throw Error(`Var must have either a name or a destructuring pattern`);return m.default.factory.createVariableStatement(this.modifiers.list(),m.default.factory.createVariableDeclarationList([m.default.factory.createVariableDeclaration(e,void 0,this.$type(this._type),this.$value())],this.kind))}};z(ka,Gi,[Vi,{overrideRender:!0}],Ki,oa,Qi);const Aa={attr:(...e)=>new Pi(...e),await:(...e)=>new Fi(...e),binary:(...e)=>new B(...e),call:(...e)=>new Li(...e),class:(...e)=>new fa(...e),const:(...e)=>new ka(...e).const(),decorator:(...e)=>new Ri(...e),describe:(...e)=>new Bi(...e),expr:(...e)=>new pa(...e),field:(...e)=>new ra(...e),func:((e,t)=>e===void 0?new ha:typeof e!=`string`||t===void 0?new ha(e):new ha(e,t)),getter:(...e)=>new ga(...e),if:(...e)=>new _a(...e),init:(...e)=>new la(...e),let:(...e)=>new ka(...e).let(),literal:(...e)=>new va(...e),method:(...e)=>new ua(...e),new:(...e)=>new ya(...e),newline:(...e)=>new da(...e),not:(...e)=>new ba(...e),object:(...e)=>new xa(...e),param:(...e)=>new sa(...e),pattern:(...e)=>new aa(...e),return:(...e)=>new Sa(...e),setter:(...e)=>new Ca(...e),template:(...e)=>new wa(...e),throw:(...e)=>new Ta(...e),type:Object.assign((...e)=>new na(...e),{attr:(...e)=>new ta(...e),expr:(...e)=>new na(...e),literal:(...e)=>new Ea(...e),object:(...e)=>new Da(...e)}),var:(...e)=>new ka(...e)},V=Object.assign((...e)=>new pa(...e),Aa),ja=`__registry`,Ma=({sdkName:e,symbol:t})=>{let n=`defaultKey`,r=`instances`;return V.class(t.placeholder).export(t.exported).generic(`T`).field(n,e=>e.private().readonly().assign(V.literal(`default`))).newline().field(r,e=>e.private().readonly().type(V.type(`Map`).generics(`string`,`T`)).assign(V.new(`Map`))).newline().method(`get`,t=>t.returns(`T`).param(`key`,e=>e.type(`string`).optional()).do(V.const(`instance`).assign(V(`this`).attr(`instances`).attr(`get`).call(V(`key`).coalesce(V(`this`).attr(n)))),V.if(V.not(`instance`)).do(V.throw(`Error`).message(V.template(`No SDK client found. Create one with "new `).add(e).add(`()" to fix this error.`))),V.return(`instance`))).newline().method(`set`,e=>e.returns(`void`).param(`value`,e=>e.type(`T`)).param(`key`,e=>e.type(`string`).optional()).do(V(`this`).attr(r).attr(`set`).call(V(`key`).coalesce(V(`this`).attr(n)),`value`)))},Na=({plugin:e,symbol:t})=>{let n=e.getSymbol({category:`client`}),r=!!(e.config.client&&n),i=e.referenceSymbol({category:`external`,resource:`client.Client`});return V.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(V.type.object().prop(`client`,e=>e.optional(r).type(i.placeholder)))).do(V(`this`).attr(`client`).assign(V(`args`).attr(`client`).optional(r).$if(r,e=>e.coalesce(n.placeholder)))))},Pa=({plugin:e})=>{let t=E(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=V.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(V.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(...Pt(m.parameters)).do(...h));p.nodes.length?p.nodes.push(V.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=x({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=e.isSymbolRegistered(a.id)?V.field(o,t=>t.static(!e.config.instance).assign(e.config.instance?V.new(a.placeholder).args(V.object().prop(`client`,V(`this`).attr(`client`))):V(a.placeholder))):V.getter(o,t=>t.$if(!e.config.instance,e=>e.public().static()).do(V.return(e.config.instance?V.new(a.placeholder).args(V.object().prop(`client`,V(`this`).attr(`client`))):a.placeholder)));t.nodes.length?t.nodes.push(V.newline(),s):t.nodes.push(s)}if(o&&!e.gen.symbols.hasValue(o.id)){let t=Na({plugin:e,symbol:o});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=V.init(e=>e.param(`args`,e=>e.optional(!r).type(V.type.object().prop(`client`,e=>e.optional(!r).type(i.placeholder)).prop(`key`,e=>e.optional().type(`string`)))).do(V(`super`).call(`args`),V(l.placeholder).attr(ja).attr(`set`).call(`this`,V(`args`).attr(`key`).optional(!r))));t.nodes.length?t.nodes.unshift(a,V.newline()):t.nodes.unshift(a);let o=Ma({plugin:e,sdkName:l.placeholder,symbol:s});e.setSymbolValue(s,o);let c=V.field(ja,e=>e.public().static().readonly().assign(V.new(s.placeholder).generic(l.placeholder)));t.nodes.unshift(c,V.newline())}let u=V.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,V.object().prop(`providedIn`,V.literal(`root`)))).do(...t.nodes);e.setSymbolValue(l,u)};for(let e of i.values())c(e)},Fa=({id:e,operation:t,plugin:n})=>n.config.methodNameBuilder?n.config.methodNameBuilder(t):e.match(ut)?`${e}_`:e,Ia=({plugin:e})=>{let t=E(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:Fa({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`})},La=({plugin:e})=>{let t=Ir(e.context.config),n=E(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)},Ra=({plugin:e})=>{let t=Ir(e.context.config),n=E(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`}),La({plugin:e}),e.config.asClass?Pa({plugin:e}):Ia({plugin:e})},za=e=>Ra(e),Ba={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:za,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`)}},Va=y(Ba),Ha=({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})]}},Ua=({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})})]},Wa=`data`,Ga=new Set,Ka=e=>e.map(e=>m.default.isStatement(e)?e:P.expressionToStatement({expression:e})),qa=({node:e})=>e.kind===m.default.SyntaxKind.ReturnStatement,Ja=({plugin:e,schema:t})=>{let n=P.identifier({text:Wa}),r=Ya({dataExpression:n,plugin:e,schema:t});return r.length&&!qa({node:r[r.length-1]})&&r.push(P.returnStatement({expression:n})),r},Ya=({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:S({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:F(n.$ref)})}),t.setSymbolValue(i,null)),!t.gen.symbols.getValue(i.id)&&!Ga.has(i.id)){Ga.add(i.id);try{let e=Ja({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(e.length){let n=P.constVariable({expression:P.arrowFunction({async:!1,multiLine:!0,parameters:[{name:Wa,type:P.keywordTypeNode({keyword:`any`})}],statements:Ka(e)}),name:i.placeholder});t.setSymbolValue(i,n)}}finally{Ga.delete(i.id)}}if(t.gen.symbols.getValue(i.id)||Ga.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?Ya({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=Ka(r);return i.some(e=>qa({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||Wa,name:a}),c=Ya({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:Ka(c)})}))}return r}if(n.items){if(n.items.length===1)return Ya({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=Ya({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:Ka(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[]},Xa=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=it(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${T(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=Ja({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:S({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id})}),o=P.constVariable({exportConst:a.exported,expression:P.arrowFunction({async:!0,multiLine:!0,parameters:[{name:Wa,type:P.keywordTypeNode({keyword:`any`})}],returnType:P.typeReferenceNode({typeArguments:[P.typeReferenceNode({typeName:r.placeholder})],typeName:`Promise`}),statements:Ka(i)}),name:a.placeholder});e.setSymbolValue(a,o)},{order:`declarations`})},Za={config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:Xa,name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,Ua]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,Ha])},tags:[`transformer`]},Qa=y(Za),$a=P.keywordTypeNode({keyword:`string`}),eo=({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||$a,`://`,t.host||$a,t.port?`:${t.port}`:``,t.path||``]})},to=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=E(e.context.config),i=t.map(e=>eo({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(P.typeIntersectionNode({types:[$a,m.default.factory.createTypeLiteralNode([])]})):i.push($a);let a=P.typeInterfaceNode({properties:[{name:ot(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)},no=({schema:e})=>{let t=[];return e.title&&t.push(gt(e.title)),e.description&&(t.length&&t.push(``),t.push(gt(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},ro=({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=x({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),k.lastIndex=0,k.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{comments:no({schema:t}),key:a,value:t.const}}),typeofItems:n}},io=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=ro({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:no({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:no({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:no({schema:t}),name:n.placeholder,obj:r.obj});e.setSymbolValue(n,i);return}}let i=P.typeAliasDeclaration({comment:no({schema:t}),exportType:n.exported,name:n.placeholder,type:r});e.setSymbolValue(n,i)},ao=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=C({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},oo=({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=ao({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=ao({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=ao({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:S({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)},so=({operation:e,plugin:t,state:n})=>{oo({operation:e,plugin:t,state:n});let{error:r,errors:i,response:a,responses:o}=it(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:S({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:S({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:S({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:S({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)}}},co=({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:S({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:no({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:S({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},lo=({operation:e,plugin:t,state:n})=>co({operation:e,plugin:t,state:n}),uo=({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)},fo=({plugin:e,schema:t,state:n})=>{if(!t.items)return P.typeArrayNode(P.keywordTypeNode({keyword:e.config.topType}));t=C({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=H({plugin:e,schema:t,state:{...n,path:D([...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}))},po=({schema:e})=>e.const===void 0?P.keywordTypeNode({keyword:`boolean`}):P.literalTypeNode({literal:P.ots.boolean(e.const)}),mo=({plugin:e,schema:t,state:n})=>H({plugin:e,schema:{...t,type:void 0},state:n}),ho=e=>P.keywordTypeNode({keyword:`never`}),go=e=>P.literalTypeNode({literal:P.null()}),_o=({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)}),vo=({context:e,name:t})=>(k.lastIndex=0,k.test(t)?t.startsWith(`-`)?m.default.factory.createStringLiteral(t):m.default.factory.createNumericLiteral(t):x({case:e.config.output.case,value:t})),yo=({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:D([...n.path.value,`properties`,r])}}),u=s.includes(r);a.push({comment:no({schema:i}),isReadOnly:i.accessScope===`read`,isRequired:u,name:vo({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})},bo=({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:x({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`})},xo=({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:D([...n.path.value,`items`,i])}});r.push(a)}),P.typeTupleNode({types:r})},So=e=>P.keywordTypeNode({keyword:`undefined`}),Co=({plugin:e})=>P.keywordTypeNode({keyword:e.config.topType}),wo=e=>P.keywordTypeNode({keyword:`void`}),To=({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 fo({...t,schema:e});case`boolean`:return po({...t,schema:e});case`enum`:return mo({...t,schema:e});case`integer`:case`number`:return _o({...t,schema:e});case`never`:return ho({...t,schema:e});case`null`:return go({...t,schema:e});case`object`:return yo({...t,schema:e});case`string`:return bo({...t,schema:e});case`tuple`:return xo({...t,schema:e});case`undefined`:return So({...t,schema:e});case`unknown`:return Co({...t,schema:e});case`void`:return wo({...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 To({plugin:e,schema:t,state:n});if(t.items){if(t=C({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 To({plugin:e,schema:{type:`unknown`},state:n})},Eo=({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);io({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:S({config:e.config.definitions,name:F(a)})}),type:r})},Do=({plugin:e})=>{let t=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`client`,role:`options`,tool:`typescript`},name:S({config:{case:e.config.case},name:`ClientOptions`})}),n=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`webhook`,tool:`typescript`,variant:`container`},name:S({config:{case:e.config.case},name:`Webhooks`})}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=O({path:t._path,tags:t.tags});switch(t.type){case`operation`:so({operation:t.operation,plugin:e,state:n});break;case`parameter`:Eo({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Eo({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Eo({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(lo({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),to({plugin:e,servers:r,symbolClientOptions:t}),uo({plugin:e,symbolWebhooks:n,webhookNames:i})};var Oo=class{schemaToType(e){return H(e)}};const ko=e=>Do(e),Ao={api:new Oo,config:{case:`PascalCase`,exportFromIndex:!0,topType:`unknown`},handler:ko,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})}},jo=y(Ao),Mo=(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})},No=({operation:e,plugin:t})=>dr({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Po=({operation:e,plugin:t})=>{let n=E(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},Fo=({operation:e,plugin:t})=>t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`,Io=({plugin:e,typeData:t})=>{let n=E(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},Lo=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol({category:`external`,resource:`${t.name}.UseMutationOptions`}),i=No({operation:e,plugin:t}),a=Po({operation:e,plugin:t}),o=Fo({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=Io({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=Mo(t,e,`mutationOptions`);m&&p.push({key:`meta`,value:m});let h=t.registerSymbol({exported:!0,name:S({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)},Ro=`TOptions`,zo=P.identifier({text:`options`}),Bo=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createQueryKey`,tool:e.name},name:S({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:Ro})],typeName:n.placeholder})}),a=ot(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:Ro})},{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:zo,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: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.binaryExpression({left:P.propertyAccessExpression({expression:zo,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:Ro}]}),name:t.placeholder});e.setSymbolValue(t,u)},Vo=({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]})},Ho=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),n=[{name:`_id`,type:P.keywordTypeNode({keyword:`string`})},{isRequired:!1,name:ot(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<${Ro}, 'path'>`}),P.typeInterfaceNode({properties:n,useLegacyResolution:!0})]})]}),typeParameters:[{extends:P.typeReferenceNode({typeName:P.identifier({text:r.placeholder})}),name:Ro}]});e.setSymbolValue(i,a)},Uo=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=Io({plugin:t,typeData:No({operation:e,plugin:t})});return P.constVariable({exportConst:n.exported,expression:P.arrowFunction({parameters:[{isRequired:tt(e),name:`options`,type:r}],statements:Vo({id:e.id,operation:e,plugin:t})}),name:n.placeholder})},Wo=`options`,Go=`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})||(Ho({plugin:t}),Bo({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:S({config:t.config.queryKeys,name:e.id})}),r=Uo({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=P.callExpression({functionName:n.placeholder,parameters:[Wo]})}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),Wo,r]})}let{strippedTypeData:a}=Io({plugin:t,typeData:No({operation:e,plugin:t})}),o=P.awaitExpression({expression:P.callExpression({functionName:n,parameters:[P.objectExpression({multiLine:!0,obj:[{spread:Wo},{spread:Go},{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:Go}],statements:s})}],l=Mo(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:S({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:Wo,type:a}],statements:P.objectExpression({obj:c})})]}),name:u.placeholder});t.setSymbolValue(u,f)},qo=({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;a=i?[e.referenceSymbol({category:`utility`,resource:`class`,resourceId:i.path[0],tool:`sdk`}).placeholder,...t.config.instance?[ja,`get()`]:[],...i.path.slice(1).map(e=>x({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&&Lo({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},Jo=e=>qo(e),Yo={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})}},Xo=y(Yo),Zo=({operation:e,plugin:t})=>dr({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Qo=({operation:e,plugin:t})=>{let n=E(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},$o=({operation:e,plugin:t})=>t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`,es=`TOptions`,ts=P.identifier({text:`infinite`}),ns=P.identifier({text:`options`}),rs=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createQueryKey`,tool:e.name},name:S({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:es})],typeName:n.placeholder})}),i=ot(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:es})},{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:ts,thenStatement:P.block({statements:[P.expressionToStatement({expression:P.binaryExpression({left:P.propertyAccessExpression({expression:`params`,name:`_infinite`}),right:ts})})]})}),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:ns,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:ns,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:ns,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:ns,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:es}]}),name:t.placeholder});e.setSymbolValue(t,s)},is=({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]})},as=({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<${es}, '${ot(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`}),P.typeInterfaceNode({properties:t,useLegacyResolution:!0})]})]}),typeParameters:[{extends:P.typeReferenceNode({typeName:P.identifier({text:n.placeholder})}),name:es}]});e.setSymbolValue(r,i)},os=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=Zo({operation:t,plugin:n});return P.constVariable({exportConst:r.exported,expression:P.arrowFunction({parameters:[{isRequired:tt(t),name:`options`,type:a}],returnType:e?i:void 0,statements:is({id:t.id,isInfinite:e,operation:t,plugin:n})}),name:r.placeholder})},ss=(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})},cs=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createInfiniteParams`,tool:e.name},name:S({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)},ls=({operation:e,plugin:t,queryFn:n})=>{let r=nt({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})||(as({plugin:t}),rs({plugin:t})),t.getSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name})||cs({plugin:t});let a=t.referenceSymbol({category:`external`,resource:`${t.name}.infiniteQueryOptions`}),o=t.referenceSymbol({category:`external`,resource:`${t.name}.InfiniteData`}),s=Zo({operation:e,plugin:t}),c=Qo({operation:e,plugin:t}),l=$o({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=`${xt({node:f.api.schemaToType({plugin:f,schema:r.schema,state:{path:{value:[]}}}),unescape:!0})} | ${d}`,m=t.registerSymbol({exported:!0,name:S({config:t.config.infiniteQueryKeys,name:e.id})}),h=os({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}]})]})}),_=t.referenceSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name}),ee=[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:_.placeholder,parameters:[`queryKey`,`page`]}),name:`params`})];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?ee.push(P.returnVariable({expression:g})):ee.push(P.constVariable({destructure:!0,expression:g,name:`data`}),P.returnVariable({expression:`data`}));let te=[{key:`queryFn`,value:P.arrowFunction({async:!0,multiLine:!0,parameters:[{destructure:[{name:`pageParam`},{name:`queryKey`},{name:`signal`}]}],statements:ee})},{key:`queryKey`,value:P.callExpression({functionName:m.placeholder,parameters:[`options`]})}],ne=ss(t,e,`infiniteQueryOptions`);ne&&te.push({key:`meta`,value:ne});let re=t.registerSymbol({exported:!0,name:S({config:t.config.infiniteQueryOptions,name:e.id})}),ie=P.constVariable({comment:t.config.comments?I({operation:e}):void 0,exportConst:re.exported,expression:P.arrowFunction({parameters:[{isRequired:i,name:`options`,type:s}],statements:[P.returnFunctionCall({args:[P.objectExpression({comments:[{jsdoc:!1,lines:[`@ts-ignore`]}],obj:te})],name:a.placeholder,types:[l,c||`unknown`,`${o.placeholder}<${l}>`,u,p]})]}),name:re.placeholder});t.setSymbolValue(re,ie)},us=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol({category:`external`,resource:`${t.name}.MutationOptions`}),i=Zo({operation:e,plugin:t}),a=Qo({operation:e,plugin:t}),o=$o({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=ss(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:S({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)},ds=`options`,fs=({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})||(as({plugin:t}),rs({plugin:t}));let i=t.referenceSymbol({category:`external`,resource:`${t.name}.queryOptions`}),a=t.registerSymbol({exported:!0,name:S({config:t.config.queryKeys,name:e.id})}),o=os({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=Zo({operation:e,plugin:t}),c=V(n).call(V.object().spread(ds).spread(V(`queryKey`).attr(0)).prop(`signal`,V(`signal`)).prop(`throwOnError`,V.literal(!0))).await(),l=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?l.push(V.return(c)):l.push(V.const().object(`data`).assign(c),V.return(`data`));let u=V.object().pretty().prop(`queryFn`,V.func().async().param(e=>e.object(`queryKey`,`signal`)).do(...l)).prop(`queryKey`,V(a.placeholder).call(ds)).$if(ss(t,e,`queryOptions`),(e,t)=>e.prop(`meta`,V(t))),d=t.registerSymbol({exported:t.config.queryOptions.exported,meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name},name:S({config:t.config.queryOptions,name:e.id})}),f=V.const(d.placeholder).export(d.exported).$if(t.config.comments&&I({operation:e}),(e,t)=>e.describe(t)).assign(V.func().param(ds,e=>e.optional(!r).type(s)).do(V(i.placeholder).call(u).return()));t.setSymbolValue(d,f)},ps=`options`,ms=({operation:e,plugin:t})=>{if(gr({operation:e})||!(`useQuery`in t.config))return;let n=t.registerSymbol({exported:!0,name:S({config:t.config.useQuery,name:e.id})}),r=t.referenceSymbol({category:`external`,resource:`${t.name}.useQuery`}),i=hr({context:t.context,operation:e}),a=Zo({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:ps,type:a}],statements:[P.returnStatement({expression:P.callExpression({functionName:r.placeholder,parameters:[P.callExpression({functionName:o.placeholder,parameters:[ps]})]})})]}),name:n.placeholder});t.setSymbolValue(n,s)},hs=({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?[ja,`get()`]:[],...i.path.slice(1).map(e=>x({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&&fs({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&ls({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&ms({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&us({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},gs=e=>hs(e),_s={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:gs,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})}},vs=y(_s),ys={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:gs,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))}},bs=y(ys),xs={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:gs,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})}},Ss=y(xs),Cs={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:gs,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})}},ws=y(Cs),Ts={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:gs,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})}},Es=y(Ts),Ds=({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 V.func().async().param(r).do(V(n.placeholder).attr(`parseAsync`).call(r).await().return())},Os=({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 V.func().async().param(r).do(V(n.placeholder).attr(`parseAsync`).call(r).await().return())};var ks=class{createRequestValidator(e){return Ds(e)}createResponseValidator(e){return Os(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`})}},As=({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?no({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)}},js=e=>{let t={};return t.def=U.primitives.null,t},Ms=({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=Fs({optional:!c,plugin:e,schema:s,state:{...n,path:D([...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}'`),k.lastIndex=0,u=k.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=Fs({plugin:e,schema:t.additionalProperties,state:{...n,path:D([...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},Ns=({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},Ps=({schema:e,...t})=>{switch(e.type){case`null`:return js({...t,schema:e});case`object`:return Ms({...t,schema:e});case`string`:return Ns({...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}},Fs=({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=Ps({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=C({schema:t}),t.items||(r=Fs({plugin:e,schema:t,state:n}));else{let t=Ps({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=Ps({plugin:e,schema:{type:`unknown`},state:n}).expression,r},Is=({plugin:e,schema:t,state:n})=>{let r=rr(n.path.value),i=Fs({plugin:e,schema:t,state:n}),a=F(r);As({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:S({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:S({config:e.config.definitions.types.infer,name:a})}):void 0})},Ls=({plugin:e})=>{e.registerSymbol({external:`arktype`,meta:{category:`external`,resource:`arktype.type`},name:`type`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=O({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:Is({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Is({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Is({plugin:e,schema:t.schema,state:n});break}})},Rs=e=>Ls(e),zs={api:new ks,config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:Rs,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:b,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:{...b,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:b,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:{...b,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:b,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:{...b,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:b,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:{...b,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:b,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},Bs=y(zs),Vs=({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:Qe(e.parameters.header),name:`Headers`,type:`${r.placeholder}['headers']`}),e.parameters.path&&n.push({isRequired:Qe(e.parameters.path),name:`Params`,type:`${r.placeholder}['path']`}),e.parameters.query&&n.push({isRequired:Qe(e.parameters.query),name:`Querystring`,type:`${r.placeholder}['query']`})));let{errors:i,responses:a}=it(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})}},Hs=({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=Vs({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)},Us={config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:Hs,name:`fastify`},Ws=y(Us),Gs=({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:S({config:t.config.useSwr,name:e.id})}),a=V(n).call(V.object().prop(`throwOnError`,V.literal(!0))).await(),o=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?o.push(V.return(a)):o.push(V.const().object(`data`).assign(a),V.return(`data`));let s=V.const(i.placeholder).export(i.exported).$if(t.config.comments&&I({operation:e}),(e,t)=>e.describe(t)).assign(V.func().do(V(r.placeholder).call(V.literal(e.path),V.func().async().do(...o)).return()));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;a=i?[e.referenceSymbol({category:`utility`,resource:`class`,resourceId:i.path[0],tool:`sdk`}).placeholder,...t.config.instance?[ja,`get()`]:[],...i.path.slice(1).map(e=>x({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&&Gs({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},qs=e=>Ks(e),Js={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:qs,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))}},Ys=y(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:{}},Xs=({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 V.func().async().param(i).do(V(r.placeholder).attr(W.async.parseAsync).call(n.placeholder,i).await().return())},Zs=({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 V.func().async().param(i).do(V(r.placeholder).attr(W.async.parseAsync).call(n.placeholder,i).await().return())};var Qs=class{createRequestValidator(e){return Xs(e)}createResponseValidator(e){return Zs(e)}};const G=({pipes:e,plugin:t})=>e.length===1?e[0]:V(t.referenceSymbol({category:`external`,resource:`valibot.v`}).placeholder).attr(W.methods.pipe).call(...e).$render(),$s=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`valibot.v`}),o=V.const(i.placeholder).export(i.exported).$if(t.config.comments&&no({schema:n}),(e,t)=>e.describe(t)).$if(r.hasLazyExpression.value,t=>t.type(V.type(a.placeholder).attr(e.typeName||W.types.GenericSchema.text))).assign(G({pipes:e.pipes,plugin:t}));t.setSymbolValue(i,o)},ec={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}},tc=e=>e!==void 0&&e in ec,nc=e=>tc(e)&&ec[e].needsBigInt,rc=({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},ic=({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],$s({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:S({config:n.config.requests,name:t.id})})})}if(n.config.responses.enabled&&t.responses){let{response:i}=it(t);if(i){let a=[...r.path.value,`responses`];$s({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:S({config:n.config.responses,name:t.id})})})}}},ac=({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],$s({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:S({config:n.config.webhooks,name:t.id})})})}},oc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:W.schemas.unknown})})},sc=({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=C({schema:t});let i=t.items.map((t,i)=>{let a=yc({plugin:e,schema:t,state:{...n,path:D([...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:[oc({plugin:e,schema:{type:`unknown`},state:n})]});r.pipes.push(i)}}else{let t=P.callExpression({functionName:a,parameters:[oc({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},cc=({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})})},lc=({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 oc({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},uc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:W.schemas.never})})},dc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:W.schemas.null})})},fc=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=nc(n),a=tc(n)?ec[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:[rc({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:[rc({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:[rc({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:[rc({isBigInt:i,value:t.maximum})]});s.push(e)}return G({pipes:s,plugin:e})},pc=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=yc({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:D([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),k.lastIndex=0;let l;l=k.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===`never`)return r.pipes=[P.callExpression({functionName:P.propertyAccessExpression({expression:o.placeholder,name:W.schemas.strictObject}),parameters:[m.default.factory.createObjectLiteralExpression(i,!0)]})],r;if(t.additionalProperties&&typeof t.additionalProperties==`object`&&t.additionalProperties.type!==void 0){let a=yc({plugin:e,schema:t.additionalProperties,state:{...n,path:D([...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},mc=({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})},hc=({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=yc({plugin:e,schema:t,state:{...n,path:D([...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:[oc({plugin:e,schema:{type:`unknown`},state:n})]}},gc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:W.schemas.undefined})})},_c=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`valibot.v`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:W.schemas.void})})},vc=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:G({pipes:sc({...t,schema:e}).pipes,plugin:t.plugin})};case`boolean`:return{expression:cc({...t,schema:e})};case`enum`:return{expression:lc({...t,schema:e})};case`integer`:case`number`:return{expression:fc({...t,schema:e})};case`never`:return{expression:uc({...t,schema:e})};case`null`:return{expression:dc({...t,schema:e})};case`object`:return{expression:G({pipes:pc({...t,schema:e}).pipes,plugin:t.plugin})};case`string`:return e.format===`int64`||e.format===`uint64`?{expression:fc({...t,schema:e})}:{expression:mc({...t,schema:e})};case`tuple`:return{expression:G({pipes:hc({...t,schema:e}).pipes,plugin:t.plugin})};case`undefined`:return{expression:gc({...t,schema:e})};case`unknown`:return{expression:oc({...t,schema:e})};case`void`:return{expression:_c({...t,schema:e})}}},yc=({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=vc({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=C({schema:n}),n.items){let e=n.items.map((e,n)=>G({pipes:yc({plugin:t,schema:e,state:{...r,path:D([...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=yc({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=vc({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=rc({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},bc=({plugin:e,schema:t,state:n})=>{let r=rr(n.path.value),i=yc({plugin:e,schema:t,state:n}),a=F(r);$s({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:S({config:e.config.definitions,name:a})})})},xc=({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=O({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:ic({getAst:(n,r)=>yc({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:bc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:bc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:bc({plugin:e,schema:t.schema,state:n});break;case`webhook`:ac({getAst:(n,r)=>yc({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Sc=e=>xc(e),Cc={api:new Qs,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:Sc,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`]},wc=y(Cc),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`})},Tc=({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 V.func().async().param(r).do(V(n.placeholder).attr(K.parseAsync).call(r).await().return())},Ec=({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 V.func().async().param(r).do(V(n.placeholder).attr(K.parseAsync).call(r).await().return())},Dc=({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 V.func().async().param(r).do(V(n.placeholder).attr(K.parseAsync).call(r).await().return())},Oc=({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 V.func().async().param(r).do(V(n.placeholder).attr(K.parseAsync).call(r).await().return())},kc=({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 V.func().async().param(r).do(V(n.placeholder).attr(K.parseAsync).call(r).await().return())},Ac=({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 V.func().async().param(r).do(V(n.placeholder).attr(K.parseAsync).call(r).await().return())};var jc=class{createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Dc(e);case`mini`:return Tc(e);case 4:default:return kc(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Oc(e);case`mini`:return Ec(e);case 4:default:return Ac(e)}}};const Mc=({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?no({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)}},Nc=({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},Pc=({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],Mc({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:S({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:S({config:n.config.requests.types.infer,name:t.id})}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=it(t);if(i){let a=[...r.path.value,`responses`];Mc({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:S({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:S({config:n.config.responses.types.infer,name:t.id})}):void 0})}}},Fc=({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],Mc({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:S({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:S({config:n.config.webhooks.types.infer,name:t.id})}):void 0})}},Ic=({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},Lc=({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:[Ic({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=C({schema:t});let o=t.items.map((t,r)=>{let a=Yc({plugin:e,schema:t,state:{...n,path:D([...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},Rc=({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)},zc=({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):Ic({plugin:e,schema:{type:`unknown`},state:n})},Bc=({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},Vc=({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},Hc=({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},Uc=({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=Yc({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:D([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i.hasLazyExpression=!0),k.lastIndex=0;let l;l=k.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=Yc({plugin:e,schema:t.additionalProperties,state:{...n,path:D([...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},Wc=({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},Gc=({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=Yc({plugin:e,schema:t,state:{...n,path:D([...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},qc=({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 Lc({...t,schema:e});case`boolean`:return Rc({...t,schema:e});case`enum`:return zc({...t,schema:e});case`integer`:case`number`:return Hc({...t,schema:e});case`never`:return Bc({...t,schema:e});case`null`:return Vc({...t,schema:e});case`object`:return Uc({...t,schema:e});case`string`:return Wc({...t,schema:e});case`tuple`:return Gc({...t,schema:e});case`undefined`:return Kc({...t,schema:e});case`unknown`:return Ic({...t,schema:e});case`void`:return qc({...t,schema:e})}},Yc=({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=C({schema:n}),n.items){let e=n.items.map((e,n)=>Yc({plugin:t,schema:e,state:{...r,path:D([...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=Yc({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},Xc=({plugin:e,schema:t,state:n})=>{let r=rr(n.path.value),i=Yc({plugin:e,schema:t,state:n}),a=F(r);Mc({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:S({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:S({config:e.config.definitions.types.infer,name:a})}):void 0})},Zc=({plugin:e})=>{e.registerSymbol({external:Nc({plugin:e}),importKind:`namespace`,meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=O({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Pc({getAst:(n,r)=>Yc({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Xc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Xc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Xc({plugin:e,schema:t.schema,state:n});break;case`webhook`:Fc({getAst:(n,r)=>Yc({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Qc=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.unknown})})},$c=({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:[Qc({plugin:e,schema:{type:`unknown`},state:n})]});else{t=C({schema:t});let s=t.items.map((t,r)=>{let i=dl({plugin:e,schema:t,state:{...n,path:D([...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}},el=({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})})},tl=({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 Qc({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},nl=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.never})})},rl=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.null})})},il=({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},al=({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=dl({optional:!o.includes(r),plugin:e,schema:s,state:{...n,path:D([...n.path.value,`properties`,r])}});c.hasLazyExpression&&(i=!0),k.lastIndex=0;let l;l=k.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=dl({plugin:e,schema:t.additionalProperties,state:{...n,path:D([...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}},ol=({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},sl=({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=dl({plugin:e,schema:t,state:{...n,path:D([...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}},cl=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.undefined})})},ll=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`});return P.callExpression({functionName:P.propertyAccessExpression({expression:t.placeholder,name:K.void})})},ul=({schema:e,...t})=>{switch(e.type){case`array`:return $c({...t,schema:e});case`boolean`:return{expression:el({...t,schema:e})};case`enum`:return{expression:tl({...t,schema:e})};case`integer`:case`number`:return{expression:il({...t,schema:e})};case`never`:return{expression:nl({...t,schema:e})};case`null`:return{expression:rl({...t,schema:e})};case`object`:return al({...t,schema:e});case`string`:return{expression:ol({...t,schema:e})};case`tuple`:return sl({...t,schema:e});case`undefined`:return{expression:cl({...t,schema:e})};case`unknown`:return{expression:Qc({...t,schema:e})};case`void`:return{expression:ll({...t,schema:e})}}},dl=({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=ul({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=C({schema:n}),n.items){let e=n.items.map((e,n)=>dl({plugin:t,schema:e,state:{...r,path:D([...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=dl({plugin:t,schema:n,state:r});else{let e=ul({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},fl=({plugin:e,schema:t,state:n})=>{let r=rr(n.path.value),i=dl({plugin:e,schema:t,state:n}),a=F(r);Mc({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:S({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:S({config:e.config.definitions.types.infer,name:a})}):void 0})},pl=({plugin:e})=>{e.registerSymbol({external:Nc({plugin:e}),meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=O({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Pc({getAst:(n,r)=>dl({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:fl({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:fl({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:fl({plugin:e,schema:t.schema,state:n});break;case`webhook`:Fc({getAst:(n,r)=>dl({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},ml=({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},hl=({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:[ml({plugin:e,schema:{type:`unknown`},state:n}).expression]});else{t=C({schema:t});let o=t.items.map((t,i)=>{let a=Dl({plugin:e,schema:t,state:{...n,path:D([...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},gl=({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)},_l=({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):ml({plugin:e,schema:{type:`unknown`},state:n})},vl=({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},yl=({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},bl=({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)},xl=({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=Dl({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:D([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),k.lastIndex=0;let l;l=k.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=Dl({plugin:e,schema:t.additionalProperties,state:{...n,path:D([...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},Sl=({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},Cl=({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=Dl({plugin:e,schema:t,state:{...n,path:D([...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},wl=({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},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.void})}),t},El=({schema:e,...t})=>{switch(e.type){case`array`:return hl({...t,schema:e});case`boolean`:return gl({...t,schema:e});case`enum`:return _l({...t,schema:e});case`integer`:case`number`:return bl({...t,schema:e});case`never`:return vl({...t,schema:e});case`null`:return yl({...t,schema:e});case`object`:return xl({...t,schema:e});case`string`:return Sl({...t,schema:e});case`tuple`:return Cl({...t,schema:e});case`undefined`:return wl({...t,schema:e});case`unknown`:return ml({...t,schema:e});case`void`:return Tl({...t,schema:e})}},Dl=({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=El({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=C({schema:n}),n.items){let e=n.items.map((e,n)=>Dl({plugin:t,schema:e,state:{...r,path:D([...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=Dl({plugin:t,schema:n,state:r});else i.expression=El({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},Ol=({plugin:e,schema:t,state:n})=>{let r=rr(n.path.value),i=Dl({plugin:e,schema:t,state:n}),a=F(r);Mc({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:S({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:S({config:e.config.definitions.types.infer,name:a})}):void 0})},kl=({plugin:e})=>{e.registerSymbol({external:Nc({plugin:e}),meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=O({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:Pc({getAst:(n,r)=>Dl({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Ol({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Ol({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Ol({plugin:e,schema:t.schema,state:n});break;case`webhook`:Fc({getAst:(n,r)=>Dl({plugin:e,schema:n,state:O({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Al=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return pl(e);case`mini`:return Zc(e);case 4:default:return kl(e)}},jl={api:new jc,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:Al,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:b,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:{...b,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:b,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:{...b,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:b,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:{...b,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:b,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:{...b,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:b,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},Ml=y(jl),Nl={"@angular/common":Ar,"@hey-api/client-angular":qr,"@hey-api/client-axios":Yr,"@hey-api/client-fetch":Zr,"@hey-api/client-ky":$r,"@hey-api/client-next":ti,"@hey-api/client-nuxt":ri,"@hey-api/client-ofetch":ai,"@hey-api/schemas":bi,"@hey-api/sdk":Ba,"@hey-api/transformers":Za,"@hey-api/typescript":Ao,"@pinia/colada":Yo,"@tanstack/angular-query-experimental":_s,"@tanstack/react-query":ys,"@tanstack/solid-query":xs,"@tanstack/svelte-query":Cs,"@tanstack/vue-query":Ts,arktype:zs,fastify:Us,swr:Js,valibot:Cc,zod:jl},Pl=[`@hey-api/typescript`,`@hey-api/sdk`],Fl=({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=Nl[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:ci(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=Nl[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=Nl[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:v};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}},Il=e=>typeof e==`string`?e.startsWith(`@hey-api/client`):e.name.startsWith(`@hey-api/client`)||e.tags&&e.tags.includes(`client`),Ll=({dependencies:e,userConfig:t})=>{let n={},r=Pl;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&Il(t.plugins[0])?[...Pl,...t.plugins]:t.plugins),Fl({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})},Rl=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),zl=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=Be(Object.keys(s).length?c:void 0));let l=s instanceof Array?s.map(e=>Ie(e,i)):[Ie(s,i)];for(let e of l){let t=Ne(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=Pe(e),n=Ne(e),i=ze(e),o=He(e),s=[];n.length||s.push(new se(`missing input - which OpenAPI specification should we use to generate your output?`)),i.path||s.push(new se(`missing output - where should we generate your output?`)),i.path=f.default.resolve(process.cwd(),i.path);let c;try{c=Ll({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??Rl(),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}},Bl=Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`}),Vl=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Hl=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},Ul=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Wl=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(Hl(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Vl(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Gl({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Gl=({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=Ul(r),s=Object.entries(i).map(([t,i])=>Gl({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},ql=({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=Wl({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=Gl({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},Yl=(...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},Xl=ql({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),Zl=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=(0,_.getResolvedInput)({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await(0,_.sendRequest)({fetchOptions:{method:`HEAD`,...e,headers:Yl(e?.headers,r.headers)},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok&&r.isHeadMethodSupported)return{error:`not-ok`,response:s};if(r.isHeadMethodSupported===void 0&&(r.isHeadMethodSupported=s.ok),s.status===304)return{error:`not-modified`,response:s};if(o===void 0){let e=s.headers.get(`ETag`);e&&(o=e!==r.headers.get(`If-None-Match`),o&&r.headers.set(`If-None-Match`,e))}if(o===void 0){let e=s.headers.get(`Last-Modified`);e&&(o=e!==r.headers.get(`If-Modified-Since`),o&&r.headers.set(`If-Modified-Since`,e))}if(o===!1)return{error:`not-modified`,response:s}}try{let t=await(0,_.sendRequest)({fetchOptions:{method:`GET`,...e},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok)return{error:`not-ok`,response:s};if(a=s.body?await s.arrayBuffer():new ArrayBuffer(0),o===void 0){let e=new TextDecoder().decode(a);o=e!==r.lastValue,r.lastValue=e}}else r.lastValue?o=!1:r.lastValue=i.type;return o===!1?{error:`not-modified`,response:s}:{arrayBuffer:a,resolvedInput:i}},Ql=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 $l=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(e instanceof L){let t=e.$render();n.push(xt({node:t,unescape:!0}))}else if(typeof e==`string`)n.push(e);else if(e instanceof Array)for(let t of e)n.push(xt({node:t,unescape:!0}));else e!=null&&n.push(xt({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(xt({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]:Ql.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(xt({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=ui(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}},eu=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 tu=(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))},nu=(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 eu(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))},ru=(e,t,n)=>n?.order===`topological`?nu(e,t,n):tu(e,t,n),iu=[`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`],au=(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}},ou=[`server`,`schema`,`parameter`,`requestBody`,`operation`,`webhook`],su=(()=>{let e={};for(let t=0;t<ou.length;t++){let n=ou[t];n&&(e[n]=t)}for(let t of iu)e[t]===void 0&&(e[t]=ou.length);return e})(),cu=10,lu=e=>{let t=au(e);return t.matched?su[t.kind]??10:10},uu=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},du=e=>{switch(e.method){case`delete`:case`patch`:case`post`:case`put`:return[`mutation`];case`get`:return[`query`];default:return}};var fu=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:lu,matchPointerToGroup:au,order:`topological`,preferGroups:ou};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:iu);ru(this.context.graph,(e,n)=>{let r=au(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 ue({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 uu(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,du];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}},pu=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=S({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 $l},root:e.output.path}),this.logger=n,this.package=ci(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 fu({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 mu=[`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`],hu=({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)?x({case:c,value:at(n)}):x({case:c,value:`${r}-${i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`)}`}),t>1&&(o=`${o}${t}`),a.ids.has(o)?hu({context:e,count:t+1,id:n,method:r,path:i,state:a}):(a.ids.set(o,T({method:r,path:i})),o)},gu=`/`,J=(e,t=``)=>`${e}/${t}`,Y=e=>{let t=e.indexOf(`/`);return{name:e.slice(t+1),namespace:e.slice(0,t)}},_u=e=>{switch(e){case`parameters`:return`parameter`;case`requestBodies`:return`body`;case`responses`:return`response`;case`definitions`:case`schemas`:return`schema`;default:return`unknown`}},vu=(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)}},yu=({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 mu){if(!i[t])continue;let a=T({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))},bu=({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 mu){if(!r[t])continue;let i=T({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))}},xu=({spec:e,...t})=>{`swagger`in e?yu({...t,spec:e}):bu({...t,spec:e})},Su=(e,t,n)=>{let r=n.timeEvent(`create-filters`),i=vu(`operation`,e?.operations?.exclude),a=vu(`operation`,e?.operations?.include),o=vu(`parameter`,e?.parameters?.exclude),s=vu(`parameter`,e?.parameters?.include),c=vu(`body`,e?.requestBodies?.exclude),l=vu(`body`,e?.requestBodies?.include),u=vu(`response`,e?.responses?.exclude),d=vu(`response`,e?.responses?.include),f=vu(`schema`,e?.schemas?.exclude),p=vu(`schema`,e?.schemas?.include);xu({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},Cu=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,wu=({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}},Tu=({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}},Eu=({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}},Du=({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}},Ou=({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}},ku=({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}}}},Au=({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}}}},ju=({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}}}},Mu=({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}}}},Nu=({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)},Pu=({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}},Fu=({filters:e,logger:t,resourceMetadata:n})=>{let r=t.timeEvent(`create-filtered-dependencies`),{schemas:i}=Ou({filters:e,resourceMetadata:n}),{parameters:a}=Tu({filters:e,resourceMetadata:n,schemas:i}),{requestBodies:o}=Eu({filters:e,resourceMetadata:n,schemas:i}),{responses:s}=Du({filters:e,resourceMetadata:n,schemas:i});Mu({filters:e,resourceMetadata:n,schemas:i}),ku({filters:e,parameters:a,resourceMetadata:n}),Au({filters:e,requestBodies:o,resourceMetadata:n}),ju({filters:e,resourceMetadata:n,responses:s});let{operations:c}=wu({filters:e,parameters:a,requestBodies:o,resourceMetadata:n,responses:s,schemas:i});if(!e.orphans&&c.size){let{operationDependencies:e}=Pu({operations:c,resourceMetadata:n});Nu({operationDependencies:e,parameters:a,requestBodies:o,responses:s,schemas:i})}return r.timeEnd(),{operations:c,parameters:a,requestBodies:o,responses:s,schemas:i}},Iu=(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=_u(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&&mu.includes(e[2])){let a=e[e.length-1],o=T({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}},Lu=e=>JSON.parse(JSON.stringify(e)),Ru=[[`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`]],zu=e=>{if(Bu(e))return e.components.schemas;if(Vu(e))return e.definitions},Bu=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,Vu=e=>typeof e==`object`&&!!e&&`definitions`in e&&typeof e.definitions==`object`&&e.definitions!==null,Hu=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,Uu=({base:e,components:t,extraComponents:n})=>{let r=2,i=e;for(;Hu(t,i)||n&&Hu(n,i);)i=`${e}${r}`,r+=1;return i},Wu=e=>e.length===3&&e[0]===`components`&&e[1]===`schemas`||e.length===2&&e[0]===`definitions`,Gu=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})},qu=({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||Ru.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)=>qu({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):qu({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Ju=({spec:e})=>{let t=zu(e);if(!t)return;let n=Gu(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,Lu(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]}},Yu=({config:e,spec:t})=>{let n=zu(t);if(!n)return;let r={};for(let[e,t]of Object.entries(n)){let n=Ku(t);n&&(r[n]=e)}let i=[];qu({key:null,node:t,parent:null,path:[],visitor:e=>{if(!Wu(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]=Uu({base:S({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=Gu(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}`})}},Xu=({config:e,spec:t})=>{if(e.mode===`inline`){Ju({spec:t});return}if(e.mode===`root`){Yu({config:e,spec:t});return}},Zu=({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||Ru.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)=>Zu({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):Zu({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Qu=({spec:e})=>{Zu({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)}}})},$u=(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(!$u(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(!$u(r[e],i[e]))return!1;return!0};var ed=$u;const td=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))}},nd=({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=nd({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=nd({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}},rd=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&&id(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 Ru){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&&id(r,a)&&n(i,a)}if(a.parentPointer){let t=e.nodes.get(a.parentPointer);t&&id(a,t)&&n(a.parentPointer,t)}}},id=(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},ad=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`])))}},od=(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);ad(r.nodes),rd(r),td(r.nodes);for(let e of r.nodes.keys()){let t=nd({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}},sd=new Set([`additionalProperties`,`allOf`,`anyOf`,`items`,`not`,`oneOf`,`patternProperties`,`properties`,`schema`]),cd=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`}},ld=(e,t)=>{let n=t.timeEvent(`capture-original-schemas`),r={};if(Bu(e))for(let[t,n]of Object.entries(e.components.schemas))r[`#/components/schemas/${t}`]=n;else if(Vu(e))for(let[t,n]of Object.entries(e.definitions))r[`#/definitions/${t}`]=n;return n.timeEnd(),r},ud=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`insert-split-schemas-into-spec`);Bu(t)?Object.assign(t.components.schemas,n.schemas):Vu(t)&&Object.assign(t.definitions,n.schemas),r.timeEnd()},dd=(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,!Ru.some(([e])=>e in t)))return!0}for(let[r,i]of Ru){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||dd(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||dd(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||dd(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||dd(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else typeof a==`object`&&a&&(a[n]===!0||dd(e,a,n))&&delete t[r]}if(t.type===`object`&&!Ru.some(([e])=>e in t))return!0}return!1},fd=({logger:e,originalSchemas:t,spec:n,split:r})=>{let i=e.timeEvent(`remove-original-split-schemas`),a=zu(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()},pd=({config:e,graph:t,logger:n,spec:r})=>{let i=n.timeEvent(`split-schemas`),a=new Set,o={mapping:{},reverseMapping:{},schemas:{}},s=Gu(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=Lu(r.node);dd(t,c,`writeOnly`);let u=S({config:e.responses,name:i}),d=u===i?u:Uu({base:u,components:a});a.add(d),o.schemas[d]=c;let f=`${s}${d}`,p=Lu(r.node);dd(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`))})&&ed(c,p)&&ed(c,r.node))continue;let h=S({config:e.requests,name:i}),g=h===i&&h!==d?h:Uu({base:h,components:a});a.add(g),o.schemas[g]=p;let _=`${s}${g}`;o.mapping[n]={read:f,write:_},o.reverseMapping[f]=n,o.reverseMapping[_]=n}return i.timeEnd(),o},md=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`update-refs-in-spec`),i=Gu(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(Wu(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=cd(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(sd.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()},hd=({config:e,logger:t,spec:n})=>{let{graph:r}=od(n,t),i=ld(n,t),a=pd({config:e,graph:r,logger:t,spec:n});ud({logger:t,spec:n,split:a}),md({logger:t,spec:n,split:a}),fd({logger:t,originalSchemas:i,spec:n,split:a})},gd=({context:e})=>{let{logger:t}=e,n=t.timeEvent(`transform-openapi-spec`);e.config.parser.transforms.enums.enabled&&Xu({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&Qu({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&hd({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},_d=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),vd=e=>e.map((e,t)=>typeof e==`number`?`[${e}]`:t===0?e:_d(e)?`.${e}`:`['${e.replace(/"/g,`\\'`)}']`).join(``),yd=e=>{let t=vd(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}`},bd=({context:e,issue:t})=>e.config.logs.level===`silent`?!1:t.severity===`error`?e.config.logs.level!==`warn`:!0,xd=({context:e,result:t})=>{for(let n of t.issues)bd({context:e,issue:n})&&console.log(yd(n));t.valid||process.exit(1)},Sd=({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 mu){if(!r[e])continue;let i=J(`operation`,T({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete i.paths[n]}a.timeEnd()},Cd=/^(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,wd=/^application\/(.*\+)?json(;.*)?$/i,Td=/^multipart\/form-data(;.*)?$/i,Ed=/^text\/[a-z0-9.+-]+(;.*)?$/i,Dd=/^application\/x-www-form-urlencoded(;.*)?$/i,Od=/^application\/octet-stream(;.*)?$/i,kd=({mediaType:e})=>(Cd.lastIndex=0,Cd.test(e)),Ad=({mediaType:e})=>{if(wd.lastIndex=0,wd.test(e))return`json`;if(Td.lastIndex=0,Td.test(e))return`form-data`;if(Ed.lastIndex=0,Ed.test(e))return`text`;if(Dd.lastIndex=0,Dd.test(e))return`url-search-params`;if(Od.lastIndex=0,Od.test(e))return`octet-stream`},jd=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&kd({mediaType:t})?{...n,format:`binary`}:n:kd({mediaType:t})?{format:`binary`,type:`string`}:void 0},Md=({mimeTypes:e,response:t})=>{let n=[];for(let r of e??[])n.push({mediaType:r,schema:t.schema,type:Ad({mediaType:r})});return n};function Nd(e){let t=`^(${e.keywords.join(`|`)})$`;return new RegExp(t)}const Pd=(e,t,n)=>{let r=[];for(let n in t)t[n]===e&&r.push(n);return!r.length&&(!n||n())?[F(e)]:r},Fd=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},Id=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},Ld=({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`)},Rd=({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=Zd({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=w({items:i,schema:t}),t},zd=({irSchema:e={}})=>(e.type=`boolean`,e),Bd=({irSchema:e={},schema:t})=>(e.type=t.type,e),Vd=({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]=Zd({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=Zd({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},Hd=({irSchema:e={}})=>(e.type=`string`,e),Ud=({schema:e})=>{let t={};return Id({irSchema:t,schema:e}),t},Wd=({context:e,schema:t,state:n})=>{let r=Ud({schema:t}),i=[],a=Fd({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=Zd({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=Pd(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=Yd({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(Fd({schema:a})===`object`){let i=Yd({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=w({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},Gd=({context:e,schema:t,state:n})=>{let r=Ud({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=Yd({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=w({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=Zd({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,Zd({context:e,schema:r,state:n}),n.$ref=i}return r},qd=({context:e,irSchema:t,schema:n,state:r})=>{t||=Ud({schema:n});let i={};return Ld({irSchema:i,schema:n}),i.default===null&&delete i.default,t=w({items:[Yd({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},Jd=({context:e,schema:t,state:n})=>{let r=Ud({schema:t});Ld({irSchema:r,schema:t});let i=Fd({schema:t});return i?t[`x-nullable`]?qd({context:e,irSchema:r,schema:{...t,type:i},state:n}):Yd({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},Yd=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Ud({schema:n}),Ld({irSchema:t,schema:n})),n.type){case`array`:return Rd({context:e,irSchema:t,schema:n,state:r});case`boolean`:return zd({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Bd({context:e,irSchema:t,schema:n,state:r});case`object`:return Vd({context:e,irSchema:t,schema:n,state:r});case`string`:return Hd({context:e,irSchema:t,schema:n,state:r});default:return Xd({context:e,irSchema:t,schema:n})}},Xd=({irSchema:e,schema:t})=>(e||=Ud({schema:t}),e.type=`unknown`,Ld({irSchema:e,schema:t}),e),Zd=({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?Gd({context:e,schema:t,state:n}):t.allOf?Wd({context:e,schema:t,state:n}):t.type||t.properties?Jd({context:e,schema:t,state:n}):Xd({context:e,schema:t})),Qd=({$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)]=Zd({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},$d=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,ef=({context:e,name:t,schema:n})=>{if(Nd(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref??``);return`in`in r&&r.in?ef({context:e,name:t,schema:`schema`in r?r.schema:{...r,in:void 0}}):ef({context:e,name:t,schema:r})}if(`in`in n)return n.in?ef({context:e,name:t,schema:`schema`in n?n.schema:{...n,in:void 0}}):!1;for(let t in n.properties)if(Nd(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&$d(Fd({schema:e})))return t}for(let r of n.allOf??[]){let n=ef({context:e,name:t,schema:r});if(n)return n}return!1},tf=({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)},nf=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:hu({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),tf({irOperation:a,operation:n}),a},rf=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=nf({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=Md({mimeTypes:a,response:{schema:i}}),d=o.find(e=>e.type===`json`)||o[0];if(d){let t=ef({context:e,name:``,schema:d.schema&&`$ref`in d.schema?{allOf:[{...d.schema}],description:r.description}:{description:r.description,...d.schema}}),n=Zd({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=Md({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:Zd({context:e,schema:{description:i.description,...jd({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},af=({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]=rf({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},of=e=>{switch(e){case`multi`:return!0;case`csv`:case`pipes`:case`ssv`:case`tsv`:default:return!1}},sf=e=>{switch(e){case`header`:case`path`:return`simple`;case`query`:default:return`form`}},cf=({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()]=lf({$ref:`#/todo/real/path/to/parameter/${n.name}`,context:e,parameter:n})}return r},lf=({$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=ef({context:t,name:n.name,schema:i}),o=sf(n.in),s={allowReserved:!1,explode:of(n.collectionFormat),location:n.in,name:n.name,schema:Zd({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},uf=({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})))},df=(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 mu){if(t===`trace`)continue;let a=n[t];if(!a)continue;let o=T({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`)}},ff=e=>{if(e.config.parser.validate_EXPERIMENTAL&&xd({context:e,result:df(e.spec,e.logger)}),Cu(e.config.parser.filters)){let t=Su(e.config.parser.filters,e.spec,e.logger),{graph:n}=od(e.spec,e.logger),{resourceMetadata:r}=Iu(n,e.logger);Sd({...Fu({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}gd({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];Qd({$ref:n,context:e,schema:r})}for(let r in uf({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:cf({context:e,operation:o,parameters:a.parameters})},path:r,securitySchemesMap:n,state:t};if(a.delete){let t=X({source:cf({context:e,operation:a.delete,parameters:a.delete.parameters}),target:s.operation.parameters});af({...s,method:`delete`,operation:{...s.operation,...a.delete,parameters:t}})}if(a.get){let t=X({source:cf({context:e,operation:a.get,parameters:a.get.parameters}),target:s.operation.parameters});af({...s,method:`get`,operation:{...s.operation,...a.get,parameters:t}})}if(a.head){let t=X({source:cf({context:e,operation:a.head,parameters:a.head.parameters}),target:s.operation.parameters});af({...s,method:`head`,operation:{...s.operation,...a.head,parameters:t}})}if(a.options){let t=X({source:cf({context:e,operation:a.options,parameters:a.options.parameters}),target:s.operation.parameters});af({...s,method:`options`,operation:{...s.operation,...a.options,parameters:t}})}if(a.patch){let t=X({source:cf({context:e,operation:a.patch,parameters:a.patch.parameters}),target:s.operation.parameters});af({...s,method:`patch`,operation:{...s.operation,...a.patch,parameters:t}})}if(a.post){let t=X({source:cf({context:e,operation:a.post,parameters:a.post.parameters}),target:s.operation.parameters});af({...s,method:`post`,operation:{...s.operation,...a.post,parameters:t}})}if(a.put){let t=X({source:cf({context:e,operation:a.put,parameters:a.put.parameters}),target:s.operation.parameters});af({...s,method:`put`,operation:{...s.operation,...a.put,parameters:t}})}}},pf=({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 mu){if(!r[e])continue;let i=J(`operation`,T({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},mf=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&kd({mediaType:t})?{...n,format:`binary`}:n:kd({mediaType:t})?{format:`binary`,type:`string`}:void 0},hf=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:Ad({mediaType:n})});return t},gf=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},_f=({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)},vf=({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`)},yf=({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=w({items:i,schema:t}),t},bf=({irSchema:e={}})=>(e.type=`boolean`,e),xf=({irSchema:e={},schema:t})=>(e.type=t.type,e),Sf=({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},Cf=({irSchema:e={}})=>(e.type=`string`,e),wf=({schema:e})=>{let t={};return _f({irSchema:t,schema:e}),t},Tf=({context:e,schema:t,state:n})=>{let r=wf({schema:t}),i=[],a=gf({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=Pd(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=Mf({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(gf({schema:a})===`object`){let i=Mf({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=w({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},Ef=({context:e,schema:t,state:n})=>{let r=wf({schema:t}),i=[],a=gf({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=Pd(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=w({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=Mf({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Df=({context:e,schema:t,state:n})=>{let r=wf({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=Mf({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=w({items:i,schema:r}),r},Of=({context:e,schema:t,state:n})=>{let r=wf({schema:t}),i=[],a=gf({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=Pd(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=w({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=Mf({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},kf=({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},Af=({context:e,irSchema:t,schema:n,state:r})=>{t||=wf({schema:n});let i={};return vf({irSchema:i,schema:n}),i.default===null&&delete i.default,t=w({items:[Mf({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},jf=({context:e,schema:t,state:n})=>{let r=wf({schema:t});vf({irSchema:r,schema:t});let i=gf({schema:t});return i?t.nullable?Af({context:e,irSchema:r,schema:{...t,type:i},state:n}):Mf({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},Mf=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=wf({schema:n}),vf({irSchema:t,schema:n})),n.type){case`array`:return yf({context:e,irSchema:t,schema:n,state:r});case`boolean`:return bf({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return xf({context:e,irSchema:t,schema:n,state:r});case`object`:return Sf({context:e,irSchema:t,schema:n,state:r});case`string`:return Cf({context:e,irSchema:t,schema:n,state:r});default:return Nf({context:e,irSchema:t,schema:n})}},Nf=({irSchema:e,schema:t})=>(e||=wf({schema:t}),e.type=`unknown`,vf({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?kf({context:e,schema:t,state:n}):t.enum?Df({context:e,schema:t,state:n}):t.allOf?Tf({context:e,schema:t,state:n}):t.anyOf?Ef({context:e,schema:t,state:n}):t.oneOf?Of({context:e,schema:t,state:n}):t.type||t.properties?jf({context:e,schema:t,state:n}):Nf({context:e,schema:t})),Pf=({$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}})},Ff=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,If=({context:e,name:t,schema:n})=>{if(Nd(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=hf({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?If({context:e,name:t,schema:n}):!1}return If({context:e,name:t,schema:r})}for(let t in n.properties)if(Nd(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&Ff(gf({schema:e})))return t}for(let r of n.allOf??[]){let n=If({context:e,name:t,schema:r});if(n)return n}return!1},Lf=({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)},Rf=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:hu({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Lf({irOperation:a,operation:n}),a},zf=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Rf({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=hf({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=If({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=hf({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,...mf({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},Bf=({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]=zf({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},Vf=e=>{switch(e){case`query`:return!1;default:return}},Hf=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},Uf=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},Wf=({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()]=Gf({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Gf=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=hf({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=If({context:t,name:n.name,schema:i}),o=n.style||Uf(n.in),s=n.explode===void 0?Hf(o):n.explode,c={allowReserved:n.allowReserved===void 0?Vf(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)]=Gf({$ref:e,context:t,parameter:n})},qf=({$ref:e,context:t,requestBody:n})=>{let r=hf({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)]=qf({$ref:e,context:t,requestBody:n})},Yf=({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:`/`}])},Xf=(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 mu){let a=n[t];if(!a)continue;let o=T({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`)}},Zf=e=>{if(e.config.parser.validate_EXPERIMENTAL&&xd({context:e,result:Xf(e.spec,e.logger)}),Cu(e.config.parser.filters)){let t=Su(e.config.parser.filters,e.spec,e.logger),{graph:n}=od(e.spec,e.logger),{resourceMetadata:r}=Iu(n,e.logger);pf({...Fu({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}gd({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];Pf({$ref:n,context:e,schema:r})}}for(let r in Yf({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:Wf({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&Bf({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:X({source:Wf({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Bf({...o,method:`get`,operation:{...o.operation,...a.get,parameters:X({source:Wf({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Bf({...o,method:`head`,operation:{...o.operation,...a.head,parameters:X({source:Wf({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Bf({...o,method:`options`,operation:{...o.operation,...a.options,parameters:X({source:Wf({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Bf({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:X({source:Wf({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Bf({...o,method:`post`,operation:{...o.operation,...a.post,parameters:X({source:Wf({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Bf({...o,method:`put`,operation:{...o.operation,...a.put,parameters:X({source:Wf({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Bf({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:X({source:Wf({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},Qf=({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 mu){if(!r[e])continue;let i=J(`operation`,T({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},$f=({content:e})=>{let{mediaType:t,schema:n}=e;return n?n.type===`string`&&!n.format&&kd({mediaType:t})?{...n,format:`binary`}:n:kd({mediaType:t})?{format:`binary`,type:`string`}:void 0},ep=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:Ad({mediaType:n})});return t},tp=({schema:e})=>typeof e.type==`string`?[e.type]:e.type?e.type:e.properties?[`object`]:[],np=({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)},rp=({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`)},ip=({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&&!tp({schema:n.items}).includes(`null`)?t={...t,...a}:i.push(a)}}return t=w({items:i,schema:t}),t},ap=({irSchema:e={}})=>(e.type=`boolean`,e),op=({irSchema:e={}})=>(e.type=`null`,e),sp=({irSchema:e={},schema:t})=>(e.type=t.type,e),cp=({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},lp=({irSchema:e={}})=>(e.type=`string`,e),up=({schema:e})=>{let t={};return np({irSchema:t,schema:e}),t},dp=({context:e,schema:t,state:n})=>{let r=up({schema:t});rp({irSchema:r,schema:t});let i=[],a=tp({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=Pd(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=gp({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(tp({schema:a}).includes(`object`)){let i=gp({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=w({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},fp=({context:e,schema:t,state:n})=>{let r=up({schema:t});rp({irSchema:r,schema:t});let i=[],a=tp({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=Pd(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=w({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=gp({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},pp=({context:e,schema:t,state:n})=>{let r=up({schema:t});r.type=`enum`;let i=[],a=tp({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=gp({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=w({items:i,schema:r}),r},mp=({context:e,schema:t,state:n})=>{let r=up({schema:t});rp({irSchema:r,schema:t});let i=[],a=tp({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=Pd(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=w({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=gp({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},hp=({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=up({schema:t});rp({irSchema:r,schema:t});let 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=w({items:a,mutateSchemaOneItem:!0,schema:r}),r},gp=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=up({schema:n}),rp({irSchema:t,schema:n})),n.type){case`array`:return ip({context:e,irSchema:t,schema:n,state:r});case`boolean`:return ap({context:e,irSchema:t,schema:n});case`integer`:case`number`:return sp({context:e,irSchema:t,schema:n});case`null`:return op({context:e,irSchema:t,schema:n});case`object`:return cp({context:e,irSchema:t,schema:n,state:r});case`string`:return lp({context:e,irSchema:t,schema:n});default:return yp({context:e,irSchema:t,schema:n})}},_p=({context:e,irSchema:t,schema:n,state:r})=>{t||=up({schema:n});let i={};rp({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=gp({context:e,irSchema:{...i},schema:{...n,type:t},state:r});a.push(o)}return t=w({items:a,schema:t}),t},vp=({context:e,schema:t,state:n})=>{let r=up({schema:t});rp({irSchema:r,schema:t});let i=tp({schema:t});return i.length===1?gp({context:e,irSchema:r,schema:{...t,type:i[0]},state:n}):_p({context:e,irSchema:r,schema:{...t,type:i},state:n})},yp=({irSchema:e,schema:t})=>(e||=up({schema:t}),e.type=`unknown`,rp({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?hp({context:e,schema:t,state:n}):t.enum?pp({context:e,schema:t,state:n}):t.allOf?dp({context:e,schema:t,state:n}):t.anyOf?fp({context:e,schema:t,state:n}):t.oneOf?mp({context:e,schema:t,state:n}):t.type||t.properties?vp({context:e,schema:t,state:n}):yp({context:e,schema:t})),bp=({$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}})},xp=e=>e.includes(`boolean`)||e.includes(`integer`)||e.includes(`number`)||e.includes(`string`),Sp=({context:e,name:t,schema:n})=>{if(Nd(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=ep({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?Sp({context:e,name:t,schema:n}):!1}return Sp({context:e,name:t,schema:r})}for(let t in n.properties)if(Nd(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`){let n=tp({schema:e});if(!n.length){let n=(e.anyOf??e.oneOf??[]).filter(e=>e.type!==`null`);if(n.length===1&&xp(tp({schema:n[0]})))return t}if(xp(n))return t}}for(let r of n.allOf??[]){let n=Sp({context:e,name:t,schema:r});if(n)return n}return!1},Cp=({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)},wp=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:hu({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Cp({irOperation:a,operation:n}),a},Tp=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=wp({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=ep({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=Sp({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=ep({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,...$f({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},Ep=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>(n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),{parsed:Tp({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})}),Dp=({context:e,method:t,path:n,...r})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={});let{parsed:i}=Ep({context:e,method:t,path:n,...r});e.ir.paths[n][t]=i},Op=({context:e,key:t,method:n,...r})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:i}=Ep({context:e,method:n,path:t,...r});e.ir.webhooks[t][n]=i},kp=e=>{switch(e){case`query`:return!1;default:return}},Ap=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},jp=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()]=Mp({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Mp=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=ep({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=Sp({context:t,name:n.name,schema:i}),o=n.style||jp(n.in),s=n.explode===void 0?Ap(o):n.explode,c={allowReserved:n.allowReserved===void 0?kp(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},Np=({$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)]=Mp({$ref:e,context:t,parameter:n})},Pp=({$ref:e,context:t,requestBody:n})=>{let r=ep({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},Fp=({$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)]=Pp({$ref:e,context:t,requestBody:n})},Ip=({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:`/`}])},Lp=(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 mu){let a=n[t];if(!a)continue;let o=T({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`)}},Rp=({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&&Op({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:X({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Op({...o,method:`get`,operation:{...o.operation,...a.get,parameters:X({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Op({...o,method:`head`,operation:{...o.operation,...a.head,parameters:X({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Op({...o,method:`options`,operation:{...o.operation,...a.options,parameters:X({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Op({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:X({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Op({...o,method:`post`,operation:{...o.operation,...a.post,parameters:X({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Op({...o,method:`put`,operation:{...o.operation,...a.put,parameters:X({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Op({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:X({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},zp=e=>{if(e.config.parser.validate_EXPERIMENTAL&&xd({context:e,result:Lp(e.spec,e.logger)}),Cu(e.config.parser.filters)){let t=Su(e.config.parser.filters,e.spec,e.logger),{graph:n}=od(e.spec,e.logger),{resourceMetadata:r}=Iu(n,e.logger);Qf({...Fu({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}gd({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];Np({$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];Fp({$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];bp({$ref:n,context:e,schema:r})}}for(let r in Ip({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&&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})}})}Rp({context:e,securitySchemesMap:n})},Bp=({config:e,dependencies:t,logger:n,spec:r})=>{let i=new pu({config:e,dependencies:t,logger:n,spec:r});if(`swagger`in i.spec)return ff(i),i;if(si(i.spec.openapi,`>=3.0.0 <3.1.0`))return Zf(i),i;if(si(i.spec.openapi,`>=3.1.0`))return zp(i),i;throw Error(`Unsupported OpenAPI specification`)};Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Pl}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return de}}),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 E}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return Pe}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return Ve}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return zl}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return Nr}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return od}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return Kr}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return Zl}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return Br}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return Bp}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return Gn}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return ce}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return re}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return le}});
19
+ //# sourceMappingURL=openApi-CT-iM-D8.cjs.map