@hey-api/openapi-ts 0.88.2 → 0.89.0

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.
@@ -1,17 +0,0 @@
1
- import{createRequire as e}from"node:module";import{Project as t,createBinding as n,mergeBindings as r,renderIds as i}from"@hey-api/codegen-core";import a from"ansi-colors";import o from"node:fs";import s from"node:path";import{fileURLToPath as c}from"node:url";import l from"typescript";import{EOL as u}from"node:os";import*as d from"semver";import{getResolvedInput as f,sendRequest as p}from"@hey-api/json-schema-ref-parser";var m=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),h=e(import.meta.url);const g=c(import.meta.url),ee=s.dirname(g),te=()=>{let e=ee;for(;e!==s.dirname(e);){let t=o.readdirSync(e).filter(e=>e===`package.json`);if(t[0]){let n=s.join(e,t[0]);return JSON.parse(o.readFileSync(n,{encoding:`utf8`}))}e=s.dirname(e)}},ne=()=>{let e=te(),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},re=e=>{if(e===null)return null;if(e){let t=s.isAbsolute(e)?e:s.resolve(ee,e);return o.existsSync(t)?t:null}let t=ee;for(;t!==s.dirname(t);){let e=o.readdirSync(t).filter(e=>e.startsWith(`tsconfig`)&&e.endsWith(`.json`)).sort(e=>e===`tsconfig.json`?-1:1);if(e[0])return s.join(t,e[0]);t=s.dirname(t)}return null},ie=e=>{if(!e)return null;let t=l.readConfigFile(e,l.sys.readFile);if(t.error)throw Error(`Couldn't read tsconfig from path: ${e}`);return l.parseJsonConfigFileContent(t.config,l.sys,s.dirname(e))},ae=e=>{o.existsSync(e)||o.mkdirSync(e,{recursive:!0})};var oe=class extends Error{constructor(e){super(e),this.name=`ConfigError`}},se=class extends Error{errors;constructor(e){super(`Found ${e.length} configuration ${e.length===1?`error`:`errors`}.`),this.name=`ConfigValidationError`,this.errors=e}},ce=class extends Error{originalError;constructor(e,t){super(e),this.name=`JobError`,this.originalError=t}},le=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 ue=(e,t)=>{if(e instanceof oe||e instanceof se)return;e instanceof ce&&(e=e.originalError.error);let n=`openapi-ts-error-${Date.now()}.log`,r=s.resolve(process.cwd(),t);ae(r);let i=s.resolve(r,n),a=`[${new Date().toISOString()}] `;e instanceof le&&(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 c=e instanceof Error?e.message:String(e),l=e instanceof Error?e.stack:void 0;return a+=`Error: ${c}\n`,l&&(a+=`Stack:\n${l}\n`),o.writeFileSync(i,a),i},de=async e=>{let t=ne();if(!t.bugs.url)return;e instanceof ce&&(e=e.originalError.error);let n=``;e instanceof le&&(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)},fe=({error:e,logPath:t})=>{if(e instanceof se&&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=a.gray(`[Job ${e+1}] `),r=n.length,i=a.red(`Found ${r} configuration ${r===1?`error`:`errors`}:`);console.error(`${t}❗️ ${i}`),n.forEach((e,n)=>{let r=` [${n+1}] `,i=a.red(r);console.error(`${t}${i}${a.white(e.message)}`)})}}else{let t=a.gray(`[root] `);e instanceof ce&&(t=a.gray(`[Job ${e.originalError.jobIndex+1}] `),e=e.originalError.error);let n=a.red(`Failed with the message:`);console.error(`${t}❌ ${n}`);let r=a.red(` `);console.error(`${t}${r}${typeof e==`string`?e:e instanceof Error?e.message:`Unknown error`}`)}if(t){let e=a.gray(`[root] `);console.error(`${e}${a.cyan(`📄 Crash log saved to:`)} ${a.gray(t)}`)}},pe=async({error:e,isInteractive:t})=>!t||e instanceof oe||e instanceof se?!1:new Promise(e=>{let t=a.gray(`[root] `);console.log(`${t}${a.yellow(`📢 Open a GitHub issue with crash details? (y/N):`)}`),process.stdin.setEncoding(`utf8`),process.stdin.once(`data`,t=>{e(t.trim().toLowerCase()===`y`)})}),me=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,he=`https://get.heyapi.dev`,ge=(e,t,n)=>`${he}/${e}/${t}${n?`?${n}`:``}`,_e=e=>{let t=e.organization,n=e.project,r;if(e.path){let i=e.path.match(me);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}},ve=e=>{let t=_e(e);return{path:ge(t.organization,t.project,t.queryParams),registry:`hey-api`}},ye=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,be=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,xe=`readme`,Se=e=>{let t=e.match(ye);if(!t)throw Error(`Invalid ReadMe shorthand format. Expected "${xe}:@organization/project#uuid" or "${xe}:uuid", received: ${xe}:${e}`);let[,,n,r,i]=t;if(!i)throw Error(`The ReadMe UUID cannot be empty.`);return{organization:n,project:r,uuid:i}},Ce=e=>{let t=Se(e.slice(`${xe}:`.length));return{...t,path:be(t.uuid),registry:`readme`}},we=/^(@[\w-]+)\/([\w.-]+)$/,Te=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,Ee=`scalar`,De=e=>{let t=e.match(we);if(!t)throw Error(`Invalid Scalar shorthand format. Expected "${Ee}:@organization/project", received: ${Ee}:${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}},Oe=e=>{let t=De(e.slice(`${Ee}:`.length));return{...t,path:Te(t.organization,t.project),registry:`scalar`}},ke=e=>{if(e.path.startsWith(`readme:`)){Object.assign(e,Ce(e.path));return}if(e.path.startsWith(`scalar:`)){Object.assign(e,Oe(e.path));return}if(e.path.startsWith(`.`))return;if(e.path.startsWith(he)){e.path=e.path.slice(23),Object.assign(e,ve(e));return}let t=e.path.split(`/`);if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,ve(e));return}},Ae={enabled:!1,interval:1e3,timeout:6e4},je=e=>{let t={...Ae};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},Me=e=>{let t=e.input instanceof Array?e.input:[e.input],n=[];for(let r of t){let t={path:``,watch:Ae};typeof r==`string`?t.path=r:r&&(r.path!==void 0||r.organization!==void 0)?(t={...t,path:he,...r},t.watch!==void 0&&(t.watch=je(t))):t={...t,path:r},typeof t.path==`string`&&ke(t),e.watch!==void 0&&t.watch.enabled===Ae.enabled&&t.watch.interval===Ae.interval&&t.watch.timeout===Ae.timeout&&(t.watch=je({path:t.path,watch:e.watch})),t.path&&n.push(t)}return n},Ne=e=>{let t={file:!0,level:`info`,path:process.cwd()};return typeof e?.logs==`string`?t.path=e.logs:t={...t,...e?.logs},t},Pe=(e,t)=>{let n=e||{},r=t||{};return{...n,...r}},Fe=(e,t)=>{let n=e||{},r=t||{},i={...n,...r};return typeof i.logs==`object`&&(i.logs=Pe(n.logs,r.logs)),i},Ie=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e!=`function`,Le=(e,t)=>{for(let[n,r]of Object.entries(t))r!==void 0&&r!==``&&(e[n]=r);return e},_=({defaultValue:e,mappers:t,value:n})=>{let r={...e};switch(typeof n){case`boolean`:if(t&&`boolean`in t){let e=t.boolean;r=Le(r,e(n))}break;case`function`:if(t&&`function`in t){let e=t.function;r=Le(r,e(n))}break;case`number`:if(t&&`number`in t){let e=t.number;r=Le(r,e(n))}break;case`string`:if(t&&`string`in t){let e=t.string;r=Le(r,e(n))}break;case`object`:if(Ie(n))if(t&&`object`in t&&typeof t.object==`function`){let i=t.object;r=Le(r,i(n,e))}else r=Le(r,n);break}return r},Re=e=>{if(e.output instanceof Array)throw Error(`Unexpected array of outputs in user configuration. This should have been expanded already.`);let t=_({defaultValue:{clean:!0,fileName:{case:`preserve`,name:`{{name}}`,suffix:`.gen`},format:null,indexFile:!0,lint:null,path:``},mappers:{object:(e,t)=>({...e,fileName:_({defaultValue:{...t.fileName},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.fileName})}),string:e=>({path:e})},value:e.output});return t.tsConfig=ie(re(t.tsConfigPath)),t.importFileExtension===void 0&&t.tsConfig?.options.moduleResolution===l.ModuleResolutionKind.NodeNext&&(t.importFileExtension=`.js`),t.importFileExtension&&!t.importFileExtension.startsWith(`.`)&&(t.importFileExtension=`.${t.importFileExtension}`),t},ze=e=>{let t=e?s.dirname(e):process.cwd();for(;t!==s.dirname(t);){let e=s.join(t,`package.json`);if(o.existsSync(e))try{let t=JSON.parse(o.readFileSync(e,`utf8`));return{...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies}}catch{}let n=s.dirname(t);if(n===t)break;t=n}return{}},Be=[`after`,`before`,`cursor`,`offset`,`page`,`start`],Ve=e=>_({defaultValue:{hooks:{},pagination:{keywords:Be},transforms:{enums:{case:`PascalCase`,enabled:!1,mode:`root`,name:`{{name}}Enum`},propertiesRequiredByDefault:!1,readWrite:{enabled:!0,requests:{case:`preserve`,name:`{{name}}Writable`},responses:{case:`preserve`,name:`{{name}}`}}},validate_EXPERIMENTAL:!1},mappers:{object:(e,t)=>({...e,pagination:_({defaultValue:{...t.pagination},value:e.pagination}),transforms:_({defaultValue:{...t.transforms},mappers:{object:(e,t)=>({...e,enums:_({defaultValue:{...t.enums,enabled:e.enums===void 0?t.enums.enabled:!!e.enums},mappers:{boolean:e=>({enabled:e}),string:e=>({mode:e})},value:e.enums}),propertiesRequiredByDefault:e.propertiesRequiredByDefault===void 0?t.propertiesRequiredByDefault:e.propertiesRequiredByDefault,readWrite:_({defaultValue:{...t.readWrite,enabled:e.readWrite===void 0?t.readWrite.enabled:!!e.readWrite},mappers:{boolean:e=>({enabled:e}),object:(e,t)=>({...e,requests:_({defaultValue:{...t.requests},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.requests}),responses:_({defaultValue:{...t.responses},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.responses})})},value:e.readWrite})})},value:e.transforms}),validate_EXPERIMENTAL:e.validate_EXPERIMENTAL===!0?`warn`:e.validate_EXPERIMENTAL})},value:e.parser}),He=e=>t=>({...e,config:{...e.config,...t}}),v={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},y=({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):``},b=({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 y({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})}}}},x=({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},S=({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),C=({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=S({items:Object.values(n.properties),mutateSchemaOneItem:!0,schema:{}});e=x({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=S({items:Object.values(r.properties),mutateSchemaOneItem:!0,schema:{}});e=x({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=w(e);return t.name===`@hey-api/client-axios`||t.name===`@hey-api/client-nuxt`?`baseURL`:`baseUrl`},w=e=>{for(let t of e.pluginOrder){let n=e.plugins[t];if(n?.tags?.includes(`client`))return n}return{config:{name:``},name:``}},T=e=>({value:e}),E=e=>{let t={};for(let n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=T(e[n]));return t};var D=class 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}$maybeId(e){return typeof e==`string`?l.factory.createIdentifier(e):e}$node(e){if(e!==void 0)return typeof e==`string`?l.factory.createIdentifier(e):e instanceof Array?e.map(e=>this.unwrap(e)):this.unwrap(e)}$type(e,t){if(e!==void 0){if(typeof e==`string`)return l.factory.createTypeReferenceNode(e,t);if(typeof e==`boolean`){let t=e?l.factory.createTrue():l.factory.createFalse();return l.factory.createLiteralTypeNode(t)}return typeof e==`number`?l.factory.createLiteralTypeNode(l.factory.createNumericLiteral(e)):e instanceof Array?e.map(e=>this.$type(e,t)):this.unwrap(e)}}unwrap(t){return t instanceof e?t.$render():t}},O=class extends D{},st=class extends D{name;constructor(e){super(),this.name=e}$render(){return l.factory.createIdentifier(this.name)}},ct=class extends D{$render(){return this.$node(new st(`
2
- `))}};function k(e,...t){let n=e.prototype;for(let r of t){let t=r;if(typeof r==`function`)try{let n=r(e);n?.prototype&&(t=n)}catch{}let i=t.prototype;if(i)for(let[e,t]of Object.entries(Object.getOwnPropertyDescriptors(i)))e!==`constructor`&&(e===`$render`&&!t.value.mixin||Object.defineProperty(n,e,t))}}var lt=class extends D{_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.$maybeId(e)):[]}$render(){throw Error(`noop`)}},ut=class extends D{name;constructor(e,...t){super(),this.name=e,this.args(...t)}$render(){let e=this.$args();return l.factory.createDecorator(e.length?l.factory.createCallExpression(this.$maybeId(this.name),void 0,e):this.$maybeId(this.name))}};k(ut,lt);var dt=class extends D{decorators;decorator(e,...t){return(this.decorators??=[]).push(new ut(e,...t)),this}$decorators(){return this.decorators?this.$node(this.decorators):[]}$render(){throw Error(`noop`)}},ft=class extends D{_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=>l.factory.createJSDocText(`${e}\n`)),r=l.factory.createJSDocComment(l.factory.createNodeArray(n),void 0),i=l.createPrinter().printNode(l.EmitHint.Unspecified,r,e.getSourceFile?.()??l.createSourceFile(``,``,l.ScriptTarget.Latest)).replace(`/*`,``).replace(`* */`,``);return l.addSyntheticLeadingComment(e,l.SyntaxKind.MultiLineCommentTrivia,i,!0),e}$render(){return this.$node(new st(``))}};function A(e){let t=e.prototype.$render;class n extends e{_doc;doc(e,t){return this._doc=new ft(e,t),this}$render(...e){let n=t.apply(this,e);return this._doc?this._doc.apply(n):n}}return n.prototype.$render.mixin=!0,n}function j(e){let t=[];function n(n,r=!0){return r&&t.push(l.factory.createModifier(n)),e}Object.assign(e,{_m:n});function r(){return t}return{list:r}}var pt=class{abstract(e=!0){return this._m(l.SyntaxKind.AbstractKeyword,e)}},mt=class{async(e=!0){return this._m(l.SyntaxKind.AsyncKeyword,e)}},ht=class{const(e=!0){return this._m(l.SyntaxKind.ConstKeyword,e)}},gt=class{default(e=!0){return this._m(l.SyntaxKind.DefaultKeyword,e)}},_t=class{export(e=!0){return this._m(l.SyntaxKind.ExportKeyword,e)}},vt=class{private(e=!0){return this._m(l.SyntaxKind.PrivateKeyword,e)}},yt=class{protected(e=!0){return this._m(l.SyntaxKind.ProtectedKeyword,e)}},bt=class{public(e=!0){return this._m(l.SyntaxKind.PublicKeyword,e)}},xt=class{readonly(e=!0){return this._m(l.SyntaxKind.ReadonlyKeyword,e)}},St=class{static(e=!0){return this._m(l.SyntaxKind.StaticKeyword,e)}},Ct=class extends O{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 l.factory.createTypeParameterDeclaration(void 0,this.$maybeId(this.name),this.$type(this.constraint),this.$type(this.defaultValue))}},wt=class extends D{_generics;generic(...e){let t=new Ct(...e);return(this._generics??=[]).push(t),this}generics(...e){return(this._generics??=[]).push(...e),this}$generics(){return this._generics?.map(e=>{let t=typeof e==`string`?new Ct(e):e;return this.$node(t)})}$render(){throw Error(`noop`)}},Tt=class extends D{value;assign(e){return this.value=e,this}$value(){return this.$node(this.value)}$render(){throw Error(`noop`)}},Et=class extends D{_generics;generic(e){return(this._generics??=[]).push(e),this}generics(...e){return(this._generics??=[]).push(...e),this}$generics(){return this.$type(this._generics)}$render(){throw Error(`noop`)}};let Dt;function Ot(e){Dt=e}let kt;function At(e){kt=e}let jt;function Mt(e){jt=e}let Nt;function Pt(e){Nt=e}let Ft;function It(e){Ft=e}var Lt=class{idx(e){return kt(this,e)}keyof(){return Nt().keyof(this)}readonly(){return Nt().readonly(this)}returnType(){return Dt(`ReturnType`).generic(Ft(this))}typeofExpr(){return jt(this)}typeofType(){return Ft(this)}typeof(){if(this instanceof D){let e=this.$render();return l.isExpression(e)?jt(this):Ft(this)}return l.isExpression(this)?jt(this):Ft(this)}unique(){return Nt().unique(this)}},Rt=class extends O{_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(!l.isEntityName(e))throw Error(`TypeAttrTsDsl: base must be an EntityName`);let t=this.$maybeId(this.right);return l.factory.createQualifiedName(e,t)}};k(Rt,Lt);var M=class extends O{_exprInput;constructor(e,t){super(),typeof e==`string`?(this._exprInput=e,t?.(this)):e?.(this)}attr(e){return this._exprInput=e instanceof Rt?e.base(this._exprInput):new Rt(this._exprInput,e),this}$render(){if(!this._exprInput)throw Error(`TypeExpr must have either an expression or an object`);return l.factory.createTypeReferenceNode(this.$type(this._exprInput),this.$generics())}};k(M,Et,Lt),Ot((...e)=>new M(...e));var zt=class extends D{modifiers=j(this);name;_type;constructor(e,t){super(),this.name=e,t?.(this)}type(e){return this._type=e instanceof O?e:new M(e),this}$render(){return l.factory.createPropertyDeclaration([...this.$decorators(),...this.modifiers.list()],this.name,void 0,this.$type(this._type),this.$value())}};k(zt,dt,A,vt,yt,bt,xt,St,Tt);var Bt=class extends D{_inner;constructor(e){super(),this._inner=e}$render(){let e=this.$node(this._inner);return l.isStatement(e)?e:l.factory.createExpressionStatement(e)}},Vt=class extends D{_do;do(...e){return(this._do??=[]).push(...e),this}$do(){return this._do?this.$node(this._do.map(e=>new Bt(e))):[]}$render(){throw Error(`noop`)}},Ht=class{_optional;optional(e){return this._optional=arguments.length===0?!0:!!e,this}required(e){return this._optional=arguments.length===0?!1:!e,this}},N=class extends D{_kind;kind(e){return this._kind=e,this}minus(){return this.kind(l.SyntaxKind.MinusToken)}optional(){return this.kind(l.SyntaxKind.QuestionToken)}plus(){return this.kind(l.SyntaxKind.PlusToken)}questionDot(){return this.kind(l.SyntaxKind.QuestionDotToken)}readonly(){return this.kind(l.SyntaxKind.ReadonlyKeyword)}spread(){return this.kind(l.SyntaxKind.DotDotDotToken)}$render(){if(!this._kind)throw Error("Token missing `.kind(kind)`");return l.factory.createToken(this._kind)}},Ut=class extends D{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?l.factory.createBindingElement(void 0,void 0,e,void 0):l.factory.createBindingElement(void 0,e,t,void 0)),t=this.createSpread();return t&&e.push(t),l.factory.createObjectBindingPattern(e)}if(this.pattern.kind===`array`){let e=this.pattern.values.map(e=>l.factory.createBindingElement(void 0,void 0,e,void 0)),t=this.createSpread();return t&&e.push(t),l.factory.createArrayBindingPattern(e)}throw Error(`PatternTsDsl requires object() or array() pattern`)}createSpread(){return this._spread?l.factory.createBindingElement(this.$node(new N().spread()),void 0,this.$node(new st(this._spread))):void 0}},Wt=class extends D{pattern;array(...e){return(this.pattern??=new Ut).array(...e),this}object(...e){return(this.pattern??=new Ut).object(...e),this}spread(e){return(this.pattern??=new Ut).spread(e),this}$pattern(){return this.$node(this.pattern)}$render(){throw Error(`noop`)}},Gt=class extends D{name;_type;constructor(e,t){super(),typeof e==`string`?(this.name=e,t?.(this)):e(this)}type(e){return this._type=e instanceof O?e:new M(e),this}$render(){let e=this.$pattern()??this.name;if(!e)throw Error(`Param must have either a name or a destructuring pattern`);return l.factory.createParameterDeclaration(this.$decorators(),void 0,e,this._optional?this.$node(new N().optional()):void 0,this.$type(this._type),this.$value())}};k(Gt,dt,Ht,Wt,Tt);var Kt=class extends D{_params;param(e,t){let n=new Gt(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`)}},qt=class extends D{modifiers=j(this);constructor(e){super(),e?.(this)}$render(){return l.factory.createConstructorDeclaration([...this.$decorators(),...this.modifiers.list()],this.$params(),l.factory.createBlock(this.$do(),!0))}};k(qt,dt,Vt,A,Kt,vt,yt,bt);var Jt=class extends D{modifiers=j(this);name;_returns;constructor(e,t){super(),this.name=e,t?.(this)}returns(e){return this._returns=e instanceof O?e:new M(e),this}$render(){return l.factory.createMethodDeclaration([...this.$decorators(),...this.modifiers.list()],void 0,this.name,this._optional?this.$node(new N().optional()):void 0,this.$generics(),this.$params(),this.$type(this._returns),l.factory.createBlock(this.$do(),!0))}};k(Jt,pt,mt,dt,Vt,A,Ht,Kt,vt,yt,bt,St,wt);var Yt=class extends D{heritageClauses=[];body=[];modifiers=j(this);name;constructor(e){super(),this.name=e}do(...e){return this.body.push(...e),this}extends(e){return e&&this.heritageClauses.push(l.factory.createHeritageClause(l.SyntaxKind.ExtendsKeyword,[l.factory.createExpressionWithTypeArguments(this.$maybeId(e),void 0)])),this}field(e,t){let n=new zt(e,t);return this.body.push(n),this}init(e){let t=new qt(e);return this.body.push(t),this}method(e,t){let n=new Jt(e,t);return this.body.push(n),this}newline(){return this.body.push(new ct),this}$render(){let e=this.$node(this.body);return l.factory.createClassDeclaration([...this.$decorators(),...this.modifiers.list()],this.name,this.$generics(),this.heritageClauses,e)}};k(Yt,pt,dt,gt,A,_t,wt);const Xt=/^[^$_\p{ID_Start}]+/u,Zt=/^-?\d+(\.\d+)?$/,Qt=/^(document|history|location|navigator|window)$/g,$t=/^(console|Array|Date|Error|Function|JSON|Map|Math|Object|Promise|RegExp|Set|WeakMap|WeakSet)$/g,en=/^(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,tn=/^(global|process|Buffer)$/g,nn=/^(any|as|bigint|boolean|namespace|never|null|number|string|symbol|type|undefined|unknown|void)$/g,rn=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u;var an=class extends D{_expr;_op;constructor(e,t){super(),this._expr=e,this._op=t}expr(e){return this._expr=e,this}neg(){return this._op=l.SyntaxKind.MinusToken,this}not(){return this._op=l.SyntaxKind.ExclamationToken,this}op(e){return this._op=e,this}$render(){if(!this._expr)throw Error(`Missing expression for prefix unary expression`);if(!this._op)throw Error(`Missing operator for prefix unary expression`);return l.factory.createPrefixUnaryExpression(this._op,this.$node(this._expr))}};let on;function sn(e){on=e}var cn=class{as(e){return on(this,e)}},P=class extends D{value;constructor(e){super(),this.value=e}$render(){if(typeof this.value==`boolean`)return this.value?l.factory.createTrue():l.factory.createFalse();if(typeof this.value==`number`){let e=l.factory.createNumericLiteral(Math.abs(this.value));return this.value<0?this.$node(new an(e).neg()):e}if(typeof this.value==`string`)return l.factory.createStringLiteral(this.value,!0);if(this.value===null)return l.factory.createNull();throw Error(`Unsupported literal: ${String(this.value)}`)}};k(P,cn);const ln=e=>(rn.lastIndex=0,rn.test(e)?new st(e).$render():new P(e).$render()),un=e=>(Zt.lastIndex=0,Zt.test(e)?e.startsWith(`-`)?new P(e).$render():l.factory.createNumericLiteral(e):(rn.lastIndex=0,rn.test(e)?new st(e).$render():new P(e).$render()));var dn=class extends D{_name;_value;constructor(e,t){super(),this._name=e,typeof t==`function`?t(this):this.value(t)}value(e){return this._value=e,this}$render(){return l.factory.createEnumMember(ln(this._name),this.$node(this._value))}};k(dn,A);var fn=class extends D{_members=[];_name;modifiers=j(this);constructor(e,t){super(),this._name=e,t?.(this)}member(e,t){let n=new dn(e,t);return this._members.push(n),this}members(...e){return this._members.push(...e),this}$render(){return l.factory.createEnumDeclaration(this.modifiers.list(),this._name,this.$node(this._members))}};k(fn,ht,A,_t);var pn=class extends D{mode;modifiers=j(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 O?e:new M(e),this}$render(){if(this.mode===`decl`){if(!this.name)throw Error(`Function declaration requires a name`);return l.factory.createFunctionDeclaration([...this.$decorators(),...this.modifiers.list()],void 0,this.name,this.$generics(),this.$params(),this.$type(this._returns),l.factory.createBlock(this.$do(),!0))}if(this.mode===`expr`)return l.factory.createFunctionExpression(this.modifiers.list(),void 0,this.name,this.$generics(),this.$params(),this.$type(this._returns),l.factory.createBlock(this.$do(),!0));let e=this.$do(),t=e.length===1&&l.isReturnStatement(e[0])?e[0].expression??l.factory.createBlock(e,!0):l.factory.createBlock(e,!0);return l.factory.createArrowFunction(this.modifiers.list(),this.$generics(),this.$params(),this.$type(this._returns),void 0,t)}};k(pn,pt,cn,mt,dt,Vt,A,Kt,vt,yt,bt,St,wt);const mn=pn;var hn=class extends D{modifiers=j(this);name;constructor(e,t){super(),this.name=e,t?.(this)}$render(){return l.factory.createGetAccessorDeclaration([...this.$decorators(),...this.modifiers.list()],this.name,this.$params(),void 0,l.factory.createBlock(this.$do(),!0))}};k(hn,pt,dt,Vt,A,Kt,vt,yt,bt,St);var gn=class extends D{modifiers=j(this);name;constructor(e,t){super(),this.name=e,t?.(this)}$render(){return l.factory.createSetAccessorDeclaration([...this.$decorators(),...this.modifiers.list()],this.name,this.$params(),l.factory.createBlock(this.$do(),!0))}};k(gn,pt,dt,Vt,A,Kt,vt,yt,bt,St);var _n=class e{static DEFAULT_THRESHOLD=3;layout;auto(t=e.DEFAULT_THRESHOLD){return this.layout=t,this}inline(){return this.layout=!1,this}pretty(){return this.layout=!0,this}$multiline(t){return this.layout===void 0&&(this.layout=e.DEFAULT_THRESHOLD),typeof this.layout==`number`?t>=this.layout:this.layout}},vn=class extends D{_elements=[];constructor(...e){super(),this.elements(...e)}element(e){let t=typeof e==`string`||typeof e==`number`||typeof e==`boolean`?new P(e):e;return this._elements.push({expr:t,kind:`element`}),this}elements(...e){for(let t of e)this.element(t);return this}spread(e){return this._elements.push({expr:e,kind:`spread`}),this}$render(){let e=this._elements.map(e=>{let t=this.$node(e.expr);return e.kind===`spread`?l.factory.createSpreadElement(t):t});return l.factory.createArrayLiteralExpression(e,this.$multiline(this._elements.length))}};k(vn,cn,_n);let yn;function bn(e){yn=e}let xn;function Sn(e){xn=e}let Cn;function wn(e){Cn=e}let Tn;function En(e){Tn=e}var Dn=class{attr(e){return yn(this,e)}await(){return xn(this)}call(...e){return Cn(this,e)}return(){return Tn(this)}},On=class extends D{expr;type;constructor(e,t){super(),this.expr=e,this.type=t}$render(){return l.factory.createAsExpression(this.$node(this.expr),this.$type(this.type))}};k(On,cn,Dn),sn((...e)=>new On(...e));var F=class extends D{_base;_expr;_op;constructor(e,t,n){super(),this._base=e,this._op=t,this._expr=n}and(e){return this.opAndExpr(`&&`,e)}assign(e){return this.opAndExpr(`=`,e)}coalesce(e){return this.opAndExpr(`??`,e)}div(e){return this.opAndExpr(`/`,e)}eq(e){return this.opAndExpr(`===`,e)}gt(e){return this.opAndExpr(`>`,e)}gte(e){return this.opAndExpr(`>=`,e)}looseEq(e){return this.opAndExpr(`==`,e)}looseNeq(e){return this.opAndExpr(`!=`,e)}lt(e){return this.opAndExpr(`<`,e)}lte(e){return this.opAndExpr(`<=`,e)}minus(e){return this.opAndExpr(`-`,e)}neq(e){return this.opAndExpr(`!==`,e)}or(e){return this.opAndExpr(`||`,e)}plus(e){return this.opAndExpr(`+`,e)}times(e){return this.opAndExpr(`*`,e)}$render(){if(!this._op)throw Error(`BinaryTsDsl: missing operator`);if(this._expr===void 0)throw Error(`BinaryTsDsl: missing right-hand expression`);let e=this.$node(this._base),t=this.$node(this._expr),n=typeof this._op==`string`?this.opToToken(this._op):this._op;return l.factory.createBinaryExpression(e,n,t)}opAndExpr(e,t){return this._expr=t,this._op=e,this}opToToken(e){let t={"!=":l.SyntaxKind.ExclamationEqualsToken,"!==":l.SyntaxKind.ExclamationEqualsEqualsToken,"&&":l.SyntaxKind.AmpersandAmpersandToken,"*":l.SyntaxKind.AsteriskToken,"+":l.SyntaxKind.PlusToken,"-":l.SyntaxKind.MinusToken,"/":l.SyntaxKind.SlashToken,"<":l.SyntaxKind.LessThanToken,"<=":l.SyntaxKind.LessThanEqualsToken,"=":l.SyntaxKind.EqualsToken,"==":l.SyntaxKind.EqualsEqualsToken,"===":l.SyntaxKind.EqualsEqualsEqualsToken,">":l.SyntaxKind.GreaterThanToken,">=":l.SyntaxKind.GreaterThanEqualsToken,"??":l.SyntaxKind.QuestionQuestionToken,"||":l.SyntaxKind.BarBarToken}[e];if(!t)throw Error(`Unsupported operator: ${e}`);return t}};k(F,cn,Dn);var kn=class{and(e){return new F(this).and(e)}assign(e){return new F(this,`=`,e)}coalesce(e){return new F(this).coalesce(e)}div(e){return new F(this).div(e)}eq(e){return new F(this).eq(e)}gt(e){return new F(this).gt(e)}gte(e){return new F(this).gte(e)}looseEq(e){return new F(this).looseEq(e)}looseNeq(e){return new F(this).looseNeq(e)}lt(e){return new F(this).lt(e)}lte(e){return new F(this).lte(e)}minus(e){return new F(this).minus(e)}neq(e){return new F(this).neq(e)}or(e){return new F(this).or(e)}plus(e){return new F(this).plus(e)}times(e){return new F(this).times(e)}},An=class extends D{left;right;constructor(e,t){super(),this.left=e,this.right=t}$render(){let e=this.$node(this.left);return rn.lastIndex=0,typeof this.right==`number`||typeof this.right==`string`&&!rn.test(this.right)?this._optional?l.factory.createElementAccessChain(e,this.$node(new N().questionDot()),this.$node(new P(this.right))):l.factory.createElementAccessExpression(e,this.$node(new P(this.right))):this._optional?l.factory.createPropertyAccessChain(e,this.$node(new N().questionDot()),this.$maybeId(this.right)):l.factory.createPropertyAccessExpression(e,this.$maybeId(this.right))}};k(An,cn,Dn,kn,Ht),bn((...e)=>new An(...e));var jn=class extends D{_awaitExpr;constructor(e){super(),this._awaitExpr=e}$render(){return l.factory.createAwaitExpression(this.$node(this._awaitExpr))}};k(jn,Dn),Sn((...e)=>new jn(...e));var Mn=class extends D{_callee;constructor(e,...t){super(),this._callee=e,this.args(...t.filter(e=>e!==void 0))}$render(){return l.factory.createCallExpression(this.$node(this._callee),this.$generics(),this.$args())}};k(Mn,lt,cn,Dn,Et),wn((e,t)=>new Mn(e,...t));var Nn=class extends D{_exprInput;constructor(e){super(),this._exprInput=e}$render(){return this.$node(this._exprInput)}};k(Nn,cn,Dn,kn,Lt);var Pn=class extends D{_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;for(let n of t)l.addSyntheticLeadingComment(e,l.SyntaxKind.SingleLineCommentTrivia,` ${n}`,!1);return e}$render(){return this.$node(new st(``))}};function Fn(e){let t=e.prototype.$render;class n extends e{_hint;hint(e,t){return this._hint=new Pn(e,t),this}$render(...e){let n=t.apply(this,e);return this._hint?this._hint.apply(n):n}}return n.prototype.$render.mixin=!0,n}var In=class extends D{_value;meta;constructor(e){super(),this.meta=e}get isValid(){return this.missingRequiredCalls().length===0}value(e){return typeof e==`function`?e(this):this._value=e,this}$render(){this.$validate();let e=this.$node(this._value);if(this.meta.kind===`spread`){if(l.isStatement(e))throw Error(`Invalid spread: object spread must be an expression, not a statement.`);return l.factory.createSpreadAssignment(e)}if(this.meta.kind===`getter`){let t=new hn(un(this.meta.name)).do(e);return this.$node(t)}if(this.meta.kind===`setter`){let t=new gn(un(this.meta.name)).do(e);return this.$node(t)}if(l.isIdentifier(e)&&e.text===this.meta.name)return l.factory.createShorthandPropertyAssignment(this.meta.name);if(l.isStatement(e))throw Error(`Invalid property: object property value must be an expression, not a statement.`);return l.factory.createPropertyAssignment(this.meta.kind===`computed`?l.factory.createComputedPropertyName(this.$node(new st(this.meta.name))):un(this.meta.name),e)}$validate(){let e=this.missingRequiredCalls();if(e.length!==0)throw Error(`Object property${this.meta.name?` "${this.meta.name}"`:``} missing ${e.join(` and `)}`)}missingRequiredCalls(){let e=[];return this._value||e.push(`.value()`),e}};k(In,A);var Ln=class extends D{_props=[];constructor(...e){super(),this.props(...e)}computed(e,t){return this._props.push(new In({kind:`computed`,name:e}).value(t)),this}getter(e,t){return this._props.push(new In({kind:`getter`,name:e}).value(t)),this}hasProps(){return this._props.length>0}get isEmpty(){return this._props.length===0}prop(e,t){return this._props.push(new In({kind:`prop`,name:e}).value(t)),this}props(...e){return this._props.push(...e),this}setter(e,t){return this._props.push(new In({kind:`setter`,name:e}).value(t)),this}spread(e){return this._props.push(new In({kind:`spread`}).value(e)),this}$render(){return l.factory.createObjectLiteralExpression(this.$node(this._props),this.$multiline(this._props.length))}};k(Ln,cn,Dn,Fn,_n);const Rn=(e,t)=>{if(e instanceof D)return e;if(e===null||typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return new P(e);if(e instanceof Array){let n=new vn(...e.map(e=>Rn(e,t)));return t?.layout===`pretty`&&n.pretty(),n}if(typeof e==`object`){let n=new Ln;for(let[r,i]of Object.entries(e)){let e=Rn(i,t);n.prop(r,e)}return t?.layout===`pretty`&&n.pretty(),n}throw Error(`$.fromValue(): Unsupported input type ${String(e)}`)};var zn=class extends D{classExpr;constructor(e,...t){super(),this.classExpr=e,this.args(...t)}$render(){return l.factory.createNewExpression(this.$node(this.classExpr),this.$generics(),this.$args())}};k(zn,lt,Dn,Et);var Bn=class extends D{pattern;flags;constructor(e,t){super(),this.pattern=e,this.flags=t}$render(){let e=`/${(this.pattern.startsWith(`/`)&&this.pattern.endsWith(`/`)?this.pattern.slice(1,-1):this.pattern).replace(/(?<!\\)\//g,`\\/`)}/${this.flags??``}`;return l.factory.createRegularExpressionLiteral(e)}},Vn=class extends D{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 l.factory.createNoSubstitutionTemplateLiteral(t[0]);if(t.length===2&&typeof t[0]==`string`&&typeof t[1]!=`string`)return l.factory.createTemplateExpression(l.factory.createTemplateHead(t[0]),[l.factory.createTemplateSpan(t[1],l.factory.createTemplateTail(``))]);let n=l.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(l.factory.createTemplateSpan(e,i?l.factory.createTemplateTail(n):l.factory.createTemplateMiddle(n)))}return l.factory.createTemplateExpression(n,r)}},Hn=class extends D{_condition;_then;_else;constructor(e){super(),e&&this.condition(e)}condition(e){return this._condition=e,this}do(e){return this._then=e,this}otherwise(e){return this._else=e,this}$render(){if(!this._condition)throw Error(`Missing condition in ternary`);if(!this._then)throw Error(`Missing then expression in ternary`);if(!this._else)throw Error(`Missing else expression in ternary`);return l.factory.createConditionalExpression(this.$node(this._condition),void 0,this.$node(this._then),void 0,this.$node(this._else))}},Un=class extends D{_expr;constructor(e){super(),this._expr=e}$render(){return l.factory.createTypeOfExpression(this.$node(this._expr))}};k(Un,kn),Mt((...e)=>new Un(...e));var Wn=class extends D{_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===``);return t.length&&l.addSyntheticLeadingComment(e,l.SyntaxKind.MultiLineCommentTrivia,`\n${t.join(`
3
- `)}\n`,!0),e}$render(){return this.$node(new st(``))}},Gn=class extends D{_condition;_else;constructor(e){super(),e&&this.condition(e)}condition(e){return this._condition=e,this}otherwise(...e){return this._else=e,this}$render(){if(!this._condition)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._condition),n=e.length===1?e[0]:l.factory.createBlock(e,!0),r=l.isBlock(n)?n:l.factory.createBlock([n],!0),i;if(this._else){let e=this.$node(this._else),t=e.length===1?e[0]:l.factory.createBlock(e,!0);i=l.isBlock(t)?t:l.factory.createBlock([t],!0)}return l.factory.createIfStatement(t,r,i)}};k(Gn,Vt);var Kn=class extends D{_returnExpr;constructor(e){super(),this._returnExpr=e}$render(){return l.factory.createReturnStatement(this.$node(this._returnExpr))}};k(Kn,Dn),En((...e)=>new Kn(...e));var qn=class extends D{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`?new P(e).$render():e);if(this.useNew)return l.factory.createThrowStatement(l.factory.createNewExpression(e,void 0,t));let n=t.length?[l.factory.createCallExpression(e,void 0,t)]:[e];return l.factory.createThrowStatement(n[0])}},Jn=class extends D{kind=l.NodeFlags.None;modifiers=j(this);name;_type;constructor(e){super(),this.name=e}const(){return this.kind=l.NodeFlags.Const,this}let(){return this.kind=l.NodeFlags.Let,this}type(e){return this._type=e instanceof O?e:new M(e),this}var(){return this.kind=l.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 l.factory.createVariableStatement(this.modifiers.list(),l.factory.createVariableDeclarationList([l.factory.createVariableDeclaration(e,void 0,this.$type(this._type),this.$value())],this.kind))}};k(Jn,gt,A,_t,Fn,Wt,Tt);var Yn=class extends D{value;modifiers=j(this);name;constructor(e,t){super(),this.name=e,t?.(this)}type(e){return this.value=e,this}$render(){if(!this.value)throw Error(`Type alias '${this.name}' is missing a type definition`);return l.factory.createTypeAliasDeclaration(this.modifiers.list(),this.name,this.$generics(),this.$type(this.value))}};k(Yn,A,_t,wt);var Xn=class extends O{_types=[];constructor(...e){super(),this.types(...e)}types(...e){return this._types.push(...e),this}$render(){let e=[];for(let t of this._types){let n=this.$type(t);l.isIntersectionTypeNode(n)?e.push(...n.types):e.push(n)}return l.factory.createIntersectionTypeNode(e)}},Zn=class extends O{value;constructor(e){super(),this.value=e}$render(){return l.factory.createLiteralTypeNode(this.$node(new P(this.value)))}},Qn=class extends O{modifiers=j(this);_key;_name;_type;constructor(e,t){super(),this._name=e,t?.(this)}get isValid(){return this.missingRequiredCalls().length===0}key(e){return this._key=e,this}type(e){return this._type=e,this}$render(){return this.$validate(),l.factory.createIndexSignature(this.modifiers.list(),[l.factory.createParameterDeclaration(void 0,void 0,this._name,void 0,this.$type(this._key))],this.$type(this._type))}$validate(){let e=this.missingRequiredCalls();if(e.length!==0)throw Error(`Index signature${this._name?` "${this._name}"`:``} missing ${e.join(` and `)}`)}missingRequiredCalls(){let e=[];return this._key||e.push(`.key()`),this._name||e.push(`.name()`),this._type||e.push(`.​type()`),e}};k(Qn,A,xt);var $n=class extends O{modifiers=j(this);name;_type;constructor(e,t){super(),this.name=e,t(this)}type(e){return this._type=e,this}$render(){if(!this._type)throw Error(`Type not specified for property '${this.name}'`);return l.factory.createPropertySignature(this.modifiers.list(),un(this.name),this._optional?this.$node(new N().optional()):void 0,this.$type(this._type))}};k($n,A,Ht,xt);var er=class extends O{props=[];hasProps(){return this.props.length>0}idxSig(e,t){let n=new Qn(e,t);return this.props.push(n),this}get isEmpty(){return!this.props.length}prop(e,t){let n=new $n(e,t);return this.props.push(n),this}$render(){return l.factory.createTypeLiteralNode(this.$node(this.props))}},tr=class extends O{_elements=[];constructor(...e){super(),this.elements(...e)}elements(...e){return this._elements.push(...e),this}$render(){return l.factory.createTupleTypeNode(this._elements.map(e=>this.$type(e)))}};const nr=e=>{if(e instanceof D)return e;if(e===null||typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return new Zn(e);if(e instanceof Array)return new tr(...e.map(e=>nr(e)));if(typeof e==`object`){let t=new er;for(let[n,r]of Object.entries(e)){let e=nr(r);t.prop(n,t=>t.type(e))}return t}throw Error(`$.type.fromValue(): Unsupported input type ${String(e)}`)};var rr=class extends O{_returns;returns(e){return this._returns=e instanceof O?e:new M(e),this}$render(){if(this._returns===void 0)throw Error(`Missing return type in function type DSL`);return l.factory.createFunctionTypeNode(this.$generics(),this.$params(),this.$type(this._returns))}};k(rr,A,Kt,wt);var ir=class extends O{_base;_index;constructor(e,t){super(),this._base=e,this._index=t}base(e){return this._base=e,this}index(e){return this._index=e,this}$render(){return l.factory.createIndexedAccessTypeNode(this.$type(this._base),this.$type(this._index))}};k(ir,Lt),At((...e)=>new ir(...e));var ar=class extends O{questionToken;readonlyToken;_key;_name;_type;constructor(e){super(),this.name(e)}get isValid(){return this.missingRequiredCalls().length===0}key(e){return this._key=e,this}mutable(){return this.readonlyToken=new N().minus(),this}name(e){return this._name=e,this}optional(){return this.questionToken=new N().optional(),this}readonly(){return this.readonlyToken=new N().readonly(),this}required(){return this.questionToken=new N().minus(),this}type(e){return this._type=e,this}$render(){return this.$validate(),l.factory.createMappedTypeNode(this.$node(this.readonlyToken),l.factory.createTypeParameterDeclaration(void 0,this._name,this.$type(this._key),void 0),void 0,this.$node(this.questionToken),this.$type(this._type),void 0)}$validate(){let e=this.missingRequiredCalls();if(e.length!==0)throw Error(`Mapped type${this._name?` "${this._name}"`:``} missing ${e.join(` and `)}`)}missingRequiredCalls(){let e=[];return this._key||e.push(`.key()`),this._name||e.push(`.name()`),this._type||e.push(`.​type()`),e}},or=class extends O{_op;_type;keyof(e){return this.operator(l.SyntaxKind.KeyOfKeyword),this.type(e),this}operator(e){return this._op=e,this}readonly(e){return this.operator(l.SyntaxKind.ReadonlyKeyword),this.type(e),this}type(e){return this._type=e,this}unique(e){return this.operator(l.SyntaxKind.UniqueKeyword),this.type(e),this}$render(){return this.$validate(),l.factory.createTypeOperatorNode(this._op,this.$type(this._type))}$validate(){let e=this.missingRequiredCalls();if(e.length!==0)throw Error(`Type operator missing ${e.join(` and `)}`)}missingRequiredCalls(){let e=[];return this._op||e.push(`.operator()`),this._type||e.push(`.​type()`),e}};Pt((...e)=>new or(...e));var sr=class extends O{_types=[];constructor(...e){super(),this.types(...e)}types(...e){return this._types.push(...e),this}$render(){let e=[];for(let t of this._types){let n=this.$type(t);l.isUnionTypeNode(n)?e.push(...n.types):e.push(n)}return l.factory.createUnionTypeNode(e)}},cr=class extends O{_expr;constructor(e){super(),this._expr=e}$render(){let e=this.$node(this._expr);return l.factory.createTypeQueryNode(e)}};k(cr,Lt),It((...e)=>new cr(...e));var lr=class extends O{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 l.factory.createTemplateLiteralType(l.factory.createTemplateHead(t[0]),[]);if(t.length===2&&typeof t[0]==`string`&&typeof t[1]!=`string`)return l.factory.createTemplateLiteralType(l.factory.createTemplateHead(t[0]),[l.factory.createTemplateLiteralTypeSpan(t[1],l.factory.createTemplateTail(``))]);let n=l.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(l.factory.createTemplateLiteralTypeSpan(e,i?l.factory.createTemplateTail(n):l.factory.createTemplateMiddle(n)))}return l.factory.createTemplateLiteralType(n,r)}};const ur={array:(...e)=>new vn(...e),as:(...e)=>new On(...e),attr:(...e)=>new An(...e),await:(...e)=>new jn(...e),binary:(...e)=>new F(...e),call:(...e)=>new Mn(...e),class:(...e)=>new Yt(...e),const:(...e)=>new Jn(...e).const(),decorator:(...e)=>new ut(...e),doc:(...e)=>new ft(...e),enum:(...e)=>new fn(...e),expr:(...e)=>new Nn(...e),field:(...e)=>new zt(...e),fromValue:(...e)=>Rn(...e),func:((e,t)=>e===void 0?new mn:typeof e!=`string`||t===void 0?new mn(e):new mn(e,t)),getter:(...e)=>new hn(...e),hint:(...e)=>new Pn(...e),id:(...e)=>new st(...e),if:(...e)=>new Gn(...e),init:(...e)=>new qt(...e),let:(...e)=>new Jn(...e).let(),literal:(...e)=>new P(...e),member:(...e)=>new dn(...e),method:(...e)=>new Jt(...e),neg:(...e)=>new an(...e).neg(),new:(...e)=>new zn(...e),newline:(...e)=>new ct(...e),not:(...e)=>new an(...e).not(),note:(...e)=>new Wn(...e),object:(...e)=>new Ln(...e),param:(...e)=>new Gt(...e),pattern:(...e)=>new Ut(...e),prefix:(...e)=>new an(...e),prop:(...e)=>new In(...e),regexp:(...e)=>new Bn(...e),return:(...e)=>new Kn(...e),setter:(...e)=>new gn(...e),stmt:(...e)=>new Bt(...e),template:(...e)=>new Vn(...e),ternary:(...e)=>new Hn(...e),throw:(...e)=>new qn(...e),token:(...e)=>new N(...e),type:Object.assign((...e)=>new M(...e),{alias:(...e)=>new Yn(...e),and:(...e)=>new Xn(...e),attr:(...e)=>new Rt(...e),expr:(...e)=>new M(...e),fromValue:(...e)=>nr(...e),func:(...e)=>new rr(...e),idx:(...e)=>new ir(...e),literal:(...e)=>new Zn(...e),mapped:(...e)=>new ar(...e),object:(...e)=>new er(...e),operator:(...e)=>new or(...e),or:(...e)=>new sr(...e),param:(...e)=>new Ct(...e),query:(...e)=>new cr(...e),template:(...e)=>new lr(...e),tuple:(...e)=>new tr(...e)}),typeofExpr:(...e)=>new Un(...e),var:(...e)=>new Jn(...e)},I=Object.assign((...e)=>new Nn(...e),ur),dr=({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},fr=({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}},pr=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return[];let n=[];for(let t of e.security){let e=fr({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},mr=`TComposable`,hr=`DefaultT`,gr=`ResT`,_r=/~1/g,vr=/~0/g,L=e=>{let t=br(e),n=t[t.length-1];return decodeURI(n)},yr=e=>String(e).replace(/~/g,`~0`).replace(/\//g,`~1`),br=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(_r,`/`).replace(vr,`~`)):[]},xr=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},Sr=e=>{let t=e.map(yr).join(`/`);return`#`+(t?`/${t}`:``)},Cr=({$ref:e,spec:t})=>{let n=br(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},wr=({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(y({case:`camelCase`,value:L(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=y({case:`camelCase`,value:L(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}},Tr=({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})},Er=({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})},Dr=({context:e,value:t})=>{let n=y({case:`PascalCase`,value:at(t)});return dr({config:e.config,name:n})},Or=({operation:e,plugin:t})=>t.config.methodNameBuilder?t.config.methodNameBuilder(e):!t.config.asClass&&e.id.match(en)?`${e.id}_`:e.id,kr=({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=y({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=Dr({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||Or({operation:t,plugin:n}),path:l.map(t=>Dr({context:e,value:t}))})}return r},Ar=({isDataAllowed:e=!0,operation:t,plugin:n,throwOnError:r})=>{let i=w(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}<${mr}, ${i}, ${s}, ${hr}>`}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},jr=({isRequiredOptions:e,operation:t,plugin:n})=>{let r={argNames:[],fields:[],parameters:[]},i=n.getPluginOrThrow(`@hey-api/typescript`),a=w(n.context.config).name===`@hey-api/client-nuxt`;if(n.config.paramsStructure===`flat`){let e=wr({operation:t,plugin:n}),a=I.type.object();if(e){let t=!1;for(let n in e.parameters){let r=e.parameters[n];r.isRequired&&(t=!0),a.prop(r.name,e=>e.required(r.isRequired).type(i.api.schemaToType({plugin:i,schema:r.schema,state:E({path:[]})})))}r.argNames.push(`parameters`);for(let t of e.fields)r.fields.push(t);r.parameters.push(I.param(`parameters`,e=>e.required(t).type(a)))}}return r.parameters.push(I.param(`options`,r=>r.required(e).type(Ar({isDataAllowed:n.config.paramsStructure===`grouped`,operation:t,plugin:n,throwOnError:a?void 0:`ThrowOnError`})))),r},Mr=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`}},Nr=({isRequiredOptions:e,opParameters:t,operation:n,plugin:r})=>{let i=w(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=I.object();if(n.body)switch(n.body.type){case`form-data`:{let e=r.referenceSymbol({category:`external`,resource:`client.formDataBodySerializer`});c.spread(e.placeholder);break}case`json`:break;case`text`:case`octet-stream`:c.prop(`bodySerializer`,I.literal(null));break;case`url-search-params`:{let e=r.referenceSymbol({category:`external`,resource:`client.urlSearchParamsBodySerializer`});c.spread(e.placeholder);break}}let l=I.object();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.prop(t.name,I.object().prop(`array`,I.object().$if(t.explode===!1,e=>e.prop(`explode`,I.literal(t.explode))).$if(t.style!==`form`,e=>e.prop(`style`,I.literal(t.style))))):t.schema.type===`object`&&(t.style!==`deepObject`||!t.explode)&&l.prop(t.name,I.object().prop(`object`,I.object().$if(t.explode===!1,e=>e.prop(`explode`,I.literal(t.explode))).$if(t.style!==`deepObject`,e=>e.prop(`style`,I.literal(t.style)))))}l.hasProps()&&c.prop(`querySerializer`,I.object().prop(`parameters`,l));let u=Tr({operation:n,plugin:r}),d=Er({operation:n,plugin:r});if(u&&c.prop(`requestValidator`,u.arrow()),r.config.transformer){let e={category:`transform`,resource:`operation`,resourceId:n.id,role:`response`};if(r.isSymbolRegistered(e)){let t=r.referenceSymbol(e);c.prop(`responseTransformer`,I(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=Mr(t.mediaType),p&&c.prop(`responseType`,I.literal(p))),t.mediaType===`text/event-stream`&&(f=!0)}d&&c.prop(`responseValidator`,d.arrow()),r.config.responseStyle===`data`&&c.prop(`responseStyle`,I.literal(r.config.responseStyle));let m=pr({context:r.context,operation:n,plugin:r});m.length&&c.prop(`security`,I.fromValue(m)),c.prop(`url`,I.literal(n.path)),c.spread(`options`);let h=[],g=t.argNames.length;if(g){let e=[],n=[];for(let n of t.argNames)e.push(I(n));for(let e of t.fields){let t=I.object();`in`in e&&t.prop(`in`,I.literal(e.in)),`key`in e&&(e.key&&t.prop(`key`,I.literal(e.key)),e.map&&t.prop(`map`,I.literal(e.map))),n.push(t)}let i=r.referenceSymbol({category:`external`,resource:`client.buildClientParams`});h.push(I.const(`params`).assign(I(i.placeholder).call(I.array(...e),I.array(I.object().prop(`args`,I.array(...n)))))),c.spread(`params`)}if(n.body){let t=n.parameters?.header?.[`content-type`];if(!t?.required){let r=I.object().pretty().prop(t?.name??`Content-Type`,I.literal(n.body.type===`form-data`?null:n.body.mediaType)).spread(I(`options`).attr(`headers`).required(e));g&&r.spread(I(`params`).attr(`headers`)),c.prop(`headers`,r)}}let ee=r.config.client?r.getSymbol({category:`client`}):void 0,te,ne=I(`options`).attr(`client`).required(e);te=r.config.instance?ne.coalesce(I(`this`).attr(`client`)):ee?ne.coalesce(ee.placeholder):ne;let re=f?te.attr(`sse`):te;return re=re.attr(n.method),h.push(I.return(re.call(c).$if(a,e=>e.generic(mr).generic(`${o} | ${hr}`).generic(s).generic(hr),e=>e.generic(o).generic(s).generic(`ThrowOnError`)).$if(r.config.responseStyle===`data`,e=>e.generic(I.type.literal(r.config.responseStyle))))),h},Pr=e=>e.replace(/\*\//g,`*`).replace(/\/\*/g,`*`).replace(/\r?\n(.*)/g,(e,t)=>u+t.trim()),R=e=>{let t=[];return e.summary&&t.push(Pr(e.summary)),e.description&&(t.length&&t.push(``),t.push(Pr(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Fr=({context:e,operation:t})=>{let n=w(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)},Ir=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType===`text/event-stream`)return!0;return!1},Lr=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=Fr({context:e.context,operation:n}),a=kr({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(I.newline(),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(I.field(y({case:`camelCase`,value:a.className})).assign(I.new(b({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name: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:b({config:{case:`preserve`,name:e.config.httpRequests.classNameBuilder},name:r.className})}),s=I.class(o.placeholder).export(o.exported).$if(r.root,e=>e.decorator(a.placeholder,I.object().prop(`providedIn`,I.literal(`root`)))).do(...r.nodes);e.setSymbolValue(o,s),n.add(r.className)};for(let e of t.values())i(e)},Rr=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let n=Fr({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=Vr({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},zr=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`client`});return I(`options`).attr(`client`).optional().$if(n,(e,t)=>e.coalesce(t.placeholder)).attr(`requestOptions`).call(I.object().prop(`responseStyle`,I.literal(`data`)).prop(`method`,I.literal(e.method.toUpperCase())).prop(`url`,I.literal(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 I.method(t).public().$if(R(n),(e,t)=>e.doc(t)).param(`options`,t=>t.required(e).type(`${a.placeholder}<${o}, ThrowOnError>`)).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(!1)).returns(`${i.placeholder}<unknown>`).do(I.return(zr({operation:n,plugin:r})))},Vr=({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 I.const(r.placeholder).export(r.exported).$if(R(t),(e,t)=>e.doc(t)).assign(I.func().param(`options`,t=>t.required(e).type(`${a.placeholder}<${o}, ThrowOnError>`)).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(!1)).returns(`${i.placeholder}<unknown>`).do(I.return(zr({operation:t,plugin:n}))))},Hr=({plugin:e})=>{e.config.httpRequests.asClass?Lr({plugin:e}):Rr({plugin:e})},Ur=({plugin:e})=>{let t=new Map,n=new Set,r=e.getPluginOrThrow(`@hey-api/sdk`);e.forEach(`operation`,({operation:n})=>{let i=Fr({context:e.context,operation:n}),a=kr({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=Kr({isRequiredOptions:i,methodName:l,operation:n,plugin:e});c.nodes.length?c.nodes.push(I.newline(),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(I.field(y({case:`camelCase`,value:a.className})).assign(I.new(b({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:a.className}))))}let a=e.referenceSymbol({category:`external`,resource:`@angular/core.Injectable`}),o=e.registerSymbol({exported:!0,name:b({config:{case:`preserve`,name:e.config.httpResources.classNameBuilder},name:r.className})}),s=I.class(o.placeholder).export(o.exported).$if(r.root,e=>e.decorator(a.placeholder,I.object().prop(`providedIn`,I.literal(`root`)))).do(...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=Fr({context:e.context,operation:t}),r=e.registerSymbol({exported:!0,name:e.config.httpResources.methodNameBuilder(t)}),i=qr({isRequiredOptions:n,operation:t,plugin:e,symbol:r});e.setSymbolValue(r,i)},{order:`declarations`})},Gr=({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=kr({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=I(t.referenceSymbol({category:`external`,resource:`@angular/core.inject`}).placeholder).call(a.placeholder);for(let e=1;e<o.path.length;e++){let t=o.path[e];t&&(s=s.attr(y({case:`camelCase`,value:t})))}return s=s.attr(t.config.httpRequests.methodNameBuilder(e)),I(r.placeholder).call(I.func().do(I.const(`opts`).assign(I.ternary(`options`).do(I(`options`).call()).otherwise(I.id(`undefined`))),I.return(I.ternary(`opts`).do(s.call(`opts`)).otherwise(I.id(`undefined`))))).generic(i)}}else{let n=t.referenceSymbol({category:`utility`,resource:`operation`,resourceId:e.id,role:`data`,tool:`angular`});return I(r.placeholder).call(I.func().do(I.const(`opts`).assign(I.ternary(`options`).do(I(`options`).call()).otherwise(I.id(`undefined`))),I.return(I.ternary(`opts`).do(I(n.placeholder).call(`opts`)).otherwise(I.id(`undefined`))))).generic(i)}return I(r.placeholder).call(I.func().do(I.return(I.id(`undefined`))).generic(i))},Kr=({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 I.method(t).public().$if(R(n),(e,t)=>e.doc(t)).param(`options`,t=>t.required(e).type(`() => ${i.placeholder}<${a}, ThrowOnError> | undefined`)).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(!1)).do(I.return(Gr({operation:n,plugin:r})))},qr=({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 I.const(r.placeholder).export(r.exported).$if(R(t),(e,t)=>e.doc(t)).assign(I.func().param(`options`,t=>t.required(e).type(`() => ${i.placeholder}<${a}, ThrowOnError> | undefined`)).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(!1)).do(I.return(Gr({operation:t,plugin:n}))))},Jr=({plugin:e})=>{e.config.httpResources.asClass?Ur({plugin:e}):Wr({plugin:e})},Yr={config:{exportFromIndex:!1},dependencies:[`@hey-api/client-angular`,`@hey-api/sdk`],handler:({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&&Hr({plugin:e}),e.config.httpResources.enabled&&Jr({plugin:e})},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`}}},Xr={baseUrl:!0,bundle:!0,exportFromIndex:!1},Zr={dependencies:[`@hey-api/typescript`],tags:[`client`]},Qr=c(import.meta.url),$r=s.dirname(Qr),ei=e=>{let t=w(e);if(`bundle`in t.config&&t.config.bundle){let t=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return s.resolve(e.output.path,`client`,`${t?.get(`index`)??`index`}.ts`)}return t.name},ti=(e,t)=>{if(o.statSync(e).isDirectory()){o.existsSync(t)||o.mkdirSync(t,{recursive:!0});let n=o.readdirSync(e);for(let r of n)ti(s.join(e,r),s.join(t,r))}else{let n=o.readFileSync(e);o.writeFileSync(t,n)}},ni=({filePath:e,project:t,renamed:n})=>{let r=s.extname(e),i=s.basename(e,r),a=t.fileName?.(i)||i;if(a!==i){let t=s.dirname(e);o.renameSync(e,s.resolve(t,`${a}${r}`)),n.set(i,a)}},ri=({filePath:e,meta:t,renamed:n})=>{let r=o.readFileSync(e,`utf8`);r=r.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g,(e,r)=>{let i=e.indexOf(r),a=s.extname(r),o=s.basename(r,a),c=s.dirname(r),l=(n.get(o)??o)+(t.importFileExtension?t.importFileExtension:a);return e.slice(0,i)+[c,l].filter(Boolean).join(`/`)+e.slice(i+r.length)}),r=`// This file is auto-generated by @hey-api/openapi-ts
4
-
5
- ${r}`,o.writeFileSync(e,r,`utf8`)},ii=({meta:e,outputPath:t,plugin:n,project:r})=>{let i=new Map;if(n.name.startsWith(`@hey-api/client-`)){let a=s.resolve(t,`core`);ae(a),ti(s.resolve($r,`clients`,`core`),a);let c=s.resolve(t,`client`);ae(c);let l=n.name.slice(16);if(ti(s.resolve($r,`clients`,l),c),r){let e=o.readdirSync(a);for(let t of e)ni({filePath:s.resolve(a,t),project:r,renamed:i});let t=o.readdirSync(c);for(let e of t)ni({filePath:s.resolve(c,e),project:r,renamed:i})}let u=o.readdirSync(a);for(let t of u)ri({filePath:s.resolve(a,t),meta:e,renamed:i});let d=o.readdirSync(c);for(let t of d)ri({filePath:s.resolve(c,t),meta:e,renamed:i});return i}let a=s.isAbsolute(n.name)?s.dirname(n.name):void 0;if(a){let e=s.resolve(t,`client`);ae(e),ti(a,e);return}let c=s.normalize(h.resolve(n.name)).split(s.sep),l=c.slice(0,c.indexOf(`dist`)+1).join(s.sep),u=[c[c.length-1],`index.d.mts`,`index.d.cts`],d=s.resolve(t,`client`);ae(d);for(let e of u)o.copyFileSync(s.resolve(l,e),s.resolve(d,e))},ai=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,oi=e=>{let t={host:``,path:``,port:``,protocol:``};ai.lastIndex=0;let n=e.match(ai);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}},si=({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},ci=({plugin:e})=>{let t=ei(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=I.object(),c=si({plugin:e});if(c){let t=oi(c);if(t.protocol&&t.host&&!c.includes(`{`))s.prop(ot(e.context.config),I.literal(c));else if(c!==`/`&&c.startsWith(`/`)){let t=c.endsWith(`/`)?c.slice(0,-1):c;s.prop(ot(e.context.config),I.literal(t))}}`throwOnError`in e.config&&e.config.throwOnError&&s.prop(`throwOnError`,I.literal(!0));let l=[I(r.placeholder).call(s.hasProps()?s:void 0).generic(i.placeholder)],u=e.registerSymbol({exported:!0,meta:{category:`client`},name:`client`}),d=I.const(u.placeholder).export(u.exported).assign(I(n.placeholder).$if(o,(e,t)=>e.call(I(t.placeholder).call(...l)),e=>e.call(...l)));e.setSymbolValue(u,d)},li=({plugin:e})=>{let t=ei(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=I.type.alias(a.placeholder).export(a.exported).doc(["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.`]).generic(`T`,e=>e.extends(i.placeholder).default(n.placeholder)).type(I.type.func().param(`override`,e=>e.optional().type(I.type(r.placeholder).generic(I.type.and(i.placeholder,`T`)))).returns(I.type(r.placeholder).generic(I.type.and(I.type(`Required`).generic(i.placeholder),`T`))));e.setSymbolValue(a,o)},ui=({plugin:e})=>{li({plugin:e}),ci({plugin:e})},di={...Zr,config:{...Xr,throwOnError:!1},handler:ui,name:`@hey-api/client-angular`},fi={...Zr,config:{...Xr,throwOnError:!1},handler:ui,name:`@hey-api/client-axios`},pi={...Zr,config:{...Xr,throwOnError:!1},handler:ui,name:`@hey-api/client-fetch`},mi={...Zr,config:{...Xr,throwOnError:!1},handler:ui,name:`@hey-api/client-ky`},hi={...Zr,config:{...Xr,throwOnError:!1},handler:ui,name:`@hey-api/client-next`},gi={...Zr,config:Xr,handler:ui,name:`@hey-api/client-nuxt`},_i={...Zr,config:{...Xr,throwOnError:!1},handler:ui,name:`@hey-api/client-ofetch`},vi=(...e)=>d.satisfies(...e),yi=e=>({getVersion:t=>{let n=e[t];if(n)try{let e=d.parse(n);if(e)return e;let t=d.minVersion(n);if(t)return t;if(e=d.coerce(n),e)return e}catch{}},isInstalled:t=>!!e[t],satisfies:(t,n,r)=>{let i=typeof t==`string`?e[t]:t;return i?vi(i,n,r):!1}}),bi=[en,nn,$t,tn,Qt],xi=e=>{let t=e.replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`_`);if(Xt.lastIndex=0,Xt.test(t))return`_${t}`;for(let e of bi){if(t.startsWith(`_`))return t;t=t.replace(e,`_$1`)}return t},Si=({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)},Ci=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Ci({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(r.$ref)return r.$ref=decodeURI(r.$ref),r;if(Si({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Ci({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Ci({context:e,plugin:t,schema:n})),r.items&&=Ci({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]=Ci({context:e,plugin:t,schema:i}))}return r},wi=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>wi({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(`$ref`in r)return r.$ref=decodeURI(r.$ref),r;if(Si({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=wi({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>wi({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>wi({context:e,plugin:t,schema:n})),r.items&&=wi({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>wi({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]=wi({context:e,plugin:t,schema:i}))}return r},Ti=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Ti({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(Si({plugin:t,schema:r}),r.$ref&&=decodeURI(r.$ref),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Ti({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Ti({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>Ti({context:e,plugin:t,schema:n})),r.items&&=Ti({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>Ti({context:e,plugin:t,schema:n})),r.prefixItems&&=r.prefixItems.map(n=>Ti({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]=Ti({context:e,plugin:t,schema:i}))}return r},Ei=({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`,xi(r)},Di=({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:Ei({name:n,plugin:t,schema:r})}),a=Ci({context:e,plugin:t,schema:r}),o=I.const(i.placeholder).export(i.exported).assign(I(I.fromValue(a,{layout:`pretty`})).as(`const`));t.setSymbolValue(i,o)}},Oi=({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:Ei({name:n,plugin:t,schema:r})}),a=wi({context:e,plugin:t,schema:r}),o=I.const(i.placeholder).export(i.exported).assign(I(I.fromValue(a,{layout:`pretty`})).as(`const`));t.setSymbolValue(i,o)}},ki=({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:Ei({name:n,plugin:t,schema:r})}),a=Ti({context:e,plugin:t,schema:r}),o=I.const(i.placeholder).export(i.exported).assign(I(I.fromValue(a,{layout:`pretty`})).as(`const`));t.setSymbolValue(i,o)}},Ai={config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:({plugin:e})=>{if(`swagger`in e.context.spec){Di({context:e.context,plugin:e});return}if(vi(e.context.spec.openapi,`>=3.0.0 <3.1.0`)){Oi({context:e.context,plugin:e});return}if(vi(e.context.spec.openapi,`>=3.1.0`)){ki({context:e.context,plugin:e});return}throw Error(`Unsupported OpenAPI specification`)},name:`@hey-api/schemas`},ji=`__registry`,Mi=({sdkName:e,symbol:t})=>{let n=`defaultKey`,r=`instances`;return I.class(t.placeholder).export(t.exported).generic(`T`).field(n,e=>e.private().readonly().assign(I.literal(`default`))).newline().field(r,e=>e.private().readonly().type(I.type(`Map`).generics(`string`,`T`)).assign(I.new(`Map`))).newline().method(`get`,t=>t.returns(`T`).param(`key`,e=>e.type(`string`).optional()).do(I.const(`instance`).assign(I(`this`).attr(`instances`).attr(`get`).call(I(`key`).coalesce(I(`this`).attr(n)))),I.if(I.not(`instance`)).do(I.throw(`Error`).message(I.template(`No SDK client found. Create one with "new `).add(e).add(`()" to fix this error.`))),I.return(`instance`))).newline().method(`set`,e=>e.returns(`void`).param(`value`,e=>e.type(`T`)).param(`key`,e=>e.type(`string`).optional()).do(I(`this`).attr(r).attr(`set`).call(I(`key`).coalesce(I(`this`).attr(n)),`value`)))},Ni=({plugin:e,symbol:t})=>{let n=e.getSymbol({category:`client`}),r=!!(e.config.client&&n),i=e.referenceSymbol({category:`external`,resource:`client.Client`});return I.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(I.type.object().prop(`client`,e=>e.optional(r).type(i.placeholder)))).do(I(`this`).attr(`client`).assign(I(`args`).attr(`client`).optional(r).$if(r,e=>e.coalesce(n.placeholder)))))},Pi=({plugin:e})=>{let t=w(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=Fr({context:e.context,operation:a}),s=r?e.querySymbol({category:`type`,resource:`operation`,resourceId:a.id,role:`response`}):void 0,c=kr({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=jr({isRequiredOptions:o,operation:a,plugin:e}),h=Nr({isRequiredOptions:o,opParameters:m,operation:a,plugin:e}),g=I.method(l.methodName,i=>i.$if(R(a),(e,t)=>e.doc(t)).public().static(!n&&!e.config.instance).$if(r,t=>t.generic(mr,t=>t.extends(e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder).default(I.type.literal(`$fetch`))).generic(hr,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(...m.parameters).do(...h));p.nodes.length?p.nodes.push(I.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=y({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)?I.field(o,t=>t.static(!e.config.instance).assign(e.config.instance?I.new(a.placeholder).args(I.object().prop(`client`,I(`this`).attr(`client`))):I(a.placeholder))):I.getter(o,t=>t.$if(!e.config.instance,e=>e.public().static()).do(I.return(e.config.instance?I.new(a.placeholder).args(I.object().prop(`client`,I(`this`).attr(`client`))):a.placeholder)));t.nodes.length?t.nodes.push(I.newline(),s):t.nodes.push(s)}if(o&&!e.gen.symbols.hasValue(o.id)){let t=Ni({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=I.init(e=>e.param(`args`,e=>e.required(r).type(I.type.object().prop(`client`,e=>e.required(r).type(i.placeholder)).prop(`key`,e=>e.optional().type(`string`)))).do(I(`super`).call(`args`),I(l.placeholder).attr(ji).attr(`set`).call(`this`,I(`args`).attr(`key`).required(r))));t.nodes.length?t.nodes.unshift(a,I.newline()):t.nodes.unshift(a);let o=Mi({plugin:e,sdkName:l.placeholder,symbol:s});e.setSymbolValue(s,o);let c=I.field(ji,e=>e.public().static().readonly().assign(I.new(s.placeholder).generic(l.placeholder)));t.nodes.unshift(c,I.newline())}let u=I.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,I.object().prop(`providedIn`,I.literal(`root`)))).do(...t.nodes);e.setSymbolValue(l,u)};for(let e of i.values())c(e)},Fi=({id:e,operation:t,plugin:n})=>n.config.methodNameBuilder?n.config.methodNameBuilder(t):e.match(en)?`${e}_`:e,Ii=({plugin:e})=>{let t=w(e.context.config),n=t.name===`@hey-api/client-nuxt`;e.forEach(`operation`,r=>{let{operation:i}=r,a=Fr({context:e.context,operation:i}),o=n?e.querySymbol({category:`type`,resource:`operation`,resourceId:i.id,role:`response`}):void 0,s=jr({isRequiredOptions:a,operation:i,plugin:e}),c=Nr({isRequiredOptions:a,opParameters:s,operation:i,plugin:e}),l=e.registerSymbol({exported:!0,meta:{category:`sdk`,path:r._path,resource:`operation`,resourceId:i.id,tags:r.tags,tool:`sdk`},name:Fi({id:i.id,operation:i,plugin:e})}),u=I.const(l.placeholder).export(l.exported).$if(R(i),(e,t)=>e.doc(t)).assign(I.func().params(...s.parameters).$if(n,t=>t.generic(mr,t=>t.extends(e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder).default(I.type.literal(`$fetch`))).generic(hr,e=>e.$if(o,(e,t)=>e.extends(t.placeholder).default(t.placeholder),e=>e.default(`undefined`))),e=>e.generic(`ThrowOnError`,e=>e.extends(`boolean`).default((`throwOnError`in t.config?t.config.throwOnError:!1)??!1))).do(...c));e.setSymbolValue(l,u)},{order:`declarations`})},Li=({plugin:e})=>{let t=ei(e.context.config),n=w(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=I.type.alias(s.placeholder).export(s.exported).$if(r,t=>t.generic(`TComposable`,t=>t.extends(e.referenceSymbol({category:`external`,resource:`client.Composable`}).placeholder).default(I.type.literal(`$fetch`))).generic(`TData`,e=>e.extends(i.placeholder).default(i.placeholder)).generic(gr,e=>e.default(`unknown`)).generic(hr,e=>e.default(`undefined`)),e=>e.generic(`TData`,e=>e.extends(i.placeholder).default(i.placeholder)).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(`boolean`))).type(I.type.and(I.type(o.placeholder).$if(r,e=>e.generic(`TComposable`).generic(`TData`).generic(gr).generic(hr),e=>e.generic(`TData`).generic(`ThrowOnError`)),I.type.object().prop(`client`,t=>t.doc(["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.`]).required(!e.config.client&&!e.config.instance).type(a.placeholder)).prop(`meta`,e=>e.doc(["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.`]).optional().type(I.type(`Record`).generics(`string`,`unknown`)))));e.setSymbolValue(s,c)},Ri=({plugin:e})=>{let t=ei(e.context.config),n=w(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`}),Li({plugin:e}),e.config.asClass?Pi({plugin:e}):Ii({plugin:e})},zi={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:e=>Ri(e),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`)}},Bi=({dataExpression:e,schema:t})=>{if(t.type!==`integer`||t.format!==`int64`)return;let n=e===void 0?void 0:I(`BigInt`).call(I.expr(e).attr(`toString`).call());if(n){if(typeof e==`string`)return[n];if(e)return[I.expr(e).assign(n)]}},Vi=({dataExpression:e,schema:t})=>{if(!(t.type!==`string`||!(t.format===`date`||t.format===`date-time`))){if(typeof e==`string`)return[I.new(`Date`).arg(e)];if(e)return[I.expr(e).assign(I.new(`Date`).arg(e))]}},Hi=`data`,Ui=new Set,Wi=e=>e.map(e=>I.stmt(e).$render()),Gi=({node:e})=>(e instanceof D&&(e=e.$render()),e.kind===l.SyntaxKind.ReturnStatement),Ki=({plugin:e,schema:t})=>{let n=qi({dataExpression:I(Hi),plugin:e,schema:t});if(n.length){let e=n[n.length-1];Gi({node:e})||n.push(I.return(Hi))}return n},qi=({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:b({config:{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`},name:L(n.$ref)})}),t.setSymbolValue(i,null)),!t.gen.symbols.getValue(i.id)&&!Ui.has(i.id)){Ui.add(i.id);try{let e=Ki({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(e.length){let n=I.const(i.placeholder).assign(I.func().param(Hi,e=>e.type(`any`)).do(...Wi(e)));t.setSymbolValue(i,n)}}finally{Ui.delete(i.id)}}if(t.gen.symbols.getValue(i.id)||Ui.has(i.id)){let n=I(t.referenceSymbol(r).placeholder).call(e);if(e)return typeof e==`string`&&e===`item`?[I.return(n)]:[typeof e==`string`?n:I(e).assign(n)]}return[]}if(n.type===`array`){if(!e||typeof e==`string`)return[];let r=n.items?qi({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=Wi(r);return i.some(e=>Gi({node:e}))||i.push(I.return(`item`)),[I(e).assign(I(e).attr(`map`).call(I.func().param(`item`,e=>e.type(`any`)).do(...i)))]}if(n.type===`object`){let r=[],i=n.required??[];for(let a in n.properties){let o=n.properties[a],s=I(e||Hi).attr(a),c=qi({dataExpression:s,plugin:t,schema:o});if(!c.length)continue;let l=!o.items?.find(e=>e.type===`null`);i.includes(a)&&l?r=r.concat(c):r.push(I.if(s).do(...Wi(c)))}return r}if(n.items){if(n.items.length===1)return qi({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=qi({dataExpression:e||`item`,plugin:t,schema:i});n.length&&(e?r=r.concat(n):r.push(I.if(`item`).do(...Wi(n)),I.return(`item`)))}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[]},Ji={config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:({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 ${C(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=Ki({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:b({config:{case:`camelCase`,name:`{{name}}ResponseTransformer`},name:t.id})}),o=I.const(a.placeholder).export(a.exported).assign(I.func().async().param(Hi,e=>e.type(`any`)).returns(I.type(`Promise`).generic(r.placeholder)).do(...Wi(i)));e.setSymbolValue(a,o)},{order:`declarations`})},name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,Vi]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,Bi])},tags:[`transformer`]},Yi=({server:e})=>{let t=oi(e.url);return t.protocol&&t.host?I.type.literal(e.url):I.type.template().add(t.protocol||I.type(`string`)).add(`://`).add(t.host||I.type(`string`)).add(t.port?`:${t.port}`:``).add(t.path||``)},Xi=({plugin:e,servers:t,symbolClientOptions:n})=>{let r=w(e.context.config),i=t.map(e=>Yi({server:e}));t.length?`strictBaseUrl`in r.config&&r.config.strictBaseUrl||i.push(I.type.and(I.type(`string`),I.type.object())):i.push(I.type(`string`));let a=I.type.alias(n.placeholder).export(n.exported).type(I.type.object().prop(ot(e.context.config),e=>e.type(I.type.or(...i))));e.setSymbolValue(n,a)},z=e=>{let t=[];return e.title&&t.push(Pr(e.title)),e.description&&(t.length&&t.push(``),t.push(Pr(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Zi=({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=y({case:e.config.enums.case,stripLeadingSeparators:!1,value:a}),Zt.lastIndex=0,Zt.test(a)&&e.config.enums.enabled&&(e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&(a=`_${a}`)),{key:a,schema:t}}),typeofItems:n}},Qi=({plugin:e,schema:t,symbol:n,type:r})=>{if(t.type===`enum`&&e.config.enums.enabled){let r=Zi({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.schema.const!==null));let i=I.const(n.placeholder).export().$if(z(t),(e,t)=>e.doc(t)).assign(I.object(...r.obj.map(e=>I.prop({kind:`prop`,name:e.key}).$if(z(e.schema),(e,t)=>e.doc(t)).value(I.fromValue(e.schema.const)))).as(`const`)),a=I.type.alias(n.placeholder).export().$if(z(t),(e,t)=>e.doc(t)).type(I.type(n.placeholder).idx(I.type(n.placeholder).typeof().keyof()).typeof());e.setSymbolValue(n,[i,a]);return}else if((e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&!r.typeofItems.some(e=>e!==`number`&&e!==`string`)){let i=I.enum(n.placeholder).export().$if(z(t),(e,t)=>e.doc(t)).const(e.config.enums.mode===`typescript-const`).members(...r.obj.map(e=>I.member(e.key).$if(z(e.schema),(e,t)=>e.doc(t)).value(I.fromValue(e.schema.const))));e.setSymbolValue(n,i);return}}let i=I.type.alias(n.placeholder).export(n.exported).$if(z(t),(e,t)=>e.doc(t)).type(r);e.setSymbolValue(n,i)},$i=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=x({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},ea=({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=$i({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=$i({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=$i({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:b({config:t.config.requests,name:e.id})}),o=I.type.alias(a.placeholder).export(a.exported).type(B({plugin:t,schema:r,state:n}));t.setSymbolValue(a,o)},ta=({operation:e,plugin:t,state:n})=>{ea({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:b({config:t.config.errors,name:e.id})}),o=I.type.alias(a.placeholder).export(a.exported).type(B({plugin:t,schema:i,state:n}));if(t.setSymbolValue(a,o),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:b({config:{case:t.config.errors.case,name:t.config.errors.error},name:e.id})}),i=I.type.alias(r.placeholder).export(r.exported).type(I.type(a.placeholder).idx(I.type(a.placeholder).keyof()));t.setSymbolValue(r,i)}}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:b({config:t.config.responses,name:e.id})}),i=I.type.alias(r.placeholder).export(r.exported).type(B({plugin:t,schema:o,state:n}));if(t.setSymbolValue(r,i),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:b({config:{case:t.config.responses.case,name:t.config.responses.response},name:e.id})}),a=I.type.alias(i.placeholder).export(i.exported).type(I.type(r.placeholder).idx(I.type(r.placeholder).keyof()));t.setSymbolValue(i,a)}}},na=({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:b({config:{case:t.config.webhooks.case,name:t.config.webhooks.payload},name:e.id})}),o=I.type.alias(a.placeholder).export(a.exported).$if(z(e.body.schema),(e,t)=>e.doc(t)).type(B({plugin:t,schema:e.body.schema,state:n}));t.setSymbolValue(a,o),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:b({config:t.config.webhooks,name:e.id})}),o=I.type.alias(a.placeholder).export(a.exported).type(B({plugin:t,schema:r,state:n}));return t.setSymbolValue(a,o),a.placeholder},ra=({operation:e,plugin:t,state:n})=>na({operation:e,plugin:t,state:n}),ia=({plugin:e,symbolWebhooks:t,webhookNames:n})=>{if(!n.length)return;let r=I.type.alias(t.placeholder).export(t.exported).type(I.type.or(...n));e.setSymbolValue(t,r)},aa=({plugin:e,schema:t,state:n})=>{if(!t.items)return I.type(`Array`).generic(I.type(e.config.topType));t=x({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=B({plugin:e,schema:t,state:{...n,path:T([...n.path.value,`items`,i])}});r.push(a)}),r.length===1?I.type(`Array`).generic(r[0]):t.logicalOperator===`and`?I.type(`Array`).generic(I.type.and(...r)):I.type(`Array`).generic(I.type.or(...r))},oa=({schema:e})=>e.const===void 0?I.type(`boolean`):I.type.literal(e.const),sa=({plugin:e,schema:t,state:n})=>B({plugin:e,schema:{...t,type:void 0},state:n}),ca=e=>I.type(`never`),la=e=>I.type.literal(null),ua=({plugin:e,schema:t})=>t.const===void 0?t.type===`integer`&&t.format===`int64`&&e.getPlugin(`@hey-api/transformers`)?.config.bigInt?I.type(`bigint`):I.type(`number`):I.type.literal(t.const),da=({plugin:e,schema:t,state:n})=>{let r=I.type.object(),i=t.required??[],a=[],o=!1;for(let s in t.properties){let c=t.properties[s],l=B({plugin:e,schema:c,state:{...n,path:T([...n.path.value,`properties`,s])}}),u=i.includes(s);r.prop(s,e=>e.$if(z(c),(e,t)=>e.doc(t)).readonly(c.accessScope===`read`).required(u).type(l)),a.push(c),u||(o=!0)}if(t.patternProperties)for(let e in t.patternProperties){let n=t.patternProperties[e];a.unshift(n)}let s=!!t.patternProperties&&Object.keys(t.patternProperties).length>0,c=t.additionalProperties,l=c!==!1&&c?c:void 0;if(s||l&&(l.type!==`never`||!a.length)){let i=l;i&&i.type!==`never`?a.unshift(i):!s&&!a.length&&i&&i.type===`never`&&(a=[i]),o&&a.push({type:`undefined`});let c=a.length===1?B({plugin:e,schema:a[0],state:n}):B({plugin:e,schema:{items:a,logicalOperator:`or`},state:n});if(t.propertyNames?.$ref)return I.type.mapped(`key`).key(B({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n})).optional().type(c);r.idxSig(`key`,e=>e.key(`string`).type(c))}return r},fa=({plugin:e,schema:t})=>{if(t.const!==void 0)return I.type.literal(t.const);if(t.format){if(t.format===`binary`)return I.type.or(I.type(`Blob`),I.type(`File`));if((t.format===`date-time`||t.format===`date`)&&e.getPlugin(`@hey-api/transformers`)?.config.dates)return I.type(`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=I.type.alias(n.placeholder).export(n.exported).generic(`T`,e=>e.extends(`string`)).type(I.type.template().add(I.type(`T`)).add(`_`).add(I.type(`string`)));e.setSymbolValue(n,r)}let n=e.referenceSymbol(t),a=e.registerSymbol({exported:!0,kind:`type`,meta:i,name:y({case:e.config.case,value:`${r}_id`})}),o=I.type.alias(a.placeholder).export(a.exported).type(I.type(n.placeholder).generic(I.type.literal(r)));e.setSymbolValue(a,o)}let a=e.referenceSymbol(i);return I.type(a.placeholder)}}return I.type(`string`)},pa=({plugin:e,schema:t,state:n})=>{let r=[];return t.const&&Array.isArray(t.const)?r=t.const.map(e=>I.type.fromValue(e)):t.items&&t.items.forEach((t,i)=>{let a=B({plugin:e,schema:t,state:{...n,path:T([...n.path.value,`items`,i])}});r.push(a)}),I.type.tuple(...r)},ma=e=>I.type(`undefined`),ha=({plugin:e})=>I.type(e.config.topType),ga=e=>I.type(`void`),_a=({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 aa({...t,schema:e});case`boolean`:return oa({...t,schema:e});case`enum`:return sa({...t,schema:e});case`integer`:case`number`:return ua({...t,schema:e});case`never`:return ca({...t,schema:e});case`null`:return la({...t,schema:e});case`object`:return da({...t,schema:e});case`string`:return fa({...t,schema:e});case`tuple`:return pa({...t,schema:e});case`undefined`:return ma({...t,schema:e});case`unknown`:return ha({...t,schema:e});case`void`:return ga({...t,schema:e})}},B=({plugin:e,schema:t,state:n})=>{if(t.$ref){let n=e.referenceSymbol({category:`type`,resource:`definition`,resourceId:t.$ref});return I.type(n.placeholder)}if(t.type)return _a({plugin:e,schema:t,state:n});if(t.items){if(t=x({detectFormat:!1,schema:t}),t.items){let r=t.items.map(t=>B({plugin:e,schema:t,state:n}));return t.logicalOperator===`and`?I.type.and(...r):I.type.or(...r)}return B({plugin:e,schema:t,state:n})}return _a({plugin:e,schema:{type:`unknown`},state:n})},va=({plugin:e,schema:t,state:n})=>{let r=B({plugin:e,schema:t,state:n}),i=t.type===`enum`&&e.config.enums.enabled,a=Sr(n.path.value);Qi({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:b({config:e.config.definitions,name:L(a)})}),type:r})},ya=({plugin:e})=>{let t=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`client`,role:`options`,tool:`typescript`},name:b({config:{case:e.config.case},name:`ClientOptions`})}),n=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`webhook`,tool:`typescript`,variant:`container`},name:b({config:{case:e.config.case},name:`Webhooks`})}),r=[],i=[];e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=E({path:t._path,tags:t.tags});switch(t.type){case`operation`:ta({operation:t.operation,plugin:e,state:n});break;case`parameter`:va({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:va({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:va({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(ra({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),Xi({plugin:e,servers:r,symbolClientOptions:t}),ia({plugin:e,symbolWebhooks:n,webhookNames:i})},ba={api:new class{schemaToType(e){return B(e)}},config:{case:`PascalCase`,exportFromIndex:!0,topType:`unknown`},handler:e=>ya(e),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})}},xa=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return I.fromValue(i)},Sa=({operation:e,plugin:t})=>Ar({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Ca=({operation:e,plugin:t})=>{let n=w(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},wa=({operation:e,plugin:t})=>t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`,Ta=({plugin:e,typeData:t})=>{let n=w(e.context.config).name===`@hey-api/client-nuxt`;return{isNuxtClient:n,strippedTypeData:n?`Omit<${t}, 'composable'>`:t}},Ea=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol({category:`external`,resource:`${t.name}.UseMutationOptions`}),i=Sa({operation:e,plugin:t}),a=Ca({operation:e,plugin:t}),o=wa({operation:e,plugin:t}),{isNuxtClient:s,strippedTypeData:c}=Ta({plugin:t,typeData:i}),l=s?`${r.placeholder}<${o}, ${c}, ${a}>`:`${r.placeholder}<${o}, ${i}, ${a}>`,u=`fnOptions`,d=I(n).call(I.object().pretty().spread(`options`).spread(u).prop(`throwOnError`,I.literal(!0))).await(),f=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?f.push(I.return(d)):f.push(I.const().object(`data`).assign(d),I.return(`data`));let p=I.object().pretty().prop(`mutation`,I.func().async().param(u,e=>e.$if(s,e=>e.type(`Partial<${c}>`))).do(...f)).$if(xa(t,e,`mutationOptions`),(e,t)=>e.prop(`meta`,t)),m=t.registerSymbol({exported:!0,name:b({config:t.config.mutationOptions,name:e.id})}),h=I.const(m.placeholder).export(m.exported).$if(t.config.comments&&R(e),(e,t)=>e.doc(t)).assign(I.func().param(`options`,e=>e.optional().type(`Partial<${c}>`)).returns(l).do(I.return(p)));t.setSymbolValue(m,h)},Da=`TOptions`,Oa=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createQueryKey`,tool:e.name},name:b({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=I.type(n.placeholder).generic(Da).idx(0),a=ot(e.context.config),o=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),s=e.getSymbol({category:`client`}),c=ei(e.context.config),l=e.registerSymbol({external:c,meta:{category:`external`,resource:`${c}.serializeQueryKeyValue`},name:`serializeQueryKeyValue`}),u=I.const(t.placeholder).assign(I.func().param(`id`,e=>e.type(`string`)).param(`options`,e=>e.optional().type(Da)).param(`tags`,e=>e.optional().type(`ReadonlyArray<string>`)).returns(I.type.tuple(i)).generic(Da,e=>e.extends(o.placeholder)).do(I.const(`params`).type(i).assign(I.object().prop(`_id`,`id`).prop(a,`options?.${a} || (options?.client ?? ${s?.placeholder}).getConfig().${a}`).as(i)),I.if(`tags`).do(I(`params`).attr(`tags`).assign(I(`tags`).as(`unknown`).as(r.placeholder))),I.if(I(`options`).attr(`body`).optional().neq(I.id(`undefined`))).do(I.const(`normalizedBody`).assign(I(l.placeholder).call(I(`options`).attr(`body`))),I.if(I(`normalizedBody`).neq(I.id(`undefined`))).do(I(`params`).attr(`body`).assign(`normalizedBody`))),I.if(I(`options`).attr(`path`).optional()).do(I(`params`).attr(`path`).assign(I(`options`).attr(`path`))),I.if(I(`options`).attr(`query`).optional().neq(I.id(`undefined`))).do(I.const(`normalizedQuery`).assign(I(l.placeholder).call(I(`options`).attr(`query`))),I.if(I(`normalizedQuery`).neq(I.id(`undefined`))).do(I(`params`).attr(`query`).assign(`normalizedQuery`))),I.return(I.array(I(`params`)))));e.setSymbolValue(t,u)},ka=({id:e,operation:t,plugin:n})=>{let r=n.config.queryKeys,i;return r.tags&&t.tags&&t.tags.length>0&&(i=I.array(...t.tags.map(e=>I.literal(e)))),I(n.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:n.name}).placeholder).call(I.literal(e),`options`,i)},Aa=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),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=I.type.alias(r.placeholder).export(r.exported).generic(Da,e=>e.extends(I.type(n.placeholder))).type(I.type.tuple(I.type.and(I.type(`Pick<${Da}, 'path'>`),I.type.object().prop(`_id`,e=>e.type(`string`)).prop(ot(e.context.config),e=>e.optional().type(t.placeholder)).prop(`body`,e=>e.optional().type(t.placeholder)).prop(`query`,e=>e.optional().type(t.placeholder)).prop(`tags`,e=>e.optional().type(t.placeholder)))));e.setSymbolValue(r,i)},ja=({operation:e,plugin:t,symbol:n})=>{let{strippedTypeData:r}=Ta({plugin:t,typeData:Sa({operation:e,plugin:t})});return I.const(n.placeholder).export(n.exported).assign(I.func().param(`options`,t=>t.required(tt(e)).type(r)).do(ka({id:e.id,operation:e,plugin:t}).return()))},Ma=`options`,Na=`context`,Pa=({operation:e,plugin:t,queryFn:n})=>{if(Ir({operation:e}))return;let r=Fr({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(Aa({plugin:t}),Oa({plugin:t}));let i;if(t.config.queryKeys.enabled){let n=t.registerSymbol({exported:!0,name:b({config:t.config.queryKeys,name:e.id})}),r=ja({operation:e,plugin:t,symbol:n});t.setSymbolValue(n,r),i=I(n.placeholder).call(Ma)}else{let n=t.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name}),r;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(r=I.array(...e.tags.map(e=>I.literal(e)))),i=I(n.placeholder).call(I.literal(e.id),Ma,r)}let{strippedTypeData:a}=Ta({plugin:t,typeData:Sa({operation:e,plugin:t})}),o=I(n).call(I.object().spread(Ma).spread(Na).prop(`throwOnError`,I.literal(!0))).await(),s=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?s.push(I.return(o)):s.push(I.const().object(`data`).assign(o),I.return(`data`));let c=I.object().pretty().prop(`key`,i).prop(`query`,I.func().async().param(Na).do(...s)).$if(xa(t,e,`queryOptions`),(e,t)=>e.prop(`meta`,t)),l=t.registerSymbol({exported:!0,meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name},name:b({config:t.config.queryOptions,name:e.id})}),u=t.referenceSymbol({category:`external`,resource:`${t.name}.defineQueryOptions`}),d=I.const(l.placeholder).export(l.exported).$if(t.config.comments&&R(e),(e,t)=>e.doc(t)).assign(I(u.placeholder).call(I.func().param(Ma,e=>e.required(r).type(a)).do(I.return(c))));t.setSymbolValue(l,d)},Fa=({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?kr({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?[ji,`get()`]:[],...i.path.slice(1).map(e=>y({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&&Pa({operation:n,plugin:e,queryFn:a}),e.hooks.operation.isMutation(n)&&e.config.mutationOptions.enabled&&Ea({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},Ia={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:e=>Fa(e),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})}},La=({operation:e,plugin:t})=>Ar({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Ra=({operation:e,plugin:t})=>{let n=w(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},za=({operation:e,plugin:t})=>t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`})?.placeholder||`unknown`,Ba=`TOptions`,Va=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createQueryKey`,tool:e.name},name:b({config:{case:e.config.case},name:`createQueryKey`})}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=ot(e.context.config),i=e.getSymbol({category:`client`}),a=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),o=I.type(n.placeholder).generic(Ba).idx(0),s=I.const(t.placeholder).assign(I.func().param(`id`,e=>e.type(`string`)).param(`options`,e=>e.optional().type(Ba)).param(`infinite`,e=>e.optional().type(`boolean`)).param(`tags`,e=>e.optional().type(`ReadonlyArray<string>`)).generic(Ba,e=>e.extends(a.placeholder)).returns(I.type.tuple(o)).do(I.const(`params`).type(o).assign(I.object().prop(`_id`,`id`).prop(r,`options?.${r} || (options?.client ?? ${i?.placeholder}).getConfig().${r}`).as(o)),I.if(`infinite`).do(I(`params`).attr(`_infinite`).assign(`infinite`)),I.if(`tags`).do(I(`params`).attr(`tags`).assign(`tags`)),I.if(I(`options`).attr(`body`).optional()).do(I(`params`).attr(`body`).assign(I(`options`).attr(`body`))),I.if(I(`options`).attr(`headers`).optional()).do(I(`params`).attr(`headers`).assign(I(`options`).attr(`headers`))),I.if(I(`options`).attr(`path`).optional()).do(I(`params`).attr(`path`).assign(I(`options`).attr(`path`))),I.if(I(`options`).attr(`query`).optional()).do(I(`params`).attr(`query`).assign(I(`options`).attr(`query`))),I.return(I.array().element(I(`params`)))));e.setSymbolValue(t,s)},Ha=({id:e,isInfinite:t,operation:n,plugin:r})=>{let i=t?r.config.infiniteQueryKeys:r.config.queryKeys,a;return i.tags&&n.tags&&n.tags.length>0&&(a=I.array().elements(...n.tags)),I(r.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:r.name}).placeholder).call(I.literal(e),`options`,t||a?I.literal(!!t):void 0,a)},Ua=({plugin:e})=>{let t=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),n=e.registerSymbol({exported:!0,kind:`type`,meta:{category:`type`,resource:`QueryKey`,tool:e.name},name:`QueryKey`}),r=I.type.alias(n.placeholder).export(n.exported).generic(Ba,e=>e.extends(t.placeholder)).type(I.type.tuple(I.type.and(I.type(`Pick<${Ba}, '${ot(e.context.config)}' | 'body' | 'headers' | 'path' | 'query'>`),I.type.object().prop(`_id`,e=>e.type(`string`)).prop(`_infinite`,e=>e.optional().type(`boolean`)).prop(`tags`,e=>e.optional().type(`ReadonlyArray<string>`)))));e.setSymbolValue(n,r)},Wa=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=La({operation:t,plugin:n});return I.const(r.placeholder).export(r.exported).assign(I.func().param(`options`,e=>e.required(tt(t)).type(a)).$if(e&&i,(e,t)=>e.returns(t)).do(Ha({id:t.id,isInfinite:e,operation:t,plugin:n}).return()))},Ga=(e,t,n)=>{let r=e.config[n].meta;if(!r)return;let i=r(t);if(Object.keys(i).length)return I.fromValue(i)},Ka=({plugin:e})=>{let t=e.registerSymbol({meta:{category:`utility`,resource:`createInfiniteParams`,tool:e.name},name:b({config:{case:e.config.case},name:`createInfiniteParams`})}),n=I.const(t.placeholder).assign(I.func().generic(`K`,e=>e.extends(`Pick<QueryKey<Options>[0], 'body' | 'headers' | 'path' | 'query'>`)).param(`queryKey`,e=>e.type(`QueryKey<Options>`)).param(`page`,e=>e.type(`K`)).do(I.const(`params`).assign(I.object().spread(I(`queryKey`).attr(0))),I.if(I(`page`).attr(`body`)).do(I(`params`).attr(`body`).assign(I.object().pretty().spread(I(`queryKey`).attr(0).attr(`body`).as(`any`)).spread(I(`page`).attr(`body`).as(`any`)))),I.if(I(`page`).attr(`headers`)).do(I(`params`).attr(`headers`).assign(I.object().pretty().spread(I(`queryKey`).attr(0).attr(`headers`)).spread(I(`page`).attr(`headers`)))),I.if(I(`page`).attr(`path`)).do(I(`params`).attr(`path`).assign(I.object().pretty().spread(I(`queryKey`).attr(0).attr(`path`).as(`any`)).spread(I(`page`).attr(`path`).as(`any`)))),I.if(I(`page`).attr(`query`)).do(I(`params`).attr(`query`).assign(I.object().pretty().spread(I(`queryKey`).attr(0).attr(`query`).as(`any`)).spread(I(`page`).attr(`query`).as(`any`)))),I.return(I(`params`).as(`unknown`).as(I(`page`).typeofType()))));e.setSymbolValue(t,n)},qa=({operation:e,plugin:t,queryFn:n})=>{let r=nt({context:t.context,operation:e});if(!r)return;let i=Fr({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(Ua({plugin:t}),Va({plugin:t})),t.getSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name})||Ka({plugin:t});let a=t.referenceSymbol({category:`external`,resource:`${t.name}.infiniteQueryOptions`}),o=t.referenceSymbol({category:`external`,resource:`${t.name}.InfiniteData`}),s=La({operation:e,plugin:t}),c=Ra({operation:e,plugin:t}),l=za({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=f.api.schemaToType({plugin:f,schema:r.schema,state:{path:{value:[]}}}),m=t.registerSymbol({exported:!0,name:b({config:t.config.infiniteQueryKeys,name:e.id})}),h=Wa({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.setSymbolValue(m,h);let g=I(n).call(I.object().spread(`options`).spread(`params`).prop(`signal`,I(`signal`)).prop(`throwOnError`,I.literal(!0))).await(),ee=t.referenceSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name}),te=[I.const(`page`).type(d).hint(`@ts-ignore`).assign(I.ternary(I(`pageParam`).typeof().eq(I.literal(`object`))).do(`pageParam`).otherwise(I.object().pretty().prop(r.in,I.object().pretty().prop(r.name,I(`pageParam`))))),I.const(`params`).assign(I(ee.placeholder).call(`queryKey`,`page`))];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?te.push(I.return(g)):te.push(I.const().object(`data`).assign(g),I.return(`data`));let ne=t.registerSymbol({exported:!0,name:b({config:t.config.infiniteQueryOptions,name:e.id})}),re=I.const(ne.placeholder).export(ne.exported).$if(t.config.comments&&R(e),(e,t)=>e.doc(t)).assign(I.func().param(`options`,e=>e.required(i).type(s)).do(I.return(I(a.placeholder).call(I.object().pretty().hint(`@ts-ignore`).prop(`queryFn`,I.func().async().param(e=>e.object(`pageParam`,`queryKey`,`signal`)).do(...te)).prop(`queryKey`,I(m.placeholder).call(`options`)).$if(Ga(t,e,`infiniteQueryOptions`),(e,t)=>e.prop(`meta`,t))).generics(l,c||`unknown`,`${o.placeholder}<${l}>`,u,I.type.or(p,d)))));t.setSymbolValue(ne,re)},Ja=({operation:e,plugin:t,queryFn:n})=>{let r=t.referenceSymbol({category:`external`,resource:`${t.name}.MutationOptions`}),i=La({operation:e,plugin:t}),a=Ra({operation:e,plugin:t}),o=za({operation:e,plugin:t}),s=`${r.placeholder}<${o}, ${a}, ${i}>`,c=`fnOptions`,l=I(n).call(I.object().spread(`options`).spread(c).prop(`throwOnError`,I.literal(!0))).await(),u=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?u.push(I.return(l)):u.push(I.const().object(`data`).assign(l),I.return(`data`));let d=`mutationOptions`,f=t.registerSymbol({exported:!0,name:b({config:t.config.mutationOptions,name:e.id})}),p=I.const(f.placeholder).export(f.exported).$if(t.config.comments&&R(e),(e,t)=>e.doc(t)).assign(I.func().param(`options`,e=>e.optional().type(`Partial<${i}>`)).returns(s).do(I.const(d).type(s).assign(I.object().pretty().prop(`mutationFn`,I.func().async().param(c).do(...u)).$if(Ga(t,e,`mutationOptions`),(e,t)=>e.prop(`meta`,t))),I(d).return()));t.setSymbolValue(f,p)},Ya=`options`,Xa=({operation:e,plugin:t,queryFn:n})=>{if(Ir({operation:e}))return;let r=Fr({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(Ua({plugin:t}),Va({plugin:t}));let i=t.referenceSymbol({category:`external`,resource:`${t.name}.queryOptions`}),a=t.registerSymbol({exported:!0,name:b({config:t.config.queryKeys,name:e.id})}),o=Wa({isInfinite:!1,operation:e,plugin:t,symbol:a});t.setSymbolValue(a,o);let s=La({operation:e,plugin:t}),c=Ra({operation:e,plugin:t}),l=za({operation:e,plugin:t}),u=I(n).call(I.object().spread(Ya).spread(I(`queryKey`).attr(0)).prop(`signal`,I(`signal`)).prop(`throwOnError`,I.literal(!0))).await(),d=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?d.push(I.return(u)):d.push(I.const().object(`data`).assign(u),I.return(`data`));let f=I.object().pretty().prop(`queryFn`,I.func().async().param(e=>e.object(`queryKey`,`signal`)).do(...d)).prop(`queryKey`,I(a.placeholder).call(Ya)).$if(Ga(t,e,`queryOptions`),(e,t)=>e.prop(`meta`,t)),p=t.registerSymbol({exported:t.config.queryOptions.exported,meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name},name:b({config:t.config.queryOptions,name:e.id})}),m=I.const(p.placeholder).export(p.exported).$if(t.config.comments&&R(e),(e,t)=>e.doc(t)).assign(I.func().param(Ya,e=>e.required(r).type(s)).do(I(i.placeholder).call(f).generics(l,c,l,I(a.placeholder).returnType()).return()));t.setSymbolValue(p,m)},Za=`options`,Qa=({operation:e,plugin:t})=>{if(Ir({operation:e})||!(`useQuery`in t.config))return;let n=t.registerSymbol({exported:!0,name:b({config:t.config.useQuery,name:e.id})}),r=t.referenceSymbol({category:`external`,resource:`${t.name}.useQuery`}),i=Fr({context:t.context,operation:e}),a=La({operation:e,plugin:t}),o=t.referenceSymbol({category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}),s=I.const(n.placeholder).export(n.exported).$if(t.config.comments&&R(e),(e,t)=>e.doc(t)).assign(I.func().param(Za,e=>e.required(i).type(a)).do(I(r.placeholder).call(I(o.placeholder).call(Za)).return()));t.setSymbolValue(n,s)},$a=({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?kr({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?[ji,`get()`]:[],...i.path.slice(1).map(e=>y({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&&Xa({operation:t,plugin:e,queryFn:a}),e.config.infiniteQueryOptions.enabled&&qa({operation:t,plugin:e,queryFn:a}),`useQuery`in e.config&&e.config.useQuery.enabled&&Qa({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&Ja({operation:t,plugin:e,queryFn:a})},{order:`declarations`})},eo=e=>$a(e),to={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:eo,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})}},no={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:eo,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))}},ro={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:eo,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})}},io={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:eo,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})}},ao={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:eo,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})}},oo=({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 I.func().async().param(r).do(I(n.placeholder).attr(`parseAsync`).call(r).await().return())},so=({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 I.func().async().param(r).do(I(n.placeholder).attr(`parseAsync`).call(r).await().return())};var co=class{createRequestValidator(e){return oo(e)}createResponseValidator(e){return so(e)}};const V={keywords:{false:`false`,true:`true`},number:{Infinity:`Infinity`,NaN:`NaN`,NegativeInfinity:`NegativeInfinity`,epoch:`epoch`,integer:`integer`,safe:`safe`},primitives:{bigint:`bigint`,boolean:`boolean`,keywords:`keywords`,null:`null`,number:`number`,string:`string`,symbol:`symbol`,undefined:`undefined`,unit:`unit`},string:{NFC:`NFC`,NFD:`NFD`,NFKC:`NFKC`,NFKD:`NFKD`,alpha:`alpha`,alphanumeric:`alphanumeric`,base64:`base64`,capitalize:`capitalize`,creditCard:`creditCard`,date:`date`,digits:`digits`,email:`email`,epoch:`epoch`,hex:`hex`,integer:`integer`,ip:`ip`,iso:`iso`,json:`json`,lower:`lower`,normalize:`normalize`,numeric:`numeric`,parse:`parse`,preformatted:`preformatted`,regex:`regex`,semver:`semver`,trim:`trim`,upper:`upper`,url:`url`,uuid:`uuid`,v1:`v1`,v2:`v2`,v3:`v3`,v4:`v4`,v5:`v5`,v6:`v6`,v7:`v7`,v8:`v8`},type:{$:`$`,allows:`allows`,and:`and`,array:`array`,as:`as`,assert:`assert`,brand:`brand`,configure:`configure`,default:`default`,describe:`describe`,description:`description`,equals:`equals`,exclude:`exclude`,expression:`expression`,extends:`extends`,extract:`extract`,filter:`filter`,from:`from`,ifEquals:`ifEquals`,ifExtends:`ifExtends`,infer:`infer`,inferIn:`inferIn`,intersect:`intersect`,json:`json`,meta:`meta`,narrow:`narrow`,onDeepUndeclaredKey:`onDeepUndeclaredKey`,onUndeclaredKey:`onUndeclaredKey`,optional:`optional`,or:`or`,overlaps:`overlaps`,pipe:`pipe`,select:`select`,to:`to`,toJsonSchema:`toJsonSchema`}},lo=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`arktype.type`}),o=I.const(r.placeholder).export(r.exported).$if(t.config.comments&&z(n),(e,t)=>e.doc(t)).assign(I(a.placeholder).call(e.def?I.literal(e.def):e.expression));if(t.setSymbolValue(r,o),i){let e=I.type.alias(i.placeholder).export(i.exported).type(I.type(r.placeholder).attr(V.type.infer).typeofType());t.setSymbolValue(i,e)}},uo=e=>{let t={};return t.def=V.primitives.null,t},fo=({plugin:e,schema:t,state:n})=>{let r={},i=I.object().pretty(),a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=a.includes(o),l=ho({optional:!c,plugin:e,schema:s,state:{...n,path:T([...n.path.value,`properties`,o])}});l.hasLazyExpression&&(r.hasLazyExpression=!0),i.prop(c?o:`${o}?`,l.expression)}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=ho({plugin:e,schema:t.additionalProperties,state:{...n,path:T([...n.path.value,`additionalProperties`])}});return r.expression=I(`TODO`).attr(`record`).call(I(`TODO`).attr(`string`).call(),i.expression),i.hasLazyExpression&&(r.hasLazyExpression=!0),r.hasLazyExpression?{...r,typeName:`TODO`}:r}return r.expression=i,r.hasLazyExpression?{...r,typeName:`TODO`}:r},po=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=V.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${V.string.date}.${V.string.iso}`;break;case`email`:n=`${n}.${V.string.email}`;break;case`ipv4`:n=`${n}.${V.string.ip}.${V.string.v4}`;break;case`ipv6`:n=`${n}.${V.string.ip}.${V.string.v6}`;break;case`uri`:n=`${n}.${V.string.url}`;break;case`uuid`:n=`${n}.${V.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},mo=({schema:e,...t})=>{switch(e.type){case`null`:return uo({...t,schema:e});case`object`:return fo({...t,schema:e});case`string`:return po({...t,schema:e})}return{def:``,expression:I(t.plugin.referenceSymbol({category:`external`,resource:`arktype.type`}).placeholder).call(I.object().prop(`name`,I.literal(`string`)).prop(`platform`,I.literal(`'android' | 'ios'`)).prop(`versions?`,I.literal(`(number | string)[]`))),hasLazyExpression:!1}},ho=({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=I(a.placeholder):(r.expression=I(`TODO`).attr(`TODO`).call(I.func().returns(`any`).do(I.return(a.placeholder))),r.hasLazyExpression=!0,n.hasLazyExpression.value=!0)}else if(t.type){let i=mo({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=x({schema:t}),t.items||(r=ho({plugin:e,schema:t,state:n}));else{let t=mo({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}return r.expression||=mo({plugin:e,schema:{type:`unknown`},state:n}).expression,r},go=({plugin:e,schema:t,state:n})=>{let r=Sr(n.path.value),i=ho({plugin:e,schema:t,state:n}),a=L(r);lo({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:b({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:b({config:e.config.definitions.types.infer,name:a})}):void 0})},_o=({plugin:e})=>{e.registerSymbol({external:`arktype`,meta:{category:`external`,resource:`arktype.type`},name:`type`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=E({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:go({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:go({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:go({plugin:e,schema:t.schema,state:n});break}})},vo={api:new co,config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>_o(e),name:`arktype`,resolveConfig:(e,t)=>{e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers:v,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:{...v,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:v,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:{...v,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:v,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:{...v,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:v,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:{...v,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:v,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},yo=({operation:e,plugin:t})=>{let n=I.type.object(),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`data`,tool:`typescript`});r&&(e.body&&n.prop(`Body`,t=>t.required(e.body.required).type(I.type(r.placeholder).idx(I.type.literal(`body`)))),e.parameters&&(e.parameters.header&&n.prop(`Headers`,t=>t.required(Qe(e.parameters.header)).type(I.type(r.placeholder).idx(I.type.literal(`headers`)))),e.parameters.path&&n.prop(`Params`,t=>t.required(Qe(e.parameters.path)).type(I.type(r.placeholder).idx(I.type.literal(`path`)))),e.parameters.query&&n.prop(`Querystring`,t=>t.required(Qe(e.parameters.query)).type(I.type(r.placeholder).idx(I.type.literal(`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);e.length&&(e.includes(`default`)?e.length>1&&(o=I.type(`Omit`,e=>e.generics(I.type(s.placeholder),I.type.literal(`default`)))):o=I.type(s.placeholder))}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);e.length&&(e.includes(`default`)?e.length>1&&(c=I.type(`Omit`,e=>e.generics(I.type(l.placeholder),I.type.literal(`default`)))):c=I.type(l.placeholder))}let u=[o,c].filter(e=>e!==void 0);if(u.length&&n.prop(`Reply`,e=>e.type(I.type.and(...u))),n.isEmpty)return;let d=t.referenceSymbol({category:`type`,resource:`route-handler`,tool:`fastify`});return{name:e.id,type:I.type(d.placeholder,e=>e.generic(n))}},bo={config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:({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=I.type.object();e.forEach(`operation`,({operation:t})=>{let r=yo({operation:t,plugin:e});r&&n.prop(r.name,e=>e.type(r.type))},{order:`declarations`});let r=I.type.alias(t.placeholder).export(t.exported).type(n);e.setSymbolValue(t,r)},name:`fastify`},xo=({operation:e,plugin:t,queryFn:n})=>{if(Ir({operation:e}))return;let r=t.referenceSymbol({category:`external`,resource:`swr`}),i=t.registerSymbol({exported:!0,name:b({config:t.config.useSwr,name:e.id})}),a=I(n).call(I.object().prop(`throwOnError`,I.literal(!0))).await(),o=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?o.push(I.return(a)):o.push(I.const().object(`data`).assign(a),I.return(`data`));let s=I.const(i.placeholder).export(i.exported).$if(t.config.comments&&R(e),(e,t)=>e.doc(t)).assign(I.func().do(I(r.placeholder).call(I.literal(e.path),I.func().async().do(...o)).return()));t.setSymbolValue(i,s)},So=({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?kr({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?[ji,`get()`]:[],...i.path.slice(1).map(e=>y({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&&xo({operation:n,plugin:e,queryFn:a})},{order:`declarations`})},Co={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:e=>So(e),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))}},H={actions:{args:`args`,base64:`base64`,bic:`bic`,brand:`brand`,bytes:`bytes`,check:`check`,checkItems:`checkItems`,creditCard:`creditCard`,cuid2:`cuid2`,decimal:`decimal`,description:`description`,digits:`digits`,email:`email`,emoji:`emoji`,empty:`empty`,endsWith:`endsWith`,entries:`entries`,everyItem:`everyItem`,excludes:`excludes`,filterItems:`filterItems`,findItem:`findItem`,finite:`finite`,flavor:`flavor`,graphemes:`graphemes`,gtValue:`gtValue`,hash:`hash`,hexColor:`hexColor`,hexadecimal:`hexadecimal`,imei:`imei`,includes:`includes`,integer:`integer`,ip:`ip`,ipv4:`ipv4`,ipv6:`ipv6`,isoDate:`isoDate`,isoDateTime:`isoDateTime`,isoTime:`isoTime`,isoTimeSecond:`isoTimeSecond`,isoTimestamp:`isoTimestamp`,isoWeek:`isoWeek`,length:`length`,ltValue:`ltValue`,mac:`mac`,mac48:`mac48`,mac64:`mac64`,mapItems:`mapItems`,maxBytes:`maxBytes`,maxEntries:`maxEntries`,maxGraphemes:`maxGraphemes`,maxLength:`maxLength`,maxSize:`maxSize`,maxValue:`maxValue`,maxWords:`maxWords`,metadata:`metadata`,mimeType:`mimeType`,minBytes:`minBytes`,minEntries:`minEntries`,minGraphemes:`minGraphemes`,minLength:`minLength`,minSize:`minSize`,minValue:`minValue`,minWords:`minWords`,multipleOf:`multipleOf`,nanoid:`nanoid`,nonEmpty:`nonEmpty`,normalize:`normalize`,notBytes:`notBytes`,notEntries:`notEntries`,notGraphemes:`notGraphemes`,notLength:`notLength`,notSize:`notSize`,notValue:`notValue`,notValues:`notValues`,notWords:`notWords`,octal:`octal`,parseJson:`parseJson`,partialCheck:`partialCheck`,rawCheck:`rawCheck`,rawTransform:`rawTransform`,readonly:`readonly`,reduceItems:`reduceItems`,regex:`regex`,returns:`returns`,rfcEmail:`rfcEmail`,safeInteger:`safeInteger`,size:`size`,slug:`slug`,someItem:`someItem`,sortItems:`sortItems`,startsWith:`startsWith`,stringifyJson:`stringifyJson`,title:`title`,toLowerCase:`toLowerCase`,toMaxValue:`toMaxValue`,toMinValue:`toMinValue`,toUpperCase:`toUpperCase`,transform:`transform`,trim:`trim`,trimEnd:`trimEnd`,trimStart:`trimStart`,ulid:`ulid`,url:`url`,uuid:`uuid`,value:`value`,values:`values`,words:`words`},async:{argsAsync:`argsAsync`,arrayAsync:`arrayAsync`,awaitAsync:`awaitAsync`,checkAsync:`checkAsync`,checkItemsAsync:`checkItemsAsync`,customAsync:`customAsync`,exactOptionalAsync:`exactOptionalAsync`,fallbackAsync:`fallbackAsync`,forwardAsync:`forwardAsync`,getDefaultsAsync:`getDefaultsAsync`,getFallbacksAsync:`getFallbacksAsync`,intersectAsync:`intersectAsync`,lazyAsync:`lazyAsync`,looseObjectAsync:`looseObjectAsync`,looseTupleAsync:`looseTupleAsync`,mapAsync:`mapAsync`,nonNullableAsync:`nonNullableAsync`,nonNullishAsync:`nonNullishAsync`,nonOptionalAsync:`nonOptionalAsync`,nullableAsync:`nullableAsync`,nullishAsync:`nullishAsync`,objectAsync:`objectAsync`,objectWithRestAsync:`objectWithRestAsync`,optionalAsync:`optionalAsync`,parseAsync:`parseAsync`,parserAsync:`parserAsync`,partialAsync:`partialAsync`,partialCheckAsync:`partialCheckAsync`,pipeAsync:`pipeAsync`,rawCheckAsync:`rawCheckAsync`,rawTransformAsync:`rawTransformAsync`,recordAsync:`recordAsync`,requiredAsync:`requiredAsync`,returnsAsync:`returnsAsync`,safeParseAsync:`safeParseAsync`,safeParserAsync:`safeParserAsync`,setAsync:`setAsync`,strictObjectAsync:`strictObjectAsync`,strictTupleAsync:`strictTupleAsync`,transformAsync:`transformAsync`,tupleAsync:`tupleAsync`,tupleWithRestAsync:`tupleWithRestAsync`,undefinedableAsync:`undefinedableAsync`,unionAsync:`unionAsync`,variantAsync:`variantAsync`},methods:{assert:`assert`,config:`config`,fallback:`fallback`,flatten:`flatten`,forward:`forward`,getDefault:`getDefault`,getDefaults:`getDefaults`,getDescription:`getDescription`,getFallback:`getFallback`,getFallbacks:`getFallbacks`,getMetadata:`getMetadata`,getTitle:`getTitle`,is:`is`,keyof:`keyof`,message:`message`,omit:`omit`,parse:`parse`,parser:`parser`,partial:`partial`,pick:`pick`,pipe:`pipe`,required:`required`,safeParse:`safeParse`,safeParser:`safeParser`,summarize:`summarize`,unwrap:`unwrap`},schemas:{any:`any`,array:`array`,bigInt:`bigint`,blob:`blob`,boolean:`boolean`,custom:`custom`,date:`date`,enum:`enum`,exactOptional:`exactOptional`,file:`file`,function:`function`,instance:`instance`,intersect:`intersect`,lazy:`lazy`,literal:`literal`,looseObject:`looseObject`,looseTuple:`looseTuple`,map:`map`,nan:`nan`,never:`never`,nonNullable:`nonNullable`,nonNullish:`nonNullish`,nonOptional:`nonOptional`,null:`null`,nullable:`nullable`,nullish:`nullish`,number:`number`,object:`object`,objectWithRest:`objectWithRest`,optional:`optional`,picklist:`picklist`,promise:`promise`,record:`record`,set:`set`,strictObject:`strictObject`,strictTuple:`strictTuple`,string:`string`,symbol:`symbol`,tuple:`tuple`,tupleWithRest:`tupleWithRest`,undefined:`undefined`,undefinedable:`undefinedable`,union:`union`,unknown:`unknown`,variant:`variant`,void:`void`},storages:{},types:{GenericSchema:`GenericSchema`},utils:{}},wo=({schema:e,v:t})=>I(t.placeholder).attr(H.async.parseAsync).call(e.placeholder,`data`).await().return(),To=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`valibot`});if(!n)return;let r={$:I,operation:e,pipes:[],plugin:t,schema:n,v:t.referenceSymbol({category:`external`,resource:`valibot.v`})},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.request,wo];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Eo=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`valibot`});if(!n)return;let r={$:I,operation:e,pipes:[],plugin:t,schema:n,v:t.referenceSymbol({category:`external`,resource:`valibot.v`})},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.response,wo];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}};var Do=class{createRequestValidator(e){return To(e)}createResponseValidator(e){return Eo(e)}};const U=({pipes:e,plugin:t})=>e.length===1?e[0]:I(t.referenceSymbol({category:`external`,resource:`valibot.v`}).placeholder).attr(H.methods.pipe).call(...e),Oo=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`valibot.v`}),o=I.const(i.placeholder).export(i.exported).$if(t.config.comments&&z(n),(e,t)=>e.doc(t)).$if(r.hasLazyExpression.value,t=>t.type(I.type(a.placeholder).attr(e.typeName||H.types.GenericSchema))).assign(U({pipes:e.pipes,plugin:t}));t.setSymbolValue(i,o)},ko={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}},Ao=e=>e!==void 0&&e in ko,jo=e=>Ao(e)&&ko[e].needsBigInt,Mo=({isBigInt:e,value:t})=>{let n=I.fromValue(t);return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?I(`BigInt`).call(n):n},No=({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],Oo({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:b({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`];Oo({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:b({config:n.config.responses,name:t.id})})})}}},Po=({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],Oo({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:b({config:n.config.webhooks,name:t.id})})})}},Fo=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`}).placeholder).attr(H.schemas.unknown).call(),Io=({plugin:e,schema:t,state:n})=>{let r={pipes:[]},i=e.referenceSymbol({category:`external`,resource:`valibot.v`}),a=I(i.placeholder).attr(H.schemas.array);if(t.items){t=x({schema:t});let i=t.items.map((t,i)=>{let a=Xo({plugin:e,schema:t,state:{...n,path:T([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),U({pipes:a.pipes,plugin:e})});if(i.length===1){let e=a.call(...i);r.pipes.push(e)}else{t.logicalOperator;let i=a.call(Fo({plugin:e,schema:{type:`unknown`},state:n}));r.pipes.push(i)}}else{let t=a.call(Fo({plugin:e,schema:{type:`unknown`},state:n}));r.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=I(i.placeholder).attr(H.actions.length).call(I.fromValue(t.minItems));r.pipes.push(e)}else{if(t.minItems!==void 0){let e=I(i.placeholder).attr(H.actions.minLength).call(I.fromValue(t.minItems));r.pipes.push(e)}if(t.maxItems!==void 0){let e=I(i.placeholder).attr(H.actions.maxLength).call(I.fromValue(t.maxItems));r.pipes.push(e)}}return r},Lo=({plugin:e,schema:t})=>{let n=[],r=e.referenceSymbol({category:`external`,resource:`valibot.v`});return typeof t.const==`boolean`?(n.push(I(r.placeholder).attr(H.schemas.literal).call(I.literal(t.const))),U({pipes:n,plugin:e})):(n.push(I(r.placeholder).attr(H.schemas.boolean).call()),U({pipes:n,plugin:e}))},Ro=({plugin:e,schema:t,state:n})=>{let r=[],i=!1;for(let e of t.items??[])e.type===`string`&&typeof e.const==`string`?r.push(I.literal(e.const)):(e.type===`null`||e.const===null)&&(i=!0);if(!r.length)return Fo({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol({category:`external`,resource:`valibot.v`}),o=I(a.placeholder).attr(H.schemas.picklist).call(I.array(...r));return i&&(o=I(a.placeholder).attr(H.schemas.nullable).call(o)),o},zo=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`}).placeholder).attr(H.schemas.never).call(),Bo=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`}).placeholder).attr(H.schemas.null).call(),Vo=({plugin:e,schema:t})=>{let n=t.format,r=t.type===`integer`,i=jo(n),a=Ao(n)?ko[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=I.literal(e);else if(typeof e==`number`&&n)r=i?I(`BigInt`).call(I.literal(e)):I.literal(e);else if(typeof e==`string`&&i){let t=e.endsWith(`n`)?e.slice(0,-1):e;r=I(`BigInt`).call(I.literal(t))}else if(typeof e==`bigint`){let t=e.toString(),n=t.endsWith(`n`)?t.slice(0,-1):t;r=I(`BigInt`).call(I.literal(n))}else r=I.fromValue(e);return I(o.placeholder).attr(H.schemas.literal).call(r)}let s=[];if(i){let e=I(o.placeholder).attr(H.schemas.union).call(I.array(I(o.placeholder).attr(H.schemas.number).call(),I(o.placeholder).attr(H.schemas.string).call(),I(o.placeholder).attr(H.schemas.bigInt).call()));s.push(e);let t=I(o.placeholder).attr(H.actions.transform).call(I.func().param(`x`).do(I(`BigInt`).call(`x`).return()));s.push(t)}else{let e=I(o.placeholder).attr(H.schemas.number).call();s.push(e)}if(!i&&r){let e=I(o.placeholder).attr(H.actions.integer).call();s.push(e)}if(a){let e=a.min,t=a.max,n=a.minError,r=a.maxError,c=I(o.placeholder).attr(H.actions.minValue).call(i?I(`BigInt`).call(I.literal(e)):I.literal(e),I.literal(n));s.push(c);let l=I(o.placeholder).attr(H.actions.maxValue).call(i?I(`BigInt`).call(I.literal(t)):I.literal(t),I.literal(r));s.push(l)}if(t.exclusiveMinimum!==void 0){let e=I(o.placeholder).attr(H.actions.gtValue).call(Mo({isBigInt:i,value:t.exclusiveMinimum}));s.push(e)}else if(t.minimum!==void 0){let e=I(o.placeholder).attr(H.actions.minValue).call(Mo({isBigInt:i,value:t.minimum}));s.push(e)}if(t.exclusiveMaximum!==void 0){let e=I(o.placeholder).attr(H.actions.ltValue).call(Mo({isBigInt:i,value:t.exclusiveMaximum}));s.push(e)}else if(t.maximum!==void 0){let e=I(o.placeholder).attr(H.actions.maxValue).call(Mo({isBigInt:i,value:t.maximum}));s.push(e)}return U({pipes:s,plugin:e})};function Ho({additional:e,pipes:t,plugin:n,shape:r}){let i=n.referenceSymbol({category:`external`,resource:`valibot.v`});return e===null?t.push(I(i.placeholder).attr(H.schemas.strictObject).call(r)):e?r.isEmpty?t.push(I(i.placeholder).attr(H.schemas.record).call(I(i.placeholder).attr(H.schemas.string).call(),e)):t.push(I(i.placeholder).attr(H.schemas.objectWithRest).call(r,e)):t.push(I(i.placeholder).attr(H.schemas.object).call(r))}const Uo=({plugin:e,schema:t,state:n})=>{let r={},i=[],a=I.object().pretty(),o=t.required??[];for(let i in t.properties){let s=t.properties[i],c=Xo({optional:!o.includes(i),plugin:e,schema:s,state:{...n,path:T([...n.path.value,`properties`,i])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),a.prop(i,U({pipes:c.pipes,plugin:e}))}let s;if(t.additionalProperties&&t.additionalProperties.type)if(t.additionalProperties.type===`never`)s=null;else{let i=Xo({plugin:e,schema:t.additionalProperties,state:{...n,path:T([...n.path.value,`additionalProperties`])}});i.hasLazyExpression&&(r.hasLazyExpression=!0),s=U({pipes:i.pipes,plugin:e})}let c={$:I,additional:s,pipes:i,plugin:e,schema:t,shape:a},l=e.config[`~resolvers`]?.object?.base;return l?.(c)||Ho(c),r.pipes=[U({pipes:i,plugin:e})],r},Wo=({pipes:e,plugin:t,schema:n})=>{let r=t.referenceSymbol({category:`external`,resource:`valibot.v`});switch(n.format){case`date`:return e.push(I(r.placeholder).attr(H.actions.isoDate).call());case`date-time`:return e.push(I(r.placeholder).attr(H.actions.isoTimestamp).call());case`email`:return e.push(I(r.placeholder).attr(H.actions.email).call());case`ipv4`:case`ipv6`:return e.push(I(r.placeholder).attr(H.actions.ip).call());case`time`:return e.push(I(r.placeholder).attr(H.actions.isoTimeSecond).call());case`uri`:return e.push(I(r.placeholder).attr(H.actions.url).call());case`uuid`:return e.push(I(r.placeholder).attr(H.actions.uuid).call())}return!0},Go=({plugin:e,schema:t})=>{let n=[],r=e.referenceSymbol({category:`external`,resource:`valibot.v`});if(typeof t.const==`string`)return n.push(I(r.placeholder).attr(H.schemas.literal).call(I.literal(t.const))),U({pipes:n,plugin:e});if(n.push(I(r.placeholder).attr(H.schemas.string).call()),t.format){let r={$:I,pipes:n,plugin:e,schema:t},i=e.config[`~resolvers`]?.string?.formats?.[t.format];i?.(r)||Wo(r)}return t.minLength===t.maxLength&&t.minLength!==void 0?n.push(I(r.placeholder).attr(H.actions.length).call(I.literal(t.minLength))):(t.minLength!==void 0&&n.push(I(r.placeholder).attr(H.actions.minLength).call(I.literal(t.minLength))),t.maxLength!==void 0&&n.push(I(r.placeholder).attr(H.actions.maxLength).call(I.literal(t.maxLength)))),t.pattern&&n.push(I(r.placeholder).attr(H.actions.regex).call(I.regexp(t.pattern))),U({pipes:n,plugin:e})},Ko=({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=>I(i.placeholder).attr(H.schemas.literal).call(I.fromValue(e)));return r.pipes=[I(i.placeholder).attr(H.schemas.tuple).call(I.array(...e))],r}if(t.items){let a=t.items.map((t,i)=>{let a=Xo({plugin:e,schema:t,state:{...n,path:T([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),U({pipes:a.pipes,plugin:e})});return r.pipes=[I(i.placeholder).attr(H.schemas.tuple).call(I.array(...a))],r}return{pipes:[Fo({plugin:e,schema:{type:`unknown`},state:n})]}},qo=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`}).placeholder).attr(H.schemas.undefined).call(),Jo=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`}).placeholder).attr(H.schemas.void).call(),Yo=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:U({pipes:Io({...t,schema:e}).pipes,plugin:t.plugin})};case`boolean`:return{expression:Lo({...t,schema:e})};case`enum`:return{expression:Ro({...t,schema:e})};case`integer`:case`number`:return{expression:Vo({...t,schema:e})};case`never`:return{expression:zo({...t,schema:e})};case`null`:return{expression:Bo({...t,schema:e})};case`object`:return{expression:U({pipes:Uo({...t,schema:e}).pipes,plugin:t.plugin})};case`string`:return e.format===`int64`||e.format===`uint64`?{expression:Vo({...t,schema:e})}:{expression:Go({...t,schema:e})};case`tuple`:return{expression:U({pipes:Ko({...t,schema:e}).pipes,plugin:t.plugin})};case`undefined`:return{expression:qo({...t,schema:e})};case`unknown`:return{expression:Fo({...t,schema:e})};case`void`:return{expression:Jo({...t,schema:e})}}},Xo=({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=I(o.placeholder);i.pipes.push(e)}else{let e=I(a.placeholder).attr(H.schemas.lazy).call(I.func().do(I(o.placeholder).return()));i.pipes.push(e),r.hasLazyExpression.value=!0}}else if(n.type){let e=Yo({plugin:t,schema:n,state:r});if(i.typeName=e.anyType,i.pipes.push(e.expression),t.config.metadata&&n.description){let e=I(a.placeholder).attr(H.actions.metadata).call(I.object().prop(`description`,I.literal(n.description)));i.pipes.push(e)}}else if(n.items)if(n=x({schema:n}),n.items){let e=n.items.map((e,n)=>U({pipes:Xo({plugin:t,schema:e,state:{...r,path:T([...r.path.value,`items`,n])}}).pipes,plugin:t}));if(n.logicalOperator===`and`){let t=I(a.placeholder).attr(H.schemas.intersect).call(I.array(...e));i.pipes.push(t)}else{let t=I(a.placeholder).attr(H.schemas.union).call(I.array(...e));i.pipes.push(t)}}else{let e=Xo({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=Yo({plugin:t,schema:{type:`unknown`},state:r});i.typeName=e.anyType,i.pipes.push(e.expression)}if(i.pipes.length){if(n.accessScope===`read`){let e=I(a.placeholder).attr(H.actions.readonly).call();i.pipes.push(e)}let r;n.default!==void 0&&(r=Mo({isBigInt:n.type===`integer`&&n.format===`int64`,value:n.default}),i.pipes=[I(a.placeholder).attr(H.schemas.optional).call(U({pipes:i.pipes,plugin:t}),r)]),e&&!r&&(i.pipes=[I(a.placeholder).attr(H.schemas.optional).call(U({pipes:i.pipes,plugin:t}))])}return i},Zo=({plugin:e,schema:t,state:n})=>{let r=Sr(n.path.value),i=Xo({plugin:e,schema:t,state:n}),a=L(r);Oo({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:b({config:e.config.definitions,name:a})})})},Qo=({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=E({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:No({getAst:(n,r)=>Xo({plugin:e,schema:n,state:E({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Zo({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Zo({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Zo({plugin:e,schema:t.schema,state:n});break;case`webhook`:Po({getAst:(n,r)=>Xo({plugin:e,schema:n,state:E({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},$o={api:new Do,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>Qo(e),name:`valibot`,resolveConfig:(e,t)=>{e.config.definitions=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.definitions}),e.config.requests=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Data`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.requests}),e.config.responses=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}Response`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.responses}),e.config.webhooks=t.valueToObject({defaultValue:{case:e.config.case??`camelCase`,enabled:!0,name:`v{{name}}WebhookRequest`},mappers:{boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})},value:e.config.webhooks})},tags:[`validator`]},W={ZodMiniOptional:`ZodMiniOptional`,ZodOptional:`ZodOptional`,_default:`_default`,and:`and`,array:`array`,bigint:`bigint`,boolean:`boolean`,check:`check`,coerce:`coerce`,date:`date`,datetime:`datetime`,default:`default`,describe:`describe`,email:`email`,enum:`enum`,globalRegistry:`globalRegistry`,gt:`gt`,gte:`gte`,infer:`infer`,int:`int`,intersection:`intersection`,ip:`ip`,ipv4:`ipv4`,ipv6:`ipv6`,iso:`iso`,lazy:`lazy`,length:`length`,literal:`literal`,lt:`lt`,lte:`lte`,max:`max`,maxLength:`maxLength`,min:`min`,minLength:`minLength`,never:`never`,null:`null`,nullable:`nullable`,number:`number`,object:`object`,optional:`optional`,parseAsync:`parseAsync`,readonly:`readonly`,record:`record`,regex:`regex`,register:`register`,string:`string`,time:`time`,tuple:`tuple`,undefined:`undefined`,union:`union`,unknown:`unknown`,url:`url`,uuid:`uuid`,void:`void`},es=({schema:e})=>I(e.placeholder).attr(W.parseAsync).call(`data`).await().return(),ts=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r={$:I,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.request,es];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},ns=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r={$:I,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.response,es];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},rs=({schema:e})=>I(e.placeholder).attr(W.parseAsync).call(`data`).await().return(),is=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r={$:I,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.request,rs];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},as=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r={$:I,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.response,rs];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},os=({schema:e})=>I(e.placeholder).attr(W.parseAsync).call(`data`).await().return(),ss=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r={$:I,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.request,os];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},cs=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r={$:I,chain:void 0,operation:e,plugin:t,schema:n},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.response,os];for(let e of a){let t=e?.(r);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}};var ls=class{createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return is(e);case`mini`:return ts(e);case 4:default:return ss(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return as(e);case`mini`:return ns(e);case 4:default:return cs(e)}}};const us=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`zod.z`}),o=I.const(r.placeholder).export(r.exported).$if(t.config.comments&&z(n),(e,t)=>e.doc(t)).$if(e.typeName,(e,t)=>e.type(I.type(a.placeholder).attr(t))).assign(e.expression);if(t.setSymbolValue(r,o),i){let e=I.type.alias(i.placeholder).export(i.exported).type(I.type(a.placeholder).attr(W.infer).generic(I(r.placeholder).typeofType()));t.setSymbolValue(i,e)}},ds=({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`}},G=({isBigInt:e,value:t})=>{let n=I.fromValue(t);return e&&(typeof t==`bigint`||typeof t==`number`||typeof t==`string`||typeof t==`boolean`)?I(`BigInt`).call(n):n},fs=({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],us({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:b({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:b({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`];us({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:b({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:b({config:n.config.responses.types.infer,name:t.id})}):void 0})}}},ps=({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],us({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:b({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:b({config:n.config.webhooks.types.infer,name:t.id})}):void 0})}},ms=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t.placeholder).attr(W.unknown).call(),n},hs=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={},a=I(r.placeholder).attr(W.array);if(!t.items)i.expression=a.call(ms({plugin:e,schema:{type:`unknown`},state:n}).expression);else{t=x({schema:t});let o=t.items.map((t,r)=>{let a=ks({plugin:e,schema:t,state:{...n,path:T([...n.path.value,`items`,r])}});return a.hasLazyExpression&&(i.hasLazyExpression=!0),a.expression});if(o.length===1)i.expression=a.call(...o);else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I(r.placeholder).attr(W.intersection).call(...o);else{n=o[0];for(let e=1;e<o.length;e++)n=I(r.placeholder).attr(W.intersection).call(n,o[e])}i.expression=a.call(n)}else i.expression=I(r.placeholder).attr(W.array).call(I(r.placeholder).attr(W.union).call(I.array(...o)))}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(I(r.placeholder).attr(W.length).call(I.fromValue(t.minItems))):(t.minItems!==void 0&&o.push(I(r.placeholder).attr(W.minLength).call(I.fromValue(t.minItems))),t.maxItems!==void 0&&o.push(I(r.placeholder).attr(W.maxLength).call(I.fromValue(t.maxItems)))),o.length&&(i.expression=i.expression.attr(W.check).call(...o)),i},gs=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(r=I(i.placeholder).attr(W.literal).call(I.literal(t.const)),n.expression=r,n):(r=I(i.placeholder).attr(W.boolean).call(),n.expression=r,n)},_s=({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=I.literal(e.const);a.push(t),o.push(I(r.placeholder).attr(W.literal).call(t))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=I.literal(e.const);o.push(I(r.placeholder).attr(W.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.literal(e.const);o.push(I(r.placeholder).attr(W.literal).call(t))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=I(r.placeholder).attr(W.enum).call(I.array(...a)):o.length===1?i.expression=o[0]:i.expression=I(r.placeholder).attr(W.union).call(I.array(...o)),s&&(i.expression=I(r.placeholder).attr(W.nullable).call(i.expression)),i):ms({plugin:e,schema:{type:`unknown`},state:n})},vs=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t.placeholder).attr(W.never).call(),n},ys=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t.placeholder).attr(W.null).call(),n},bs=({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=I(n.placeholder).attr(W.literal).call(I.literal(t.const)),r;r.expression=i?I(n.placeholder).attr(W.coerce).attr(W.bigint).call():I(n.placeholder).attr(W.number).call(),!i&&t.type===`integer`&&(r.expression=I(n.placeholder).attr(W.int).call());let a=[];return t.exclusiveMinimum===void 0?t.minimum!==void 0&&a.push(I(n.placeholder).attr(W.gte).call(G({isBigInt:i,value:t.minimum}))):a.push(I(n.placeholder).attr(W.gt).call(G({isBigInt:i,value:t.exclusiveMinimum}))),t.exclusiveMaximum===void 0?t.maximum!==void 0&&a.push(I(n.placeholder).attr(W.lte).call(G({isBigInt:i,value:t.maximum}))):a.push(I(n.placeholder).attr(W.lt).call(G({isBigInt:i,value:t.exclusiveMaximum}))),a.length&&(r.expression=r.expression.attr(W.check).call(...a)),r};function xs({additional:e,plugin:t,shape:n}){let r=t.referenceSymbol({category:`external`,resource:`zod.z`});return e?I(r.placeholder).attr(W.record).call(I(r.placeholder).attr(W.string).call(),e):I(r.placeholder).attr(W.object).call(n)}const Ss=({plugin:e,schema:t,state:n})=>{let r={},i=I.object().pretty(),a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=ks({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:T([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),c.hasLazyExpression?i.getter(o,c.expression.return()):i.prop(o,c.expression)}let o;if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=ks({plugin:e,schema:t.additionalProperties,state:{...n,path:T([...n.path.value,`additionalProperties`])}});i.hasLazyExpression&&(r.hasLazyExpression=!0),o=i.expression}let s={$:I,additional:o,chain:void 0,plugin:e,schema:t,shape:i},c=e.config[`~resolvers`]?.object?.base;return r.expression=c?.(s)??xs(s),r},Cs=({chain:e,plugin:t,schema:n})=>{let r=t.referenceSymbol({category:`external`,resource:`zod.z`});switch(n.format){case`date`:return I(r.placeholder).attr(W.iso).attr(W.date).call();case`date-time`:{let e=I.object().$if(t.config.dates.offset,e=>e.prop(`offset`,I.literal(!0))).$if(t.config.dates.local,e=>e.prop(`local`,I.literal(!0)));return I(r.placeholder).attr(W.iso).attr(W.datetime).call(e.hasProps()?e:void 0)}case`email`:return I(r.placeholder).attr(W.email).call();case`ipv4`:return I(r.placeholder).attr(W.ipv4).call();case`ipv6`:return I(r.placeholder).attr(W.ipv6).call();case`time`:return I(r.placeholder).attr(W.iso).attr(W.time).call();case`uri`:return I(r.placeholder).attr(W.url).call();case`uuid`:return I(r.placeholder).attr(W.uuid).call();default:return e}},ws=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});if(typeof t.const==`string`)return r=I(i.placeholder).attr(W.literal).call(I.literal(t.const)),n.expression=r,n;if(r=I(i.placeholder).attr(W.string).call(),t.format){let n={$:I,chain:r,plugin:e,schema:t},i=e.config[`~resolvers`]?.string?.formats?.[t.format];r=i?.(n)??Cs(n)}let a=[];return t.minLength===t.maxLength&&t.minLength!==void 0?a.push(I(i.placeholder).attr(W.length).call(I.literal(t.minLength))):(t.minLength!==void 0&&a.push(I(i.placeholder).attr(W.minLength).call(I.literal(t.minLength))),t.maxLength!==void 0&&a.push(I(i.placeholder).attr(W.maxLength).call(I.literal(t.maxLength)))),t.pattern&&a.push(I(i.placeholder).attr(W.regex).call(I.regexp(t.pattern))),a.length&&(r=r.attr(W.check).call(...a)),n.expression=r,n},Ts=({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=>I(r.placeholder).attr(W.literal).call(I.fromValue(e)));return i.expression=I(r.placeholder).attr(W.tuple).call(I.array(...e)),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=ks({plugin:e,schema:t,state:{...n,path:T([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=I(r.placeholder).attr(W.tuple).call(I.array(...a)),i},Es=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t.placeholder).attr(W.undefined).call(),n},Ds=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t.placeholder).attr(W.void).call(),n},Os=({schema:e,...t})=>{switch(e.type){case`array`:return hs({...t,schema:e});case`boolean`:return gs({...t,schema:e});case`enum`:return _s({...t,schema:e});case`integer`:case`number`:return bs({...t,schema:e});case`never`:return vs({...t,schema:e});case`null`:return ys({...t,schema:e});case`object`:return Ss({...t,schema:e});case`string`:return ws({...t,schema:e});case`tuple`:return Ts({...t,schema:e});case`undefined`:return Es({...t,schema:e});case`unknown`:return ms({...t,schema:e});case`void`:return Ds({...t,schema:e})}},ks=({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=I(o.placeholder):(i.expression=I(a.placeholder).attr(W.lazy).call(I.func().returns(`any`).do(I(o.placeholder).return())),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=Os({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=i.expression.attr(W.register).call(I(a.placeholder).attr(W.globalRegistry),I.object().pretty().prop(`description`,I.literal(n.description))))}else if(n.items)if(n=x({schema:n}),n.items){let e=n.items.map((e,n)=>ks({plugin:t,schema:e,state:{...r,path:T([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I(a.placeholder).attr(W.intersection).call(...e.map(e=>e.expression)):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=I(a.placeholder).attr(W.intersection).call(i.expression,e.hasLazyExpression?I(a.placeholder).attr(W.lazy).call(I.func().do(e.expression.return())):e.expression)}))}else i.expression=I(a.placeholder).attr(W.union).call(I.array().pretty().elements(...e.map(e=>e.expression)))}else i=ks({plugin:t,schema:n,state:r});else i.expression=Os({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=I(a.placeholder).attr(W.readonly).call(i.expression)),e&&(i.expression=I(a.placeholder).attr(W.optional).call(i.expression),i.typeName=W.ZodMiniOptional),n.default!==void 0)){let e=n.type===`integer`&&n.format===`int64`;i.expression=I(a.placeholder).attr(W._default).call(i.expression,G({isBigInt:e,value:n.default}))}return i},As=({plugin:e,schema:t,state:n})=>{let r=Sr(n.path.value),i=ks({plugin:e,schema:t,state:n}),a=L(r);us({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:b({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:b({config:e.config.definitions.types.infer,name:a})}):void 0})},js=({plugin:e})=>{e.registerSymbol({external:ds({plugin:e}),importKind:`namespace`,meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=E({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:fs({getAst:(n,r)=>ks({plugin:e,schema:n,state:E({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:As({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:As({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:As({plugin:e,schema:t.schema,state:n});break;case`webhook`:ps({getAst:(n,r)=>ks({plugin:e,schema:n,state:E({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Ms=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`}).placeholder).attr(W.unknown).call(),Ns=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=I(r.placeholder).attr(W.array),a,o=!1;if(!t.items)a=i.call(Ms({plugin:e,schema:{type:`unknown`},state:n}));else{t=x({schema:t});let s=t.items.map((t,r)=>{let i=qs({plugin:e,schema:t,state:{...n,path:T([...n.path.value,`items`,r])}});return i.hasLazyExpression&&(o=!0),i.expression});if(s.length===1)a=i.call(...s);else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I(r.placeholder).attr(W.intersection).call(...s);else{n=s[0];for(let e=1;e<s.length;e++)n=n.attr(W.and).call(s[e])}a=i.call(n)}else a=I(r.placeholder).attr(W.array).call(I(r.placeholder).attr(W.union).call(I.array(...s)))}return t.minItems===t.maxItems&&t.minItems!==void 0?a=a.attr(W.length).call(I.fromValue(t.minItems)):(t.minItems!==void 0&&(a=a.attr(W.min).call(I.fromValue(t.minItems))),t.maxItems!==void 0&&(a=a.attr(W.max).call(I.fromValue(t.maxItems)))),{expression:a,hasLazyExpression:o}},Ps=({plugin:e,schema:t})=>{let n,r=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(n=I(r.placeholder).attr(W.literal).call(I.literal(t.const)),n):(n=I(r.placeholder).attr(W.boolean).call(),n)},Fs=({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=I.literal(e.const);i.push(t),a.push(I(r.placeholder).attr(W.literal).call(t))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){s=!1;let t=I.literal(e.const);a.push(I(r.placeholder).attr(W.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=I.literal(e.const);a.push(I(r.placeholder).attr(W.literal).call(t))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return Ms({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?I(r.placeholder).attr(W.enum).call(I.array(...i)):a.length===1?a[0]:I(r.placeholder).attr(W.union).call(I.array(...a)),o&&(c=c.attr(W.nullable).call()),c},Is=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`}).placeholder).attr(W.never).call(),Ls=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`}).placeholder).attr(W.null).call(),Rs=({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 I(n.placeholder).attr(W.literal).call(I.literal(t.const));let i=r?I(n.placeholder).attr(W.coerce).attr(W.bigint).call():I(n.placeholder).attr(W.number).call();return!r&&t.type===`integer`&&(i=i.attr(W.int).call()),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(i=i.attr(W.gte).call(G({isBigInt:r,value:t.minimum}))):i=i.attr(W.gt).call(G({isBigInt:r,value:t.exclusiveMinimum})),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(i=i.attr(W.lte).call(G({isBigInt:r,value:t.maximum}))):i=i.attr(W.lt).call(G({isBigInt:r,value:t.exclusiveMaximum})),i};function zs({additional:e,plugin:t,shape:n}){let r=t.referenceSymbol({category:`external`,resource:`zod.z`});return e?I(r.placeholder).attr(W.record).call(e):I(r.placeholder).attr(W.object).call(n)}const Bs=({plugin:e,schema:t,state:n})=>{let r=!1,i=I.object().pretty(),a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=qs({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:T([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r=!0),i.prop(o,c.expression)}let o,s={};if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=qs({plugin:e,schema:t.additionalProperties,state:{...n,path:T([...n.path.value,`additionalProperties`])}});r=i.hasLazyExpression||r,o=i.expression}let c={$:I,additional:o,chain:void 0,plugin:e,schema:t,shape:i},l=e.config[`~resolvers`]?.object?.base;return s.expression=l?.(c)??zs(c),{anyType:`AnyZodObject`,expression:s.expression,hasLazyExpression:r}},Vs=({chain:e,plugin:t,schema:n})=>{switch(n.format){case`date`:return e.attr(W.date).call();case`date-time`:{let n=I.object().$if(t.config.dates.offset,e=>e.prop(`offset`,I.literal(!0))).$if(t.config.dates.local,e=>e.prop(`local`,I.literal(!0)));return e.attr(W.datetime).call(n.hasProps()?n:void 0)}case`email`:return e.attr(W.email).call();case`ipv4`:case`ipv6`:return e.attr(W.ip).call();case`time`:return e.attr(W.time).call();case`uri`:return e.attr(W.url).call();case`uuid`:return e.attr(W.uuid).call();default:return e}},Hs=({plugin:e,schema:t})=>{let n,r=e.referenceSymbol({category:`external`,resource:`zod.z`});if(typeof t.const==`string`)return n=I(r.placeholder).attr(W.literal).call(I.literal(t.const)),n;if(n=I(r.placeholder).attr(W.string).call(),t.format){let r={$:I,chain:n,plugin:e,schema:t},i=e.config[`~resolvers`]?.string?.formats?.[t.format];n=i?.(r)??Vs(r)}return t.minLength===t.maxLength&&t.minLength!==void 0?n=n.attr(W.length).call(I.literal(t.minLength)):(t.minLength!==void 0&&(n=n.attr(W.min).call(I.literal(t.minLength))),t.maxLength!==void 0&&(n=n.attr(W.max).call(I.literal(t.maxLength)))),t.pattern&&(n=n.attr(W.regex).call(I.regexp(t.pattern))),n},Us=({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=>I(r.placeholder).attr(W.literal).call(I.fromValue(e)));return{expression:I(r.placeholder).attr(W.tuple).call(I.array(...e)),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=qs({plugin:e,schema:t,state:{...n,path:T([...n.path.value,`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:I(r.placeholder).attr(W.tuple).call(I.array(...a)),hasLazyExpression:i}},Ws=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`}).placeholder).attr(W.undefined).call(),Gs=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`}).placeholder).attr(W.void).call(),Ks=({schema:e,...t})=>{switch(e.type){case`array`:return Ns({...t,schema:e});case`boolean`:return{expression:Ps({...t,schema:e})};case`enum`:return{expression:Fs({...t,schema:e})};case`integer`:case`number`:return{expression:Rs({...t,schema:e})};case`never`:return{expression:Is({...t,schema:e})};case`null`:return{expression:Ls({...t,schema:e})};case`object`:return Bs({...t,schema:e});case`string`:return{expression:Hs({...t,schema:e})};case`tuple`:return Us({...t,schema:e});case`undefined`:return{expression:Ws({...t,schema:e})};case`unknown`:return{expression:Ms({...t,schema:e})};case`void`:return{expression:Gs({...t,schema:e})}}},qs=({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=I(o.placeholder):(i.expression=I(a.placeholder).attr(W.lazy).call(I.func().do(I(o.placeholder).return())),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=Ks({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=i.expression.attr(W.describe).call(I.literal(n.description)))}else if(n.items)if(n=x({schema:n}),n.items){let e=n.items.map((e,n)=>qs({plugin:t,schema:e,state:{...r,path:T([...r.path.value,`items`,n])}}).expression);if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I(a.placeholder).attr(W.intersection).call(...e):(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=i.expression.attr(W.and).call(e)}))}else i.expression=I(a.placeholder).attr(W.union).call(I.array().pretty().elements(...e))}else i=qs({plugin:t,schema:n,state:r});else{let e=Ks({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}if(i.expression&&(n.accessScope===`read`&&(i.expression=i.expression.attr(W.readonly).call()),e&&(i.expression=i.expression.attr(W.optional).call()),n.default!==void 0)){let e=n.type===`integer`&&n.format===`int64`;i.expression=i.expression.attr(W.default).call(G({isBigInt:e,value:n.default}))}return r.hasLazyExpression.value?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},Js=({plugin:e,schema:t,state:n})=>{let r=Sr(n.path.value),i=qs({plugin:e,schema:t,state:n}),a=L(r);us({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:b({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:b({config:e.config.definitions.types.infer,name:a})}):void 0})},Ys=({plugin:e})=>{e.registerSymbol({external:ds({plugin:e}),meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=E({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:fs({getAst:(n,r)=>qs({plugin:e,schema:n,state:E({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Js({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Js({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Js({plugin:e,schema:t.schema,state:n});break;case`webhook`:ps({getAst:(n,r)=>qs({plugin:e,schema:n,state:E({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Xs=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`}).placeholder).attr(W.unknown).call(),t},Zs=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a=I(i.placeholder).attr(W.array);if(!t.items)r.expression=a.call(Xs({plugin:e,schema:{type:`unknown`},state:n}).expression);else{t=x({schema:t});let o=t.items.map((t,i)=>{let a=dc({plugin:e,schema:t,state:{...n,path:T([...n.path.value,`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),a.expression});if(o.length===1)r.expression=a.call(...o);else if(t.logicalOperator===`and`){let e=t.items[0],n;if(e.logicalOperator===`or`||e.type&&e.type!==`object`)n=I(i.placeholder).attr(W.intersection).call(...o);else{n=o[0];for(let e=1;e<o.length;e++)n=n.attr(W.and).call(o[e])}r.expression=a.call(n)}else r.expression=I(i.placeholder).attr(W.array).call(I(i.placeholder).attr(W.union).call(I.array(...o)))}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=r.expression.attr(W.length).call(I.fromValue(t.minItems)):(t.minItems!==void 0&&(r.expression=r.expression.attr(W.min).call(I.fromValue(t.minItems))),t.maxItems!==void 0&&(r.expression=r.expression.attr(W.max).call(I.fromValue(t.maxItems)))),r},Qs=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(r=I(i.placeholder).attr(W.literal).call(I.literal(t.const)),n.expression=r,n):(r=I(i.placeholder).attr(W.boolean).call(),n.expression=r,n)},$s=({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=I.literal(e.const);a.push(t),o.push(I(i.placeholder).attr(W.literal).call(t))}else if((e.type===`number`||e.type===`integer`)&&typeof e.const==`number`){c=!1;let t=I.literal(e.const);o.push(I(i.placeholder).attr(W.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.literal(e.const);o.push(I(i.placeholder).attr(W.literal).call(t))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=I(i.placeholder).attr(W.enum).call(I.array(...a)):o.length===1?r.expression=o[0]:r.expression=I(i.placeholder).attr(W.union).call(I.array(...o)),s&&(r.expression=I(i.placeholder).attr(W.nullable).call(r.expression)),r):Xs({plugin:e,schema:{type:`unknown`},state:n})},ec=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`}).placeholder).attr(W.never).call(),t},tc=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`}).placeholder).attr(W.null).call(),t},nc=({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=I(i.placeholder).attr(W.literal).call(I.literal(t.const)),n):(n.expression=r?I(i.placeholder).attr(W.coerce).attr(W.bigint).call():I(i.placeholder).attr(W.number).call(),!r&&t.type===`integer`&&(n.expression=I(i.placeholder).attr(W.int).call()),t.exclusiveMinimum===void 0?t.minimum!==void 0&&(n.expression=n.expression.attr(W.gte).call(G({isBigInt:r,value:t.minimum}))):n.expression=n.expression.attr(W.gt).call(G({isBigInt:r,value:t.exclusiveMinimum})),t.exclusiveMaximum===void 0?t.maximum!==void 0&&(n.expression=n.expression.attr(W.lte).call(G({isBigInt:r,value:t.maximum}))):n.expression=n.expression.attr(W.lt).call(G({isBigInt:r,value:t.exclusiveMaximum})),n)};function rc({additional:e,plugin:t,shape:n}){let r=t.referenceSymbol({category:`external`,resource:`zod.z`});return e?I(r.placeholder).attr(W.record).call(I(r.placeholder).attr(W.string).call(),e):I(r.placeholder).attr(W.object).call(n)}const ic=({plugin:e,schema:t,state:n})=>{let r={},i=I.object().pretty(),a=t.required??[];for(let o in t.properties){let s=t.properties[o],c=dc({optional:!a.includes(o),plugin:e,schema:s,state:{...n,path:T([...n.path.value,`properties`,o])}});c.hasLazyExpression&&(r.hasLazyExpression=!0),c.hasLazyExpression?i.getter(o,c.expression.return()):i.prop(o,c.expression)}let o;if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=dc({plugin:e,schema:t.additionalProperties,state:{...n,path:T([...n.path.value,`additionalProperties`])}});i.hasLazyExpression&&(r.hasLazyExpression=!0),o=i.expression}let s={$:I,additional:o,chain:void 0,plugin:e,schema:t,shape:i},c=e.config[`~resolvers`]?.object?.base;return r.expression=c?.(s)??rc(s),r.hasLazyExpression?{...r,typeName:`ZodType`}:r},ac=({chain:e,plugin:t,schema:n})=>{let r=t.referenceSymbol({category:`external`,resource:`zod.z`});switch(n.format){case`date`:return I(r.placeholder).attr(W.iso).attr(W.date).call();case`date-time`:{let e=I.object().$if(t.config.dates.offset,e=>e.prop(`offset`,I.literal(!0))).$if(t.config.dates.local,e=>e.prop(`local`,I.literal(!0)));return I(r.placeholder).attr(W.iso).attr(W.datetime).call(e.hasProps()?e:void 0)}case`email`:return I(r.placeholder).attr(W.email).call();case`ipv4`:return I(r.placeholder).attr(W.ipv4).call();case`ipv6`:return I(r.placeholder).attr(W.ipv6).call();case`time`:return I(r.placeholder).attr(W.iso).attr(W.time).call();case`uri`:return I(r.placeholder).attr(W.url).call();case`uuid`:return I(r.placeholder).attr(W.uuid).call();default:return e}},oc=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});if(typeof t.const==`string`)return r=I(i.placeholder).attr(W.literal).call(I.literal(t.const)),n.expression=r,n;if(r=I(i.placeholder).attr(W.string).call(),t.format){let n={$:I,chain:r,plugin:e,schema:t},i=e.config[`~resolvers`]?.string?.formats?.[t.format];r=i?.(n)??ac(n)}return t.minLength===t.maxLength&&t.minLength!==void 0?r=r.attr(W.length).call(I.literal(t.minLength)):(t.minLength!==void 0&&(r=r.attr(W.min).call(I.literal(t.minLength))),t.maxLength!==void 0&&(r=r.attr(W.max).call(I.literal(t.maxLength)))),t.pattern&&(r=r.attr(W.regex).call(I.regexp(t.pattern))),n.expression=r,n},sc=({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=>I(i.placeholder).attr(W.literal).call(I.fromValue(e)));return r.expression=I(i.placeholder).attr(W.tuple).call(I.array(...e)),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=dc({plugin:e,schema:t,state:{...n,path:T([...n.path.value,`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=I(i.placeholder).attr(W.tuple).call(I.array(...a)),r},cc=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`}).placeholder).attr(W.undefined).call(),t},lc=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`}).placeholder).attr(W.void).call(),t},uc=({schema:e,...t})=>{switch(e.type){case`array`:return Zs({...t,schema:e});case`boolean`:return Qs({...t,schema:e});case`enum`:return $s({...t,schema:e});case`integer`:case`number`:return nc({...t,schema:e});case`never`:return ec({...t,schema:e});case`null`:return tc({...t,schema:e});case`object`:return ic({...t,schema:e});case`string`:return oc({...t,schema:e});case`tuple`:return sc({...t,schema:e});case`undefined`:return cc({...t,schema:e});case`unknown`:return Xs({...t,schema:e});case`void`:return lc({...t,schema:e})}},dc=({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=I(o.placeholder):(i.expression=I(a.placeholder).attr(W.lazy).call(I.func().returns(`any`).do(I(o.placeholder).return())),i.hasLazyExpression=!0,r.hasLazyExpression.value=!0)}else if(n.type){let e=uc({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=i.expression.attr(W.register).call(I(a.placeholder).attr(W.globalRegistry),I.object().pretty().prop(`description`,I.literal(n.description))))}else if(n.items)if(n=x({schema:n}),n.items){let e=n.items.map((e,n)=>dc({plugin:t,schema:e,state:{...r,path:T([...r.path.value,`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I(a.placeholder).attr(W.intersection).call(...e.map(e=>e.expression)):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=i.expression.attr(W.and).call(e.hasLazyExpression?I(a.placeholder).attr(W.lazy).call(I.func().do(e.expression.return())):e.expression)}))}else i.expression=I(a.placeholder).attr(W.union).call(I.array().pretty().elements(...e.map(e=>e.expression)))}else i=dc({plugin:t,schema:n,state:r});else i.expression=uc({plugin:t,schema:{type:`unknown`},state:r}).expression;if(i.expression&&(n.accessScope===`read`&&(i.expression=i.expression.attr(W.readonly).call()),e&&(i.expression=I(a.placeholder).attr(W.optional).call(i.expression),i.typeName=W.ZodOptional),n.default!==void 0)){let e=n.type===`integer`&&n.format===`int64`;i.expression=i.expression.attr(W.default).call(G({isBigInt:e,value:n.default}))}return i},fc=({plugin:e,schema:t,state:n})=>{let r=Sr(n.path.value),i=dc({plugin:e,schema:t,state:n}),a=L(r);us({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:b({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:b({config:e.config.definitions.types.infer,name:a})}):void 0})},pc=({plugin:e})=>{e.registerSymbol({external:ds({plugin:e}),meta:{category:`external`,resource:`zod.z`},name:`z`}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=E({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:fs({getAst:(n,r)=>dc({plugin:e,schema:n,state:E({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:fc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:fc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:fc({plugin:e,schema:t.schema,state:n});break;case`webhook`:ps({getAst:(n,r)=>dc({plugin:e,schema:n,state:E({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},mc={api:new ls,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Ys(e);case`mini`:return js(e);case 4:default:return pc(e)}},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(`🔌 ${a.yellow(`Warning:`)} Installed ${a.cyan(`zod`)} ${a.cyan(`v${n.version}`)} does not support compatibility version ${a.yellow(String(e))}, using ${a.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:v,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:{...v,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:v,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:{...v,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:v,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:{...v,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:v,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:{...v,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:v,value:e.infer})})},value:e.types})})},value:e.config.webhooks})},tags:[`validator`]},hc={"@angular/common":Yr,"@hey-api/client-angular":di,"@hey-api/client-axios":fi,"@hey-api/client-fetch":pi,"@hey-api/client-ky":mi,"@hey-api/client-next":hi,"@hey-api/client-nuxt":gi,"@hey-api/client-ofetch":_i,"@hey-api/schemas":Ai,"@hey-api/sdk":zi,"@hey-api/transformers":Ji,"@hey-api/typescript":ba,"@pinia/colada":Ia,"@tanstack/angular-query-experimental":to,"@tanstack/react-query":no,"@tanstack/solid-query":ro,"@tanstack/svelte-query":io,"@tanstack/vue-query":ao,arktype:vo,fastify:bo,swr:Co,valibot:$o,zod:mc},gc=[`@hey-api/typescript`,`@hey-api/sdk`],_c=({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=hc[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:yi(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=hc[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=hc[i]||n[i];if(t&&t.tags?.includes(e)&&i!==s)return i}throw Error(a||`missing plugin - no plugin with tag "${e}" found`)},valueToObject:_};u.resolveConfig(u,r)}for(let e of u.dependencies)o(e);r.delete(s),i.add(s),a[s]=u};for(let e of t)o(e);return{pluginOrder:Array.from(i),plugins:a}},vc=e=>typeof e==`string`?e.startsWith(`@hey-api/client`):e.name.startsWith(`@hey-api/client`)||e.tags&&e.tags.includes(`client`),yc=({dependencies:e,userConfig:t})=>{let n={},r=gc;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&vc(t.plugins[0])?[...gc,...t.plugins]:t.plugins),_c({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})},bc=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),xc=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 o=e.timeEvent(`c12`),{loadConfig:s}=await import(`c12`),{config:c,configFile:l}=await s({configFile:t,name:`openapi-ts`});o.timeEnd(),Object.keys(r).length||(r=ze(Object.keys(c).length?l:void 0));let u=c instanceof Array?c.map(e=>Fe(e,i)):[Fe(c,i)];for(let e of u){let t=Me(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${a.yellow(`Warning:`)} You provided ${a.cyan(String(r))} ${a.cyan(r===1?`input`:`inputs`)} and ${a.yellow(String(i))} ${a.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 o=[],c=e.timeEvent(`build`);for(let e of n){let t=Ne(e),n=Me(e),i=Re(e),c=Ve(e),l=[];n.length||l.push(new oe(`missing input - which OpenAPI specification should we use to generate your output?`)),i.path||l.push(new oe(`missing output - where should we generate your output?`)),i.path=s.resolve(process.cwd(),i.path);let u;try{u=yc({dependencies:r,userConfig:e})}catch(e){l.push(e),u={pluginOrder:[],plugins:{}}}let d={configFile:e.configFile??``,dryRun:e.dryRun??!1,input:n,interactive:e.interactive??bc(),logs:t,output:i,parser:c,pluginOrder:u.pluginOrder,plugins:u.plugins},f=o.length;if(t.level===`debug`){let e=a.gray(`[Job ${f+1}] `);console.warn(`${e}${a.cyan(`config:`)}`,d)}o.push({config:d,errors:l,jobIndex:f})}return c.timeEnd(),{dependencies:r,results:o}};Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`});const Sc=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Cc=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},wc=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},Tc=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(Cc(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=Sc(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):Ec({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},Ec=({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)}`},Dc=({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=wc(r),s=Object.entries(i).map(([t,i])=>Ec({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},Oc=({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=Tc({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=Dc({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=Ec({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},kc=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},Ac=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?kc(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};Oc({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}});const jc=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=f({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await p({fetchOptions:{method:`HEAD`,...e,headers:Ac(e?.headers,r.headers)},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok&&r.isHeadMethodSupported)return{error:`not-ok`,response:s};if(r.isHeadMethodSupported===void 0&&(r.isHeadMethodSupported=s.ok),s.status===304)return{error:`not-modified`,response:s};if(o===void 0){let e=s.headers.get(`ETag`);e&&(o=e!==r.headers.get(`If-None-Match`),o&&r.headers.set(`If-None-Match`,e))}if(o===void 0){let e=s.headers.get(`Last-Modified`);e&&(o=e!==r.headers.get(`If-Modified-Since`),o&&r.headers.set(`If-Modified-Since`,e))}if(o===!1)return{error:`not-modified`,response:s}}try{let t=await p({fetchOptions:{method:`GET`,...e},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok)return{error:`not-ok`,response:s};if(a=s.body?await s.arrayBuffer():new ArrayBuffer(0),o===void 0){let e=new TextDecoder().decode(a);o=e!==r.lastValue,r.lastValue=e}}else r.lastValue?o=!1:r.lastValue=i.type;return o===!1?{error:`not-modified`,response:s}:{arrayBuffer:a,resolvedInput:i}},Mc=l.createPrinter({newLine:l.NewLineKind.LineFeed,removeComments:!1}),Nc=(e=>l.createSourceFile(``,e,l.ScriptTarget.ESNext,!1,l.ScriptKind.TS))(``),Pc=e=>e.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)));function Fc(e){let t=Mc.printNode(l.EmitHint.Unspecified,e,Nc);try{return Pc(t)}catch{return t}}const Ic=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 Lc=class{renderFile(e,t,n,r){let a=new Map;if(e=i(e,e=>{let i=n.symbols.get(e),o=this.replacerFn({file:t,project:n,symbol:i});return i&&this.addBinding({bindings:a,file:t,meta:r,project:n,symbol:i}),o}),!e.length)return``;let o=``,s=this.getHeaderLines();o+=`${s.join(`
6
- `)}${s.length?`
7
-
8
- `:``}`;let c=this.getImportLines(a,t,n);return o+=`${c.join(`
9
- `)}${c.length?`
10
-
11
- `:``}`,`${o}${e}`}renderSymbols(e,t,n){let r=new Map,a=``,o=this.getBodyLines(e,t);a+=`${o.join(`
12
-
13
- `)}${o.length?`
14
- `:``}`,a=i(a,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 s=this.getExportLines(r,e,t);return a+=`${s.join(`
15
- `)}${s.length?`
16
- `:``}`,a}addBinding({bindings:e,file:t,meta:i,project:a,symbol:o}){if(!o.external&&!a.symbols.hasValue(o.id))return;let[s]=a.symbolIdToFiles(o.id);if(!s||t===s)return;let c=this.getBindingPath(t,s,i),l=e.get(c),u=n({file:t,modulePath:c,symbol:o,symbolFile:s});l?(r(l,u),e.set(c,l)):e.set(c,u)}getBindingPath(e,t,n){if(!e.path||!t.path)return``;if(t.external&&!s.isAbsolute(t.path))return t.path;let r=s.posix.relative(s.posix.dirname(e.path.split(s.sep).join(s.posix.sep)),t.path.split(s.sep).join(s.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}getBodyLine(e,t){if(e instanceof D){let n=e.$render();t.push(Fc(n))}else if(typeof e==`string`)t.push(e);else if(e instanceof Array)for(let n of e)this.getBodyLine(n,t);else e!=null&&t.push(Fc(e))}getBodyLines(e,t){let n=[];for(let r of e.symbols.body)this.getBodyLine(t.symbols.getValue(r),n);return n}getExportLines(e,t,n){let r=[];for(let[a,o]of e.entries()){let e=[],s,c=!1;if(o.namespaceBinding!==void 0)typeof o.namespaceBinding==`string`&&(s=i(o.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})})),o.typeNamespaceBinding&&(c=!0);else if(o.names&&o.names.length>0){o.names.every(e=>(o.typeNames??[]).includes(e))&&(c=!0);for(let r of o.names){let a=o.aliases?.[r],s=r,u;a&&a!==s&&(u=s,s=a),s=i(s,e=>{let r=n.symbols.get(e),i=this.replacerFn({file:t,project:n,symbol:r}),[a]=n.symbolIdToFiles(e),o=a?a.resolvedNames.get(e):void 0;return o&&o!==i&&(u||=o),i}),u&&(u=i(u,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),u===s&&(u=void 0));let d=l.factory.createExportSpecifier(c?!1:o.typeNames?.includes(r)??!1,u?I.id(u).$render():void 0,I.id(s).$render());e.push(d)}}let u=s?l.factory.createNamespaceExport(I.id(s).$render()):e.length?l.factory.createNamedExports(e):void 0,d=l.factory.createExportDeclaration(void 0,c,u,I.literal(a).$render());r.push(Fc(d))}return r}getHeaderLines(){return[`// This file is auto-generated by @hey-api/openapi-ts`]}getImportLines(e,t,n){let r=[],a=-1,o=e=>{let t=e.from;return t.startsWith(`.`)?t.startsWith(`./`)?[2,0,t]:[2,t.match(/\.\.\//g)?.length??0,t]:Ic.has(t.split(`/`)[0])?[0,0,t]:[1,0,t]},s=Array.from(e.values()).map(e=>({...e,k:o(e)})).sort((e,t)=>e.k[0]-t.k[0]||e.k[1]-t.k[1]||e.k[2].localeCompare(t.k[2]));for(let e of s){let o=[],s,c,u=!1;if(e.defaultBinding){let r=i(e.defaultBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})});s=I.id(r).$render(),e.typeDefaultBinding&&(u=!0)}else if(typeof e.namespaceBinding==`string`)c=i(e.namespaceBinding,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),e.typeNamespaceBinding&&(u=!0);else if(e.names&&e.names.length>0){e.names.every(t=>e.typeNames?.includes(t))&&(u=!0);let r=[];for(let a of e.names){let o=e.aliases?.[a],s=a,c;o&&o!==s&&(c=s,s=o),s=i(s,e=>{let r=n.symbols.get(e),i=this.replacerFn({file:t,project:n,symbol:r}),[a]=n.symbolIdToFiles(e),o=a?a.resolvedNames.get(e):void 0;return o&&o!==i&&(c||=o),i}),c&&(c=i(c,e=>{let r=n.symbols.get(e);return this.replacerFn({file:t,project:n,symbol:r})}),c===s&&(c=void 0)),r.push({isTypeOnly:u?!1:e.typeNames?.includes(a)??!1,name:s,propertyName:c?I.id(c).$render():void 0})}o=r.sort((e,t)=>e.name.localeCompare(t.name)).map(({isTypeOnly:e,name:t,propertyName:n})=>l.factory.createImportSpecifier(e,n,I.id(t).$render()))}let d=l.factory.createImportClause(u,s,c?l.factory.createNamespaceImport(I.id(c).$render()):o.length?l.factory.createNamedImports(o):void 0),f=l.factory.createImportDeclaration(void 0,d,I.literal(e.from).$render());a!==-1&&e.k[0]!==a&&r.push(``),r.push(Fc(f)),a=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=xi(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}},Rc=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 zc=(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))},Bc=(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 Rc(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))},Vc=(e,t,n)=>n?.order===`topological`?Bc(e,t,n):zc(e,t,n),Hc=[`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`],Uc=(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}},Wc=[`server`,`schema`,`parameter`,`requestBody`,`operation`,`webhook`],Gc=(()=>{let e={};for(let t=0;t<Wc.length;t++){let n=Wc[t];n&&(e[n]=t)}for(let t of Hc)e[t]===void 0&&(e[t]=Wc.length);return e})(),Kc=e=>{let t=Uc(e);return t.matched?Gc[t.kind]??10:10},qc=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},Jc=e=>{switch(e.method){case`delete`:case`patch`:case`post`:case`put`:return[`mutation`];case`get`:return[`query`];default:return}};var Yc=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:Kc,matchPointerToGroup:Uc,order:`topological`,preferGroups:Wc};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:Hc);Vc(this.context.graph,(e,n)=>{let r=Uc(e);if(!r.matched||!i.has(r.kind))return;let a,o={_path:br(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:s.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 le({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 qc(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,Jc];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}},Xc=class{config;gen;graph;ir={};logger;package;plugins={};spec;constructor({config:e,dependencies:n,logger:r,spec:i}){this.config=e,this.gen=new t({defaultFileName:`index`,fileName:t=>{let n=b({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 Lc},root:e.output.path}),this.logger=r,this.package=yi(n),this.spec=i}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 Yc({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 Cr({$ref:e,spec:this.ir})}resolveRef(e){return Cr({$ref:e,spec:this.spec})}};const Zc=[`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`],Qc=({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)?y({case:c,value:at(n)}):y({case:c,value:`${r}-${i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`)}`}),t>1&&(o=`${o}${t}`),a.ids.has(o)?Qc({context:e,count:t+1,id:n,method:r,path:i,state:a}):(a.ids.set(o,C({method:r,path:i})),o)},K=(e,t=``)=>`${e}/${t}`,q=e=>{let t=e.indexOf(`/`);return{name:e.slice(t+1),namespace:e.slice(0,t)}},$c=e=>{switch(e){case`parameters`:return`parameter`;case`requestBodies`:return`body`;case`responses`:return`response`;case`definitions`:case`schemas`:return`schema`;default:return`unknown`}},J=(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(K(e,i));return{regexps:r,set:new Set(n)}},el=({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 Zc){if(!i[t])continue;let a=C({method:t,path:r});e.regexps.some(e=>e.test(a))&&e.set.add(K(`operation`,a)),n.regexps.some(e=>e.test(a))&&n.set.add(K(`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(K(`schema`,e)),r.regexps.some(t=>t.test(e))&&r.set.add(K(`schema`,e))},tl=({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 Zc){if(!r[t])continue;let i=C({method:t,path:n});e.regexps.some(e=>e.test(i))&&e.set.add(K(`operation`,i)),a.regexps.some(e=>e.test(i))&&a.set.add(K(`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(K(`parameter`,e)),o.regexps.some(t=>t.test(e))&&o.set.add(K(`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(K(`body`,e)),s.regexps.some(t=>t.test(e))&&s.set.add(K(`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(K(`response`,e)),c.regexps.some(t=>t.test(e))&&c.set.add(K(`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(K(`schema`,e)),l.regexps.some(t=>t.test(e))&&l.set.add(K(`schema`,e))}},nl=({spec:e,...t})=>{`swagger`in e?el({...t,spec:e}):tl({...t,spec:e})},rl=(e,t,n)=>{let r=n.timeEvent(`create-filters`),i=J(`operation`,e?.operations?.exclude),a=J(`operation`,e?.operations?.include),o=J(`parameter`,e?.parameters?.exclude),s=J(`parameter`,e?.parameters?.include),c=J(`body`,e?.requestBodies?.exclude),l=J(`body`,e?.requestBodies?.include),u=J(`response`,e?.responses?.exclude),d=J(`response`,e?.responses?.include),f=J(`schema`,e?.schemas?.exclude),p=J(`schema`,e?.schemas?.include);nl({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},il=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,al=({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}=q(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}},ol=({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}=q(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}},sl=({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}=q(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}},cl=({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}=q(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}},ll=({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}=q(t);switch(i){case`schema`:!n.has(t)&&!e.schemas.exclude.has(t)&&r.push(t);break}}}return{schemas:n}},ul=({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}}}},dl=({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}}}},fl=({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}}}},pl=({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}}}},ml=({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)},hl=({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}=q(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}},gl=({filters:e,logger:t,resourceMetadata:n})=>{let r=t.timeEvent(`create-filtered-dependencies`),{schemas:i}=ll({filters:e,resourceMetadata:n}),{parameters:a}=ol({filters:e,resourceMetadata:n,schemas:i}),{requestBodies:o}=sl({filters:e,resourceMetadata:n,schemas:i}),{responses:s}=cl({filters:e,resourceMetadata:n,schemas:i});pl({filters:e,resourceMetadata:n,schemas:i}),ul({filters:e,parameters:a,resourceMetadata:n}),dl({filters:e,requestBodies:o,resourceMetadata:n}),fl({filters:e,resourceMetadata:n,responses:s});let{operations:c}=al({filters:e,parameters:a,requestBodies:o,resourceMetadata:n,responses:s,schemas:i});if(!e.orphans&&c.size){let{operationDependencies:e}=hl({operations:c,resourceMetadata:n});ml({operationDependencies:e,parameters:a,requestBodies:o,responses:s,schemas:i})}return r.timeEnd(),{operations:c,parameters:a,requestBodies:o,responses:s,schemas:i}},_l=(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=br(e),r=t[t.length-2],i=t[t.length-1];if(r&&i){let e=$c(r);e===`unknown`&&console.warn(`unsupported type: ${r}`),n.add(K(e,i))}}return n};for(let[t,n]of e.nodes){let e=br(t);if(e[0]===`components`){if(e.length===3){if(e[1]===`schemas`){let a=e[e.length-1];r.schemas.set(K(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`parameters`){let a=e[e.length-1];r.parameters.set(K(`parameter`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`requestBodies`){let a=e[e.length-1];r.requestBodies.set(K(`body`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}else if(e[1]===`responses`){let a=e[e.length-1];r.responses.set(K(`response`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}}continue}if(e[0]===`paths`){if(e.length===3&&Zc.includes(e[2])){let a=e[e.length-1],o=C({method:a,path:e.slice(1,-1).join(`/`)});r.operations.set(K(`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(K(`schema`,a),{dependencies:i(t),deprecated:n.deprecated??!1})}continue}}return n.timeEnd(),{resourceMetadata:r}},vl=e=>JSON.parse(JSON.stringify(e)),yl=[[`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`]],bl=e=>{if(xl(e))return e.components.schemas;if(Sl(e))return e.definitions},xl=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,Sl=e=>typeof e==`object`&&!!e&&`definitions`in e&&typeof e.definitions==`object`&&e.definitions!==null,Cl=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,wl=({base:e,components:t,extraComponents:n})=>{let r=2,i=e;for(;Cl(t,i)||n&&Cl(n,i);)i=`${e}${r}`,r+=1;return i},Tl=e=>e.length===3&&e[0]===`components`&&e[1]===`schemas`||e.length===2&&e[0]===`definitions`,El=e=>{if(e&&typeof e==`object`){if(`swagger`in e)return`#/definitions/`;if(`openapi`in e)return`#/components/schemas/`}return``},Dl=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})},Ol=({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||yl.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)=>Ol({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):Ol({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},kl=({spec:e})=>{let t=bl(e);if(!t)return;let n=El(e),r={};for(let[e,i]of Object.entries(t))Dl(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,vl(r[n])),delete e.$ref):i(n)};i(e);for(let e of Object.keys(r)){let n=br(e),r=n[n.length-1];r&&delete t[r]}},Al=({config:e,spec:t})=>{let n=bl(t);if(!n)return;let r={};for(let[e,t]of Object.entries(n)){let n=Dl(t);n&&(r[n]=e)}let i=[];Ol({key:null,node:t,parent:null,path:[],visitor:e=>{if(!Tl(e.path)){let t=Dl(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]=wl({base:b({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=El(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}`})}},jl=({config:e,spec:t})=>{if(e.mode===`inline`){kl({spec:t});return}if(e.mode===`root`){Al({config:e,spec:t});return}},Ml=({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||yl.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)=>Ml({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):Ml({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},Nl=({spec:e})=>{Ml({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)}}})},Pl=(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(!Pl(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(!Pl(r[e],i[e]))return!1;return!0};var Fl=Pl;const Il=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))}},Ll=({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=Ll({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=Ll({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}},Rl=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&&zl(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 yl){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&&zl(r,a)&&n(i,a)}if(a.parentPointer){let t=e.nodes.get(a.parentPointer);t&&zl(a,t)&&n(a.parentPointer,t)}}},zl=(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},Bl=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`])))}},Vl=(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=Sr(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=xr(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);Bl(r.nodes),Rl(r),Il(r.nodes);for(let e of r.nodes.keys()){let t=Ll({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}},Hl=new Set([`additionalProperties`,`allOf`,`anyOf`,`items`,`not`,`oneOf`,`patternProperties`,`properties`,`schema`]),Ul=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`}},Wl=(e,t)=>{let n=t.timeEvent(`capture-original-schemas`),r={};if(xl(e))for(let[t,n]of Object.entries(e.components.schemas))r[`#/components/schemas/${t}`]=n;else if(Sl(e))for(let[t,n]of Object.entries(e.definitions))r[`#/definitions/${t}`]=n;return n.timeEnd(),r},Gl=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`insert-split-schemas-into-spec`);xl(t)?Object.assign(t.components.schemas,n.schemas):Sl(t)&&Object.assign(t.definitions,n.schemas),r.timeEnd()},Kl=(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,!yl.some(([e])=>e in t)))return!0}for(let[r,i]of yl){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||Kl(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||Kl(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||Kl(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||Kl(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else typeof a==`object`&&a&&(a[n]===!0||Kl(e,a,n))&&delete t[r]}if(t.type===`object`&&!yl.some(([e])=>e in t))return!0}return!1},ql=({logger:e,originalSchemas:t,spec:n,split:r})=>{let i=e.timeEvent(`remove-original-split-schemas`),a=bl(n);for(let e of Object.keys(r.mapping)){let n=br(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()},Jl=({config:e,graph:t,logger:n,spec:r})=>{let i=n.timeEvent(`split-schemas`),a=new Set,o={mapping:{},reverseMapping:{},schemas:{}},s=El(r),c=s.split(`/`).length-1,l=e=>{if(e.startsWith(s)){let t=br(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=vl(r.node);Kl(t,c,`writeOnly`);let u=b({config:e.responses,name:i}),d=u===i?u:wl({base:u,components:a});a.add(d),o.schemas[d]=c;let f=`${s}${d}`,p=vl(r.node);Kl(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`))})&&Fl(c,p)&&Fl(c,r.node))continue;let h=b({config:e.requests,name:i}),g=h===i&&h!==d?h:wl({base:h,components:a});a.add(g),o.schemas[g]=p;let ee=`${s}${g}`;o.mapping[n]={read:f,write:ee},o.reverseMapping[f]=n,o.reverseMapping[ee]=n}return i.timeEnd(),o},Yl=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`update-refs-in-spec`),i=El(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(Tl(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=Ul(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(Hl.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()},Xl=({config:e,logger:t,spec:n})=>{let{graph:r}=Vl(n,t),i=Wl(n,t),a=Jl({config:e,graph:r,logger:t,spec:n});Gl({logger:t,spec:n,split:a}),Yl({logger:t,spec:n,split:a}),ql({logger:t,originalSchemas:i,spec:n,split:a})},Zl=({context:e})=>{let{logger:t}=e,n=t.timeEvent(`transform-openapi-spec`);e.config.parser.transforms.enums.enabled&&jl({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&Nl({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&Xl({config:e.config.parser.transforms.readWrite,logger:t,spec:e.spec}),n.timeEnd()},Y=({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},Ql=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),$l=e=>e.map((e,t)=>typeof e==`number`?`[${e}]`:t===0?e:Ql(e)?`.${e}`:`['${e.replace(/"/g,`\\'`)}']`).join(``),eu=e=>{let t=$l(e.path),n=e.severity===`error`?a.bold.red:a.bold.yellow,r=e.message.replace(/`([^`]+)`/g,(e,t)=>a.yellow(`\`${t}\``));return`${n(`[${e.severity.toUpperCase()}]`)} ${a.cyan(t)}: ${r}`},tu=({context:e,issue:t})=>e.config.logs.level===`silent`?!1:t.severity===`error`?e.config.logs.level!==`warn`:!0,nu=({context:e,result:t})=>{for(let n of t.issues)tu({context:e,issue:n})&&console.log(eu(n));t.valid||process.exit(1)},ru=({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(K(`schema`,t))&&(e[t]=n);else for(let t of r){let{name:n}=q(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 Zc){if(!r[e])continue;let i=K(`operation`,C({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete i.paths[n]}a.timeEnd()},iu=/^(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,au=/^application\/(.*\+)?json(;.*)?$/i,ou=/^multipart\/form-data(;.*)?$/i,su=/^text\/[a-z0-9.+-]+(;.*)?$/i,cu=/^application\/x-www-form-urlencoded(;.*)?$/i,lu=/^application\/octet-stream(;.*)?$/i,uu=({mediaType:e})=>(iu.lastIndex=0,iu.test(e)),du=({mediaType:e})=>{if(au.lastIndex=0,au.test(e))return`json`;if(ou.lastIndex=0,ou.test(e))return`form-data`;if(su.lastIndex=0,su.test(e))return`text`;if(cu.lastIndex=0,cu.test(e))return`url-search-params`;if(lu.lastIndex=0,lu.test(e))return`octet-stream`},fu=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&uu({mediaType:t})?{...n,format:`binary`}:n:uu({mediaType:t})?{format:`binary`,type:`string`}:void 0},pu=({mimeTypes:e,response:t})=>{let n=[];for(let r of e??[])n.push({mediaType:r,schema:t.schema,type:du({mediaType:r})});return n};function mu(e){let t=`^(${e.keywords.join(`|`)})$`;return new RegExp(t)}const hu=(e,t,n)=>{let r=[];for(let n in t)t[n]===e&&r.push(n);return!r.length&&(!n||n())?[L(e)]:r},gu=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},_u=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},vu=({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`)},yu=({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=X({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=S({items:i,schema:t}),t},bu=({irSchema:e={}})=>(e.type=`boolean`,e),xu=({irSchema:e={},schema:t})=>(e.type=t.type,e),Su=({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]=X({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=X({context:e,schema:n.additionalProperties,state:r}),n.required&&(t.required=n.required),t},Cu=({irSchema:e={}})=>(e.type=`string`,e),wu=({schema:e})=>{let t={};return _u({irSchema:t,schema:e}),t},Tu=({context:e,schema:t,state:n})=>{let r=wu({schema:t}),i=[],a=gu({schema:t}),o=t.allOf;for(let r of o){let a=n.inAllOf;`$ref`in r||(n.inAllOf=!0);let o=X({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=hu(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=Au({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(gu({schema:a})===`object`){let i=Au({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=S({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},Eu=({context:e,schema:t,state:n})=>{let r=wu({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=Au({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=S({items:i,schema:r}),r},Du=({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=X({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,X({context:e,schema:r,state:n}),n.$ref=i}return r},Ou=({context:e,irSchema:t,schema:n,state:r})=>{t||=wu({schema:n});let i={};return vu({irSchema:i,schema:n}),i.default===null&&delete i.default,t=S({items:[Au({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},ku=({context:e,schema:t,state:n})=>{let r=wu({schema:t});vu({irSchema:r,schema:t});let i=gu({schema:t});return i?t[`x-nullable`]?Ou({context:e,irSchema:r,schema:{...t,type:i},state:n}):Au({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},Au=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=wu({schema:n}),vu({irSchema:t,schema:n})),n.type){case`array`:return yu({context:e,irSchema:t,schema:n,state:r});case`boolean`:return bu({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return xu({context:e,irSchema:t,schema:n,state:r});case`object`:return Su({context:e,irSchema:t,schema:n,state:r});case`string`:return Cu({context:e,irSchema:t,schema:n,state:r});default:return ju({context:e,irSchema:t,schema:n})}},ju=({irSchema:e,schema:t})=>(e||=wu({schema:t}),e.type=`unknown`,vu({irSchema:e,schema:t}),e),X=({context:e,schema:t,state:n})=>(n||={circularReferenceTracker:new Set},n.$ref&&n.circularReferenceTracker.add(n.$ref),t.$ref?Du({context:e,schema:t,state:n}):t.enum?Eu({context:e,schema:t,state:n}):t.allOf?Tu({context:e,schema:t,state:n}):t.type||t.properties?ku({context:e,schema:t,state:n}):ju({context:e,schema:t})),Mu=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[L(e)]=X({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Nu=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,Pu=({context:e,name:t,schema:n})=>{if(mu(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref??``);return`in`in r&&r.in?Pu({context:e,name:t,schema:`schema`in r?r.schema:{...r,in:void 0}}):Pu({context:e,name:t,schema:r})}if(`in`in n)return n.in?Pu({context:e,name:t,schema:`schema`in n?n.schema:{...n,in:void 0}}):!1;for(let t in n.properties)if(mu(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&Nu(gu({schema:e})))return t}for(let r of n.allOf??[]){let n=Pu({context:e,name:t,schema:r});if(n)return n}return!1},Fu=({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)},Iu=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:Qc({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Fu({irOperation:a,operation:n}),a},Lu=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Iu({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=pu({mimeTypes:a,response:{schema:i}}),d=o.find(e=>e.type===`json`)||o[0];if(d){let t=Pu({context:e,name:``,schema:d.schema&&`$ref`in d.schema?{allOf:[{...d.schema}],description:r.description}:{description:r.description,...d.schema}}),n=X({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=pu({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:X({context:e,schema:{description:i.description,...fu({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},Ru=({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]=Lu({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},zu=e=>{switch(e){case`multi`:return!0;case`csv`:case`pipes`:case`ssv`:case`tsv`:default:return!1}},Bu=e=>{switch(e){case`header`:case`path`:return`simple`;case`query`:default:return`form`}},Vu=({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()]=Hu({$ref:`#/todo/real/path/to/parameter/${n.name}`,context:e,parameter:n})}return r},Hu=({$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=Pu({context:t,name:n.name,schema:i}),o=Bu(n.in),s={allowReserved:!1,explode:zu(n.collectionFormat),location:n.in,name:n.name,schema:X({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},Uu=({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=oi(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})))},Wu=(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 Zc){if(t===`trace`)continue;let a=n[t];if(!a)continue;let o=C({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`)}},Gu=e=>{if(e.config.parser.validate_EXPERIMENTAL&&nu({context:e,result:Wu(e.spec,e.logger)}),il(e.config.parser.filters)){let t=rl(e.config.parser.filters,e.spec,e.logger),{graph:n}=Vl(e.spec,e.logger),{resourceMetadata:r}=_l(n,e.logger);ru({...gl({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Zl({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];Mu({$ref:n,context:e,schema:r})}for(let r in Uu({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:Vu({context:e,operation:o,parameters:a.parameters})},path:r,securitySchemesMap:n,state:t};if(a.delete){let t=Y({source:Vu({context:e,operation:a.delete,parameters:a.delete.parameters}),target:s.operation.parameters});Ru({...s,method:`delete`,operation:{...s.operation,...a.delete,parameters:t}})}if(a.get){let t=Y({source:Vu({context:e,operation:a.get,parameters:a.get.parameters}),target:s.operation.parameters});Ru({...s,method:`get`,operation:{...s.operation,...a.get,parameters:t}})}if(a.head){let t=Y({source:Vu({context:e,operation:a.head,parameters:a.head.parameters}),target:s.operation.parameters});Ru({...s,method:`head`,operation:{...s.operation,...a.head,parameters:t}})}if(a.options){let t=Y({source:Vu({context:e,operation:a.options,parameters:a.options.parameters}),target:s.operation.parameters});Ru({...s,method:`options`,operation:{...s.operation,...a.options,parameters:t}})}if(a.patch){let t=Y({source:Vu({context:e,operation:a.patch,parameters:a.patch.parameters}),target:s.operation.parameters});Ru({...s,method:`patch`,operation:{...s.operation,...a.patch,parameters:t}})}if(a.post){let t=Y({source:Vu({context:e,operation:a.post,parameters:a.post.parameters}),target:s.operation.parameters});Ru({...s,method:`post`,operation:{...s.operation,...a.post,parameters:t}})}if(a.put){let t=Y({source:Vu({context:e,operation:a.put,parameters:a.put.parameters}),target:s.operation.parameters});Ru({...s,method:`put`,operation:{...s.operation,...a.put,parameters:t}})}}},Ku=({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(K(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=q(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(K(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=q(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(K(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=q(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(K(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=q(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 Zc){if(!r[e])continue;let i=K(`operation`,C({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},qu=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&uu({mediaType:t})?{...n,format:`binary`}:n:uu({mediaType:t})?{format:`binary`,type:`string`}:void 0},Ju=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:du({mediaType:n})});return t},Yu=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},Xu=({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)},Zu=({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`)},Qu=({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=S({items:i,schema:t}),t},$u=({irSchema:e={}})=>(e.type=`boolean`,e),ed=({irSchema:e={},schema:t})=>(e.type=t.type,e),td=({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},nd=({irSchema:e={}})=>(e.type=`string`,e),rd=({schema:e})=>{let t={};return Xu({irSchema:t,schema:e}),t},id=({context:e,schema:t,state:n})=>{let r=rd({schema:t}),i=[],a=Yu({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=hu(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=dd({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(Yu({schema:a})===`object`){let i=dd({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=S({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},ad=({context:e,schema:t,state:n})=>{let r=rd({schema:t}),i=[],a=Yu({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=hu(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=S({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=dd({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},od=({context:e,schema:t,state:n})=>{let r=rd({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=dd({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=S({items:i,schema:r}),r},sd=({context:e,schema:t,state:n})=>{let r=rd({schema:t}),i=[],a=Yu({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=hu(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=S({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=dd({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},cd=({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},ld=({context:e,irSchema:t,schema:n,state:r})=>{t||=rd({schema:n});let i={};return Zu({irSchema:i,schema:n}),i.default===null&&delete i.default,t=S({items:[dd({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},ud=({context:e,schema:t,state:n})=>{let r=rd({schema:t});Zu({irSchema:r,schema:t});let i=Yu({schema:t});return i?t.nullable?ld({context:e,irSchema:r,schema:{...t,type:i},state:n}):dd({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},dd=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=rd({schema:n}),Zu({irSchema:t,schema:n})),n.type){case`array`:return Qu({context:e,irSchema:t,schema:n,state:r});case`boolean`:return $u({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return ed({context:e,irSchema:t,schema:n,state:r});case`object`:return td({context:e,irSchema:t,schema:n,state:r});case`string`:return nd({context:e,irSchema:t,schema:n,state:r});default:return fd({context:e,irSchema:t,schema:n})}},fd=({irSchema:e,schema:t})=>(e||=rd({schema:t}),e.type=`unknown`,Zu({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?cd({context:e,schema:t,state:n}):t.enum?od({context:e,schema:t,state:n}):t.allOf?id({context:e,schema:t,state:n}):t.anyOf?ad({context:e,schema:t,state:n}):t.oneOf?sd({context:e,schema:t,state:n}):t.type||t.properties?ud({context:e,schema:t,state:n}):fd({context:e,schema:t})),pd=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[L(e)]=Z({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},md=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,hd=({context:e,name:t,schema:n})=>{if(mu(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=Ju({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?hd({context:e,name:t,schema:n}):!1}return hd({context:e,name:t,schema:r})}for(let t in n.properties)if(mu(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&md(Yu({schema:e})))return t}for(let r of n.allOf??[]){let n=hd({context:e,name:t,schema:r});if(n)return n}return!1},gd=({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)},_d=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:Qc({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),gd({irOperation:a,operation:n}),a},vd=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=_d({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=Ju({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=hd({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=Ju({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,...qu({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},yd=({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]=vd({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},bd=e=>{switch(e){case`query`:return!1;default:return}},xd=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},Sd=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},Cd=({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()]=wd({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},wd=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=Ju({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=hd({context:t,name:n.name,schema:i}),o=n.style||Sd(n.in),s=n.explode===void 0?xd(o):n.explode,c={allowReserved:n.allowReserved===void 0?bd(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},Td=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[L(e)]=wd({$ref:e,context:t,parameter:n})},Ed=({$ref:e,context:t,requestBody:n})=>{let r=Ju({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},Dd=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[L(e)]=Ed({$ref:e,context:t,requestBody:n})},Od=({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=oi(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},kd=(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 Zc){let a=n[t];if(!a)continue;let o=C({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`)}},Ad=e=>{if(e.config.parser.validate_EXPERIMENTAL&&nu({context:e,result:kd(e.spec,e.logger)}),il(e.config.parser.filters)){let t=rl(e.config.parser.filters,e.spec,e.logger),{graph:n}=Vl(e.spec,e.logger),{resourceMetadata:r}=_l(n,e.logger);Ku({...gl({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Zl({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];Td({$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];Dd({$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];pd({$ref:n,context:e,schema:r})}}for(let r in Od({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:Cd({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&yd({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:Cd({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&yd({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:Cd({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&yd({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:Cd({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&yd({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:Cd({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&yd({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:Cd({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&yd({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:Cd({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&yd({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:Cd({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&yd({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:Cd({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},jd=({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(K(`parameter`,t))&&(e[t]=r);else for(let t of n){let{name:n}=q(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(K(`body`,t))&&(e[t]=n);else for(let t of i){let{name:n}=q(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(K(`response`,t))&&(e[t]=n);else for(let t of a){let{name:n}=q(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(K(`schema`,t))&&(e[t]=n);else for(let t of o){let{name:n}=q(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 Zc){if(!r[e])continue;let i=K(`operation`,C({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},Md=({content:e})=>{let{mediaType:t,schema:n}=e;return n?n.type===`string`&&!n.format&&uu({mediaType:t})?{...n,format:`binary`}:n:uu({mediaType:t})?{format:`binary`,type:`string`}:void 0},Nd=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:du({mediaType:n})});return t},Pd=({schema:e})=>typeof e.type==`string`?[e.type]:e.type?e.type:e.properties?[`object`]:[],Fd=({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)},Id=({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`)},Ld=({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&&!Pd({schema:n.items}).includes(`null`)?t={...t,...a}:i.push(a)}}return t=S({items:i,schema:t}),t},Rd=({irSchema:e={}})=>(e.type=`boolean`,e),zd=({irSchema:e={}})=>(e.type=`null`,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]=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},Hd=({irSchema:e={}})=>(e.type=`string`,e),Ud=({schema:e})=>{let t={};return Fd({irSchema:t,schema:e}),t},Wd=({context:e,schema:t,state:n})=>{let r=Ud({schema:t});Id({irSchema:r,schema:t});let i=[],a=Pd({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=hu(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=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(Pd({schema:a}).includes(`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=S({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},Gd=({context:e,schema:t,state:n})=>{let r=Ud({schema:t});Id({irSchema:r,schema:t});let i=[],a=Pd({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=hu(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=S({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=Yd({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Kd=({context:e,schema:t,state:n})=>{let r=Ud({schema:t});r.type=`enum`;let i=[],a=Pd({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=Yd({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=S({items:i,schema:r}),r},qd=({context:e,schema:t,state:n})=>{let r=Ud({schema:t});Id({irSchema:r,schema:t});let i=[],a=Pd({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=hu(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=S({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=Yd({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Jd=({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=Ud({schema:t});Id({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=S({items:a,mutateSchemaOneItem:!0,schema:r}),r},Yd=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Ud({schema:n}),Id({irSchema:t,schema:n})),n.type){case`array`:return Ld({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Rd({context:e,irSchema:t,schema:n});case`integer`:case`number`:return Bd({context:e,irSchema:t,schema:n});case`null`:return zd({context:e,irSchema:t,schema:n});case`object`:return Vd({context:e,irSchema:t,schema:n,state:r});case`string`:return Hd({context:e,irSchema:t,schema:n});default:return Qd({context:e,irSchema:t,schema:n})}},Xd=({context:e,irSchema:t,schema:n,state:r})=>{t||=Ud({schema:n});let i={};Id({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=Yd({context:e,irSchema:{...i},schema:{...n,type:t},state:r});a.push(o)}return t=S({items:a,schema:t}),t},Zd=({context:e,schema:t,state:n})=>{let r=Ud({schema:t});Id({irSchema:r,schema:t});let i=Pd({schema:t});return i.length===1?Yd({context:e,irSchema:r,schema:{...t,type:i[0]},state:n}):Xd({context:e,irSchema:r,schema:{...t,type:i},state:n})},Qd=({irSchema:e,schema:t})=>(e||=Ud({schema:t}),e.type=`unknown`,Id({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?Jd({context:e,schema:t,state:n}):t.enum?Kd({context:e,schema:t,state:n}):t.allOf?Wd({context:e,schema:t,state:n}):t.anyOf?Gd({context:e,schema:t,state:n}):t.oneOf?qd({context:e,schema:t,state:n}):t.type||t.properties?Zd({context:e,schema:t,state:n}):Qd({context:e,schema:t})),$d=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[L(e)]=Q({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},ef=e=>e.includes(`boolean`)||e.includes(`integer`)||e.includes(`number`)||e.includes(`string`),tf=({context:e,name:t,schema:n})=>{if(mu(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=Nd({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?tf({context:e,name:t,schema:n}):!1}return tf({context:e,name:t,schema:r})}for(let t in n.properties)if(mu(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`){let n=Pd({schema:e});if(!n.length){let n=(e.anyOf??e.oneOf??[]).filter(e=>e.type!==`null`);if(n.length===1&&ef(Pd({schema:n[0]})))return t}if(ef(n))return t}}for(let r of n.allOf??[]){let n=tf({context:e,name:t,schema:r});if(n)return n}return!1},nf=({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:Qc({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),nf({irOperation:a,operation:n}),a},af=({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=Nd({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=tf({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=Nd({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,...Md({content:s})},state:void 0})}:o.responses[t]={schema:{description:i.description,type:t===`204`?`void`:`unknown`}}}if(n.security){let e=new Map;for(let t of n.security)for(let n in t){let t=i.get(n);t&&e.set(n,t)}e.size&&(o.security=Array.from(e.values()))}return o},of=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>(n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),{parsed:af({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})}),sf=({context:e,method:t,path:n,...r})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={});let{parsed:i}=of({context:e,method:t,path:n,...r});e.ir.paths[n][t]=i},cf=({context:e,key:t,method:n,...r})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:i}=of({context:e,method:n,path:t,...r});e.ir.webhooks[t][n]=i},lf=e=>{switch(e){case`query`:return!1;default:return}},uf=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},df=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()]=ff({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},ff=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=Nd({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=tf({context:t,name:n.name,schema:i}),o=n.style||df(n.in),s=n.explode===void 0?uf(o):n.explode,c={allowReserved:n.allowReserved===void 0?lf(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},pf=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[L(e)]=ff({$ref:e,context:t,parameter:n})},mf=({$ref:e,context:t,requestBody:n})=>{let r=Nd({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},hf=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[L(e)]=mf({$ref:e,context:t,requestBody:n})},gf=({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=oi(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},_f=(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 Zc){let a=n[t];if(!a)continue;let o=C({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`)}},vf=({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&&cf({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&cf({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&cf({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&cf({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&cf({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&cf({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&cf({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&cf({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},yf=e=>{if(e.config.parser.validate_EXPERIMENTAL&&nu({context:e,result:_f(e.spec,e.logger)}),il(e.config.parser.filters)){let t=rl(e.config.parser.filters,e.spec,e.logger),{graph:n}=Vl(e.spec,e.logger),{resourceMetadata:r}=_l(n,e.logger);jd({...gl({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}Zl({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];pf({$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];hf({$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];$d({$ref:n,context:e,schema:r})}}for(let r in gf({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&&sf({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&sf({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&sf({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&sf({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&sf({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&sf({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&sf({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&sf({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}vf({context:e,securitySchemesMap:n})},bf=({config:e,dependencies:t,logger:n,spec:r})=>{let i=new Xc({config:e,dependencies:t,logger:n,spec:r});if(`swagger`in i.spec)return Gu(i),i;if(vi(i.spec.openapi,`>=3.0.0 <3.1.0`))return Ad(i),i;if(vi(i.spec.openapi,`>=3.1.0`))return yf(i),i;throw Error(`Unsupported OpenAPI specification`)};export{pe as C,h as E,fe as S,m as T,oe as _,gc as a,ue as b,Xr as c,D as d,w as f,Ne as g,Be as h,xc as i,Zr as l,He as m,Vl as n,ui as o,y as p,jc as r,ii as s,bf as t,I as u,se as v,ne as w,de as x,ce as y};
17
- //# sourceMappingURL=openApi-DlyxIg9f.mjs.map