@hey-api/openapi-ts 0.90.1 → 0.90.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,14 +0,0 @@
1
-
2
- var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),s=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},c=(n,r,a)=>(a=n==null?{}:e(i(n)),s(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));let l=require(`@hey-api/codegen-core`),u=require(`ansi-colors`);u=c(u);let d=require(`node:fs`);d=c(d);let f=require(`node:path`);f=c(f);let p=require(`node:url`),m=require(`typescript`);m=c(m);let ee=require(`node:os`),h=require(`semver`);h=c(h);let te=require(`@hey-api/json-schema-ref-parser`);const ne=(0,p.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),re=f.default.dirname(ne),ie=()=>{let e=re;for(;e!==f.default.dirname(e);){let t=d.default.readdirSync(e).filter(e=>e===`package.json`);if(t[0]){let n=f.default.join(e,t[0]);return JSON.parse(d.default.readFileSync(n,{encoding:`utf8`}))}e=f.default.dirname(e)}},ae=()=>{let e=ie(),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},oe=e=>{if(e===null)return null;if(e){let t=f.default.isAbsolute(e)?e:f.default.resolve(re,e);return d.default.existsSync(t)?t:null}let t=re;for(;t!==f.default.dirname(t);){let e=d.default.readdirSync(t).filter(e=>e.startsWith(`tsconfig`)&&e.endsWith(`.json`)).sort(e=>e===`tsconfig.json`?-1:1);if(e[0])return f.default.join(t,e[0]);t=f.default.dirname(t)}return null},se=e=>{if(!e)return null;let t=m.default.readConfigFile(e,m.default.sys.readFile);if(t.error)throw Error(`Couldn't read tsconfig from path: ${e}`);return m.default.parseJsonConfigFileContent(t.config,m.default.sys,f.default.dirname(e))},ce=e=>{d.default.existsSync(e)||d.default.mkdirSync(e,{recursive:!0})};var le=class extends Error{constructor(e){super(e),this.name=`ConfigError`}},ue=class extends Error{errors;constructor(e){super(`Found ${e.length} configuration ${e.length===1?`error`:`errors`}.`),this.name=`ConfigValidationError`,this.errors=e}},de=class extends Error{originalError;constructor(e,t){super(e),this.name=`JobError`,this.originalError=t}},fe=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 pe=(e,t)=>{if(e instanceof le||e instanceof ue)return;e instanceof de&&(e=e.originalError.error);let n=`openapi-ts-error-${Date.now()}.log`,r=f.default.resolve(process.cwd(),t);ce(r);let i=f.default.resolve(r,n),a=`[${new Date().toISOString()}] `;e instanceof fe&&(a+=`${e.name} during event "${e.event}"\n`,e.pluginName&&(a+=`Plugin: ${e.pluginName}\n`),a+=`Arguments: ${JSON.stringify(e.args,null,2)}\n\n`);let o=e instanceof Error?e.message:String(e),s=e instanceof Error?e.stack:void 0;return a+=`Error: ${o}\n`,s&&(a+=`Stack:\n${s}\n`),d.default.writeFileSync(i,a),i},me=async e=>{let t=ae();if(!t.bugs.url)return;e instanceof de&&(e=e.originalError.error);let n=``;e instanceof fe&&(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)},he=({error:e,logPath:t})=>{if(e instanceof ue&&e.errors.length){let t=new Map;for(let{error:n,jobIndex:r}of e.errors)t.has(r)||t.set(r,[]),t.get(r).push(n);for(let[e,n]of t.entries()){let t=u.default.gray(`[Job ${e+1}] `),r=n.length,i=u.default.red(`Found ${r} configuration ${r===1?`error`:`errors`}:`);console.error(`${t}❗️ ${i}`),n.forEach((e,n)=>{let r=` [${n+1}] `,i=u.default.red(r);console.error(`${t}${i}${u.default.white(e.message)}`)})}}else{let t=u.default.gray(`[root] `);e instanceof de&&(t=u.default.gray(`[Job ${e.originalError.jobIndex+1}] `),e=e.originalError.error);let n=u.default.red(`Failed with the message:`);console.error(`${t}❌ ${n}`);let r=u.default.red(` `);console.error(`${t}${r}${typeof e==`string`?e:e instanceof Error?e.message:`Unknown error`}`)}if(t){let e=u.default.gray(`[root] `);console.error(`${e}${u.default.cyan(`📄 Crash log saved to:`)} ${u.default.gray(t)}`)}},ge=async({error:e,isInteractive:t})=>!t||e instanceof le||e instanceof ue?!1:new Promise(e=>{let t=u.default.gray(`[root] `);console.log(`${t}${u.default.yellow(`📢 Open a GitHub issue with crash details? (y/N):`)}`),process.stdin.setEncoding(`utf8`),process.stdin.once(`data`,t=>{e(t.trim().toLowerCase()===`y`)})}),_e=/^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/,ve=`https://get.heyapi.dev`,ye=(e,t,n)=>`${ve}/${e}/${t}${n?`?${n}`:``}`,be=e=>{let t=e.organization,n=e.project,r;if(e.path){let i=e.path.match(_e);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}},xe=e=>{let t=be(e);return{path:ye(t.organization,t.project,t.queryParams),registry:`hey-api`}},Se=/^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/,Ce=e=>`https://dash.readme.com/api/v1/api-registry/${e}`,we=`readme`,Te=e=>{let t=e.match(Se);if(!t)throw Error(`Invalid ReadMe shorthand format. Expected "${we}:@organization/project#uuid" or "${we}:uuid", received: ${we}:${e}`);let[,,n,r,i]=t;if(!i)throw Error(`The ReadMe UUID cannot be empty.`);return{organization:n,project:r,uuid:i}},Ee=e=>{let t=Te(e.slice(`${we}:`.length));return{...t,path:Ce(t.uuid),registry:`readme`}},De=/^(@[\w-]+)\/([\w.-]+)$/,Oe=(e,t)=>`https://registry.scalar.com/${e}/apis/${t}/latest?format=json`,ke=`scalar`,Ae=e=>{let t=e.match(De);if(!t)throw Error(`Invalid Scalar shorthand format. Expected "${ke}:@organization/project", received: ${ke}:${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}},je=e=>{let t=Ae(e.slice(`${ke}:`.length));return{...t,path:Oe(t.organization,t.project),registry:`scalar`}},Me=e=>{if(e.path.startsWith(`readme:`)){Object.assign(e,Ee(e.path));return}if(e.path.startsWith(`scalar:`)){Object.assign(e,je(e.path));return}if(e.path.startsWith(`.`))return;if(e.path.startsWith(ve)){e.path=e.path.slice(23),Object.assign(e,xe(e));return}let t=e.path.split(`/`);if(t.length===2&&t.filter(Boolean).length===2){Object.assign(e,xe(e));return}},Ne={enabled:!1,interval:1e3,timeout:6e4},Pe=e=>{let t={...Ne};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},Fe=e=>{let t=e.input instanceof Array?e.input:[e.input],n=[];for(let r of t){let t={path:``,watch:Ne};typeof r==`string`?t.path=r:r&&(r.path!==void 0||r.organization!==void 0)?(t={...t,path:ve,...r},t.watch!==void 0&&(t.watch=Pe(t))):t={...t,path:r},typeof t.path==`string`&&Me(t),e.watch!==void 0&&t.watch.enabled===Ne.enabled&&t.watch.interval===Ne.interval&&t.watch.timeout===Ne.timeout&&(t.watch=Pe({path:t.path,watch:e.watch})),t.path&&n.push(t)}return n},Ie=e=>{let t={file:!0,level:`info`,path:process.cwd()};return typeof e?.logs==`string`?t.path=e.logs:t={...t,...e?.logs},t},Le=(e,t)=>{let n=e||{},r=t||{};return{...n,...r}},Re=(e,t)=>{let n=e||{},r=t||{},i={...n,...r};return typeof i.logs==`object`&&(i.logs=Le(n.logs,r.logs)),i},ze=e=>typeof e==`object`&&!!e&&!Array.isArray(e)&&typeof e!=`function`,Be=(e,t)=>{for(let[n,r]of Object.entries(t))r!==void 0&&r!==``&&(e[n]=r);return e},g=({defaultValue:e,mappers:t,value:n})=>{let r={...e};switch(typeof n){case`boolean`:if(t&&`boolean`in t){let e=t.boolean;r=Be(r,e(n))}break;case`function`:if(t&&`function`in t){let e=t.function;r=Be(r,e(n))}break;case`number`:if(t&&`number`in t){let e=t.number;r=Be(r,e(n))}break;case`string`:if(t&&`string`in t){let e=t.string;r=Be(r,e(n))}break;case`object`:if(ze(n))if(t&&`object`in t&&typeof t.object==`function`){let i=t.object;r=Be(r,i(n,e))}else r=Be(r,n);break}return r};function Ve(e){let t=g({defaultValue:{enabled:!!e.source,extension:`json`,fileName:`source`,serialize:e=>JSON.stringify(e,null,2)},mappers:{boolean:e=>({enabled:e})},value:e.source});return t.path===void 0||t.path===!0?t.path=``:t.path===!1&&(t.path=null),t}function He(e){if(e.output instanceof Array)throw Error(`Unexpected array of outputs in user configuration. This should have been expanded already.`);let t=g({defaultValue:{clean:!0,fileName:{case:`preserve`,name:`{{name}}`,suffix:`.gen`},format:null,header:`// This file is auto-generated by @hey-api/openapi-ts`,indexFile:!0,lint:null,path:``,preferExportAll:!1},mappers:{object:(e,t)=>({...e,fileName:g({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=se(oe(t.tsConfigPath)),t.importFileExtension===void 0&&(t.tsConfig?.options.moduleResolution===m.default.ModuleResolutionKind.NodeNext||t.tsConfig?.options.moduleResolution===m.default.ModuleResolutionKind.Node16)&&(t.importFileExtension=`.js`),t.importFileExtension&&!t.importFileExtension.startsWith(`.`)&&(t.importFileExtension=`.${t.importFileExtension}`),t.source=Ve(t),t}var Ue=o(((e,t)=>{t.exports=a,a.sync=o;var n=require(`fs`);function r(e,t){var n=t.pathExt===void 0?process.env.PATHEXT:t.pathExt;if(!n||(n=n.split(`;`),n.indexOf(``)!==-1))return!0;for(var r=0;r<n.length;r++){var i=n[r].toLowerCase();if(i&&e.substr(-i.length).toLowerCase()===i)return!0}return!1}function i(e,t,n){return!e.isSymbolicLink()&&!e.isFile()?!1:r(t,n)}function a(e,t,r){n.stat(e,function(n,a){r(n,n?!1:i(a,e,t))})}function o(e,t){return i(n.statSync(e),e,t)}})),We=o(((e,t)=>{t.exports=r,r.sync=i;var n=require(`fs`);function r(e,t,r){n.stat(e,function(e,n){r(e,e?!1:a(n,t))})}function i(e,t){return a(n.statSync(e),t)}function a(e,t){return e.isFile()&&o(e,t)}function o(e,t){var n=e.mode,r=e.uid,i=e.gid,a=t.uid===void 0?process.getuid&&process.getuid():t.uid,o=t.gid===void 0?process.getgid&&process.getgid():t.gid,s=64,c=8,l=1,u=s|c;return n&l||n&c&&i===o||n&s&&r===a||n&u&&a===0}})),Ge=o(((e,t)=>{require(`fs`);var n=process.platform===`win32`||global.TESTING_WINDOWS?Ue():We();t.exports=r,r.sync=i;function r(e,t,i){if(typeof t==`function`&&(i=t,t={}),!i){if(typeof Promise!=`function`)throw TypeError(`callback not provided`);return new Promise(function(n,i){r(e,t||{},function(e,t){e?i(e):n(t)})})}n(e,t||{},function(e,n){e&&(e.code===`EACCES`||t&&t.ignoreErrors)&&(e=null,n=!1),i(e,n)})}function i(e,t){try{return n.sync(e,t||{})}catch(e){if(t&&t.ignoreErrors||e.code===`EACCES`)return!1;throw e}}})),Ke=o(((e,t)=>{let n=process.platform===`win32`||process.env.OSTYPE===`cygwin`||process.env.OSTYPE===`msys`,r=require(`path`),i=n?`;`:`:`,a=Ge(),o=e=>Object.assign(Error(`not found: ${e}`),{code:`ENOENT`}),s=(e,t)=>{let r=t.colon||i,a=e.match(/\//)||n&&e.match(/\\/)?[``]:[...n?[process.cwd()]:[],...(t.path||process.env.PATH||``).split(r)],o=n?t.pathExt||process.env.PATHEXT||`.EXE;.CMD;.BAT;.COM`:``,s=n?o.split(r):[``];return n&&e.indexOf(`.`)!==-1&&s[0]!==``&&s.unshift(``),{pathEnv:a,pathExt:s,pathExtExe:o}},c=(e,t,n)=>{typeof t==`function`&&(n=t,t={}),t||={};let{pathEnv:i,pathExt:c,pathExtExe:l}=s(e,t),u=[],d=n=>new Promise((a,s)=>{if(n===i.length)return t.all&&u.length?a(u):s(o(e));let c=i[n],l=/^".*"$/.test(c)?c.slice(1,-1):c,d=r.join(l,e);a(f(!l&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d,n,0))}),f=(e,n,r)=>new Promise((i,o)=>{if(r===c.length)return i(d(n+1));let s=c[r];a(e+s,{pathExt:l},(a,o)=>{if(!a&&o)if(t.all)u.push(e+s);else return i(e+s);return i(f(e,n,r+1))})});return n?d(0).then(e=>n(null,e),n):d(0)};t.exports=c,c.sync=(e,t)=>{t||={};let{pathEnv:n,pathExt:i,pathExtExe:c}=s(e,t),l=[];for(let o=0;o<n.length;o++){let s=n[o],u=/^".*"$/.test(s)?s.slice(1,-1):s,d=r.join(u,e),f=!u&&/^\.[\\\/]/.test(e)?e.slice(0,2)+d:d;for(let e=0;e<i.length;e++){let n=f+i[e];try{if(a.sync(n,{pathExt:c}))if(t.all)l.push(n);else return n}catch{}}}if(t.all&&l.length)return l;if(t.nothrow)return null;throw o(e)}})),qe=o(((e,t)=>{let n=(e={})=>{let t=e.env||process.env;return(e.platform||process.platform)===`win32`?Object.keys(t).reverse().find(e=>e.toUpperCase()===`PATH`)||`Path`:`PATH`};t.exports=n,t.exports.default=n})),Je=o(((e,t)=>{let n=require(`path`),r=Ke(),i=qe();function a(e,t){let a=e.options.env||process.env,o=process.cwd(),s=e.options.cwd!=null,c=s&&process.chdir!==void 0&&!process.chdir.disabled;if(c)try{process.chdir(e.options.cwd)}catch{}let l;try{l=r.sync(e.command,{path:a[i({env:a})],pathExt:t?n.delimiter:void 0})}catch{}finally{c&&process.chdir(o)}return l&&=n.resolve(s?e.options.cwd:``,l),l}function o(e){return a(e)||a(e,!0)}t.exports=o})),Ye=o(((e,t)=>{let n=/([()\][%!^"`<>&|;, *?])/g;function r(e){return e=e.replace(n,`^$1`),e}function i(e,t){return e=`${e}`,e=e.replace(/(?=(\\+?)?)\1"/g,`$1$1\\"`),e=e.replace(/(?=(\\+?)?)\1$/,`$1$1`),e=`"${e}"`,e=e.replace(n,`^$1`),t&&(e=e.replace(n,`^$1`)),e}t.exports.command=r,t.exports.argument=i})),Xe=o(((e,t)=>{t.exports=/^#!(.*)/})),Ze=o(((e,t)=>{let n=Xe();t.exports=(e=``)=>{let t=e.match(n);if(!t)return null;let[r,i]=t[0].replace(/#! ?/,``).split(` `),a=r.split(`/`).pop();return a===`env`?i:i?`${a} ${i}`:a}})),Qe=o(((e,t)=>{let n=require(`fs`),r=Ze();function i(e){let t=Buffer.alloc(150),i;try{i=n.openSync(e,`r`),n.readSync(i,t,0,150,0),n.closeSync(i)}catch{}return r(t.toString())}t.exports=i})),$e=o(((e,t)=>{let n=require(`path`),r=Je(),i=Ye(),a=Qe(),o=process.platform===`win32`,s=/\.(?:com|exe)$/i,c=/node_modules[\\/].bin[\\/][^\\/]+\.cmd$/i;function l(e){e.file=r(e);let t=e.file&&a(e.file);return t?(e.args.unshift(e.file),e.command=t,r(e)):e.file}function u(e){if(!o)return e;let t=l(e),r=!s.test(t);if(e.options.forceShell||r){let r=c.test(t);e.command=n.normalize(e.command),e.command=i.command(e.command),e.args=e.args.map(e=>i.argument(e,r)),e.args=[`/d`,`/s`,`/c`,`"${[e.command].concat(e.args).join(` `)}"`],e.command=process.env.comspec||`cmd.exe`,e.options.windowsVerbatimArguments=!0}return e}function d(e,t,n){t&&!Array.isArray(t)&&(n=t,t=null),t=t?t.slice(0):[],n=Object.assign({},n);let r={command:e,args:t,options:n,file:void 0,original:{command:e,args:t}};return n.shell?r:u(r)}t.exports=d})),et=o(((e,t)=>{let n=process.platform===`win32`;function r(e,t){return Object.assign(Error(`${t} ${e.command} ENOENT`),{code:`ENOENT`,errno:`ENOENT`,syscall:`${t} ${e.command}`,path:e.command,spawnargs:e.args})}function i(e,t){if(!n)return;let r=e.emit;e.emit=function(n,i){if(n===`exit`){let n=a(i,t);if(n)return r.call(e,`error`,n)}return r.apply(e,arguments)}}function a(e,t){return n&&e===1&&!t.file?r(t.original,`spawn`):null}function o(e,t){return n&&e===1&&!t.file?r(t.original,`spawnSync`):null}t.exports={hookChildProcess:i,verifyENOENT:a,verifyENOENTSync:o,notFoundError:r}})),tt=o(((e,t)=>{let n=require(`child_process`),r=$e(),i=et();function a(e,t,a){let o=r(e,t,a),s=n.spawn(o.command,o.args,o.options);return i.hookChildProcess(s,o),s}function o(e,t,a){let o=r(e,t,a),s=n.spawnSync(o.command,o.args,o.options);return s.error=s.error||i.verifyENOENTSync(s.status,o),s}t.exports=a,t.exports.spawn=a,t.exports.sync=o,t.exports._parse=r,t.exports._enoent=i})),nt=tt();const rt={biome:{args:e=>[`format`,`--write`,e],command:`biome`,name:`Biome (Format)`},prettier:{args:e=>[`--ignore-unknown`,e,`--write`,`--ignore-path`,`./.prettierignore`],command:`prettier`,name:`Prettier`}},it={biome:{args:e=>[`lint`,`--apply`,e],command:`biome`,name:`Biome (Lint)`},eslint:{args:e=>[e,`--fix`],command:`eslint`,name:`ESLint`},oxlint:{args:e=>[`--fix`,e],command:`oxlint`,name:`oxlint`}},at=e=>{if(e.lint){let t=it[e.lint];console.log(`✨ Running ${t.name}`),(0,nt.sync)(t.command,t.args(e.path))}if(e.format){let t=rt[e.format];console.log(`✨ Running ${t.name}`),(0,nt.sync)(t.command,t.args(e.path))}},ot=e=>{let t=e?f.default.dirname(e):process.cwd();for(;t!==f.default.dirname(t);){let e=f.default.join(t,`package.json`);if(d.default.existsSync(e))try{let t=JSON.parse(d.default.readFileSync(e,`utf8`));return{...t.dependencies,...t.devDependencies,...t.peerDependencies,...t.optionalDependencies}}catch{}let n=f.default.dirname(t);if(n===t)break;t=n}return{}},st=[`after`,`before`,`cursor`,`offset`,`page`,`start`],ct=e=>g({defaultValue:{hooks:{},pagination:{keywords:st},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:g({defaultValue:{...t.pagination},value:e.pagination}),transforms:g({defaultValue:{...t.transforms},mappers:{object:(e,t)=>({...e,enums:g({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:g({defaultValue:{...t.readWrite,enabled:e.readWrite===void 0?t.readWrite.enabled:!!e.readWrite},mappers:{boolean:e=>({enabled:e}),object:(e,t)=>({...e,requests:g({defaultValue:{...t.requests},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.requests}),responses:g({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}),_=e=>t=>({...e,config:{...e.config,...t}}),v={boolean:e=>({enabled:e}),function:e=>({name:e}),string:e=>({name:e})};function lt(e,t){let n=e.httpRequests;typeof n==`string`||typeof n==`function`?n={strategy:n}:(typeof n==`boolean`||!n)&&(n={enabled:!!n});let r=n.strategy??`flat`;return t.valueToObject({defaultValue:{container:`class`,enabled:!0,methods:`instance`,nesting:`operationId`,nestingDelimiters:/[./]/,strategy:r,strategyDefaultTag:`default`},mappers:{object(e){return e.containerName=t.valueToObject({defaultValue:r===`single`?{casing:`PascalCase`,name:`HttpRequests`}:{casing:`PascalCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.containerName}),e.methodName=t.valueToObject({defaultValue:r===`flat`?{casing:`camelCase`,name:`{{name}}Request`}:{casing:`camelCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.methodName}),e.segmentName=t.valueToObject({defaultValue:{casing:`PascalCase`,name:`{{name}}Requests`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.segmentName}),e}},value:n})}const y={byTags:e=>t=>{let n=t.tags&&t.tags.length>0?t.tags:[e.fallback],r=(e.path??b.id())(t);return n.map(e=>[e,...r])},flat:e=>t=>{let n=(e?.path??b.id())(t);return[[n[n.length-1]]]},single:e=>t=>{let n=(e.path??b.id())(t);return[[e.root,...n]]}},b={fromOperationId:e=>t=>{let n=e?.fallback??b.id();if(!t.operationId)return n(t);let r=e?.delimiters??/[./]/,i=t.operationId.split(r).filter(Boolean);return i.length===0?n(t):i},fromPath:e=>t=>{let n=e?.delimiters??/[./]/,r=t.path.split(n).filter(Boolean);switch(e?.methodPosition){case`prefix`:r.unshift(t.method.toLowerCase());break;case`suffix`:r.push(t.method.toLowerCase());break;default:break}return r},id:()=>e=>[e.id]};function ut(e){return e.config.httpRequests.nesting===`id`?b.id():e.config.httpRequests.nesting===`operationId`?b.fromOperationId({delimiters:e.config.httpRequests.nestingDelimiters,fallback:b.id()}):e.config.httpRequests.nesting}function dt(e){if(e.config.httpRequests.strategy===`flat`)return y.flat({path:t=>[ut(e)(t).join(`.`)]});if(e.config.httpRequests.strategy===`single`){let t=e.config.httpRequests.containerName;return y.single({path:ut(e),root:typeof t.name==`string`?t.name:t.name?.(``)??``})}return e.config.httpRequests.strategy===`byTags`?y.byTags({fallback:e.config.httpRequests.strategyDefaultTag,path:ut(e)}):e.config.httpRequests.strategy}function ft(e,t){let n=e.httpResources;typeof n==`string`||typeof n==`function`?n={strategy:n}:(typeof n==`boolean`||!n)&&(n={enabled:!!n});let r=n.strategy??`flat`;return t.valueToObject({defaultValue:{container:`class`,enabled:!0,methods:`instance`,nesting:`operationId`,nestingDelimiters:/[./]/,strategy:r,strategyDefaultTag:`default`},mappers:{object(e){return e.containerName=t.valueToObject({defaultValue:r===`single`?{casing:`PascalCase`,name:`HttpResources`}:{casing:`PascalCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.containerName}),e.methodName=t.valueToObject({defaultValue:r===`flat`?{casing:`camelCase`,name:`{{name}}Resource`}:{casing:`camelCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.methodName}),e.segmentName=t.valueToObject({defaultValue:{casing:`PascalCase`,name:`{{name}}Resources`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.segmentName}),e}},value:n})}function pt(e){return e.config.httpResources.nesting===`id`?b.id():e.config.httpResources.nesting===`operationId`?b.fromOperationId({delimiters:e.config.httpResources.nestingDelimiters,fallback:b.id()}):e.config.httpResources.nesting}function mt(e){if(e.config.httpResources.strategy===`flat`)return y.flat({path:t=>[pt(e)(t).join(`.`)]});if(e.config.httpResources.strategy===`single`){let t=e.config.httpResources.containerName;return y.single({path:pt(e),root:typeof t.name==`string`?t.name:t.name?.(``)??``})}return e.config.httpResources.strategy===`byTags`?y.byTags({fallback:e.config.httpResources.strategyDefaultTag,path:pt(e)}):e.config.httpResources.strategy}const ht=e=>{let t=x(e);return t.name===`@hey-api/client-axios`||t.name===`@hey-api/client-nuxt`?`baseURL`:`baseUrl`},x=e=>{for(let t of e.pluginOrder){let n=e.plugins[t];if(n?.tags?.includes(`client`))return n}return{config:{name:``},name:``}},gt=({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]},_t=e=>{for(let t in e)if(e[t].required)return!0;return!1},vt=e=>e?!!(_t(e.cookie)||_t(e.header)||_t(e.path)||_t(e.query)):!1,yt=({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:gt({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:gt({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:gt({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:gt({context:e,parameter:r})}}}},S=({detectFormat:e=!0,schema:t})=>{if(!t.items)return t;let n=[],r=[];for(let i of t.items){if(!i.type&&i.items||t.type===`tuple`){n.push(i);continue}if(!i.type||i.type===`boolean`||i.type===`integer`||i.type===`null`||i.type===`number`||i.type===`string`||i.type===`unknown`||i.type===`void`){let t=i.const===void 0?``:`const-${i.const}`,a=i.format!==void 0&&e?`format-${i.format}`:``,o=[i.minLength===void 0?``:`minLength-${i.minLength}`,i.maxLength===void 0?``:`maxLength-${i.maxLength}`,i.minimum===void 0?``:`minimum-${i.minimum}`,i.maximum===void 0?``:`maximum-${i.maximum}`,i.exclusiveMinimum===void 0?``:`exclusiveMinimum-${i.exclusiveMinimum}`,i.exclusiveMaximum===void 0?``:`exclusiveMaximum-${i.exclusiveMaximum}`,i.minItems===void 0?``:`minItems-${i.minItems}`,i.maxItems===void 0?``:`maxItems-${i.maxItems}`,i.pattern===void 0?``:`pattern-${i.pattern}`].join(``),s=`${i.$ref??``}${i.type??``}${t}${a}${o}`;r.includes(s)||(r.push(s),n.push(i));continue}n.push(i)}let i={...t};if(i.items=n,i.items.length<=1&&i.type!==`array`&&i.type!==`enum`&&i.type!==`tuple`){let e=i.items[0];delete i.logicalOperator,delete i.items,i={...i,...e}}return i.type===`unknown`?{}:i},C=({items:e,logicalOperator:t=`or`,mutateSchemaOneItem:n=!1,schema:r})=>e.length?r.type===`tuple`?(r.items=e,r):e.length===1?n?(r={...r,...e[0]},r):(r.items=e,r):(r.items=e,r.logicalOperator=t,r):r,bt=e=>!!(vt(e.parameters)||e.body?.required),w=({method:e,path:t})=>`${e.toUpperCase()} ${t}`,xt=({context:e,operation:t})=>{let n=t.body;if(!n||!n.pagination)return yt({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}:yt({context:e,parameters:t.parameters})},St=({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`}},Ct=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(St({statusCode:t})){case`1XX`:case`3XX`:break;case`2XX`:r.properties[t]=a.schema;break;case`4XX`:case`5XX`:n.properties[t]=a.schema;break;case`default`:i=a;break}}if(i){let e=!1;Object.keys(r.properties).length||(r.properties.default=i.schema,e=!0);let t=(i.schema.description??``).toLocaleLowerCase(),a=(i.schema.$ref??``).toLocaleLowerCase();[`success`].some(e=>t.includes(e)||a.includes(e))&&(r.properties.default=i.schema,e=!0),[`error`,`problem`].some(e=>t.includes(e)||a.includes(e))&&(n.properties.default=i.schema,e=!0),e||(n.properties.default=i.schema)}let a=Object.keys(n.properties);if(a.length){n.required=a,t.errors=n;let e=C({items:Object.values(n.properties),mutateSchemaOneItem:!0,schema:{}});e=S({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.error=e)}let o=Object.keys(r.properties);if(o.length){r.required=o,t.responses=r;let e=C({items:Object.values(r.properties),mutateSchemaOneItem:!0,schema:{}});e=S({schema:e}),Object.keys(e).length&&e.type!==`unknown`&&(t.response=e)}return t};var T=class{analyze(e){}clone(){let e=Object.create(Object.getPrototypeOf(this));return Object.assign(e,this),e}exported;file;get name(){return{...this._name,set:e=>{this._name=(0,l.ref)(e),(0,l.isSymbol)(e)&&e.setNode(this)},toString:()=>this._name?this.$name(this._name):``}}nameSanitizer;language=`typescript`;parent;root=!1;scope=`value`;structuralChildren;structuralParents;symbol;toAst(){}"~brand"=l.nodeBrand;$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`?m.default.factory.createIdentifier(e):e}$name(e){let t=(0,l.fromRef)(e);if((0,l.isSymbol)(t))try{return t.finalName}catch{return t.name}return String(t)}$node(e){if(e!==void 0)return(0,l.isRef)(e)&&(e=(0,l.fromRef)(e)),(0,l.isSymbol)(e)?this.$maybeId(e.finalName):typeof e==`string`?this.$maybeId(e):e instanceof Array?e.map(e=>((0,l.isRef)(e)&&(e=(0,l.fromRef)(e)),this.unwrap(e))):this.unwrap(e)}$type(e,t){if(e!==void 0){if((0,l.isRef)(e)&&(e=(0,l.fromRef)(e)),(0,l.isSymbol)(e))return m.default.factory.createTypeReferenceNode(e.finalName,t);if(typeof e==`string`)return m.default.factory.createTypeReferenceNode(e,t);if(typeof e==`boolean`){let t=e?m.default.factory.createTrue():m.default.factory.createFalse();return m.default.factory.createLiteralTypeNode(t)}return typeof e==`number`?m.default.factory.createLiteralTypeNode(m.default.factory.createNumericLiteral(e)):e instanceof Array?e.map(e=>this.$type(e,t)):this.unwrap(e)}}_name;unwrap(e){return(0,l.isNode)(e)?e.toAst():e}},wt=class extends T{};const Tt=T;var Et=class extends Tt{"~dsl"=`IdTsDsl`;constructor(e){super(),this.name.set(e)}analyze(e){super.analyze(e)}toAst(){return m.default.factory.createIdentifier(this.name.toString())}},Dt=class extends T{"~dsl"=`NewlineTsDsl`;analyze(e){super.analyze(e)}toAst(){return this.$node(new Et(`
3
- `))}};function Ot(e){class t extends e{_args=[];analyze(e){super.analyze(e);for(let t of this._args)e.analyze(t)}arg(e){return e!==void 0&&this._args.push((0,l.ref)(e)),this}args(...e){return this._args.push(...e.filter(e=>e!==void 0).map(e=>(0,l.ref)(e))),this}$args(){return this.$node(this._args).map(e=>this.$node(e))}}return t}const kt=T;var At=class extends kt{"~dsl"=`PrefixTsDsl`;_expr;_op;constructor(e,t){super(),this._expr=e,this._op=t}analyze(e){super.analyze(e),e.analyze(this._expr)}expr(e){return this._expr=e,this}neg(){return this._op=m.default.SyntaxKind.MinusToken,this}not(){return this._op=m.default.SyntaxKind.ExclamationToken,this}op(e){return this._op=e,this}toAst(){if(!this._expr)throw Error(`Missing expression for prefix unary expression`);if(!this._op)throw Error(`Missing operator for prefix unary expression`);return m.default.factory.createPrefixUnaryExpression(this._op,this.$node(this._expr))}};function E(e){let t,n=((...n)=>{if(!t)throw Error(`${e} factory not registered`);return t(...n)});return n.set=e=>{t=e},n}const D={as:E(`as`),attr:E(`attr`),await:E(`await`),call:E(`call`),new:E(`new`),return:E(`return`),type:{expr:E(`type.expr`),idx:E(`type.idx`),operator:E(`type.operator`),query:E(`type.query`)},typeofExpr:E(`typeofExpr`)};function O(e){class t extends e{analyze(e){super.analyze(e)}as(...e){return D.as(this,...e)}}return t}const jt=O(T);var k=class extends jt{"~dsl"=`LiteralTsDsl`;value;constructor(e){super(),this.value=e}analyze(e){super.analyze(e)}toAst(){if(typeof this.value==`boolean`)return this.value?m.default.factory.createTrue():m.default.factory.createFalse();if(typeof this.value==`number`){let e=m.default.factory.createNumericLiteral(Math.abs(this.value));return this.value<0?this.$node(new At(e).neg()):e}if(typeof this.value==`string`)return m.default.factory.createStringLiteral(this.value,!0);if(typeof this.value==`bigint`)return m.default.factory.createBigIntLiteral(this.value.toString());if(this.value===null)return m.default.factory.createNull();throw Error(`Unsupported literal: ${String(this.value)}`)}};const Mt=/^[^$_\p{ID_Start}]+/u,Nt=/^-?\d+(\.\d+)?$/,Pt=/^[$_\p{ID_Start}][$\u200c\u200d\p{ID_Continue}]*$/u,A={illegalStartCharacters:Mt,number:Nt,typeScriptIdentifier:Pt},Ft=[`document`,`history`,`location`,`navigator`,`window`],It=[`console`,`Array`,`Date`,`Error`,`Function`,`JSON`,`Map`,`Math`,`Object`,`Promise`,`RegExp`,`Set`,`WeakMap`,`WeakSet`],Lt=`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`.split(`.`),Rt=[`global`,`process`,`Buffer`],zt=[`any`,`as`,`bigint`,`boolean`,`namespace`,`never`,`null`,`number`,`string`,`symbol`,`type`,`undefined`,`unknown`,`void`],Bt={browserGlobals:Ft,javaScriptGlobals:It,javaScriptKeywords:Lt,nodeGlobals:Rt,typeScriptKeywords:zt};var Vt=class{_array;_set;constructor(e){this._array=e,this._set=new Set(e)}get"~values"(){return this._set}set(e){let t=typeof e==`function`?e(this._array):e;this._array=t,this._set=new Set(t)}};const Ht=new Vt([...Bt.browserGlobals,...Bt.javaScriptGlobals,...Bt.javaScriptKeywords,...Bt.nodeGlobals,...Bt.typeScriptKeywords]),Ut=new Vt([...Bt.javaScriptKeywords,...Bt.typeScriptKeywords]),Wt={runtime:Ht,type:Ut},Gt=e=>(A.number.lastIndex=0,A.number.test(e)?e.startsWith(`-`)?`'${e}'`:e:(A.typeScriptIdentifier.lastIndex=0,A.typeScriptIdentifier.test(e)?e:`'${e}'`)),Kt=e=>(A.typeScriptIdentifier.lastIndex=0,A.typeScriptIdentifier.test(e)?new Et(e):new k(e)),qt=e=>(A.number.lastIndex=0,A.number.test(e)?e.startsWith(`-`)?new k(e):new k(Number(e)):(A.typeScriptIdentifier.lastIndex=0,A.typeScriptIdentifier.test(e)?new Et(e):new k(e))),Jt=(e,t)=>{let n=``,r,i=e[0];for(A.illegalStartCharacters.lastIndex=0,A.illegalStartCharacters.test(i)?(n+=`_`,r=0):(n+=i,r=1);r<e.length;){let t=e[r];n+=/^[\u200c\u200d\p{ID_Continue}]$/u.test(t)?t:`_`,r+=1}return t[`~values`].has(n)&&(n=`${n}_`),n||`_`},Yt=e=>Jt(e,Wt.runtime),Xt=e=>Jt(e,Wt.type),Zt=Ot(T);var Qt=class extends Zt{"~dsl"=`DecoratorTsDsl`;nameSanitizer=Yt;constructor(e,...t){super(),this.name.set(e),this.args(...t)}analyze(e){super.analyze(e),e.analyze(this.name)}toAst(){let e=this.$node(this.name),t=this.$args();return m.default.factory.createDecorator(t.length?m.default.factory.createCallExpression(e,void 0,t):e)}};function $t(e){class t extends e{decorators=[];analyze(e){super.analyze(e);for(let t of this.decorators)e.analyze(t)}decorator(e,...t){return this.decorators.push(new Qt(e,...t)),this}$decorators(){return this.$node(this.decorators)}}return t}function en(e){let t;return e.forEach((e,n)=>{t=n===0?e:t.attr(e.name)}),t}function tn(e){let t=sn([...rn(e,new Set)]);return t.length===0?[e.clone()]:t.map(e=>e.clone())}function nn(e){return e.scope??`value`}function rn(e,t){if(t.has(e)||(t.add(e),on(e)))return[];if(e.structuralParents)for(let[n]of e.structuralParents){if(nn(n)!==nn(e))continue;let r=rn(n,t);if(r.length>0)return[...r,e]}return e.root?[e]:[]}function an(e){return e[`~dsl`]===`FieldTsDsl`||e[`~dsl`]===`GetterTsDsl`||e[`~dsl`]===`MethodTsDsl`}function on(e){return e[`~dsl`]===`FuncTsDsl`||e[`~dsl`]===`TemplateTsDsl`}function sn(e){let t=[];return e.forEach((e,n)=>{(n===0||an(e))&&t.push(e)}),t}function cn(e,t={}){return e.map((n,r)=>{let i=t.transform?.(n,r,e);if(i)return i;let a=n.toAccessNode?.(n,t,{chain:e,index:r,isLeaf:r===e.length-1,isRoot:r===0,length:e.length});if(a)return a;if(r===0){if(n[`~dsl`]===`ClassTsDsl`){let t=e[r+1];return t&&an(t)&&t.hasModifier(`static`)?I(n.name):I.new(n.name).args()}return I(n.name)}return n})}var ln=class{access(e,t){let n=(0,l.isSymbol)(e)?e.node:e;if(!n)throw Error(`Symbol ${e.name} is not resolved to a node.`);return en(cn(tn(n),t))}example(e,t,n){if(n)return Fi.astToString(n);t||={};let r=tn(e);t.importName&&r[0].name.set(t.importName);let i=I(r[0].name.toString()),a=cn(r,{context:`example`}),o=t.importSetup?typeof t.importSetup==`function`?t.importSetup({$:I,node:i}):t.importSetup:a[0],s=t.setupName,c=typeof t.payload==`function`?t.payload({$:I}):t.payload;c=c instanceof Array?c:c?[c]:[];let l=[];l=s?[I.const(s).assign(o),I.await(en([I(s),...a.slice(1)]).call(...c))]:[I.await(en([o,...a.slice(1)]).call(...c))];let u=i.name.toString();return Fi.astToString({imports:[[{imports:!t.importKind||t.importKind===`named`?[{isTypeOnly:!1,localName:u,sourceName:u}]:[],isTypeOnly:!1,kind:t.importKind??`named`,localName:t.importKind===`named`?void 0:u,modulePath:t.moduleName??`your-package`}]],nodes:l,trailingNewline:!1})}};const un=new ln;var dn=class extends T{"~dsl"=`DocTsDsl`;_lines=[];constructor(e,t){super(),e&&this.add(e),t?.(this)}analyze(e){super.analyze(e)}add(e){return this._lines.push(e),this}apply(e){let t=this._lines.reduce((e,t)=>{typeof t==`function`&&(t=t(un));for(let n of typeof t==`string`?[t]:t)(n||n===``)&&e.push(n);return e},[]);if(!t.length)return e;let n=t.map(e=>m.default.factory.createJSDocText(`${e}\n`)),r=m.default.factory.createJSDocComment(m.default.factory.createNodeArray(n),void 0),i=m.default.createPrinter().printNode(m.default.EmitHint.Unspecified,r,e.getSourceFile?.()??m.default.createSourceFile(``,``,m.default.ScriptTarget.Latest)).replace(`/*`,``).replace(`* */`,``);return m.default.addSyntheticLeadingComment(e,m.default.SyntaxKind.MultiLineCommentTrivia,i,!0),e}toAst(){return this.$node(new Et(``))}};function j(e){class t extends e{_doc;analyze(e){super.analyze(e)}doc(e,t){return this._doc=new dn(e,t),this}$docs(e){return this._doc?this._doc.apply(e):e}}return t}function fn(e){switch(e){case`abstract`:return m.default.SyntaxKind.AbstractKeyword;case`async`:return m.default.SyntaxKind.AsyncKeyword;case`const`:return m.default.SyntaxKind.ConstKeyword;case`declare`:return m.default.SyntaxKind.DeclareKeyword;case`default`:return m.default.SyntaxKind.DefaultKeyword;case`export`:return m.default.SyntaxKind.ExportKeyword;case`override`:return m.default.SyntaxKind.OverrideKeyword;case`private`:return m.default.SyntaxKind.PrivateKeyword;case`protected`:return m.default.SyntaxKind.ProtectedKeyword;case`public`:return m.default.SyntaxKind.PublicKeyword;case`readonly`:return m.default.SyntaxKind.ReadonlyKeyword;case`static`:return m.default.SyntaxKind.StaticKeyword}}function M(e){class t extends e{modifiers=[];analyze(e){super.analyze(e)}hasModifier(e){let t=fn(e);return!!this.modifiers.find(e=>e.kind===t)}_m(e,t){if(t){let t=fn(e);this.modifiers.push(m.default.factory.createModifier(t))}return this}}return t}function pn(e){let t=M(e);class n extends t{abstract(e){let t=arguments.length===0?!0:!!e;return this._m(`abstract`,t)}}return n}function mn(e){let t=M(e);class n extends t{async(e){let t=arguments.length===0?!0:!!e;return this._m(`async`,t)}}return n}function hn(e){let t=M(e);class n extends t{const(e){let t=arguments.length===0?!0:!!e;return this._m(`const`,t)}}return n}function gn(e){let t=M(e);class n extends t{default(e){let t=arguments.length===0?!0:!!e;return this._m(`default`,t)}}return n}function _n(e){let t=M(e);class n extends t{export(e){let t=arguments.length===0?!0:!!e;return this.exported=t,this.symbol&&this.symbol.setExported(t),this._m(`export`,t)}}return n}function vn(e){let t=M(e);class n extends t{private(e){let t=arguments.length===0?!0:!!e;return this._m(`private`,t)}}return n}function yn(e){let t=M(e);class n extends t{protected(e){let t=arguments.length===0?!0:!!e;return this._m(`protected`,t)}}return n}function bn(e){let t=M(e);class n extends t{public(e){let t=arguments.length===0?!0:!!e;return this._m(`public`,t)}}return n}function xn(e){let t=M(e);class n extends t{readonly(e){let t=arguments.length===0?!0:!!e;return this._m(`readonly`,t)}}return n}function Sn(e){let t=M(e);class n extends t{static(e){let t=arguments.length===0?!0:!!e;return this._m(`static`,t)}}return n}const Cn=T;var wn=class extends Cn{"~dsl"=`TypeParamTsDsl`;scope=`type`;constraint;defaultValue;constructor(e,t){super(),e&&this.name.set(e),t?.(this)}analyze(e){super.analyze(e),e.analyze(this.name),e.analyze(this.constraint),e.analyze(this.defaultValue)}default(e){return this.defaultValue=(0,l.ref)(e),this}extends(e){return this.constraint=(0,l.ref)(e),this}toAst(){if(!this.name.toString())throw Error(`Missing type name`);return m.default.factory.createTypeParameterDeclaration(void 0,this.$node(this.name),this.$type(this.constraint),this.$type(this.defaultValue))}};function Tn(e){class t extends e{_generics=[];analyze(e){super.analyze(e);for(let t of this._generics)e.analyze(t)}generic(...e){let t=new wn(...e);return this._generics.push(t),this}generics(...e){for(let t of e)(typeof t==`string`||typeof t==`number`||(0,l.isSymbol)(t)||(0,l.isRef)(t))&&(t=new wn(t)),this._generics.push(t);return this}$generics(){return this.$node(this._generics)}}return t}function En(e){class t extends e{_optional;analyze(e){super.analyze(e)}optional(e){return this._optional=arguments.length===0?!0:!!e,this}required(e){return this._optional=arguments.length===0?!1:!e,this}}return t}function Dn(e){class t extends e{value;analyze(e){super.analyze(e),e.analyze(this.value)}assign(e){return this.value=e,this}$value(){return this.$node(this.value)}}return t}var N=class extends T{"~dsl"=`TokenTsDsl`;_kind;kind(e){return this._kind=e,this}minus(){return this.kind(m.default.SyntaxKind.MinusToken)}optional(){return this.kind(m.default.SyntaxKind.QuestionToken)}plus(){return this.kind(m.default.SyntaxKind.PlusToken)}questionDot(){return this.kind(m.default.SyntaxKind.QuestionDotToken)}readonly(){return this.kind(m.default.SyntaxKind.ReadonlyKeyword)}spread(){return this.kind(m.default.SyntaxKind.DotDotDotToken)}toAst(){if(!this._kind)throw Error("Token missing `.kind(kind)`");return m.default.factory.createToken(this._kind)}};function On(e){class t extends e{_generics=[];analyze(e){super.analyze(e);for(let t of this._generics)e.analyze(t)}generic(e){return this._generics.push((0,l.ref)(e)),this}generics(...e){return this._generics.push(...e.map(e=>(0,l.ref)(e))),this}$generics(){return this.$type(this._generics)}}return t}function kn(e){class t extends e{analyze(e){super.analyze(e)}idx(...e){return D.type.idx(this,...e)}keyof(){return D.type.operator().keyof(this)}readonly(){return D.type.operator().readonly(this)}returnType(...e){return D.type.expr(`ReturnType`).generic(D.type.query(this,...e))}typeofExpr(...e){return D.typeofExpr(this,...e)}typeofType(...e){return D.type.query(this,...e)}unique(){return D.type.operator().unique(this)}}return t}const An=kn(T);var jn=class extends An{"~dsl"=`TypeAttrTsDsl`;scope=`type`;_base;_right;constructor(e,t){super(),t?(this.base(e),this.right(t)):(this.base(),this.right(e))}analyze(e){super.analyze(e),e.analyze(this._base),e.analyze(this._right)}base(e){return(0,l.isRef)(e)?this._base=e:this._base=e?(0,l.ref)(e):void 0,this}right(e){return this._right=(0,l.ref)(e),this}toAst(){if(!this._base)throw Error(`TypeAttrTsDsl: missing base for qualified name`);let e=this.$node(this._base);if(!m.default.isEntityName(e))throw Error(`TypeAttrTsDsl: base must be an EntityName`);return m.default.factory.createQualifiedName(e,this.$node(this._right))}};const Mn=On(kn(T));var Nn=class extends Mn{"~dsl"=`TypeExprTsDsl`;scope=`type`;_exprInput;constructor(e,t){super(),typeof e==`function`?e(this):(this._exprInput=e?(0,l.ref)(e):void 0,t?.(this))}analyze(e){super.analyze(e),e.analyze(this._exprInput)}attr(e){return this._exprInput=(0,l.isNode)(e)?(0,l.ref)(e.base(this._exprInput)):(0,l.ref)(new jn(this._exprInput,e)),this}toAst(){if(!this._exprInput)throw Error(`TypeExpr must have an expression`);return m.default.factory.createTypeReferenceNode(this.$type(this._exprInput),this.$generics())}};D.type.expr.set((...e)=>new Nn(...e));const Pn=$t(j(En(vn(yn(bn(xn(Sn(Dn(T)))))))));var Fn=class extends Pn{"~dsl"=`FieldTsDsl`;nameSanitizer=Gt;_type;constructor(e,t){super(),this.name.set(e),t?.(this)}analyze(e){super.analyze(e),e.analyze(this.name),e.analyze(this._type)}type(e){return this._type=e instanceof wt?e:new Nn(e),this}toAst(){let e=m.default.factory.createPropertyDeclaration([...this.$decorators(),...this.modifiers],this.$node(this.name),this._optional?this.$node(new N().optional()):void 0,this.$type(this._type),this.$value());return this.$docs(e)}};const In=T;var Ln=class extends In{"~dsl"=`StmtTsDsl`;_inner;constructor(e){super(),this._inner=e}analyze(e){super.analyze(e),e.analyze(this._inner)}toAst(){let e=this.$node(this._inner);return m.default.isStatement(e)?e:m.default.factory.createExpressionStatement(e)}};function Rn(e){class t extends e{_do=[];analyze(e){super.analyze(e),e.pushScope();try{for(let t of this._do)e.analyze(t)}finally{e.popScope()}}do(...e){return this._do.push(...e),this}$do(){return this.$node(this._do.map(e=>new Ln(e)))}}return t}const zn=T;var Bn=class extends zn{"~dsl"=`PatternTsDsl`;pattern;_spread;analyze(e){super.analyze(e)}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}toAst(){if(!this.pattern)throw Error(`PatternTsDsl requires object() or array() pattern`);if(this.pattern.kind===`object`){let e=Object.entries(this.pattern.values).map(([e,t])=>e===t?m.default.factory.createBindingElement(void 0,void 0,e,void 0):m.default.factory.createBindingElement(void 0,e,t,void 0)),t=this.createSpread();return t&&e.push(t),m.default.factory.createObjectBindingPattern(e)}if(this.pattern.kind===`array`){let e=this.pattern.values.map(e=>m.default.factory.createBindingElement(void 0,void 0,e,void 0)),t=this.createSpread();return t&&e.push(t),m.default.factory.createArrayBindingPattern(e)}throw Error(`PatternTsDsl requires object() or array() pattern`)}createSpread(){return this._spread?m.default.factory.createBindingElement(this.$node(new N().spread()),void 0,this.$node(new Et(this._spread))):void 0}};function Vn(e){class t extends e{pattern;analyze(e){super.analyze(e),e.analyze(this.pattern)}array(...e){return(this.pattern??=new Bn).array(...e),this}object(...e){return(this.pattern??=new Bn).object(...e),this}spread(e){return(this.pattern??=new Bn).spread(e),this}$pattern(){if(this.pattern)return this.$node(this.pattern)}}return t}const Hn=$t(En(Vn(Dn(T))));var Un=class extends Hn{"~dsl"=`ParamTsDsl`;_type;constructor(e,t){super(),typeof e==`function`?e(this):(this.name.set(e),t?.(this))}analyze(e){super.analyze(e),e.analyze(this.name),e.analyze(this._type)}type(e){return this._type=e instanceof wt?e:new Nn(e),this}toAst(){let e=this.$pattern()||this.name.toString();if(!e)throw Error(`Param must have either a name or a destructuring pattern`);return m.default.factory.createParameterDeclaration(this.$decorators(),void 0,e,this._optional?this.$node(new N().optional()):void 0,this.$type(this._type),this.$value())}};function Wn(e){class t extends e{_params=[];analyze(e){super.analyze(e);for(let t of this._params)e.analyze(t)}param(e,t){let n=new Un(e,t);return this._params.push(n),this}params(...e){return this._params.push(...e),this}$params(){return this.$node(this._params)}}return t}function Gn(e){class t extends e{static DEFAULT_THRESHOLD=3;layout;analyze(e){super.analyze(e)}auto(e=t.DEFAULT_THRESHOLD){return this.layout=e,this}inline(){return this.layout=!1,this}pretty(){return this.layout=!0,this}$multiline(e){return this.layout===void 0&&(this.layout=t.DEFAULT_THRESHOLD),e===0?!1:typeof this.layout==`number`?e>=this.layout:this.layout}}return t}const Kn=Rn(Gn(T));var P=class extends Kn{"~dsl"=`BlockTsDsl`;constructor(...e){super(),this.do(...e)}analyze(e){super.analyze(e)}toAst(){let e=this.$do();return m.default.factory.createBlock(e,this.$multiline(e.length))}};const qn=$t(Rn(j(Wn(vn(yn(bn(T)))))));var Jn=class extends qn{"~dsl"=`InitTsDsl`;constructor(e){super(),e?.(this)}analyze(e){e.pushScope();try{super.analyze(e)}finally{e.popScope()}}toAst(){let e=m.default.factory.createConstructorDeclaration([...this.$decorators(),...this.modifiers],this.$params(),this.$node(new P(...this._do).pretty()));return this.$docs(e)}};function Yn(e){class t extends e{_returns;analyze(e){super.analyze(e),e.analyze(this._returns)}returns(e){return this._returns=e instanceof wt?e:new Nn(e),this}$returns(){return this.$type(this._returns)}}return t}const Xn=pn(mn($t(Rn(j(En(Wn(vn(yn(bn(Sn(Tn(Yn(T)))))))))))));var Zn=class extends Xn{"~dsl"=`MethodTsDsl`;nameSanitizer=Gt;constructor(e,t){super(),this.name.set(e),t?.(this)}analyze(e){e.analyze(this.name),e.pushScope();try{super.analyze(e)}finally{e.popScope()}}toAst(){let e=m.default.factory.createMethodDeclaration([...this.$decorators(),...this.modifiers],void 0,this.$node(this.name),this._optional?this.$node(new N().optional()):void 0,this.$generics(),this.$params(),this.$returns(),this.$node(new P(...this._do).pretty()));return this.$docs(e)}};const Qn=pn($t(gn(j(_n(Tn(T))))));var $n=class extends Qn{"~dsl"=`ClassTsDsl`;nameSanitizer=Yt;baseClass;body=[];constructor(e){super(),this.name.set(e),(0,l.isSymbol)(e)&&e.setKind(`class`)}analyze(e){super.analyze(e),e.analyze(this.baseClass),e.analyze(this.name),e.pushScope();try{for(let t of this.body)e.analyze(t)}finally{e.popScope()}}get hasBody(){return this.body.length>0}do(...e){return this.body.push(...e),this}extends(e){return this.baseClass=e?(0,l.ref)(e):void 0,this}field(e,t){let n=new Fn(e,t);return this.body.push(n),this}init(e){let t=typeof e==`function`?new Jn(e):e||new Jn;return this.body.push(t),this}method(e,t){let n=new Zn(e,t);return this.body.push(n),this}newline(){return this.body.push(new Dt),this}toAst(){let e=this.$node(this.body),t=m.default.factory.createClassDeclaration([...this.$decorators(),...this.modifiers],this.$node(this.name),this.$generics(),this._heritage(),e);return this.$docs(t)}_heritage(){let e=this.$node(this.baseClass);return e?[m.default.factory.createHeritageClause(m.default.SyntaxKind.ExtendsKeyword,[m.default.factory.createExpressionWithTypeArguments(e,void 0)])]:[]}};const er=j(T);var tr=class extends er{"~dsl"=`EnumMemberTsDsl`;_value;constructor(e,t){super(),this.name.set(e),typeof t==`function`?t(this):this.value(t)}analyze(e){super.analyze(e),e.analyze(this._value)}value(e){return this._value=e,this}toAst(){let e=m.default.factory.createEnumMember(this.$node(Kt(this.name.toString())),this.$node(this._value));return this.$docs(e)}};const nr=hn(j(_n(T)));var rr=class extends nr{"~dsl"=`EnumTsDsl`;nameSanitizer=Yt;_members=[];constructor(e,t){super(),this.name.set(e),(0,l.isSymbol)(e)&&e.setKind(`enum`),t?.(this)}analyze(e){super.analyze(e),e.analyze(this.name),e.pushScope();try{for(let t of this._members)e.analyze(t)}finally{e.popScope()}}member(e,t){let n=new tr(e,t);return this._members.push(n),this}members(...e){return this._members.push(...e),this}toAst(){let e=m.default.factory.createEnumDeclaration(this.modifiers,this.$node(this.name),this.$node(this._members));return this.$docs(e)}};const ir=pn(O(mn($t(Rn(j(Wn(vn(yn(bn(Sn(Tn(Yn(T)))))))))))));var ar=class extends ir{"~dsl"=`FuncTsDsl`;nameSanitizer=Yt;mode;constructor(e,t){super(),typeof e==`function`?(this.mode=`arrow`,e(this)):e&&(this.mode=`decl`,this.name.set(e),(0,l.isSymbol)(e)&&e.setKind(`function`),t?.(this))}analyze(e){e.pushScope();try{super.analyze(e),e.analyze(this.name)}finally{e.popScope()}}arrow(){return this.mode=`arrow`,this}decl(){return this.mode=`decl`,this}expr(){return this.mode=`expr`,this}toAst(){let e=this.$node(new P(...this._do).pretty());if(this.mode===`decl`){if(!this.name.toString())throw Error(`Function declaration requires a name`);let t=m.default.factory.createFunctionDeclaration([...this.$decorators(),...this.modifiers],void 0,this.$node(this.name),this.$generics(),this.$params(),this.$returns(),e);return this.$docs(t)}if(this.mode===`expr`){let t=m.default.factory.createFunctionExpression(this.modifiers,void 0,this.$node(this.name),this.$generics(),this.$params(),this.$returns(),e);return this.$docs(t)}let t=m.default.factory.createArrowFunction(this.modifiers,this.$generics(),this.$params(),this.$returns(),void 0,e.statements.length===1&&m.default.isReturnStatement(e.statements[0])&&e.statements[0].expression?e.statements[0].expression:e);return this.$docs(t)}};const or=ar,sr=pn(mn($t(Rn(j(Wn(vn(yn(bn(Sn(Yn(T)))))))))));var cr=class extends sr{"~dsl"=`GetterTsDsl`;nameSanitizer=Gt;constructor(e,t){super(),this.name.set(e),t?.(this)}analyze(e){e.analyze(this.name),e.pushScope();try{super.analyze(e)}finally{e.popScope()}}toAst(){let e=m.default.factory.createGetAccessorDeclaration([...this.$decorators(),...this.modifiers],this.$node(this.name),this.$params(),this.$returns(),this.$node(new P(...this._do).pretty()));return this.$docs(e)}};const lr=pn(mn($t(Rn(j(Wn(vn(yn(bn(Sn(T))))))))));var ur=class extends lr{"~dsl"=`SetterTsDsl`;nameSanitizer=Gt;constructor(e,t){super(),this.name.set(e),t?.(this)}analyze(e){e.analyze(this.name),e.pushScope();try{super.analyze(e)}finally{e.popScope()}}toAst(){let e=m.default.factory.createSetAccessorDeclaration([...this.$decorators(),...this.modifiers],this.$node(this.name),this.$params(),this.$node(new P(...this._do).pretty()));return this.$docs(e)}};const dr=O(Gn(T));var fr=class extends dr{"~dsl"=`ArrayTsDsl`;_elements=[];constructor(...e){super(),this.elements(...e)}analyze(e){super.analyze(e);for(let t of this._elements)e.analyze(t.expr)}element(e){let t=typeof e==`string`||typeof e==`number`||typeof e==`boolean`?new k(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}toAst(){let e=this._elements.map(e=>{let t=this.$node(e.expr);return e.kind===`spread`?m.default.factory.createSpreadElement(t):t});return m.default.factory.createArrayLiteralExpression(e,this.$multiline(this._elements.length))}};function pr(e){class t extends e{analyze(e){super.analyze(e)}attr(...e){return D.attr(this,...e)}await(){return D.await(this)}call(...e){return D.call(this,...e)}return(){return D.return(this)}}return t}const mr=O(pr(T));var hr=class extends mr{"~dsl"=`AsTsDsl`;expr;type;constructor(e,t){super(),this.expr=(0,l.ref)(e),this.type=(0,l.ref)(t)}analyze(e){super.analyze(e),e.analyze(this.expr),e.analyze(this.type)}toAst(){return m.default.factory.createAsExpression(this.$node(this.expr),this.$type(this.type))}};D.as.set((...e)=>new hr(...e));const gr=O(pr(T));var F=class extends gr{"~dsl"=`BinaryTsDsl`;_base;_expr;_op;constructor(e,t,n){super(),this._base=(0,l.ref)(e),this._op=t,n&&(this._expr=(0,l.ref)(n))}analyze(e){super.analyze(e),e.analyze(this._base),e.analyze(this._expr)}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)}nullishAssign(e){return this.opAndExpr(`??=`,e)}or(e){return this.opAndExpr(`||`,e)}plus(e){return this.opAndExpr(`+`,e)}times(e){return this.opAndExpr(`*`,e)}toAst(){if(!this._op)throw Error(`BinaryTsDsl: missing operator`);let e=this.$node(this._expr);if(!e)throw Error(`BinaryTsDsl: missing right-hand expression`);let t=this.$node(this._base),n=typeof this._op==`string`?this.opToToken(this._op):this._op;return m.default.factory.createBinaryExpression(t,n,e)}opAndExpr(e,t){return this._expr=(0,l.ref)(t),this._op=e,this}opToToken(e){let t={"!=":m.default.SyntaxKind.ExclamationEqualsToken,"!==":m.default.SyntaxKind.ExclamationEqualsEqualsToken,"&&":m.default.SyntaxKind.AmpersandAmpersandToken,"*":m.default.SyntaxKind.AsteriskToken,"+":m.default.SyntaxKind.PlusToken,"-":m.default.SyntaxKind.MinusToken,"/":m.default.SyntaxKind.SlashToken,"<":m.default.SyntaxKind.LessThanToken,"<=":m.default.SyntaxKind.LessThanEqualsToken,"=":m.default.SyntaxKind.EqualsToken,"==":m.default.SyntaxKind.EqualsEqualsToken,"===":m.default.SyntaxKind.EqualsEqualsEqualsToken,">":m.default.SyntaxKind.GreaterThanToken,">=":m.default.SyntaxKind.GreaterThanEqualsToken,"??":m.default.SyntaxKind.QuestionQuestionToken,"??=":m.default.SyntaxKind.QuestionQuestionEqualsToken,"||":m.default.SyntaxKind.BarBarToken}[e];if(!t)throw Error(`Unsupported operator: ${e}`);return t}};function _r(e){class t extends e{analyze(e){super.analyze(e)}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)}nullishAssign(e){return new F(this).nullishAssign(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)}}return t}const vr=O(pr(_r(En(T))));var yr=class extends vr{"~dsl"=`AttrTsDsl`;left;constructor(e,t){super(),this.left=(0,l.ref)(e),this.name.set(t)}analyze(e){super.analyze(e),e.analyze(this.left),e.analyze(this.name)}toAst(){let e=this.$node(this.left);A.typeScriptIdentifier.lastIndex=0;let t=(0,l.fromRef)(this.name);if(!A.typeScriptIdentifier.test(this.name.toString())){let n=(0,l.isSymbol)(t)?t.finalName:t;return typeof n==`string`&&(n.startsWith(`'`)&&n.endsWith(`'`)||n.startsWith(`"`)&&n.endsWith(`"`))&&(n=n.slice(1,-1)),this._optional?m.default.factory.createElementAccessChain(e,this.$node(new N().questionDot()),this.$node(new k(n))):m.default.factory.createElementAccessExpression(e,this.$node(new k(n)))}return this._optional?m.default.factory.createPropertyAccessChain(e,this.$node(new N().questionDot()),this.$node(this.name)):m.default.factory.createPropertyAccessExpression(e,this.$node(this.name))}};D.attr.set((...e)=>new yr(...e));const br=pr(T);var xr=class extends br{"~dsl"=`AwaitTsDsl`;_awaitExpr;constructor(e){super(),this._awaitExpr=(0,l.ref)(e)}analyze(e){super.analyze(e),e.analyze(this._awaitExpr)}toAst(){return m.default.factory.createAwaitExpression(this.$node(this._awaitExpr))}};D.await.set((...e)=>new xr(...e));const Sr=Ot(O(pr(On(T))));var Cr=class extends Sr{"~dsl"=`CallTsDsl`;_callExpr;constructor(e,...t){super(),this._callExpr=(0,l.ref)(e),this.args(...t)}analyze(e){super.analyze(e),e.analyze(this._callExpr)}toAst(){return m.default.factory.createCallExpression(this.$node(this._callExpr),this.$generics(),this.$args())}};D.call.set((...e)=>new Cr(...e));const wr=O(pr(_r(kn(T))));var Tr=class extends wr{"~dsl"=`ExprTsDsl`;_exprInput;constructor(e){super(),this._exprInput=(0,l.ref)(e),typeof e==`string`||(0,l.isSymbol)(e)?this.name.set(e):(0,l.isNode)(e)&&this.name.set(e.name)}analyze(e){super.analyze(e),e.analyze(this._exprInput)}toAst(){return this.$node(this._exprInput)}},Er=class extends T{"~dsl"=`HintTsDsl`;_lines=[];constructor(e,t){super(),e&&this.add(e),t?.(this)}analyze(e){super.analyze(e)}add(e){return this._lines.push(e),this}apply(e){let t=this._lines.reduce((e,t)=>{typeof t==`function`&&(t=t(un));for(let n of typeof t==`string`?[t]:t)(n||n===``)&&e.push(n);return e},[]);if(!t.length)return e;for(let n of t)m.default.addSyntheticLeadingComment(e,m.default.SyntaxKind.SingleLineCommentTrivia,` ${n}`,!1);return e}toAst(){return this.$node(new Et(``))}};function Dr(e){class t extends e{_hint;analyze(e){super.analyze(e)}hint(e,t){return this._hint=new Er(e,t),this}$hint(e){return this._hint?this._hint.apply(e):e}}return t}const Or=j(T);var kr=class extends Or{"~dsl"=`ObjectPropTsDsl`;_value;meta;constructor(e){super(),this.meta=e}analyze(e){super.analyze(e),e.analyze(this._value)}get isValid(){return this.missingRequiredCalls().length===0}value(e){return typeof e==`function`?e(this):this._value=(0,l.ref)(e),this}toAst(){this.$validate();let e=this.$node(this._value);if(this.meta.kind===`spread`){if(m.default.isStatement(e))throw Error(`Invalid spread: object spread must be an expression, not a statement.`);let t=m.default.factory.createSpreadAssignment(e);return this.$docs(t)}if(this.meta.kind===`getter`){let t=new cr(this.meta.name).do(e),n=this.$node(t);return this.$docs(n)}if(this.meta.kind===`setter`){let t=new ur(this.meta.name).do(e),n=this.$node(t);return this.$docs(n)}if(m.default.isIdentifier(e)&&e.text===this.meta.name){let e=m.default.factory.createShorthandPropertyAssignment(this.meta.name);return this.$docs(e)}if(m.default.isStatement(e))throw Error(`Invalid property: object property value must be an expression, not a statement.`);let t=m.default.factory.createPropertyAssignment(this.meta.kind===`computed`?m.default.factory.createComputedPropertyName(this.$node(new Et(this.meta.name))):this.$node(qt(this.meta.name)),e);return this.$docs(t)}$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}};const Ar=O(pr(Dr(Gn(T))));var jr=class extends Ar{"~dsl"=`ObjectTsDsl`;_props=[];constructor(...e){super(),this.props(...e)}analyze(e){super.analyze(e);for(let t of this._props)e.analyze(t)}computed(e,t){return this._props.push(new kr({kind:`computed`,name:e}).value(t)),this}getter(e,t){return this._props.push(new kr({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 kr({kind:`prop`,name:e}).value(t)),this}props(...e){return this._props.push(...e),this}setter(e,t){return this._props.push(new kr({kind:`setter`,name:e}).value(t)),this}spread(e){return this._props.push(new kr({kind:`spread`}).value(e)),this}toAst(){let e=m.default.factory.createObjectLiteralExpression(this.$node(this._props),this.$multiline(this._props.length));return this.$hint(e)}};const Mr=(e,t)=>{if((0,l.isNode)(e))return e;if(e===null||typeof e==`number`||typeof e==`boolean`||typeof e==`string`||typeof e==`bigint`)return new k(e);if(e instanceof Array){let n=new fr(...e.map(e=>Mr(e,t)));return t?.layout===`pretty`&&n.pretty(),n}if(typeof e==`object`){let n=new jr;for(let[r,i]of Object.entries(e)){let e=Mr(i,t);n.prop(r,e)}return t?.layout===`pretty`&&n.pretty(),n}throw Error(`$.fromValue(): Unsupported input type ${String(e)}`)},Nr=Ot(O(pr(On(T))));var Pr=class extends Nr{"~dsl"=`NewTsDsl`;_newExpr;constructor(e,...t){super(),this._newExpr=(0,l.ref)(e),this.args(...t)}analyze(e){super.analyze(e),e.analyze(this._newExpr)}toAst(){return m.default.factory.createNewExpression(this.$node(this._newExpr),this.$generics(),this.$args())}};D.new.set((...e)=>new Pr(...e));const Fr=T;var Ir=class extends Fr{"~dsl"=`RegExpTsDsl`;pattern;flags;constructor(e,t){super(),this.pattern=e,this.flags=t}analyze(e){super.analyze(e)}toAst(){let e=`/${(this.pattern.startsWith(`/`)&&this.pattern.endsWith(`/`)?this.pattern.slice(1,-1):this.pattern).replace(/(?<!\\)\//g,`\\/`)}/${this.flags??``}`;return m.default.factory.createRegularExpressionLiteral(e)}};const Lr=T;var Rr=class extends Lr{"~dsl"=`TemplateTsDsl`;parts=[];constructor(e){super(),e!==void 0&&this.add(e)}analyze(e){super.analyze(e);for(let t of this.parts)e.analyze(t)}add(e){return this.parts.push((0,l.ref)(e)),this}toAst(){let e=this.$node(this.parts.map(e=>{let t=(0,l.fromRef)(e);return(0,l.isSymbol)(t)?t.finalName:t})),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 typeof r==`number`?t.push(String(r)):t.push(r)}if((t.length===0||typeof t[0]!=`string`)&&t.unshift(``),t.length===1&&typeof t[0]==`string`)return m.default.factory.createNoSubstitutionTemplateLiteral(t[0]);if(t.length===2&&typeof t[0]==`string`&&typeof t[1]!=`string`)return m.default.factory.createTemplateExpression(m.default.factory.createTemplateHead(t[0]),[m.default.factory.createTemplateSpan(t[1],m.default.factory.createTemplateTail(``))]);let n=m.default.factory.createTemplateHead(t.shift()),r=[];for(;t.length;){let e=t.shift(),n=typeof t[0]==`string`?t.shift():``,i=t.length===0;r.push(m.default.factory.createTemplateSpan(e,i?m.default.factory.createTemplateTail(n):m.default.factory.createTemplateMiddle(n)))}return m.default.factory.createTemplateExpression(n,r)}};const zr=T;var Br=class extends zr{"~dsl"=`TernaryTsDsl`;_condition;_then;_else;constructor(e){super(),e&&this.condition(e)}analyze(e){super.analyze(e),e.analyze(this._condition),e.analyze(this._then),e.analyze(this._else)}condition(e){return this._condition=e,this}do(e){return this._then=e,this}otherwise(e){return this._else=e,this}toAst(){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 m.default.factory.createConditionalExpression(this.$node(this._condition),void 0,this.$node(this._then),void 0,this.$node(this._else))}};const Vr=_r(T);var Hr=class extends Vr{"~dsl"=`TypeOfExprTsDsl`;_expr;constructor(e){super(),this._expr=e}analyze(e){super.analyze(e),e.analyze(this._expr)}toAst(){return m.default.factory.createTypeOfExpression(this.$node(this._expr))}};D.typeofExpr.set((...e)=>new Hr(...e));var Ur=class extends T{"~dsl"=`NoteTsDsl`;_lines=[];constructor(e,t){super(),e&&this.add(e),t?.(this)}analyze(e){super.analyze(e)}add(e){return this._lines.push(e),this}apply(e){let t=this._lines.reduce((e,t)=>{typeof t==`function`&&(t=t(un));for(let n of typeof t==`string`?[t]:t)(n||n===``)&&e.push(n);return e},[]);return t.length&&m.default.addSyntheticLeadingComment(e,m.default.SyntaxKind.MultiLineCommentTrivia,`\n${t.join(`
4
- `)}\n`,!0),e}toAst(){return this.$node(new Et(``))}};const Wr=Rn(T);var Gr=class extends Wr{"~dsl"=`IfTsDsl`;_condition;_else;constructor(e){super(),e&&this.condition(e)}analyze(e){if(super.analyze(e),e.analyze(this._condition),this._else){e.pushScope();try{for(let t of this._else)e.analyze(t)}finally{e.popScope()}}}condition(e){return this._condition=e,this}otherwise(...e){return this._else=e,this}toAst(){if(!this._condition)throw Error(`Missing condition in if`);if(!this._do)throw Error(`Missing then block in if`);return m.default.factory.createIfStatement(this.$node(this._condition),this.$node(new P(...this._do).pretty()),this._else?this.$node(new P(...this._else).pretty()):void 0)}};const Kr=T;var qr=class extends Kr{"~dsl"=`ReturnTsDsl`;_returnExpr;constructor(e){super(),e&&(this._returnExpr=(0,l.ref)(e))}analyze(e){super.analyze(e),e.analyze(this._returnExpr)}toAst(){return m.default.factory.createReturnStatement(this.$node(this._returnExpr))}};D.return.set((...e)=>new qr(...e));const Jr=T;var Yr=class extends Jr{"~dsl"=`ThrowTsDsl`;error;msg;useNew;constructor(e,t=!0){super(),this.error=e,this.useNew=t}analyze(e){super.analyze(e),e.analyze(this.error),e.analyze(this.msg)}message(e){return this.msg=e,this}toAst(){let e=this.$node(this.error),t=this.$node(this.msg?[this.msg]:[]).map(e=>typeof e==`string`?this.$node(new k(e)):e);if(this.useNew)return m.default.factory.createThrowStatement(m.default.factory.createNewExpression(e,void 0,t));let n=t.length?[m.default.factory.createCallExpression(e,void 0,t)]:[e];return m.default.factory.createThrowStatement(n[0])}};const Xr=T;var Zr=class extends Xr{"~dsl"=`TryTsDsl`;_catch;_catchArg;_finally;_try;constructor(...e){super(),this.try(...e)}analyze(e){if(super.analyze(e),this._try){e.pushScope();try{for(let t of this._try)e.analyze(t)}finally{e.popScope()}}if(this._catch||this._catchArg){e.pushScope();try{if(e.analyze(this._catchArg),this._catch)for(let t of this._catch)e.analyze(t)}finally{e.popScope()}}if(this._finally){e.pushScope();try{for(let t of this._finally)e.analyze(t)}finally{e.popScope()}}}catch(...e){return this._catch=e,this}catchArg(e){return this._catchArg=e,this}finally(...e){return this._finally=e,this}try(...e){return this._try=e,this}toAst(){if(!this._try?.length)throw Error(`Missing try block`);let e=this._catchArg?this.$node(this._catchArg):void 0;return m.default.factory.createTryStatement(this.$node(new P(...this._try).pretty()),m.default.factory.createCatchClause(e?m.default.factory.createVariableDeclaration(e):void 0,this.$node(new P(...this._catch??[]).pretty())),this._finally?this.$node(new P(...this._finally).pretty()):void 0)}};const Qr=gn(j(_n(Dr(Vn(Dn(T))))));var $r=class extends Qr{"~dsl"=`VarTsDsl`;nameSanitizer=Yt;kind=m.default.NodeFlags.None;_type;constructor(e){super(),e&&this.name.set(e),(0,l.isSymbol)(e)&&e.setKind(`var`)}analyze(e){super.analyze(e),e.analyze(this.name),e.analyze(this._type)}const(){return this.kind=m.default.NodeFlags.Const,this}let(){return this.kind=m.default.NodeFlags.Let,this}type(e){return this._type=e instanceof wt?e:new Nn(e),this}var(){return this.kind=m.default.NodeFlags.None,this}toAst(){let e=this.$pattern()??this.$node(this.name);if(!e)throw Error(`Var must have either a name or a destructuring pattern`);let t=m.default.factory.createVariableStatement(this.modifiers,m.default.factory.createVariableDeclarationList([m.default.factory.createVariableDeclaration(e,void 0,this.$type(this._type),this.$value())],this.kind));return this.$docs(this.$hint(t))}};const ei=j(_n(Tn(T)));var ti=class extends ei{"~dsl"=`TypeAliasTsDsl`;nameSanitizer=Xt;scope=`type`;value;constructor(e,t){super(),this.name.set(e),(0,l.isSymbol)(e)&&e.setKind(`type`),t?.(this)}analyze(e){super.analyze(e),e.analyze(this.name),e.analyze(this.value)}type(e){return this.value=e,this}toAst(){if(!this.value)throw Error(`Type alias '${this.name.toString()}' is missing a type definition`);let e=m.default.factory.createTypeAliasDeclaration(this.modifiers,this.$node(this.name),this.$generics(),this.$type(this.value));return this.$docs(e)}};const ni=T;var ri=class extends ni{"~dsl"=`TypeAndTsDsl`;scope=`type`;_types=[];constructor(...e){super(),this.types(...e)}analyze(e){super.analyze(e);for(let t of this._types)e.analyze(t)}types(...e){return this._types.push(...e.map(e=>(0,l.ref)(e))),this}toAst(){let e=[];for(let t of this._types){let n=this.$type(t);m.default.isIntersectionTypeNode(n)?e.push(...n.types):e.push(n)}return m.default.factory.createIntersectionTypeNode(e)}};const ii=T;var ai=class extends ii{"~dsl"=`TypeLiteralTsDsl`;scope=`type`;value;constructor(e){super(),this.value=e}analyze(e){super.analyze(e)}toAst(){return m.default.factory.createLiteralTypeNode(this.$node(new k(this.value)))}};const oi=j(xn(T));var si=class extends oi{"~dsl"=`TypeIdxSigTsDsl`;scope=`type`;_key;_type;constructor(e,t){super(),this.name.set(e),t?.(this)}analyze(e){super.analyze(e),e.analyze(this._key),e.analyze(this._type)}get isValid(){return this.missingRequiredCalls().length===0}key(e){return this._key=e,this}type(e){return this._type=e,this}toAst(){this.$validate();let e=m.default.factory.createIndexSignature(this.modifiers,[m.default.factory.createParameterDeclaration(void 0,void 0,this.$node(this.name),void 0,this.$type(this._key))],this.$type(this._type));return this.$docs(e)}$validate(){let e=this.missingRequiredCalls();if(e.length===0)return;let t=this.name.toString();throw Error(`Index signature${t?` "${t}"`:``} missing ${e.join(` and `)}`)}missingRequiredCalls(){let e=[];return this._key||e.push(`.key()`),this._type||e.push(`.​type()`),e}};const ci=j(En(xn(T)));var li=class extends ci{"~dsl"=`TypePropTsDsl`;scope=`type`;_type;constructor(e,t){super(),this.name.set(e),t(this)}analyze(e){super.analyze(e),e.analyze(this._type)}type(e){return this._type=(0,l.ref)(e),this}toAst(){let e=this.name.toString();if(!this._type||!e)throw Error(`Type not specified for property '${e}'`);let t=m.default.factory.createPropertySignature(this.modifiers,this.$node(qt(e)),this._optional?this.$node(new N().optional()):void 0,this.$type(this._type));return this.$docs(t)}};const ui=T;var di=class extends ui{"~dsl"=`TypeObjectTsDsl`;scope=`type`;props=[];analyze(e){super.analyze(e);for(let t of this.props)e.analyze(t)}hasProps(){return this.props.length>0}idxSig(e,t){let n=new si(e,t);return this.props.push(n),this}get isEmpty(){return!this.props.length}prop(e,t){let n=new li(e,t);return this.props.push(n),this}toAst(){return m.default.factory.createTypeLiteralNode(this.$node(this.props))}};const fi=T;var pi=class extends fi{"~dsl"=`TypeTupleTsDsl`;scope=`type`;_elements=[];constructor(...e){super(),this.elements(...e)}analyze(e){super.analyze(e);for(let t of this._elements)e.analyze(t)}elements(...e){return this._elements.push(...e),this}toAst(){return m.default.factory.createTupleTypeNode(this._elements.map(e=>this.$type(e)))}};const mi=e=>{if((0,l.isNode)(e))return e;if(e===null||typeof e==`number`||typeof e==`boolean`||typeof e==`string`)return new ai(e);if(e instanceof Array)return new pi(...e.map(e=>mi(e)));if(typeof e==`object`){let t=new di;for(let[n,r]of Object.entries(e)){let e=mi(r);t.prop(n,t=>t.type(e))}return t}throw Error(`$.type.fromValue(): Unsupported input type ${String(e)}`)},hi=j(Wn(Tn(Yn(T))));var gi=class extends hi{"~dsl"=`TypeFuncTsDsl`;scope=`type`;analyze(e){super.analyze(e)}toAst(){let e=this.$returns();if(e===void 0)throw Error(`Missing return type in function type DSL`);let t=m.default.factory.createFunctionTypeNode(this.$generics(),this.$params(),e);return this.$docs(t)}};const _i=kn(T);var vi=class extends _i{"~dsl"=`TypeIdxTsDsl`;scope=`type`;_base;_index;constructor(e,t){super(),this.base(e),this.index(t)}analyze(e){super.analyze(e),e.analyze(this._base),e.analyze(this._index)}base(e){return this._base=e,this}index(e){return this._index=e,this}toAst(){return m.default.factory.createIndexedAccessTypeNode(this.$type(this._base),this.$type(this._index))}};D.type.idx.set((...e)=>new vi(...e));const yi=T;var bi=class extends yi{"~dsl"=`TypeMappedTsDsl`;scope=`type`;questionToken;readonlyToken;_key;_type;constructor(e){super(),e&&this.name.set(e)}analyze(e){super.analyze(e),e.analyze(this.questionToken),e.analyze(this.readonlyToken),e.analyze(this._key),e.analyze(this._type)}get isValid(){return this.missingRequiredCalls().length===0}key(e){return this._key=e,this}mutable(){return this.readonlyToken=new N().minus(),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}toAst(){return this.$validate(),m.default.factory.createMappedTypeNode(this.$node(this.readonlyToken),m.default.factory.createTypeParameterDeclaration(void 0,this.$node(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)return;let t=this.name.toString();throw Error(`Mapped type${t?` "${t}"`:``} missing ${e.join(` and `)}`)}missingRequiredCalls(){let e=[];return this._key||e.push(`.key()`),this._type||e.push(`.​type()`),e}};const xi=T;var Si=class extends xi{"~dsl"=`TypeOperatorTsDsl`;scope=`type`;_op;_type;analyze(e){super.analyze(e),e.analyze(this._type)}keyof(e){return this.operator(m.default.SyntaxKind.KeyOfKeyword),this.type(e),this}operator(e){return this._op=e,this}readonly(e){return this.operator(m.default.SyntaxKind.ReadonlyKeyword),this.type(e),this}type(e){return this._type=e,this}unique(e){return this.operator(m.default.SyntaxKind.UniqueKeyword),this.type(e),this}toAst(){return this.$validate(),m.default.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}};D.type.operator.set((...e)=>new Si(...e));const Ci=T;var wi=class extends Ci{"~dsl"=`TypeOrTsDsl`;scope=`type`;_types=[];constructor(...e){super(),this.types(...e)}analyze(e){super.analyze(e);for(let t of this._types)e.analyze(t)}types(...e){return this._types.push(...e.map(e=>(0,l.ref)(e))),this}toAst(){let e=[];for(let t of this._types){let n=this.$type(t);m.default.isUnionTypeNode(n)?e.push(...n.types):e.push(n)}return m.default.factory.createUnionTypeNode(e)}};const Ti=kn(T);var Ei=class extends Ti{"~dsl"=`TypeQueryTsDsl`;scope=`type`;_expr;constructor(e){super(),this._expr=e}analyze(e){super.analyze(e),e.analyze(this._expr)}toAst(){let e=this.$node(this._expr);return m.default.factory.createTypeQueryNode(e)}};D.type.query.set((...e)=>new Ei(...e));const Di=T;var Oi=class extends Di{"~dsl"=`TypeTemplateTsDsl`;scope=`type`;parts=[];constructor(e){super(),e!==void 0&&this.add(e)}analyze(e){super.analyze(e);for(let t of this.parts)e.analyze(t)}add(e){return this.parts.push(e),this}toAst(){let e=this.$node(this.parts),t=[];for(let n=0;n<e.length;n++){let r=e[n];if(typeof r==`string`){let i=r;for(;n+1<e.length&&typeof e[n+1]==`string`;)i+=e[n+1],n++;t.push(i)}else t.push(r)}if((t.length===0||typeof t[0]!=`string`)&&t.unshift(``),t.length===1&&typeof t[0]==`string`)return m.default.factory.createTemplateLiteralType(m.default.factory.createTemplateHead(t[0]),[]);if(t.length===2&&typeof t[0]==`string`&&typeof t[1]!=`string`)return m.default.factory.createTemplateLiteralType(m.default.factory.createTemplateHead(t[0]),[m.default.factory.createTemplateLiteralTypeSpan(t[1],m.default.factory.createTemplateTail(``))]);let n=m.default.factory.createTemplateHead(t.shift()),r=[];for(;t.length;){let e=t.shift(),n=typeof t[0]==`string`?t.shift():``,i=t.length===0;r.push(m.default.factory.createTemplateLiteralTypeSpan(e,i?m.default.factory.createTemplateTail(n):m.default.factory.createTemplateMiddle(n)))}return m.default.factory.createTemplateLiteralType(n,r)}},ki=class extends T{"~dsl"=`LazyTsDsl`;_thunk;constructor(e){super(),this._thunk=e}analyze(e){super.analyze(e),e.analyze(this.toResult())}toResult(){return this._thunk(un)}toAst(){return this.toResult().toAst()}};const Ai=m.default.createPrinter({newLine:m.default.NewLineKind.LineFeed,removeComments:!1}),ji=m.default.createSourceFile(``,``,m.default.ScriptTarget.ESNext,!1,m.default.ScriptKind.TS);function Mi(e){let t=Ai.printNode(m.default.EmitHint.Unspecified,e,ji);try{return t.replace(/\\u([0-9a-fA-F]{4})/g,(e,t)=>String.fromCharCode(Number.parseInt(t,16)))}catch{return t}}const Ni=({file:e,fromFile:t,preferFileExtension:n,root:r})=>{let i=e.finalPath.split(f.default.sep).join(`/`),a=t.finalPath.split(f.default.sep).join(`/`);if(t.external&&!f.default.isAbsolute(a))return[0,0,a];if(!a.startsWith(r.split(f.default.sep).join(`/`)))return[1,0,a];let o=f.default.relative(f.default.dirname(i),f.default.dirname(a)).split(f.default.sep).join(`/`),s;return o.startsWith(`..`)?(a=`${o}/${t.name}${t.extension??``}`,s=o.split(f.default.sep).filter(e=>e===`..`).length):(a=`./${o?`${o}/`:``}${t.name}${t.extension??``}`,s=0),a.endsWith(`.ts`)&&(a=a.slice(0,-3)),n?a+=n:a.endsWith(`/index`)&&(a=a.slice(0,-6)),[2,s,a]};function Pi(e){if(!e)return[];let t=[];if(typeof e==`string`)return t.push(...e.split(/\r?\n/)),t;for(let n of e)t.push(...n.split(/\r?\n/));return t}var Fi=class e{_header;_preferExportAll;_preferFileExtension;_resolveModuleName;constructor(e={}){this._header=e.header,this._preferExportAll=e.preferExportAll??!1,this._preferFileExtension=e.preferFileExtension??``,this._resolveModuleName=e.resolveModuleName}render(t){let n=typeof this._header==`function`?this._header(t):this._header;return e.astToString({exports:this.getExports(t),exportsOptions:{preferExportAll:this._preferExportAll},header:n,imports:this.getImports(t),nodes:t.file.nodes})}supports(e){return e.file.language===`typescript`}static astToString(t){let n=``;for(let e of Pi(t.header))n+=`${e}\n`;let r=``;for(let n of t.imports??[]){r&&(r+=`
5
- `);for(let t of n)r+=`${Mi(e.toImportAst(t))}\n`}n=`${n}${n&&r?`
6
- `:``}${r}`;let i=``;for(let e of t.nodes??[])i&&(i+=`
7
- `),i+=`${Mi(e.toAst())}\n`;n=`${n}${n&&i?`
8
- `:``}${i}`;let a=``;for(let n of t.exports??[]){(!a&&i||a)&&(a+=`
9
- `);for(let r of n)a+=`${Mi(e.toExportAst(r,t.exportsOptions))}\n`}return n=`${n}${n&&a?`
10
- `:``}${a}`,t.trailingNewline===!1&&n.endsWith(`
11
- `)&&(n=n.slice(0,-1)),n}static toExportAst(e,t){let n=e.exports.map(e=>m.default.factory.createExportSpecifier(e.isTypeOnly,e.sourceName===e.exportedName?void 0:I.id(e.sourceName).toAst(),I.id(e.exportedName).toAst())),r=e.namespaceExport?m.default.factory.createNamespaceExport(I.id(e.namespaceExport).toAst()):(!e.canExportAll||!t?.preferExportAll)&&n.length?m.default.factory.createNamedExports(n):void 0;return m.default.factory.createExportDeclaration(void 0,e.isTypeOnly,r,I.literal(e.modulePath).toAst())}static toImportAst(e){let t=e.imports.map(e=>m.default.factory.createImportSpecifier(e.isTypeOnly,e.sourceName===e.localName?void 0:I.id(e.sourceName).toAst(),I.id(e.localName).toAst())),n=m.default.factory.createImportClause(e.isTypeOnly,e.kind===`default`?I.id(e.localName??``).toAst():void 0,e.kind===`namespace`?m.default.factory.createNamespaceImport(I.id(e.localName??``).toAst()):t.length>0?m.default.factory.createNamedImports(t):void 0);return m.default.factory.createImportDeclaration(void 0,n,I.literal(e.modulePath).toAst())}getExports(e){let t=new Map;for(let n of e.file.exports){let r=Ni({file:e.file,fromFile:n.from,preferFileExtension:this._preferFileExtension,root:e.project.root}),i=this._resolveModuleName?.(r[2])??r[2],[a]=r;t.has(a)||t.set(a,new Map);let o=t.get(a);o.has(i)||o.set(i,{group:{canExportAll:n.canExportAll,exports:n.exports,isTypeOnly:n.isTypeOnly,modulePath:i,namespaceExport:n.namespaceExport},sortKey:r})}return Array.from(t.entries()).sort((e,t)=>e[0]-t[0]).map(([,e])=>{let t=Array.from(e.values());return t.sort((e,t)=>{let n=e.sortKey[1]-t.sortKey[1];return n===0?e.group.modulePath.localeCompare(t.group.modulePath):n}),t.map(e=>{let t=e.group;if(t.namespaceExport)t.exports=[];else{if(!t.exports.find(e=>!e.isTypeOnly)){t.isTypeOnly=!0;for(let e of t.exports)e.isTypeOnly=!1}t.exports.sort((e,t)=>e.exportedName.localeCompare(t.exportedName))}return t})})}getImports(e){let t=new Map;for(let n of e.file.imports){let r=Ni({file:e.file,fromFile:n.from,preferFileExtension:this._preferFileExtension,root:e.project.root}),i=this._resolveModuleName?.(r[2])??r[2],[a]=r;t.has(a)||t.set(a,new Map);let o=t.get(a);o.has(i)||o.set(i,{group:{imports:[],isTypeOnly:!1,kind:n.kind,modulePath:i},sortKey:r});let s=o.get(i).group;n.kind===`named`?s.imports.push(...n.imports):(s.isTypeOnly=n.isTypeOnly,s.kind=n.kind,s.localName=n.localName)}return Array.from(t.entries()).sort((e,t)=>e[0]-t[0]).map(([,e])=>{let t=Array.from(e.values());return t.sort((e,t)=>{let n=e.sortKey[1]-t.sortKey[1];return n===0?e.group.modulePath.localeCompare(t.group.modulePath):n}),t.map(e=>{let t=e.group;if(t.kind===`namespace`)t.imports=[];else{if(!t.imports.find(e=>!e.isTypeOnly)){t.isTypeOnly=!0;for(let e of t.imports)e.isTypeOnly=!1}t.imports.sort((e,t)=>e.localName.localeCompare(t.localName))}return t})})}};const Ii={array:(...e)=>new fr(...e),as:(...e)=>new hr(...e),attr:(...e)=>new yr(...e),await:(...e)=>new xr(...e),binary:(...e)=>new F(...e),block:(...e)=>new P(...e),call:(...e)=>new Cr(...e),class:(...e)=>new $n(...e),const:(...e)=>new $r(...e).const(),decorator:(...e)=>new Qt(...e),doc:(...e)=>new dn(...e),enum:(...e)=>new rr(...e),expr:(...e)=>new Tr(...e),field:(...e)=>new Fn(...e),fromValue:(...e)=>Mr(...e),func:((e,t)=>e===void 0?new or:typeof e!=`string`||t===void 0?new or(e):new or(e,t)),getter:(...e)=>new cr(...e),hint:(...e)=>new Er(...e),id:(...e)=>new Et(...e),if:(...e)=>new Gr(...e),init:(...e)=>new Jn(...e),lazy:(...e)=>new ki(...e),let:(...e)=>new $r(...e).let(),literal:(...e)=>new k(...e),member:(...e)=>new tr(...e),method:(...e)=>new Zn(...e),neg:(...e)=>new At(...e).neg(),new:(...e)=>new Pr(...e),newline:(...e)=>new Dt(...e),not:(...e)=>new At(...e).not(),note:(...e)=>new Ur(...e),object:(...e)=>new jr(...e),param:(...e)=>new Un(...e),pattern:(...e)=>new Bn(...e),prefix:(...e)=>new At(...e),prop:(...e)=>new kr(...e),regexp:(...e)=>new Ir(...e),return:(...e)=>new qr(...e),setter:(...e)=>new ur(...e),stmt:(...e)=>new Ln(...e),template:(...e)=>new Rr(...e),ternary:(...e)=>new Br(...e),throw:(...e)=>new Yr(...e),token:(...e)=>new N(...e),try:(...e)=>new Zr(...e),type:Object.assign((...e)=>new Nn(...e),{alias:(...e)=>new ti(...e),and:(...e)=>new ri(...e),attr:(...e)=>new jn(...e),expr:(...e)=>new Nn(...e),fromValue:(...e)=>mi(...e),func:(...e)=>new gi(...e),idx:(...e)=>new vi(...e),literal:(...e)=>new ai(...e),mapped:(...e)=>new bi(...e),object:(...e)=>new di(...e),operator:(...e)=>new Si(...e),or:(...e)=>new wi(...e),param:(...e)=>new wn(...e),query:(...e)=>new Ei(...e),template:(...e)=>new Oi(...e),tuple:(...e)=>new pi(...e)}),typeofExpr:(...e)=>new Hr(...e),var:(...e)=>new $r(...e)},I=Object.assign((...e)=>new Tr(...e),Ii),Li=/[\p{Lu}]/u,Ri=/[\p{Ll}]/u,zi=/([\p{Alpha}\p{N}_]|$)/u,Bi=/[_.$+:\- `\\[\](){}\\/]+/,Vi=RegExp(`^${Bi.source}`),Hi=RegExp(`${Bi.source}${zi.source}`,`gu`),Ui=RegExp(`\\d+${zi.source}`,`gu`),Wi=(e,t)=>{let n=!1,r=!1,i=!1,a=!1,o=t===`snake_case`||t===`SCREAMING_SNAKE_CASE`?`_`:`-`;for(let t=0;t<e.length;t++){let s=e[t];a=t>2?e[t-3]===o:!0;let c=t+1,l=e[c];for(Bi.lastIndex=0;l&&Bi.test(l);)c+=1,l=e[c];let u=c!==t+1;if(Ri.lastIndex=0,Li.lastIndex=0,Li.test(s)&&(n||l&&!u&&l!==`s`&&Ri.test(l)))e=`${e.slice(0,t)}${o}${e.slice(t)}`,t++,i=r,n=!1,r=!0;else if(r&&i&&Ri.test(s)&&!a&&!(s===`s`&&(!l||l.toLocaleLowerCase()!==l)))e=`${e.slice(0,t-1)}${o}${e.slice(t-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 e},L=(e,t,n={})=>{let r=n.stripLeadingSeparators??!0,i=e.trim();return!i.length||!t||t===`preserve`?i:i.length===1?(Bi.lastIndex=0,Bi.test(i)?``:t===`PascalCase`||t===`SCREAMING_SNAKE_CASE`?i.toLocaleUpperCase():i.toLocaleLowerCase()):(i!==i.toLocaleLowerCase()&&(i=Wi(i,t)),(r||i[0]!==e[0])&&(i=i.replace(Vi,``)),i=t===`SCREAMING_SNAKE_CASE`?i.toLocaleUpperCase():i.toLocaleLowerCase(),t===`PascalCase`&&(i=`${i.charAt(0).toLocaleUpperCase()}${i.slice(1)}`),t===`snake_case`||t===`SCREAMING_SNAKE_CASE`?(i=i.replaceAll(Hi,(e,t,n)=>n===0&&!r?e:`_${t}`),i[i.length-1]===`_`&&(i=i.slice(0,i.length-1))):(Hi.lastIndex=0,Ui.lastIndex=0,i=i.replaceAll(Ui,(e,t,n)=>[`_`,`-`,`.`].includes(i.charAt(n+e.length))?e:e.toLocaleUpperCase()),i=i.replaceAll(Hi,(t,n,i)=>i===0&&!r&&t[0]&&e.startsWith(t[0])?t:n.toLocaleUpperCase())),i)};function R(e,t){let n=e,r=t.casing??t.case;if(t.name)if(typeof t.name==`function`)n=t.name(n);else{let e=!r||r===`preserve`?``:`-`;n=t.name.replace(`{{name}}`,`${e}${n}${e}`)}return L(n,r)}const Gi=({plugin:e,sdkSymbol:t,symbol:n})=>{let r=e.symbol(`defaultKey`),i=e.symbol(`instances`);return I.class(n).generic(`T`).field(r,e=>e.private().readonly().assign(I.literal(`default`))).newline().field(i,e=>e.private().readonly().type(I.type(`Map`).generics(`string`,`T`)).assign(I.new(`Map`))).newline().method(`get`,e=>e.returns(`T`).param(`key`,e=>e.type(`string`).optional()).do(I.const(`instance`).assign(I(`this`).attr(i).attr(`get`).call(I(`key`).coalesce(I(`this`).attr(r)))),I.if(I.not(`instance`)).do(I.throw(`Error`).message(I.template(`No SDK client found. Create one with "new `).add(t).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(i).attr(`set`).call(I(`key`).coalesce(I(`this`).attr(r)),`value`)))},Ki=({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).field(`client`,e=>e.protected().type(i)).newline().init(e=>e.param(`args`,e=>e.optional(r).type(I.type.object().prop(`client`,e=>e.optional(r).type(i)))).do(I(`this`).attr(`client`).assign(I(`args`).attr(`client`).optional(r).$if(r,e=>e.coalesce(n)))))},qi=`TComposable`,Ji=`DefaultT`,Yi=`ResT`,Xi=({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}},Zi=({operation:e,plugin:t})=>{if(!e.security||!t.config.auth)return[];let n=[];for(let t of e.security){let e=Xi({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},Qi=/~1/g,$i=/~0/g,z=e=>{let t=ta(e),n=t[t.length-1];return decodeURI(n)},ea=e=>String(e).replace(/~/g,`~0`).replace(/\//g,`~1`),ta=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(Qi,`/`).replace($i,`~`)):[]},na=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},ra=e=>{let t=e.map(ea).join(`/`);return`#`+(t?`/${t}`:``)},ia=({$ref:e,spec:t})=>{let n=ta(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},aa=({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(L(z(e.body.schema.$ref),`camelCase`),`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=L(z(e.body.schema.$ref),`camelCase`),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}},oa=({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})},sa=({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})},ca=({isDataAllowed:e=!0,operation:t,plugin:n,throwOnError:r})=>{let i=x(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`});return I.type(o).generic(qi).generic(e?a??`unknown`:`never`).generic(r??`unknown`).generic(Ji)}return r?I.type(o).generic(e?a??`unknown`:`never`).generic(r):I.type(o).$if(!e||a,t=>t.generic(e?a:`never`))},la=({isRequiredOptions:e,operation:t,plugin:n})=>{let r={argNames:[],fields:[],parameters:[]},i=n.getPluginOrThrow(`@hey-api/typescript`),a=x(n.context.config).name===`@hey-api/client-nuxt`;if(n.config.paramsStructure===`flat`){let e=aa({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:(0,l.refs)({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(ca({isDataAllowed:n.config.paramsStructure===`grouped`,operation:t,plugin:n,throwOnError:a?void 0:`ThrowOnError`})))),r},ua=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`}},da=({isRequiredOptions:e,opParameters:t,operation:n,plugin:r})=>{let i=x(r.context.config),a=i.name===`@hey-api/client-nuxt`,o=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:a?`response`:`responses`}),s=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:a?`error`:`errors`}),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);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);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=oa({operation:n,plugin:r}),d=sa({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))}}let f=!1,p;for(let e in n.responses){let t=n.responses[e];!p&&i.name===`@hey-api/client-axios`&&St({statusCode:e})===`2XX`&&(p=ua(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=Zi({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 ee=[],h=t.argNames.length;if(h){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`});ee.push(I.const(`params`).assign(I(i).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));h&&r.spread(I(`params`).attr(`headers`)),c.prop(`headers`,r)}}let te=r.config.client?r.getSymbol({category:`client`}):void 0,ne,re=I(`options`).attr(`client`).required(e);ne=pa(r)?re.coalesce(I(`this`).attr(`client`)):te?re.coalesce(te):re;let ie=f?ne.attr(`sse`):ne;return ie=ie.attr(n.method),ee.push(I.return(ie.call(c).$if(a,e=>e.generic(qi).generic(I.type.or(o??`unknown`,Ji)).generic(s??`unknown`).generic(Ji),e=>e.generic(o??`unknown`).generic(s??`unknown`).generic(`ThrowOnError`)).$if(r.config.responseStyle===`data`,e=>e.generic(I.type.literal(r.config.responseStyle))))),ee},fa=globalThis.Symbol(`@hey-api/sdk`);function pa(e){let t=e.config.operations;return t.container===`class`&&t.methods===`instance`&&t.strategy!==`flat`}function ma(e){let{node:t,operation:n}=e;return t.$if(wa(n),(e,t)=>e.doc(t))}function ha(e){return{category:`utility`,resource:`class`,resourceId:e.getPath().join(`.`),tool:`sdk`}}function ga(e,t){let{operation:n,path:r,tags:i}=t.data,a=t.location[t.location.length-1];return e.symbol(R(a,e.config.operations.methodName),{meta:{category:`sdk`,path:r,resource:`operation`,resourceId:n.id,tags:i,tool:`sdk`}})}function _a(e,t){let n=t.referenceSymbol(ha(e)),r=L(n.name,t.config.operations.methodName.casing??`camelCase`),i=t.symbol(r);if(pa(t)){let e=t.symbol(`_${r}`);return[I.field(e,e=>e.private().optional().type(n)),I.getter(i,t=>t.returns(n).do(I(`this`).attr(e).nullishAssign(I.new(n).args(I.object().prop(`client`,I(`this`).attr(`client`)))).return()))]}return t.isSymbolRegistered(n.id)?[I.field(i,e=>e.static().assign(I(n)))]:[I.getter(i,e=>e.public().static().do(I.return(n)))]}function va(e){let t=x(e.context.config).name===`@hey-api/client-angular`;return{define:n=>{let r=e.symbol(R(n.name,n.isRoot?e.config.operations.containerName:e.config.operations.segmentName),{meta:ha(n)}),i=I.class(r).export().$if(pa(e),t=>t.extends(e.referenceSymbol({category:`utility`,resource:`class`,resourceId:`HeyApiClient`,tool:`sdk`}))).$if(t&&n.isRoot,t=>t.decorator(e.external(`@angular/core.Injectable`),I.object().prop(`providedIn`,I.literal(`root`)))),a=[];return n.isRoot&&pa(e)&&ya({dependencies:a,node:i,plugin:e,symbol:r}),{dependencies:a,node:i}}}}function ya(e){let{dependencies:t,node:n,plugin:r,symbol:i}=e,a=r.symbol(`HeyApiClient`,{meta:{category:`utility`,resource:`class`,resourceId:`HeyApiClient`,tool:`sdk`}});t.push(Ki({plugin:r,symbol:a}));let o=r.symbol(`HeyApiRegistry`,{meta:{category:`utility`,resource:`class`,resourceId:`HeyApiRegistry`,tool:`sdk`}});t.push(Gi({plugin:r,sdkSymbol:i,symbol:o}));let s=!r.config.client||!r.getSymbol({category:`client`}),c=r.symbol(`__registry`);n.toAccessNode=(e,t)=>{if(!t.context)return I(e.name).attr(c).attr(`get`).call()},n.do(I.field(c,e=>e.public().static().readonly().assign(I.new(o).generic(i))),I.newline(),I.init(e=>e.param(`args`,e=>e.required(s).type(I.type.object().prop(`client`,e=>e.required(s).type(r.external(`client.Client`))).prop(`key`,e=>e.optional().type(`string`)))).do(I(`super`).call(`args`),I(i).attr(c).attr(`set`).call(`this`,I(`args`).attr(`key`).required(s)))))}function ba(e,t,n){let r=n.config.examples;r.enabled&&n.intent({async run(n){let{payload:i}=r,a=un.example(e,{...r,payload:e=>typeof i==`function`?i(t,e):i});r.transform&&(a=await r.transform(a,t)),a&&n.setExample(t,{lang:r.language,source:a})}})}function xa(e){let{node:t,operation:n,plugin:r}=e,i=x(r.context.config),a=i.name===`@hey-api/client-nuxt`,o=Ta({context:r.context,operation:n}),s=la({isRequiredOptions:o,operation:n,plugin:r}),c=da({isRequiredOptions:o,opParameters:s,operation:n,plugin:r});return t.$if(a,e=>e.generic(qi,e=>e.extends(r.external(`client.Composable`)).default(I.type.literal(`$fetch`))).generic(Ji,e=>e.$if(r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`response`}),(e,t)=>e.extends(t).default(t),e=>e.default(`undefined`))),e=>e.generic(`ThrowOnError`,e=>e.extends(`boolean`).default((`throwOnError`in i.config?i.config.throwOnError:!1)??!1))).params(...s.parameters).do(...c)}function Sa(e,t){if(e.virtual){let n=[];for(let r of e.itemsFrom(fa)){let{operation:e}=r.data,i=I.const(ga(t,r)).export().assign(xa({node:I.func(),operation:e,plugin:t}));i=ma({node:i,operation:e}),n.push(i),ba(i,e,t)}return{nodes:n}}if(!e.shell)return{nodes:[]};let n=[],r=x(t.context.config).name===`@hey-api/client-angular`,i=e.shell.define(e),a=i.node,o=0;for(let n of e.itemsFrom(fa)){let{operation:e}=n.data;if(a[`~dsl`]!==`VarTsDsl`){(o>0||a.hasBody)&&a.newline();let i=xa({node:I.method(ga(t,n),n=>ma({node:n,operation:e}).public().static(!r&&!pa(t))),operation:e,plugin:t});a.do(i),ba(i,e,t)}o+=1}for(let n of e.children.values())a[`~dsl`]===`VarTsDsl`||(a.hasBody&&a.newline(),a.do(..._a(n,t)));return n.push(a),{dependencies:i.dependencies,nodes:n}}const Ca=e=>e.replace(/\*\//g,`*`).replace(/\/\*/g,`*`).replace(/\r?\n(.*)/g,(e,t)=>ee.EOL+t.trim()),wa=e=>{let t=[];return e.summary&&t.push(Ca(e.summary)),e.description&&(t.length&&t.push(``),t.push(Ca(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},Ta=({context:e,operation:t})=>{let n=x(e.config).name===`@hey-api/client-nuxt`,r=e.config.plugins[`@hey-api/sdk`];if(r){if(!r.config.client&&!pa(r))return!0;if(r.config.paramsStructure===`flat`)return!1}return n||bt(t)},Ea=({operation:e})=>{for(let t in e.responses)if(e.responses[t].mediaType===`text/event-stream`)return!0;return!1},Da=globalThis.Symbol(`@angular/common`);function Oa(e){let{node:t,operation:n}=e;return t.$if(wa(n),(e,t)=>e.doc(t))}function ka(e){return{category:`utility`,resource:`operation`,resourceId:e.id,role:`request`,tool:`angular`}}function Aa(e){return{category:`utility`,resource:`shell`,resourceId:e.getPath().join(`.`),role:`request`,tool:`angular`}}function ja(e){return{category:`utility`,resource:`operation`,resourceId:e.id,role:`resource`,tool:`angular`}}function Ma(e){return{category:`utility`,resource:`shell`,resourceId:e.getPath().join(`.`),role:`resource`,tool:`angular`}}function Na(e,t){let{operation:n}=t.data,r=t.location[t.location.length-1];return e.symbol(R(r,e.config.httpRequests.methodName),{meta:ka(n)})}function Pa(e,t){let{operation:n}=t.data,r=t.location[t.location.length-1];return e.symbol(R(r,e.config.httpResources.methodName),{meta:ja(n)})}function Fa(e,t){let n=t.referenceSymbol(Aa(e)),r=L(n.name,`camelCase`),i=t.symbol(r),a=t.symbol(`_${r}`);return[I.field(a,e=>e.private().optional().type(n)),I.getter(i,e=>e.returns(n).do(I(`this`).attr(a).nullishAssign(I.new(n).args()).return()))]}function Ia(e,t){let n=t.referenceSymbol(Ma(e)),r=L(n.name,`camelCase`),i=t.symbol(r),a=t.symbol(`_${r}`);return[I.field(a,e=>e.private().optional().type(n)),I.getter(i,e=>e.returns(n).do(I(`this`).attr(a).nullishAssign(I.new(n).args()).return()))]}function La(e){let t=x(e.context.config).name===`@hey-api/client-angular`,n=e.external(`@angular/core.Injectable`);return{define:r=>{let i=e.symbol(R(r.name,r.isRoot?e.config.httpRequests.containerName:e.config.httpRequests.segmentName),{meta:Aa(r)});return{dependencies:[],node:I.class(i).export().$if(t&&r.isRoot,e=>e.decorator(n,I.object().prop(`providedIn`,I.literal(`root`))))}}}}function Ra(e){let t=x(e.context.config).name===`@hey-api/client-angular`,n=e.external(`@angular/core.Injectable`);return{define:r=>{let i=e.symbol(R(r.name,r.isRoot?e.config.httpResources.containerName:e.config.httpResources.segmentName),{meta:Ma(r)});return{dependencies:[],node:I.class(i).export().$if(t&&r.isRoot,e=>e.decorator(n,I.object().prop(`providedIn`,I.literal(`root`))))}}}}function za(e){let{node:t,operation:n,plugin:r}=e,i=Ta({context:r.context,operation:n}),a=r.external(`@angular/common/http.HttpRequest`),o=r.getSymbol({category:`client`}),s=r.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),c=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`data`,tool:`typescript`});return t.param(`options`,e=>e.required(i).type(I.type(s).generic(c??`unknown`).generic(`ThrowOnError`))).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(!1)).returns(I.type(a).generic(`unknown`)).do(I.return(I(`options`).attr(`client`).optional().$if(o,(e,t)=>e.coalesce(t)).attr(`requestOptions`).call(I.object().prop(`responseStyle`,I.literal(`data`)).prop(`method`,I.literal(n.method.toUpperCase())).prop(`url`,I.literal(n.path)).spread(`options`))))}function Ba(e){let{node:t,operation:n,plugin:r}=e,i=Ta({context:r.context,operation:n}),a=r.external(`@angular/common/http.httpResource`),o=r.external(`@angular/core.inject`),s=r.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),c=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`data`,tool:`typescript`}),l=r.querySymbol({category:`type`,resource:`operation`,resourceId:n.id,role:`response`});return t.param(`options`,e=>e.required(i).type(I.type.func().returns(I.type.or(I.type(s).generic(c??`unknown`).generic(`ThrowOnError`),I.type(`undefined`))))).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(!1)).do(I.return(I(a).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.lazy(e=>e.access(r.referenceSymbol(ka(n)),{transform:(e,t)=>t===0?e[`~dsl`]===`ClassTsDsl`?I(o).call(I(e.name)):I(e.name):e}).call(`opts`))).otherwise(I.id(`undefined`))))).generic(l??`unknown`)))}function Va(e,t){if(e.virtual){let n=[];for(let r of e.itemsFrom(Da)){let{operation:e}=r.data,i=I.const(Na(t,r)).export().assign(za({node:I.func(),operation:e,plugin:t}));i=Oa({node:i,operation:e}),n.push(i)}return{nodes:n}}if(!e.shell)return{nodes:[]};let n=[],r=e.shell.define(e),i=r.node,a=0;for(let n of e.itemsFrom(Da)){let{operation:e}=n.data;(a>0||i.hasBody)&&i.newline(),i.do(za({node:I.method(Na(t,n),t=>Oa({node:t,operation:e}).public()),operation:e,plugin:t})),a+=1}for(let n of e.children.values())i.hasBody&&i.newline(),i.do(...Fa(n,t));return n.push(i),{dependencies:r.dependencies,nodes:n}}function Ha(e,t){if(e.virtual){let n=[];for(let r of e.itemsFrom(Da)){let{operation:e}=r.data,i=I.const(Pa(t,r)).export().assign(Ba({node:I.func(),operation:e,plugin:t}));i=Oa({node:i,operation:e}),n.push(i)}return{nodes:n}}if(!e.shell)return{nodes:[]};let n=[],r=e.shell.define(e),i=r.node,a=0;for(let n of e.itemsFrom(Da)){let{operation:e}=n.data;(a>0||i.hasBody)&&i.newline(),i.do(Ba({node:I.method(Pa(t,n),t=>Oa({node:t,operation:e}).public()),operation:e,plugin:t})),a+=1}for(let n of e.children.values())i.hasBody&&i.newline(),i.do(...Ia(n,t));return n.push(i),{dependencies:r.dependencies,nodes:n}}const Ua=({plugin:e})=>{e.symbol(`HttpRequest`,{external:`@angular/common/http`,kind:`type`,meta:{category:`external`,resource:`@angular/common/http.HttpRequest`}}),e.symbol(`inject`,{external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.inject`}}),e.symbol(`Injectable`,{external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.Injectable`}}),e.symbol(`httpResource`,{external:`@angular/common/http`,meta:{category:`external`,resource:`@angular/common/http.httpResource`}});let t=new l.StructureModel,n=new l.StructureModel;if(e.config.httpRequests.enabled){let n=La(e),r=dt(e);e.forEach(`operation`,({operation:e})=>{t.insert({data:{operation:e},locations:r(e).map(e=>({path:e,shell:n})),source:Da})},{order:`declarations`})}if(e.config.httpResources.enabled){let t=Ra(e),r=mt(e);e.forEach(`operation`,({operation:e})=>{n.insert({data:{operation:e},locations:r(e).map(e=>({path:e,shell:t})),source:Da})},{order:`declarations`})}let r=[],i=[];for(let n of t.walk()){let{dependencies:t,nodes:a}=Va(n,e);r.push(...t??[]),i.push(...a)}for(let t of n.walk()){let{dependencies:n,nodes:a}=Ha(t,e);r.push(...n??[]),i.push(...a)}let a=new Map;for(let e of r)e.symbol&&a.set(e.symbol.id,e);for(let t of a.values())e.node(t);for(let t of i)e.node(t)},Wa={config:{exportFromIndex:!1},dependencies:[`@hey-api/client-angular`,`@hey-api/sdk`],handler:Ua,name:`@angular/common`,resolveConfig:(e,t)=>{e.config.httpRequests=lt(e.config,t),e.config.httpResources=ft(e.config,t)}},Ga=_(Wa),Ka={baseUrl:!0,bundle:!0,exportFromIndex:!1},qa={dependencies:[`@hey-api/typescript`],tags:[`client`]},Ja=(0,p.fileURLToPath)(require(`url`).pathToFileURL(__filename).href),Ya=f.default.dirname(Ja),Xa=e=>{let t=x(e);if(`bundle`in t.config&&t.config.bundle){let t=e._FRAGILE_CLIENT_BUNDLE_RENAMED;return f.default.resolve(e.output.path,`client`,`${t?.get(`index`)??`index`}.ts`)}return t.name},Za=(e,t)=>{if(d.default.statSync(e).isDirectory()){d.default.existsSync(t)||d.default.mkdirSync(t,{recursive:!0});let n=d.default.readdirSync(e);for(let r of n)Za(f.default.join(e,r),f.default.join(t,r))}else{let n=d.default.readFileSync(e);d.default.writeFileSync(t,n)}},Qa=({filePath:e,project:t,renamed:n})=>{let r=f.default.extname(e),i=f.default.basename(e,r),a=t.fileName?.(i)||i;if(a!==i){let t=f.default.dirname(e);d.default.renameSync(e,f.default.resolve(t,`${a}${r}`)),n.set(i,a)}},$a=({filePath:e,meta:t,renamed:n})=>{let r=d.default.readFileSync(e,`utf8`);r=r.replace(/from\s+['"](\.\.?\/[^'"]*?)['"]/g,(e,r)=>{let i=e.indexOf(r),a=f.default.extname(r),o=f.default.basename(r,a),s=f.default.dirname(r),c=(n.get(o)??o)+(t.importFileExtension?t.importFileExtension:a);return e.slice(0,i)+[s,c].filter(Boolean).join(`/`)+e.slice(i+r.length)}),r=`// This file is auto-generated by @hey-api/openapi-ts
12
-
13
- ${r}`,d.default.writeFileSync(e,r,`utf8`)},eo=({meta:e,outputPath:t,plugin:n,project:r})=>{let i=new Map;if(n.name.startsWith(`@hey-api/client-`)){let a=f.default.resolve(t,`core`);ce(a),Za(f.default.resolve(Ya,`clients`,`core`),a);let o=f.default.resolve(t,`client`);ce(o);let s=n.name.slice(16);if(Za(f.default.resolve(Ya,`clients`,s),o),r){let e=d.default.readdirSync(a);for(let t of e)Qa({filePath:f.default.resolve(a,t),project:r,renamed:i});let t=d.default.readdirSync(o);for(let e of t)Qa({filePath:f.default.resolve(o,e),project:r,renamed:i})}let c=d.default.readdirSync(a);for(let t of c)$a({filePath:f.default.resolve(a,t),meta:e,renamed:i});let l=d.default.readdirSync(o);for(let t of l)$a({filePath:f.default.resolve(o,t),meta:e,renamed:i});return i}let a=f.default.isAbsolute(n.name)?f.default.dirname(n.name):void 0;if(a){let e=f.default.resolve(t,`client`);ce(e),Za(a,e);return}let o=f.default.normalize(require.resolve(n.name)).split(f.default.sep),s=o.slice(0,o.indexOf(`dist`)+1).join(f.default.sep),c=[o[o.length-1],`index.d.mts`,`index.d.cts`],l=f.default.resolve(t,`client`);ce(l);for(let e of c)d.default.copyFileSync(f.default.resolve(s,e),f.default.resolve(l,e))},to=/^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/,no=e=>{let t={host:``,path:``,port:``,protocol:``};to.lastIndex=0;let n=e.match(to);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}},ro=({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},io=({plugin:e})=>{let t=Xa(e.context.config),n=e.symbol(`createClient`,{external:t}),r=e.symbol(`createConfig`,{external:t}),i=e.referenceSymbol({category:`type`,resource:`client`,role:`options`}),{runtimeConfigPath:a}=e.config,o=a?e.symbol(`createClientConfig`,{external:a}):void 0,s=I.object(),c=ro({plugin:e});if(c){let t=no(c);if(t.protocol&&t.host&&!c.includes(`{`))s.prop(ht(e.context.config),I.literal(c));else if(c!==`/`&&c.startsWith(`/`)){let t=c.endsWith(`/`)?c.slice(0,-1):c;s.prop(ht(e.context.config),I.literal(t))}}`throwOnError`in e.config&&e.config.throwOnError&&s.prop(`throwOnError`,I.literal(!0));let l=[I(r).call(s.hasProps()?s:void 0).generic(i)],u=e.symbol(`client`,{meta:{category:`client`}}),d=I.const(u).export().assign(I(n).$if(o,(e,t)=>e.call(I(t).call(...l)),e=>e.call(...l)));e.node(d)},ao=({plugin:e})=>{let t=Xa(e.context.config),n=e.referenceSymbol({category:`type`,resource:`client`,role:`options`}),r=e.symbol(`Config`,{external:t,kind:`type`}),i=e.symbol(`ClientOptions`,{external:t,kind:`type`}),a=e.symbol(`CreateClientConfig`),o=I.type.alias(a).export().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).default(n)).type(I.type.func().param(`override`,e=>e.optional().type(I.type(r).generic(I.type.and(i,`T`)))).returns(I.type(r).generic(I.type.and(I.type(`Required`).generic(i),`T`))));e.node(o)},oo=({plugin:e})=>{ao({plugin:e}),io({plugin:e})},so={...qa,config:{...Ka,throwOnError:!1},handler:oo,name:`@hey-api/client-angular`},co=_(so),lo={...qa,config:{...Ka,throwOnError:!1},handler:oo,name:`@hey-api/client-axios`},uo=_(lo),fo={...qa,config:{...Ka,throwOnError:!1},handler:oo,name:`@hey-api/client-fetch`},po=_(fo),mo={...qa,config:{...Ka,throwOnError:!1},handler:oo,name:`@hey-api/client-ky`},ho=_(mo),go={...qa,config:{...Ka,throwOnError:!1},handler:oo,name:`@hey-api/client-next`},_o=_(go),vo={...qa,config:Ka,handler:oo,name:`@hey-api/client-nuxt`},yo=_(vo),bo={...qa,config:{...Ka,throwOnError:!1},handler:oo,name:`@hey-api/client-ofetch`},xo=_(bo),So=(...e)=>h.satisfies(...e),Co=e=>({getVersion:t=>{let n=e[t];if(n)try{let e=h.parse(n);if(e)return e;let t=h.minVersion(n);if(t)return t;if(e=h.coerce(n),e)return e}catch{}},isInstalled:t=>!!e[t],satisfies:(t,n,r)=>{let i=typeof t==`string`?e[t]:t;return i?So(i,n,r):!1}}),wo=({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)},To=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>To({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(r.$ref)return r.$ref=decodeURI(r.$ref),r;if(wo({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=To({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>To({context:e,plugin:t,schema:n})),r.items&&=To({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]=To({context:e,plugin:t,schema:i}))}return r},Eo=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Eo({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(`$ref`in r)return r.$ref=decodeURI(r.$ref),r;if(wo({plugin:t,schema:r}),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Eo({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Eo({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>Eo({context:e,plugin:t,schema:n})),r.items&&=Eo({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>Eo({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]=Eo({context:e,plugin:t,schema:i}))}return r},Do=({context:e,plugin:t,schema:n})=>{if(Array.isArray(n))return n.map(n=>Do({context:e,plugin:t,schema:n}));let r=structuredClone(n);if(wo({plugin:t,schema:r}),r.$ref&&=decodeURI(r.$ref),r.additionalProperties&&typeof r.additionalProperties!=`boolean`&&(r.additionalProperties=Do({context:e,plugin:t,schema:r.additionalProperties})),r.allOf&&=r.allOf.map(n=>Do({context:e,plugin:t,schema:n})),r.anyOf&&=r.anyOf.map(n=>Do({context:e,plugin:t,schema:n})),r.items&&=Do({context:e,plugin:t,schema:r.items}),r.oneOf&&=r.oneOf.map(n=>Do({context:e,plugin:t,schema:n})),r.prefixItems&&=r.prefixItems.map(n=>Do({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]=Do({context:e,plugin:t,schema:i}))}return r},Oo=({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`,r},ko=({context:e,plugin:t})=>{if(e.spec.definitions)for(let n in e.spec.definitions){let r=e.spec.definitions[n],i=t.symbol(Oo({name:n,plugin:t,schema:r}),{meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`}}),a=To({context:e,plugin:t,schema:r}),o=I.const(i).export().assign(I(I.fromValue(a,{layout:`pretty`})).as(`const`));t.node(o)}},Ao=({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.symbol(Oo({name:n,plugin:t,schema:r}),{meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`}}),a=Eo({context:e,plugin:t,schema:r}),o=I.const(i).export().assign(I(I.fromValue(a,{layout:`pretty`})).as(`const`));t.node(o)}},jo=({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.symbol(Oo({name:n,plugin:t,schema:r}),{meta:{category:`schema`,resource:`definition`,resourceId:n,tool:`json-schema`}}),a=Do({context:e,plugin:t,schema:r}),o=I.const(i).export().assign(I(I.fromValue(a,{layout:`pretty`})).as(`const`));t.node(o)}},Mo=({plugin:e})=>{if(`swagger`in e.context.spec){ko({context:e.context,plugin:e});return}if(So(e.context.spec.openapi,`>=3.0.0 <3.1.0`)){Ao({context:e.context,plugin:e});return}if(So(e.context.spec.openapi,`>=3.1.0`)){jo({context:e.context,plugin:e});return}throw Error(`Unsupported OpenAPI specification`)},No={config:{exportFromIndex:!1,nameBuilder:e=>`${e}Schema`,type:`json`},handler:Mo,name:`@hey-api/schemas`},Po=_(No);function Fo(e,t){return t.valueToObject({defaultValue:{enabled:!!e.examples,language:`JavaScript`},mappers:{boolean:e=>({enabled:e})},value:e.examples})}function Io(e,t){e.asClass!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`asClass`,replacement:[`operations: { strategy: "byTags" }`,`operations: { strategy: "single" }`]}),e.classNameBuilder!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`classNameBuilder`,replacement:`operations: { containerName: "..." }`}),e.classStructure!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`classStructure`,replacement:[`operations: { nesting: "operationId" }`,`operations: { nesting: "id" }`]}),e.instance!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`instance`,replacement:`operations: { strategy: "single", containerName: "${e.instance||`Name`}", methods: "instance" }`}),e.methodNameBuilder!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`methodNameBuilder`,replacement:`operations: { methodName: "..." }`}),e.operationId!==void 0&&l.log.warnDeprecated({context:`@hey-api/sdk`,field:`operationId`,replacement:[`operations: { nesting: "operationId" }`,`operations: { nesting: "id" }`]});let n=Ro(e);return Lo(e.operations,n,t)}function Lo(e,t,n){(!e||typeof e==`string`||typeof e==`function`)&&(e={strategy:e});let r=t.strategy??e.strategy??`flat`,i=r===`single`?`instance`:`static`;return n.valueToObject({defaultValue:{container:`class`,methods:i,nesting:`operationId`,nestingDelimiters:/[./]/,strategy:r,strategyDefaultTag:`default`},mappers:{object(e){return e.containerName=n.valueToObject({defaultValue:r===`single`?{casing:`PascalCase`,name:`Sdk`}:{casing:`PascalCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.containerName}),e.methodName=n.valueToObject({defaultValue:{casing:`camelCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.methodName}),e.segmentName=n.valueToObject({defaultValue:{casing:`PascalCase`},mappers:{function:e=>({name:e}),string:e=>({name:e})},value:e.segmentName}),e}},value:{...t,...e}})}function Ro(e){let t;e.instance?t=`single`:e.asClass?t=`byTags`:(e.instance===!1||e.asClass===!1)&&(t=`flat`);let n,r;if(e.instance){let t=typeof e.instance==`string`?e.instance:`Sdk`;r={casing:`PascalCase`},e.classNameBuilder&&(r.name=e.classNameBuilder,t=typeof e.classNameBuilder==`string`?e.classNameBuilder.replace(`{{name}}`,t):e.classNameBuilder(t)),n={casing:`PascalCase`,name:t}}else e.classNameBuilder?(n={casing:`PascalCase`,name:e.classNameBuilder},r={...n}):e.asClass&&(n={casing:`PascalCase`},r={...n});let i;e.instance?i=`instance`:e.asClass&&(i=`static`);let a;e.classStructure===`off`||e.operationId===!1?a=`id`:e.classStructure===`auto`&&(a=`operationId`);let o;return e.methodNameBuilder&&(o={casing:`camelCase`,name:e.methodNameBuilder}),{containerName:n,methodName:o,methods:i,nesting:a,segmentName:r,strategy:t}}function zo(e){return e.config.operations.nesting===`id`?b.id():e.config.operations.nesting===`operationId`?b.fromOperationId({delimiters:e.config.operations.nestingDelimiters,fallback:b.id()}):e.config.operations.nesting}function Bo(e){if(e.config.operations.strategy===`flat`)return y.flat({path:t=>[zo(e)(t).join(`.`)]});if(e.config.operations.strategy===`single`){let t=e.config.operations.containerName;return y.single({path:zo(e),root:typeof t.name==`string`?t.name:t.name?.(``)??``})}return e.config.operations.strategy===`byTags`?y.byTags({fallback:e.config.operations.strategyDefaultTag,path:zo(e)}):e.config.operations.strategy}const Vo=({plugin:e})=>{let t=Xa(e.context.config),n=x(e.context.config),r=n.name===`@hey-api/client-nuxt`,i=e.symbol(`TDataShape`,{external:t,kind:`type`}),a=e.symbol(`Client`,{external:t,kind:`type`,meta:{category:`external`,resource:`client.Client`,tool:n.name}}),o=e.symbol(`Options`,{external:t,kind:`type`}),s=e.symbol(`Options`,{meta:{category:`type`,resource:`client-options`,tool:`sdk`}}),c=I.type.alias(s).export().$if(r,t=>t.generic(`TComposable`,t=>t.extends(e.referenceSymbol({category:`external`,resource:`client.Composable`})).default(I.type.literal(`$fetch`))).generic(`TData`,e=>e.extends(i).default(i)).generic(Yi,e=>e.default(`unknown`)).generic(Ji,e=>e.default(`undefined`)),e=>e.generic(`TData`,e=>e.extends(i).default(i)).generic(`ThrowOnError`,e=>e.extends(`boolean`).default(`boolean`))).type(I.type.and(I.type(o).$if(r,e=>e.generic(`TComposable`).generic(`TData`).generic(Yi).generic(Ji),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&&!pa(e)).type(a)).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.node(c)},Ho=({plugin:e})=>{let t=Xa(e.context.config),n=x(e.context.config),r=n.name===`@hey-api/client-angular`,i=n.name===`@hey-api/client-nuxt`;e.symbol(`formDataBodySerializer`,{external:t,meta:{category:`external`,resource:`client.formDataBodySerializer`,tool:n.name}}),e.symbol(`urlSearchParamsBodySerializer`,{external:t,meta:{category:`external`,resource:`client.urlSearchParamsBodySerializer`,tool:n.name}}),e.symbol(`buildClientParams`,{external:t,meta:{category:`external`,resource:`client.buildClientParams`,tool:n.name}}),i&&e.symbol(`Composable`,{external:t,kind:`type`,meta:{category:`external`,resource:`client.Composable`,tool:n.name}}),r&&e.symbol(`Injectable`,{external:`@angular/core`,meta:{category:`external`,resource:`@angular/core.Injectable`}}),Vo({plugin:e});let a=new l.StructureModel,o=va(e),s=Bo(e);e.forEach(`operation`,e=>{a.insert({data:{operation:e.operation,path:e._path,tags:e.tags},locations:s(e.operation).map(e=>({path:e,shell:o})),source:fa})},{order:`declarations`});let c=[],u=[];for(let t of a.walk()){let{dependencies:n,nodes:r}=Sa(t,e);c.push(...n??[]),u.push(...r)}let d=new Map;for(let e of c)e.symbol&&d.set(e.symbol.id,e);for(let t of d.values())e.node(t);for(let t of u)e.node(t)},Uo=e=>Ho(e),Wo={config:{auth:!0,client:!0,exportFromIndex:!0,paramsStructure:`grouped`,responseStyle:`fields`,transformer:!1,validator:!1,response:`body`},dependencies:[`@hey-api/typescript`],handler:Uo,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.examples=Fo(e.config,t),e.config.operations=Io(e.config,t)}},Go=_(Wo),Ko=({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)]}},qo=({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))]}},Jo=`data`,Yo=new Set,Xo=e=>e[`~dsl`]===`ReturnTsDsl`,Zo=({plugin:e,schema:t})=>{let n=Qo({dataExpression:I(Jo),plugin:e,schema:t});if(n.length){let e=n[n.length-1];Xo(e)||n.push(I.return(Jo))}return n},Qo=({dataExpression:e,plugin:t,schema:n})=>{if(n.$ref){let r={category:`transform`,resource:`definition`,resourceId:n.$ref},i=t.getSymbol(r)??t.symbol(R(z(n.$ref),{case:`camelCase`,name:`{{name}}SchemaResponseTransformer`}),{meta:r});if(!i.node&&!Yo.has(i.id)){Yo.add(i.id);try{let e=Zo({plugin:t,schema:t.context.resolveIrRef(n.$ref)});if(e.length){let n=I.const(i).assign(I.func().param(Jo,e=>e.type(`any`)).do(...e));t.node(n)}}finally{Yo.delete(i.id)}}if(i.node||Yo.has(i.id)){let n=I(t.referenceSymbol(r)).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?Qo({dataExpression:`item`,plugin:t,schema:n.items?.[0]?n.items[0]:{...n,type:void 0}}):[];if(!r.length)return[];let i=r;return i.some(e=>Xo(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||Jo).attr(a),c=Qo({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(...c))}return r}if(n.items){if(n.items.length===1)return Qo({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=Qo({dataExpression:e||`item`,plugin:t,schema:i});n.length&&(e?r=r.concat(n):r.push(I.if(`item`).do(...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[]},$o=({plugin:e})=>{e.forEach(`operation`,({operation:t})=>{let{response:n}=Ct(t);if(!n)return;if(n.items&&n.items.length>1){e.context.config.logs.level===`debug`&&console.warn(`❗️ Transformers warning: route ${w(t)} has ${n.items.length} non-void success responses. This is currently not handled and we will not generate a response transformer. Please open an issue if you'd like this feature https://github.com/hey-api/openapi-ts/issues`);return}let r=e.querySymbol({category:`type`,resource:`operation`,resourceId:t.id,role:`response`});if(!r)return;let i=Zo({plugin:e,schema:n});if(!i.length)return;let a=e.symbol(R(t.id,{case:`camelCase`,name:`{{name}}ResponseTransformer`}),{meta:{category:`transform`,resource:`operation`,resourceId:t.id,role:`response`}}),o=I.const(a).export().assign(I.func().async().param(Jo,e=>e.type(`any`)).returns(I.type(`Promise`).generic(r)).do(...i));e.node(o)},{order:`declarations`})},es={config:{bigInt:!0,dates:!0,exportFromIndex:!1,transformers:[],typeTransformers:[]},dependencies:[`@hey-api/typescript`],handler:$o,name:`@hey-api/transformers`,resolveConfig:e=>{e.config.transformers||(e.config.transformers=[]),e.config.dates&&(e.config.transformers=[...e.config.transformers,qo]),e.config.bigInt&&(e.config.transformers=[...e.config.transformers,Ko])},tags:[`transformer`]},ts=_(es),ns=({server:e})=>{let t=no(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||``)},rs=({nodeIndex:e,plugin:t,servers:n})=>{let r=x(t.context.config),i=n.map(e=>ns({server:e}));n.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=t.symbol(R(`ClientOptions`,{case:t.config.case}),{meta:{category:`type`,resource:`client`,role:`options`,tool:`typescript`}}),o=I.type.alias(a).export().type(I.type.object().prop(ht(t.context.config),e=>e.type(I.type.or(...i))));t.node(o,e)},B=e=>{let t=[];return e.title&&t.push(Ca(e.title)),e.description&&(t.length&&t.push(``),t.push(Ca(e.description))),e.deprecated&&(t.length&&t.push(``),t.push(`@deprecated`)),t.length?t:void 0},is=({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=L(a,e.config.enums.case,{stripLeadingSeparators:!1}),A.number.lastIndex=0,A.number.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}},as=({plugin:e,schema:t,state:n,type:r})=>{let i=ra((0,l.fromRef)(n.path));if(t.type===`enum`&&e.config.enums.enabled){let r=is({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 a=e.symbol(R(z(i),e.config.definitions),{meta:{category:`utility`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:i,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.const(a).export().$if(B(t),(e,t)=>e.doc(t)).assign(I.object(...r.obj.map(e=>I.prop({kind:`prop`,name:e.key}).$if(B(e.schema),(e,t)=>e.doc(t)).value(I.fromValue(e.schema.const)))).as(`const`));e.node(o);let s=e.symbol(R(z(i),e.config.definitions),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:i,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),c=I.type.alias(s).export().$if(B(t),(e,t)=>e.doc(t)).type(I.type(s).idx(I.type(s).typeofType().keyof()).typeofType());e.node(c);return}else if((e.config.enums.mode===`typescript`||e.config.enums.mode===`typescript-const`)&&!r.typeofItems.some(e=>e!==`number`&&e!==`string`)){let a=e.symbol(R(z(i),e.config.definitions),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:i,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.enum(a).export().$if(B(t),(e,t)=>e.doc(t)).const(e.config.enums.mode===`typescript-const`).members(...r.obj.map(e=>I.member(e.key).$if(B(e.schema),(e,t)=>e.doc(t)).value(I.fromValue(e.schema.const))));e.node(o);return}}let a=e.symbol(R(z(i),e.config.definitions),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:i,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.type.alias(a).export().$if(B(t),(e,t)=>e.doc(t)).type(r);e.node(o)},os=({parameters:e})=>{let t={type:`object`};if(e){let n={},r=[];for(let t in e){let i=e[t];n[i.name]=S({detectFormat:!1,schema:i.schema}),i.required&&r.push(i.name)}t.properties=n,r.length&&(t.required=r)}return t},ss=({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=os({parameters:e.parameters.header}),r.properties.headers.required&&i.push(`headers`)),e.parameters?.path?(r.properties.path=os({parameters:e.parameters.path}),r.properties.path.required&&i.push(`path`)):r.properties.path={type:`never`},e.parameters?.query?(r.properties.query=os({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.symbol(R(e.id,t.config.requests),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`operation`,resourceId:e.id,role:`data`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.type.alias(a).export().type(V({plugin:t,schema:r,state:n}));t.node(o)},cs=({operation:e,plugin:t,state:n})=>{ss({operation:e,plugin:t,state:n});let{error:r,errors:i,response:a,responses:o}=Ct(e);if(i){let a=t.symbol(R(e.id,t.config.errors),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`operation`,resourceId:e.id,role:`errors`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.type.alias(a).export().type(V({plugin:t,schema:i,state:n}));if(t.node(o),r){let r=t.symbol(R(e.id,{case:t.config.errors.case,name:t.config.errors.error}),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`operation`,resourceId:e.id,role:`error`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),i=I.type.alias(r).export().type(I.type(a).idx(I.type(a).keyof()));t.node(i)}}if(o){let r=t.symbol(R(e.id,t.config.responses),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`operation`,resourceId:e.id,role:`responses`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),i=I.type.alias(r).export().type(V({plugin:t,schema:o,state:n}));if(t.node(i),a){let i=t.symbol(R(e.id,{case:t.config.responses.case,name:t.config.responses.response}),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`operation`,resourceId:e.id,role:`response`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),a=I.type.alias(i).export().type(I.type(r).idx(I.type(r).keyof()));t.node(a)}}},ls=({operation:e,plugin:t,state:n})=>{let r={type:`object`},i=[];if(r.properties||={},e.body){let a=t.symbol(R(e.id,{case:t.config.webhooks.case,name:t.config.webhooks.payload}),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`webhook`,resourceId:e.id,role:`data`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.type.alias(a).export().$if(B(e.body.schema),(e,t)=>e.doc(t)).type(V({plugin:t,schema:e.body.schema,state:n}));t.node(o),r.properties.body={symbolRef:a},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.symbol(R(e.id,t.config.webhooks),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`webhook`,resourceId:e.id,role:`data`,tags:(0,l.fromRef)(n.tags),tool:`typescript`}}),o=I.type.alias(a).export().type(V({plugin:t,schema:r,state:n}));return t.node(o),a},us=({operation:e,plugin:t,state:n})=>ls({operation:e,plugin:t,state:n}),ds=({plugin:e,schema:t,state:n})=>{if(!t.items)return I.type(`Array`).generic(I.type(e.config.topType));t=S({detectFormat:!0,schema:t});let r=[];return t.items&&t.items.forEach((t,i)=>{let a=V({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`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))},fs=({schema:e})=>e.const===void 0?I.type(`boolean`):I.type.literal(e.const),ps=({plugin:e,schema:t,state:n})=>V({plugin:e,schema:{...t,type:void 0},state:n}),ms=e=>I.type(`never`),hs=e=>I.type.literal(null),gs=({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),_s=({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],u=V({plugin:e,schema:c,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`properties`,s])}}),d=i.includes(s);r.prop(s,e=>e.$if(B(c),(e,t)=>e.doc(t)).readonly(c.accessScope===`read`).required(d).type(u)),a.push(c),d||(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,u=c!==!1&&c?c:void 0;if(s||u&&(u.type!==`never`||!a.length)){let i=u;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?V({plugin:e,schema:a[0],state:n}):V({plugin:e,schema:{items:a,logicalOperator:`or`},state:n});if(t.propertyNames?.$ref)return I.type.mapped(`key`).key(V({plugin:e,schema:{$ref:t.propertyNames.$ref},state:n})).optional().type(c);r.idxSig(`key`,e=>e.key(`string`).type(c))}return r},vs=({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.symbol(`TypeID`,{meta:t}),r=I.type.alias(n).export().generic(`T`,e=>e.extends(`string`)).type(I.type.template().add(I.type(`T`)).add(`_`).add(I.type(`string`)));e.node(r)}let n=e.referenceSymbol(t),a=e.symbol(L(`${r}_id`,e.config.case),{meta:i}),o=I.type.alias(a).export().type(I.type(n).generic(I.type.literal(r)));e.node(o)}let a=e.referenceSymbol(i);return I.type(a)}}return I.type(`string`)},ys=({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=V({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,i])}});r.push(a)}),I.type.tuple(...r)},bs=e=>I.type(`undefined`),xs=({plugin:e})=>I.type(e.config.topType),Ss=e=>I.type(`void`),Cs=({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 ds({...t,schema:e});case`boolean`:return fs({...t,schema:e});case`enum`:return ps({...t,schema:e});case`integer`:case`number`:return gs({...t,schema:e});case`never`:return ms({...t,schema:e});case`null`:return hs({...t,schema:e});case`object`:return _s({...t,schema:e});case`string`:return vs({...t,schema:e});case`tuple`:return ys({...t,schema:e});case`undefined`:return bs({...t,schema:e});case`unknown`:return xs({...t,schema:e});case`void`:return Ss({...t,schema:e})}},V=({plugin:e,schema:t,state:n})=>{if(t.symbolRef){let e=I.type(t.symbolRef);if(t.omit&&t.omit.length>0){let n=t.omit.length===1?I.type.literal(t.omit[0]):I.type.or(...t.omit.map(e=>I.type.literal(e)));return I.type(`Omit`).generics(e,n)}return e}if(t.$ref){let n=e.referenceSymbol({category:`type`,resource:`definition`,resourceId:t.$ref}),r=I.type(n);if(t.omit&&t.omit.length>0){let e=t.omit.length===1?I.type.literal(t.omit[0]):I.type.or(...t.omit.map(e=>I.type.literal(e)));return I.type(`Omit`).generics(r,e)}return r}if(t.type)return Cs({plugin:e,schema:t,state:n});if(t.items){if(t=S({detectFormat:!1,schema:t}),t.items){let r=t.items.map(t=>V({plugin:e,schema:t,state:n}));return t.logicalOperator===`and`?I.type.and(...r):I.type.or(...r)}return V({plugin:e,schema:t,state:n})}return Cs({plugin:e,schema:{type:`unknown`},state:n})},ws=({plugin:e,schema:t,state:n})=>{as({plugin:e,schema:t,state:n,type:V({plugin:e,schema:t,state:n})})},Ts=({plugin:e})=>{let t=e.node(null),n=e.node(null),r=[],i=[];if(e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`,t=>{let n=(0,l.refs)({path:t._path,tags:t.tags});switch(t.type){case`operation`:cs({operation:t.operation,plugin:e,state:n});break;case`parameter`:ws({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:ws({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:ws({plugin:e,schema:t.schema,state:n});break;case`server`:r.push(t.server);break;case`webhook`:i.push(us({operation:t.operation,plugin:e,state:n}));break}},{order:`declarations`}),rs({nodeIndex:t,plugin:e,servers:r}),i.length>0){let t=e.symbol(R(`Webhooks`,{case:e.config.case}),{meta:{category:`type`,resource:`webhook`,tool:`typescript`,variant:`container`}}),r=I.type.alias(t).export().type(I.type.or(...i));e.node(r,n)}};var Es=class{schemaToType(e){return V(e)}};const Ds=e=>Ts(e),Os={api:new Es,config:{case:`PascalCase`,exportFromIndex:!0,topType:`unknown`},handler:Ds,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})}},ks=_(Os),As=(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)},js=({operation:e,plugin:t})=>ca({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Ms=({operation:e,plugin:t})=>{let n=x(t.context.config),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`error`})||`Error`;if(n.name===`@hey-api/client-axios`){let e=t.referenceSymbol({category:`external`,resource:`axios.AxiosError`});return I.type(e).generic(r)}return I.type(r)},Ns=({operation:e,plugin:t})=>{let n=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`});return I.type(n??`unknown`)},Ps=({isNuxtClient:e,operation:t,plugin:n})=>{let r=js({operation:t,plugin:n});return e?I.type(`Omit`).generic(r).generic(`composable`):r},Fs=({operation:e,plugin:t})=>{let n=t.referenceSymbol({category:`external`,resource:`${t.name}.UseMutationOptions`}),r=x(t.context.config).name===`@hey-api/client-nuxt`,i=Ps({isNuxtClient:r,operation:e,plugin:t}),a=t.symbol(`options`),o=t.symbol(`vars`),s=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().pretty().spread(a).spread(o).prop(`throwOnError`,I.literal(!0))).await()),c=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?c.push(I.return(s)):c.push(I.const().object(`data`).assign(s),I.return(`data`));let l=I.object().pretty().prop(`mutation`,I.func().async().param(o,e=>e.$if(r,e=>e.type(I.type(`Partial`).generic(i)))).do(...c)).$if(As(t,e,`mutationOptions`),(e,t)=>e.prop(`meta`,t)),u=t.symbol(R(e.id,t.config.mutationOptions)),d=I.const(u).export().$if(t.config.comments&&wa(e),(e,t)=>e.doc(t)).assign(I.func().param(a,e=>e.optional().type(I.type(`Partial`).generic(i))).returns(I.type(n).generic(Ns({operation:e,plugin:t})).generic(i).generic(Ms({operation:e,plugin:t}))).do(I.return(l)));t.node(d)},Is=`TOptions`,Ls=({plugin:e})=>{let t=e.symbol(R(`createQueryKey`,{case:e.config.case}),{meta:{category:`utility`,resource:`createQueryKey`,tool:e.name}}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),i=I.type(n).generic(Is).idx(0),a=ht(e.context.config),o=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),s=e.getSymbol({category:`client`}),c=Xa(e.context.config),l=e.symbol(`serializeQueryKeyValue`,{external:c,meta:{category:`external`,resource:`${c}.serializeQueryKeyValue`}}),u=I.const(t).assign(I.func().param(`id`,e=>e.type(`string`)).param(`options`,e=>e.optional().type(Is)).param(`tags`,e=>e.optional().type(`ReadonlyArray<string>`)).returns(I.type.tuple(i)).generic(Is,e=>e.extends(o)).do(I.const(`params`).type(i).assign(I.object().prop(`_id`,`id`).prop(a,I(`options`).attr(a).optional().or(I(`options`).attr(`client`).optional().$if(s,(e,t)=>e.coalesce(t)).attr(`getConfig`).call().attr(a))).as(i)),I.if(`tags`).do(I(`params`).attr(`tags`).assign(I(`tags`).as(`unknown`).as(r))),I.if(I(`options`).attr(`body`).optional().neq(I.id(`undefined`))).do(I.const(`normalizedBody`).assign(I(l).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).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.node(u)},Rs=({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})).call(I.literal(e),`options`,i)},zs=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`${e.name}._JSONValue`}),n=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),r=e.symbol(`QueryKey`,{meta:{category:`type`,resource:`QueryKey`,tool:e.name}}),i=I.type.alias(r).export().generic(Is,e=>e.extends(I.type(n))).type(I.type.tuple(I.type.and(I.type(`Pick<${Is}, 'path'>`),I.type.object().prop(`_id`,e=>e.type(`string`)).prop(ht(e.context.config),e=>e.optional().type(t)).prop(`body`,e=>e.optional().type(t)).prop(`query`,e=>e.optional().type(t)).prop(`tags`,e=>e.optional().type(t)))));e.node(i)},Bs=({operation:e,plugin:t,symbol:n})=>{let r=x(t.context.config).name===`@hey-api/client-nuxt`;return I.const(n).export().assign(I.func().param(`options`,n=>n.required(bt(e)).type(Ps({isNuxtClient:r,operation:e,plugin:t}))).do(Rs({id:e.id,operation:e,plugin:t}).return()))},Vs=`options`,Hs=`context`,Us=({operation:e,plugin:t})=>{if(Ea({operation:e}))return;let n=Ta({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(zs({plugin:t}),Ls({plugin:t}));let r;if(t.config.queryKeys.enabled){let n=t.symbol(R(e.id,t.config.queryKeys)),i=Bs({operation:e,plugin:t,symbol:n});t.node(i),r=I(n).call(Vs)}else{let n=t.referenceSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name}),i;t.config.queryKeys.tags&&e.tags&&e.tags.length>0&&(i=I.array(...e.tags.map(e=>I.literal(e)))),r=I(n).call(I.literal(e.id),Vs,i)}let i=Ps({isNuxtClient:x(t.context.config).name===`@hey-api/client-nuxt`,operation:e,plugin:t}),a=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().spread(Vs).spread(Hs).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.object().pretty().prop(`key`,r).prop(`query`,I.func().async().param(Hs).do(...o)).$if(As(t,e,`queryOptions`),(e,t)=>e.prop(`meta`,t)),c=t.symbol(R(e.id,t.config.queryOptions),{meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}}),l=t.referenceSymbol({category:`external`,resource:`${t.name}.defineQueryOptions`}),u=I.const(c).export().$if(t.config.comments&&wa(e),(e,t)=>e.doc(t)).assign(I(l).call(I.func().param(Vs,e=>e.required(n).type(i)).do(I.return(s))));t.node(u)},Ws=({plugin:e})=>{e.symbol(`defineQueryOptions`,{external:e.name,meta:{category:`external`,resource:`${e.name}.defineQueryOptions`}}),e.symbol(`UseMutationOptions`,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.UseMutationOptions`}}),e.symbol(`UseQueryOptions`,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.UseQueryOptions`}}),e.symbol(`_JSONValue`,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}._JSONValue`}}),e.symbol(`AxiosError`,{external:`axios`,kind:`type`,meta:{category:`external`,resource:`axios.AxiosError`}}),e.forEach(`operation`,({operation:t})=>{e.hooks.operation.isQuery(t)&&e.config.queryOptions.enabled&&Us({operation:t,plugin:e}),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&Fs({operation:t,plugin:e})},{order:`declarations`})},Gs=e=>Ws(e),Ks={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/typescript`,`@hey-api/sdk`],handler:Gs,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})}},qs=_(Ks),Js=({operation:e,plugin:t})=>ca({operation:e,plugin:t.getPluginOrThrow(`@hey-api/sdk`)}),Ys=({operation:e,plugin:t})=>{let n=x(t.context.config),r=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`error`})||t.referenceSymbol({category:`external`,resource:`${t.name}.DefaultError`});if(n.name===`@hey-api/client-axios`){let e=t.referenceSymbol({category:`external`,resource:`axios.AxiosError`});return I.type(e).generic(r)}return I.type(r)},Xs=({operation:e,plugin:t})=>{let n=t.querySymbol({category:`type`,resource:`operation`,resourceId:e.id,role:`response`});return I.type(n??`unknown`)},Zs=`TOptions`,Qs=({plugin:e})=>{let t=e.symbol(R(`createQueryKey`,{case:e.config.case}),{meta:{category:`utility`,resource:`createQueryKey`,tool:e.name}}),n=e.referenceSymbol({category:`type`,resource:`QueryKey`,tool:e.name}),r=ht(e.context.config),i=e.getSymbol({category:`client`}),a=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),o=I.type(n).generic(Zs).idx(0),s=I.const(t).assign(I.func().param(`id`,e=>e.type(`string`)).param(`options`,e=>e.optional().type(Zs)).param(`infinite`,e=>e.optional().type(`boolean`)).param(`tags`,e=>e.optional().type(`ReadonlyArray<string>`)).generic(Zs,e=>e.extends(a)).returns(I.type.tuple(o)).do(I.const(`params`).type(o).assign(I.object().prop(`_id`,`id`).prop(r,I(`options`).attr(r).optional().or(I(`options`).attr(`client`).optional().$if(i,(e,t)=>e.coalesce(t)).attr(`getConfig`).call().attr(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.node(s)},$s=({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})).call(I.literal(e),`options`,t||a?I.literal(!!t):void 0,a)},ec=({plugin:e})=>{let t=e.referenceSymbol({category:`type`,resource:`client-options`,tool:`sdk`}),n=e.symbol(`QueryKey`,{meta:{category:`type`,resource:`QueryKey`,tool:e.name}}),r=I.type.alias(n).export().generic(Zs,e=>e.extends(t)).type(I.type.tuple(I.type.and(I.type(`Pick<${Zs}, '${ht(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.node(r)},tc=({isInfinite:e,operation:t,plugin:n,symbol:r,typeQueryKey:i})=>{let a=Js({operation:t,plugin:n});return I.const(r).export().assign(I.func().param(`options`,e=>e.required(bt(t)).type(a)).$if(e&&i,(e,t)=>e.returns(t)).do($s({id:t.id,isInfinite:e,operation:t,plugin:n}).return()))},nc=(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)},rc=({plugin:e})=>{let t=e.symbol(R(`createInfiniteParams`,{case:e.config.case}),{meta:{category:`utility`,resource:`createInfiniteParams`,tool:e.name}}),n=I.const(t).assign(I.func().generic(`K`,e=>e.extends(I.type(`Pick`).generics(I.type(`QueryKey`).generic(`Options`).idx(0),I.type.or(I.type.literal(`body`),I.type.literal(`headers`),I.type.literal(`path`),I.type.literal(`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.node(n)},ic=({operation:e,plugin:t})=>{let n=xt({context:t.context,operation:e});if(!n)return;let r=Ta({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(ec({plugin:t}),Qs({plugin:t})),t.getSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name})||rc({plugin:t});let i=t.referenceSymbol({category:`external`,resource:`${t.name}.infiniteQueryOptions`}),a=t.referenceSymbol({category:`external`,resource:`${t.name}.InfiniteData`}),o=Js({operation:e,plugin:t}),s=Xs({operation:e,plugin:t}),c=t.referenceSymbol({category:`type`,resource:`QueryKey`,tool:t.name}),u=I.type(c).generic(o),d=I.type(`Pick`).generics(u.idx(0),I.type.or(I.type.literal(`body`),I.type.literal(`headers`),I.type.literal(`path`),I.type.literal(`query`))),f=t.getPluginOrThrow(`@hey-api/typescript`),p=f.api.schemaToType({plugin:f,schema:n.schema,state:{path:(0,l.ref)([])}}),m=t.symbol(R(e.id,t.config.infiniteQueryKeys)),ee=tc({isInfinite:!0,operation:e,plugin:t,symbol:m,typeQueryKey:u});t.node(ee);let h=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().spread(`options`).spread(`params`).prop(`signal`,I(`signal`)).prop(`throwOnError`,I.literal(!0))).await()),te=t.referenceSymbol({category:`utility`,resource:`createInfiniteParams`,tool:t.name}),ne=[I.const(`page`).type(d).hint(`@ts-ignore`).assign(I.ternary(I(`pageParam`).typeofExpr().eq(I.literal(`object`))).do(`pageParam`).otherwise(I.object().pretty().prop(n.in,I.object().pretty().prop(n.name,I(`pageParam`))))),I.const(`params`).assign(I(te).call(`queryKey`,`page`))];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?ne.push(I.return(h)):ne.push(I.const().object(`data`).assign(h),I.return(`data`));let re=t.symbol(R(e.id,t.config.infiniteQueryOptions)),ie=I.const(re).export().$if(t.config.comments&&wa(e),(e,t)=>e.doc(t)).assign(I.func().param(`options`,e=>e.required(r).type(o)).do(I.return(I(i).call(I.object().pretty().hint(`@ts-ignore`).prop(`queryFn`,I.func().async().param(e=>e.object(`pageParam`,`queryKey`,`signal`)).do(...ne)).prop(`queryKey`,I(m).call(`options`)).$if(nc(t,e,`infiniteQueryOptions`),(e,t)=>e.prop(`meta`,t))).generics(s,Ys({operation:e,plugin:t}),I.type(a).generic(s),u,I.type.or(p,d)))));t.node(ie)},ac=({operation:e,plugin:t})=>{let n=t.referenceSymbol({category:`external`,resource:`${t.name}.MutationOptions`}),r=Js({operation:e,plugin:t}),i=I.type(n).generic(Xs({operation:e,plugin:t})).generic(Ys({operation:e,plugin:t})).generic(r),a=`fnOptions`,o=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().spread(`options`).spread(a).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=`mutationOptions`,l=t.symbol(R(e.id,t.config.mutationOptions)),u=I.const(l).export().$if(t.config.comments&&wa(e),(e,t)=>e.doc(t)).assign(I.func().param(`options`,e=>e.optional().type(I.type(`Partial`).generic(r))).returns(i).do(I.const(c).type(i).assign(I.object().pretty().prop(`mutationFn`,I.func().async().param(a).do(...s)).$if(nc(t,e,`mutationOptions`),(e,t)=>e.prop(`meta`,t))),I(c).return()));t.node(u)},oc=`options`,sc=({operation:e,plugin:t})=>{if(Ea({operation:e}))return;let n=Ta({context:t.context,operation:e});t.getSymbol({category:`utility`,resource:`createQueryKey`,tool:t.name})||(ec({plugin:t}),Qs({plugin:t}));let r=t.referenceSymbol({category:`external`,resource:`${t.name}.queryOptions`}),i=t.symbol(R(e.id,t.config.queryKeys)),a=tc({isInfinite:!1,operation:e,plugin:t,symbol:i});t.node(a);let o=Xs({operation:e,plugin:t}),s=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().spread(oc).spread(I(`queryKey`).attr(0)).prop(`signal`,I(`signal`)).prop(`throwOnError`,I.literal(!0))).await()),c=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?c.push(I.return(s)):c.push(I.const().object(`data`).assign(s),I.return(`data`));let l=I.object().pretty().prop(`queryFn`,I.func().async().param(e=>e.object(`queryKey`,`signal`)).do(...c)).prop(`queryKey`,I(i).call(oc)).$if(nc(t,e,`queryOptions`),(e,t)=>e.prop(`meta`,t)),u=t.symbol(R(e.id,t.config.queryOptions),{meta:{category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}}),d=I.const(u).export(t.config.queryOptions.exported).$if(t.config.comments&&wa(e),(e,t)=>e.doc(t)).assign(I.func().param(oc,r=>r.required(n).type(Js({operation:e,plugin:t}))).do(I(r).call(l).generics(o,Ys({operation:e,plugin:t}),o,I(i).returnType()).return()));t.node(d)},cc=`options`,lc=({operation:e,plugin:t})=>{if(Ea({operation:e})||!(`useQuery`in t.config))return;let n=t.symbol(R(e.id,t.config.useQuery)),r=t.referenceSymbol({category:`external`,resource:`${t.name}.useQuery`}),i=Ta({context:t.context,operation:e}),a=Js({operation:e,plugin:t}),o=t.referenceSymbol({category:`hook`,resource:`operation`,resourceId:e.id,role:`queryOptions`,tool:t.name}),s=I.const(n).export().$if(t.config.comments&&wa(e),(e,t)=>e.doc(t)).assign(I.func().param(cc,e=>e.required(i).type(a)).do(I(r).call(I(o).call(cc)).return()));t.node(s)},uc=({plugin:e})=>{e.symbol(`DefaultError`,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.DefaultError`}}),e.symbol(`InfiniteData`,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.InfiniteData`}});let t=e.name===`@tanstack/angular-query-experimental`||e.name===`@tanstack/svelte-query`||e.name===`@tanstack/solid-query`?`MutationOptions`:`UseMutationOptions`;e.symbol(t,{external:e.name,kind:`type`,meta:{category:`external`,resource:`${e.name}.MutationOptions`}}),e.symbol(`infiniteQueryOptions`,{external:e.name,meta:{category:`external`,resource:`${e.name}.infiniteQueryOptions`}}),e.symbol(`queryOptions`,{external:e.name,meta:{category:`external`,resource:`${e.name}.queryOptions`}}),e.symbol(`useQuery`,{external:e.name,meta:{category:`external`,resource:`${e.name}.useQuery`}}),e.symbol(`AxiosError`,{external:`axios`,kind:`type`,meta:{category:`external`,resource:`axios.AxiosError`}}),e.forEach(`operation`,({operation:t})=>{e.hooks.operation.isQuery(t)&&(e.config.queryOptions.enabled&&sc({operation:t,plugin:e}),e.config.infiniteQueryOptions.enabled&&ic({operation:t,plugin:e}),`useQuery`in e.config&&e.config.useQuery.enabled&&lc({operation:t,plugin:e})),e.hooks.operation.isMutation(t)&&e.config.mutationOptions.enabled&&ac({operation:t,plugin:e})},{order:`declarations`})},dc=e=>uc(e),fc={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:dc,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})}},pc=_(fc),mc={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:dc,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))}},hc=_(mc),gc={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:dc,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})}},_c=_(gc),vc={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:dc,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})}},yc=_(vc),bc={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:dc,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})}},xc=_(bc),Sc=({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).attr(`parseAsync`).call(r).await().return())},Cc=({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).attr(`parseAsync`).call(r).await().return())};var wc=class{createRequestValidator(e){return Sc(e)}createResponseValidator(e){return Cc(e)}};const H={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`}},Tc=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`arktype.type`}),o=I.const(r).export().$if(t.config.comments&&B(n),(e,t)=>e.doc(t)).assign(I(a).call(e.def?I.literal(e.def):e.expression));if(t.node(o),i){let e=I.type.alias(i).export().type(I.type(r).attr(H.type.infer).typeofType());t.node(e)}},Ec=e=>{let t={};return t.def=H.primitives.null,t},Dc=({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),u=Ac({optional:!c,plugin:e,schema:s,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`properties`,o])}});u.hasLazyExpression&&(r.hasLazyExpression=!0),i.prop(c?o:`${o}?`,u.expression)}if(t.additionalProperties&&(!t.properties||!Object.keys(t.properties).length)){let i=Ac({plugin:e,schema:t.additionalProperties,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`additionalProperties`])}});return r.expression=I(`TODO`).attr(`record`).call(I(`TODO`).attr(`string`).call(),i.expression),i.hasLazyExpression&&(r.hasLazyExpression=!0),r}return r.expression=i,r.hasLazyExpression?{...r,typeName:`TODO`}:r},Oc=({schema:e})=>{let t={};if(typeof e.const==`string`)return t.def=e.const,t;let n=H.primitives.string;if(e.format)switch(e.format){case`date`:case`date-time`:case`time`:n=`${n}.${H.string.date}.${H.string.iso}`;break;case`email`:n=`${n}.${H.string.email}`;break;case`ipv4`:n=`${n}.${H.string.ip}.${H.string.v4}`;break;case`ipv6`:n=`${n}.${H.string.ip}.${H.string.v6}`;break;case`uri`:n=`${n}.${H.string.url}`;break;case`uuid`:n=`${n}.${H.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},kc=({schema:e,...t})=>{switch(e.type){case`null`:return Ec({...t,schema:e});case`object`:return Dc({...t,schema:e});case`string`:return Oc({...t,schema:e})}return{def:``,expression:I(t.plugin.referenceSymbol({category:`external`,resource:`arktype.type`})).call(I.object().prop(`name`,I.literal(`string`)).prop(`platform`,I.literal(`'android' | 'ios'`)).prop(`versions?`,I.literal(`(number | string)[]`))),hasLazyExpression:!1}},Ac=({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);if(e.isSymbolRegistered(i)){let e=I(a);r.expression=e}else{let e=I(`TODO`).attr(`TODO`).call(I.func().returns(`any`).do(I.return(a)));r.expression=e,r.hasLazyExpression=!0,n.hasLazyExpression[`~ref`]=!0}}else if(t.type){let i=kc({plugin:e,schema:t,state:n});r.def=i.def,r.expression=i.expression,r.hasLazyExpression=i.hasLazyExpression,e.config.metadata&&t.description}else if(t.items)t=S({schema:t}),t.items||(r=Ac({plugin:e,schema:t,state:n}));else{let t=kc({plugin:e,schema:{type:`unknown`},state:n});r.def=t.def,r.expression=t.expression}if(!r.expression){let t=kc({plugin:e,schema:{type:`unknown`},state:n});r.expression=t.expression}return r},jc=({plugin:e,schema:t,state:n})=>{let r=ra((0,l.fromRef)(n.path)),i=Ac({plugin:e,schema:t,state:n}),a=z(r);Tc({ast:i,plugin:e,schema:t,symbol:e.symbol(R(a,e.config.definitions),{meta:{category:`schema`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`arktype`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(R(a,e.config.definitions.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tool:`arktype`,variant:`infer`}}):void 0})},Mc=({plugin:e})=>{e.symbol(`type`,{external:`arktype`,meta:{category:`external`,resource:`arktype.type`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=(0,l.refs)({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`parameter`:jc({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:jc({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:jc({plugin:e,schema:t.schema,state:n});break}})},Nc=e=>Mc(e),Pc={api:new wc,config:{case:`PascalCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:Nc,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`]},Fc=_(Pc),Ic=({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).idx(I.type.literal(`body`)))),e.parameters&&(e.parameters.header&&n.prop(`Headers`,t=>t.required(_t(e.parameters.header)).type(I.type(r).idx(I.type.literal(`headers`)))),e.parameters.path&&n.prop(`Params`,t=>t.required(_t(e.parameters.path)).type(I.type(r).idx(I.type.literal(`path`)))),e.parameters.query&&n.prop(`Querystring`,t=>t.required(_t(e.parameters.query)).type(I.type(r).idx(I.type.literal(`query`))))));let{errors:i,responses:a}=Ct(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),I.type.literal(`default`)))):o=I.type(s))}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),I.type.literal(`default`)))):c=I.type(l))}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,e=>e.generic(n))}},Lc=({plugin:e})=>{e.symbol(`RouteHandler`,{external:`fastify`,kind:`type`,meta:{category:`type`,resource:`route-handler`,tool:`fastify`}});let t=e.symbol(`RouteHandlers`),n=I.type.object();e.forEach(`operation`,({operation:t})=>{let r=Ic({operation:t,plugin:e});r&&n.prop(r.name,e=>e.type(r.type))},{order:`declarations`});let r=I.type.alias(t).export().type(n);e.node(r)},Rc={config:{exportFromIndex:!1},dependencies:[`@hey-api/typescript`],handler:Lc,name:`fastify`},zc=_(Rc),Bc=({operation:e,plugin:t})=>{if(Ea({operation:e}))return;let n=t.referenceSymbol({category:`external`,resource:`swr`}),r=t.symbol(R(e.id,t.config.useSwr)),i=I.lazy(n=>n.access(t.referenceSymbol({category:`sdk`,resource:`operation`,resourceId:e.id})).call(I.object().prop(`throwOnError`,I.literal(!0))).await()),a=[];t.getPluginOrThrow(`@hey-api/sdk`).config.responseStyle===`data`?a.push(I.return(i)):a.push(I.const().object(`data`).assign(i),I.return(`data`));let o=I.const(r).export().$if(t.config.comments&&wa(e),(e,t)=>e.doc(t)).assign(I.func().do(I(n).call(I.literal(e.path),I.func().async().do(...a)).return()));t.node(o)},Vc=({plugin:e})=>{e.symbol(`useSWR`,{external:`swr`,importKind:`default`,kind:`function`,meta:{category:`external`,resource:`swr`}}),e.forEach(`operation`,({operation:t})=>{e.hooks.operation.isQuery(t)&&e.config.useSwr.enabled&&Bc({operation:t,plugin:e})},{order:`declarations`})},Hc=e=>Vc(e),Uc={config:{case:`camelCase`,comments:!0,exportFromIndex:!1},dependencies:[`@hey-api/sdk`,`@hey-api/typescript`],handler:Hc,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))}},Wc=_(Uc),U={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:{}},W=(e,t)=>e instanceof Array?e.length===1?e[0]:I(t.external(`valibot.v`)).attr(U.methods.pipe).call(...e):e,Gc=(e,t)=>(t instanceof Array?e.push(...t):e.push(t),e),Kc={push:Gc,toNode:W},qc=e=>{let{schema:t,v:n}=e.symbols;return I(n).attr(U.async.parseAsync).call(t,`data`).await().return()},Jc=({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:{...Kc,current:[]},plugin:t,symbols:{schema:n,v:t.external(`valibot.v`)}},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.request,qc];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])}},Yc=({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:{...Kc,current:[]},plugin:t,symbols:{schema:n,v:t.external(`valibot.v`)}},i=t.config[`~resolvers`]?.validator,a=[typeof i==`function`?i:i?.response,qc];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 Xc=class{createRequestValidator(e){return Jc(e)}createResponseValidator(e){return Yc(e)}};const Zc=e=>e===`int64`||e===`uint64`,Qc=(e,t)=>Zc(t)?typeof e==`string`?(e.endsWith(`n`)&&(e=e.slice(0,-1)),I(`BigInt`).call(I.fromValue(e))):typeof e==`number`?I(`BigInt`).call(I.fromValue(e)):I.fromValue(e):I.fromValue(e),$c=({ast:e,plugin:t,schema:n,state:r,symbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`valibot.v`}),o=I.const(i).export().$if(t.config.comments&&B(n),(e,t)=>e.doc(t)).$if(r.hasLazyExpression[`~ref`],t=>t.type(I.type(a).attr(e.typeName||U.types.GenericSchema))).assign(W(e.pipes,t));t.node(o)},el=({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],$c({ast:e(a,(0,l.fromRef)(r.path)),plugin:n,schema:a,state:r,symbol:n.symbol(R(t.id,n.config.requests),{meta:{category:`schema`,path:(0,l.fromRef)(r.path),resource:`operation`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`valibot`}})})}if(n.config.responses.enabled&&t.responses){let{response:i}=Ct(t);if(i){let a=[...(0,l.fromRef)(r.path),`responses`];$c({ast:e(i,a),plugin:n,schema:i,state:r,symbol:n.symbol(R(t.id,n.config.responses),{meta:{category:`schema`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:(0,l.fromRef)(r.tags),tool:`valibot`}})})}}},tl=({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],$c({ast:e(a,(0,l.fromRef)(r.path)),plugin:n,schema:a,state:r,symbol:n.symbol(R(t.id,n.config.webhooks),{meta:{category:`schema`,path:(0,l.fromRef)(r.path),resource:`webhook`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`valibot`}})})}},nl=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.unknown).call(),rl=({plugin:e,schema:t,state:n})=>{let r={pipes:[]},i=e.referenceSymbol({category:`external`,resource:`valibot.v`}),a=I(i).attr(U.schemas.array);if(t.items){t=S({schema:t});let i=t.items.map((t,i)=>{let a=Fl({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),W(a.pipes,e)});if(i.length===1){let e=a.call(...i);r.pipes.push(e)}else{t.logicalOperator;let i=a.call(nl({plugin:e,schema:{type:`unknown`},state:n}));r.pipes.push(i)}}else{let t=a.call(nl({plugin:e,schema:{type:`unknown`},state:n}));r.pipes.push(t)}if(t.minItems===t.maxItems&&t.minItems!==void 0){let e=I(i).attr(U.actions.length).call(I.fromValue(t.minItems));r.pipes.push(e)}else{if(t.minItems!==void 0){let e=I(i).attr(U.actions.minLength).call(I.fromValue(t.minItems));r.pipes.push(e)}if(t.maxItems!==void 0){let e=I(i).attr(U.actions.maxLength).call(I.fromValue(t.maxItems));r.pipes.push(e)}}return r},il=({plugin:e,schema:t})=>{let n=[],r=e.referenceSymbol({category:`external`,resource:`valibot.v`});return typeof t.const==`boolean`?(n.push(I(r).attr(U.schemas.literal).call(I.literal(t.const))),W(n,e)):(n.push(I(r).attr(U.schemas.boolean).call()),W(n,e))},al=({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 nl({plugin:e,schema:{type:`unknown`},state:n});let a=e.referenceSymbol({category:`external`,resource:`valibot.v`}),o=I(a).attr(U.schemas.picklist).call(I.array(...r));return i&&(o=I(a).attr(U.schemas.nullable).call(o)),o},ol=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.never).call(),sl=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.null).call(),cl=(e,t)=>({maxError:`Invalid value: Expected ${e} to be <= ${t[1]}`,minError:`Invalid value: Expected ${e} to be >= ${t[0]}`}),ll={int16:[-32768,32767],int32:[-2147483648,2147483647],int64:[`-9223372036854775808`,`9223372036854775807`],int8:[-128,127],uint16:[0,65535],uint32:[0,4294967295],uint64:[`0`,`18446744073709551615`],uint8:[0,255]},ul=e=>{if(!e)return;let t=ll[e];if(!t)return;let n=cl(e,t);return{maxValue:t[1],minValue:t[0],...n}};function dl(e){let{schema:t,symbols:n}=e,{v:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return[I(r).attr(U.schemas.union).call(I.array(I(r).attr(U.schemas.number).call(),I(r).attr(U.schemas.string).call(),I(r).attr(U.schemas.bigInt).call())),I(r).attr(U.actions.transform).call(I.func().param(`x`).do(I(`BigInt`).call(`x`).return()))];let i=[];return i.push(I(r).attr(U.schemas.number).call()),t.type===`integer`&&i.push(I(r).attr(U.actions.integer).call()),i}function fl(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.const!==void 0)return I(r).attr(U.schemas.literal).call(e.utils.maybeBigInt(t.const,t.format))}function pl(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.exclusiveMaximum!==void 0)return I(r).attr(U.actions.ltValue).call(e.utils.maybeBigInt(t.exclusiveMaximum,t.format));if(t.maximum!==void 0)return I(r).attr(U.actions.maxValue).call(e.utils.maybeBigInt(t.maximum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return I(r).attr(U.actions.maxValue).call(e.utils.maybeBigInt(i.maxValue,t.format),I.literal(i.maxError))}function ml(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.exclusiveMinimum!==void 0)return I(r).attr(U.actions.gtValue).call(e.utils.maybeBigInt(t.exclusiveMinimum,t.format));if(t.minimum!==void 0)return I(r).attr(U.actions.minValue).call(e.utils.maybeBigInt(t.minimum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return I(r).attr(U.actions.minValue).call(e.utils.maybeBigInt(i.minValue,t.format),I.literal(i.minError))}function hl(e){let t=e.nodes.const(e);if(t)return e.pipes.push(e.pipes.current,t);let n=e.nodes.base(e);n&&e.pipes.push(e.pipes.current,n);let r=e.nodes.min(e);r&&e.pipes.push(e.pipes.current,r);let i=e.nodes.max(e);return i&&e.pipes.push(e.pipes.current,i),e.pipes.current}const gl=({plugin:e,schema:t})=>{let n={$:I,nodes:{base:dl,const:fl,max:pl,min:ml},pipes:{...Kc,current:[]},plugin:e,schema:t,symbols:{v:e.external(`valibot.v`)},utils:{getIntegerLimit:ul,maybeBigInt:Qc,shouldCoerceToBigInt:Zc}},r=e.config[`~resolvers`]?.number,i=r?.(n)??hl(n);return n.pipes.toNode(i,e)};function _l(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||!n.additionalProperties.type)return;if(n.additionalProperties.type===`never`)return null;let r=Fl({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`additionalProperties`])}});return r.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),Kc.toNode(r.pipes,t)}function vl(e){let{nodes:t,symbols:n}=e,{v:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i===null?I(r).attr(U.schemas.strictObject).call(a):i?a.isEmpty?I(r).attr(U.schemas.record).call(I(r).attr(U.schemas.string).call(),i):I(r).attr(U.schemas.objectWithRest).call(a,i):I(r).attr(U.schemas.object).call(a)}function yl(e){return e.nodes.base(e)}function bl(e){let{plugin:t,schema:n}=e,r=I.object().pretty();for(let i in n.properties){let a=n.properties[i],o=Fl({optional:!n.required?.includes(i),plugin:t,schema:a,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`properties`,i])}});o.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),r.prop(i,Kc.toNode(o.pipes,t))}return r}const xl=({plugin:e,schema:t,state:n})=>{let r={$:I,nodes:{additionalProperties:_l,base:vl,shape:bl},pipes:{...Kc,current:[]},plugin:e,schema:t,symbols:{v:e.external(`valibot.v`)},utils:{ast:{},state:n}},i=e.config[`~resolvers`]?.object,a=i?.(r)??yl(r);return r.utils.ast.pipes=[r.pipes.toNode(a,e)],r.utils.ast};function Sl(e){let{v:t}=e.symbols;return I(t).attr(U.schemas.string).call()}function Cl(e){let{schema:t,symbols:n}=e,{v:r}=n;if(typeof t.const==`string`)return I(r).attr(U.schemas.literal).call(I.literal(t.const))}function wl(e){let{schema:t,symbols:n}=e,{v:r}=n;switch(t.format){case`date`:return I(r).attr(U.actions.isoDate).call();case`date-time`:return I(r).attr(U.actions.isoTimestamp).call();case`email`:return I(r).attr(U.actions.email).call();case`ipv4`:case`ipv6`:return I(r).attr(U.actions.ip).call();case`time`:return I(r).attr(U.actions.isoTimeSecond).call();case`uri`:return I(r).attr(U.actions.url).call();case`uuid`:return I(r).attr(U.actions.uuid).call()}}function Tl(e){let{schema:t,symbols:n}=e,{v:r}=n;if(!(t.minLength===void 0||t.minLength!==t.maxLength))return I(r).attr(U.actions.length).call(I.literal(t.minLength))}function El(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.maxLength!==void 0)return I(r).attr(U.actions.maxLength).call(I.literal(t.maxLength))}function Dl(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.minLength!==void 0)return I(r).attr(U.actions.minLength).call(I.literal(t.minLength))}function Ol(e){let{schema:t,symbols:n}=e,{v:r}=n;if(t.pattern)return I(r).attr(U.actions.regex).call(I.regexp(t.pattern))}function kl(e){let t=e.nodes.const(e);if(t)return e.pipes.push(e.pipes.current,t);let n=e.nodes.base(e);n&&e.pipes.push(e.pipes.current,n);let r=e.nodes.format(e);r&&e.pipes.push(e.pipes.current,r);let i=e.nodes.length(e);if(i)e.pipes.push(e.pipes.current,i);else{let t=e.nodes.minLength(e);t&&e.pipes.push(e.pipes.current,t);let n=e.nodes.maxLength(e);n&&e.pipes.push(e.pipes.current,n)}let a=e.nodes.pattern(e);return a&&e.pipes.push(e.pipes.current,a),e.pipes.current}const Al=({plugin:e,schema:t})=>{let n={$:I,nodes:{base:Sl,const:Cl,format:wl,length:Tl,maxLength:El,minLength:Dl,pattern:Ol},pipes:{...Kc,current:[]},plugin:e,schema:t,symbols:{v:e.external(`valibot.v`)}},r=e.config[`~resolvers`]?.string,i=r?.(n)??kl(n);return n.pipes.toNode(i,e)},jl=({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).attr(U.schemas.literal).call(I.fromValue(e)));return r.pipes=[I(i).attr(U.schemas.tuple).call(I.array(...e))],r}if(t.items){let a=t.items.map((t,i)=>{let a=Fl({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,i])}});return a.hasLazyExpression&&(r.hasLazyExpression=!0),W(a.pipes,e)});return r.pipes=[I(i).attr(U.schemas.tuple).call(I.array(...a))],r}return{pipes:[nl({plugin:e,schema:{type:`unknown`},state:n})]}},Ml=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.undefined).call(),Nl=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`valibot.v`})).attr(U.schemas.void).call(),Pl=({schema:e,...t})=>{switch(e.type){case`array`:return{expression:W(rl({...t,schema:e}).pipes,t.plugin)};case`boolean`:return{expression:il({...t,schema:e})};case`enum`:return{expression:al({...t,schema:e})};case`integer`:case`number`:return{expression:gl({...t,schema:e})};case`never`:return{expression:ol({...t,schema:e})};case`null`:return{expression:sl({...t,schema:e})};case`object`:return{expression:W(xl({...t,schema:e}).pipes,t.plugin)};case`string`:return{expression:Zc(e.format)?gl({...t,schema:{...e,type:`number`}}):Al({...t,schema:e})};case`tuple`:return{expression:W(jl({...t,schema:e}).pipes,t.plugin)};case`undefined`:return{expression:Ml({...t,schema:e})};case`unknown`:return{expression:nl({...t,schema:e})};case`void`:return{expression:Nl({...t,schema:e})}}},Fl=({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);i.pipes.push(e)}else{let e=I(a).attr(U.schemas.lazy).call(I.func().do(I(o).return()));i.pipes.push(e),r.hasLazyExpression[`~ref`]=!0}}else if(n.type){let e=Pl({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).attr(U.actions.metadata).call(I.object().prop(`description`,I.literal(n.description)));i.pipes.push(e)}}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>W(Fl({plugin:t,schema:e,state:{...r,path:(0,l.ref)([...(0,l.fromRef)(r.path),`items`,n])}}).pipes,t));if(n.logicalOperator===`and`){let t=I(a).attr(U.schemas.intersect).call(I.array(...e));i.pipes.push(t)}else{let t=I(a).attr(U.schemas.union).call(I.array(...e));i.pipes.push(t)}}else{let e=Fl({plugin:t,schema:n,state:r});i.pipes.push(...e.pipes)}else{let e=Pl({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).attr(U.actions.readonly).call();i.pipes.push(e)}n.default===void 0?e&&(i.pipes=[I(a).attr(U.schemas.optional).call(W(i.pipes,t))]):i.pipes=[I(a).attr(U.schemas.optional).call(W(i.pipes,t),n.type===`integer`||n.type===`number`?Qc(n.default,n.format):I.fromValue(n.default))]}return i},Il=({plugin:e,schema:t,state:n})=>{let r=ra((0,l.fromRef)(n.path)),i=Fl({plugin:e,schema:t,state:n}),a=z(r);$c({ast:i,plugin:e,schema:t,state:n,symbol:e.symbol(R(a,e.config.definitions),{meta:{category:`schema`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`valibot`}})})},Ll=({plugin:e})=>{e.symbol(`v`,{external:`valibot`,importKind:`namespace`,meta:{category:`external`,resource:`valibot.v`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=(0,l.refs)({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:el({getAst:(n,r)=>Fl({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Il({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Il({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Il({plugin:e,schema:t.schema,state:n});break;case`webhook`:tl({getAst:(n,r)=>Fl({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Rl=e=>Ll(e),zl={api:new Xc,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:Rl,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`]},Bl=_(zl),G={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`,maximum:`maximum`,min:`min`,minLength:`minLength`,minimum:`minimum`,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`},Vl=e=>{let{schema:t}=e.symbols;return I(t).attr(G.parseAsync).call(`data`).await().return()},Hl=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.request,Vl];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Ul=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.response,Vl];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Wl=e=>{let{schema:t}=e.symbols;return I(t).attr(G.parseAsync).call(`data`).await().return()},Gl=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.request,Wl];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Kl=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.response,Wl];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},ql=e=>{let{schema:t}=e.symbols;return I(t).attr(G.parseAsync).call(`data`).await().return()},Jl=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`data`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.request,ql];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}},Yl=({operation:e,plugin:t})=>{let n=t.getSymbol({category:`schema`,resource:`operation`,resourceId:e.id,role:`responses`,tool:`zod`});if(!n)return;let r=t.external(`zod.z`),i={$:I,chain:{current:I(r)},operation:e,plugin:t,symbols:{schema:n,z:r}},a=t.config[`~resolvers`]?.validator,o=[typeof a==`function`?a:a?.response,ql];for(let e of o){let t=e?.(i);if(t===null)return;if(t!==void 0)return I.func().async().param(`data`).do(...t instanceof Array?t:[t])}};var Xl=class{createRequestValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Gl(e);case`mini`:return Hl(e);case 4:default:return Jl(e)}}createResponseValidator(e){let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return Kl(e);case`mini`:return Ul(e);case 4:default:return Yl(e)}}};const Zl=({ast:e,plugin:t,schema:n,symbol:r,typeInferSymbol:i})=>{let a=t.referenceSymbol({category:`external`,resource:`zod.z`}),o=I.const(r).export().$if(t.config.comments&&B(n),(e,t)=>e.doc(t)).$if(e.typeName,(e,t)=>e.type(I.type(a).attr(t))).assign(e.expression);if(t.node(o),i){let e=I.type.alias(i).export().type(I.type(a).attr(G.infer).generic(I(r).typeofType()));t.node(e)}},Ql=({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`}},$l=({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],Zl({ast:e(a,(0,l.fromRef)(r.path)),plugin:n,schema:a,symbol:n.symbol(R(t.id,n.config.requests),{meta:{category:`schema`,path:(0,l.fromRef)(r.path),resource:`operation`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`zod`}}),typeInferSymbol:n.config.requests.types.infer.enabled?n.symbol(R(t.id,n.config.requests.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(r.path),resource:`operation`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`zod`,variant:`infer`}}):void 0})}if(n.config.responses.enabled&&t.responses){let{response:i}=Ct(t);if(i){let a=[...(0,l.fromRef)(r.path),`responses`];Zl({ast:e(i,a),plugin:n,schema:i,symbol:n.symbol(R(t.id,n.config.responses),{meta:{category:`schema`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:(0,l.fromRef)(r.tags),tool:`zod`}}),typeInferSymbol:n.config.responses.types.infer.enabled?n.symbol(R(t.id,n.config.responses.types.infer),{meta:{category:`type`,path:a,resource:`operation`,resourceId:t.id,role:`responses`,tags:(0,l.fromRef)(r.tags),tool:`zod`,variant:`infer`}}):void 0})}}},eu=({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],Zl({ast:e(a,(0,l.fromRef)(r.path)),plugin:n,schema:a,symbol:n.symbol(R(t.id,n.config.webhooks),{meta:{category:`schema`,path:(0,l.fromRef)(r.path),resource:`webhook`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`zod`}}),typeInferSymbol:n.config.webhooks.types.infer.enabled?n.symbol(R(t.id,n.config.webhooks.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(r.path),resource:`webhook`,resourceId:t.id,role:`data`,tags:(0,l.fromRef)(r.tags),tool:`zod`,variant:`infer`}}):void 0})}},tu=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t).attr(G.unknown).call(),n},nu=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i={},a=I(r).attr(G.array);if(!t.items)i.expression=a.call(tu({plugin:e,schema:{type:`unknown`},state:n}).expression);else{t=S({schema:t});let o=t.items.map((t,r)=>{let a=ju({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`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).attr(G.intersection).call(...o);else{n=o[0];for(let e=1;e<o.length;e++)n=I(r).attr(G.intersection).call(n,o[e])}i.expression=a.call(n)}else i.expression=I(r).attr(G.array).call(I(r).attr(G.union).call(I.array(...o)))}let o=[];return t.minItems===t.maxItems&&t.minItems!==void 0?o.push(I(r).attr(G.length).call(I.fromValue(t.minItems))):(t.minItems!==void 0&&o.push(I(r).attr(G.minLength).call(I.fromValue(t.minItems))),t.maxItems!==void 0&&o.push(I(r).attr(G.maxLength).call(I.fromValue(t.maxItems)))),o.length>0&&(i.expression=i.expression.attr(G.check).call(...o)),i},ru=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(r=I(i).attr(G.literal).call(I.literal(t.const)),n.expression=r,n):(r=I(i).attr(G.boolean).call(),n.expression=r,n)},iu=({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).attr(G.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).attr(G.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.literal(e.const);o.push(I(r).attr(G.literal).call(t))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?i.expression=I(r).attr(G.enum).call(I.array(...a)):o.length===1?i.expression=o[0]:i.expression=I(r).attr(G.union).call(I.array(...o)),s&&(i.expression=I(r).attr(G.nullable).call(i.expression)),i):tu({plugin:e,schema:{type:`unknown`},state:n})},au=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t).attr(G.never).call(),n},ou=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t).attr(G.null).call(),n};function su(e){let{schema:t,symbols:n}=e,{z:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return I(r).attr(G.coerce).attr(G.bigint).call();let i=I(r).attr(G.number).call();return t.type===`integer`&&(i=I(r).attr(G.int).call()),i}function cu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.const!==void 0)return I(r).attr(G.literal).call(e.utils.maybeBigInt(t.const,t.format))}function lu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.exclusiveMaximum!==void 0)return I(r).attr(G.lt).call(e.utils.maybeBigInt(t.exclusiveMaximum,t.format));if(t.maximum!==void 0)return I(r).attr(G.lte).call(e.utils.maybeBigInt(t.maximum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return I(r).attr(G.maximum).call(e.utils.maybeBigInt(i.maxValue,t.format),I.object().prop(`error`,I.literal(i.maxError)))}function uu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.exclusiveMinimum!==void 0)return I(r).attr(G.gt).call(e.utils.maybeBigInt(t.exclusiveMinimum,t.format));if(t.minimum!==void 0)return I(r).attr(G.gte).call(e.utils.maybeBigInt(t.minimum,t.format));let i=e.utils.getIntegerLimit(t.format);if(i)return I(r).attr(G.minimum).call(e.utils.maybeBigInt(i.minValue,t.format),I.object().prop(`error`,I.literal(i.minError)))}function du(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=[],i=e.nodes.min(e);i&&r.push(i);let a=e.nodes.max(e);return a&&r.push(a),r.length>0&&(e.chain.current=e.chain.current.attr(G.check).call(...r)),e.chain.current}const fu=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{base:su,const:cu,max:lu,min:uu},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,getIntegerLimit:ul,maybeBigInt:Qc,shouldCoerceToBigInt:Zc,state:n}},o=e.config[`~resolvers`]?.number;return r.expression=o?.(a)??du(a),r};function pu(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||n.properties&&Object.keys(n.properties).length>0)return;let r=ju({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`additionalProperties`])}});return r.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),r.expression}function mu(e){let{nodes:t,symbols:n}=e,{z:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i?I(r).attr(G.record).call(I(r).attr(G.string).call(),i):I(r).attr(G.object).call(a)}function hu(e){return e.nodes.base(e)}function gu(e){let{plugin:t,schema:n}=e,r=I.object().pretty();for(let i in n.properties){let a=n.properties[i],o=ju({optional:!n.required?.includes(i),plugin:t,schema:a,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`properties`,i])}});o.hasLazyExpression?(e.utils.ast.hasLazyExpression=!0,r.getter(i,o.expression.return())):r.prop(i,o.expression)}return r}const _u=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{additionalProperties:pu,base:mu,shape:gu},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,state:n}},o=e.config[`~resolvers`]?.object;return r.expression=o?.(a)??hu(a),r};function vu(e){let{z:t}=e.symbols;return I(t).attr(G.string).call()}function yu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(typeof t.const==`string`)return I(r).attr(G.literal).call(I.literal(t.const))}function bu(e){let{plugin:t,schema:n,symbols:r}=e,{z:i}=r;switch(n.format){case`date`:return I(i).attr(G.iso).attr(G.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(i).attr(G.iso).attr(G.datetime).call(e.hasProps()?e:void 0)}case`email`:return I(i).attr(G.email).call();case`ipv4`:return I(i).attr(G.ipv4).call();case`ipv6`:return I(i).attr(G.ipv6).call();case`time`:return I(i).attr(G.iso).attr(G.time).call();case`uri`:return I(i).attr(G.url).call();case`uuid`:return I(i).attr(G.uuid).call()}}function xu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(!(t.minLength===void 0||t.minLength!==t.maxLength))return I(r).attr(G.length).call(I.literal(t.minLength))}function Su(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.maxLength!==void 0)return I(r).attr(G.maxLength).call(I.literal(t.maxLength))}function Cu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.minLength!==void 0)return I(r).attr(G.minLength).call(I.literal(t.minLength))}function wu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.pattern)return I(r).attr(G.regex).call(I.regexp(t.pattern))}function Tu(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=e.nodes.format(e);r&&(e.chain.current=r);let i=[],a=e.nodes.length(e);if(a)i.push(a);else{let t=e.nodes.minLength(e);t&&i.push(t);let n=e.nodes.maxLength(e);n&&i.push(n)}let o=e.nodes.pattern(e);return o&&i.push(o),i.length>0&&(e.chain.current=e.chain.current.attr(G.check).call(...i)),e.chain.current}const Eu=({plugin:e,schema:t})=>{let n=e.external(`zod.z`),r={$:I,chain:{current:I(n)},nodes:{base:vu,const:yu,format:bu,length:xu,maxLength:Su,minLength:Cu,pattern:wu},plugin:e,schema:t,symbols:{z:n}},i=e.config[`~resolvers`]?.string;return{expression:i?.(r)??Tu(r)}},Du=({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).attr(G.literal).call(I.fromValue(e)));return i.expression=I(r).attr(G.tuple).call(I.array(...e)),i}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=ju({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i.hasLazyExpression=!0)}),i.expression=I(r).attr(G.tuple).call(I.array(...a)),i},Ou=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t).attr(G.undefined).call(),n},ku=({plugin:e})=>{let t=e.referenceSymbol({category:`external`,resource:`zod.z`}),n={};return n.expression=I(t).attr(G.void).call(),n},Au=({schema:e,...t})=>{switch(e.type){case`array`:return nu({...t,schema:e});case`boolean`:return ru({...t,schema:e});case`enum`:return iu({...t,schema:e});case`integer`:case`number`:return fu({...t,schema:e});case`never`:return au({...t,schema:e});case`null`:return ou({...t,schema:e});case`object`:return _u({...t,schema:e});case`string`:return Zc(e.format)?fu({...t,schema:{...e,type:`number`}}):Eu({...t,schema:e});case`tuple`:return Du({...t,schema:e});case`undefined`:return Ou({...t,schema:e});case`unknown`:return tu({...t,schema:e});case`void`:return ku({...t,schema:e})}},ju=({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):(i.expression=I(a).attr(G.lazy).call(I.func().returns(`any`).do(I(o).return())),i.hasLazyExpression=!0,r.hasLazyExpression[`~ref`]=!0)}else if(n.type){let e=Au({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=i.expression.attr(G.register).call(I(a).attr(G.globalRegistry),I.object().pretty().prop(`description`,I.literal(n.description))))}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>ju({plugin:t,schema:e,state:{...r,path:(0,l.ref)([...(0,l.fromRef)(r.path),`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I(a).attr(G.intersection).call(...e.map(e=>e.expression)):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=I(a).attr(G.intersection).call(i.expression,e.hasLazyExpression?I(a).attr(G.lazy).call(I.func().do(e.expression.return())):e.expression)}))}else i.expression=I(a).attr(G.union).call(I.array().pretty().elements(...e.map(e=>e.expression)))}else i=ju({plugin:t,schema:n,state:r});else{let e=Au({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression}return i.expression&&(n.accessScope===`read`&&(i.expression=I(a).attr(G.readonly).call(i.expression)),e&&(i.expression=I(a).attr(G.optional).call(i.expression),i.typeName=G.ZodMiniOptional),n.default!==void 0&&(i.expression=I(a).attr(G._default).call(i.expression,n.type===`integer`||n.type===`number`?Qc(n.default,n.format):I.fromValue(n.default)))),i},Mu=({plugin:e,schema:t,state:n})=>{let r=ra((0,l.fromRef)(n.path)),i=ju({plugin:e,schema:t,state:n}),a=z(r);Zl({ast:i,plugin:e,schema:t,symbol:e.symbol(R(a,e.config.definitions),{meta:{category:`schema`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(R(a,e.config.definitions.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`,variant:`infer`}}):void 0})},Nu=({plugin:e})=>{e.symbol(`z`,{external:Ql({plugin:e}),importKind:`namespace`,meta:{category:`external`,resource:`zod.z`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=(0,l.refs)({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:$l({getAst:(n,r)=>ju({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Mu({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Mu({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Mu({plugin:e,schema:t.schema,state:n});break;case`webhook`:eu({getAst:(n,r)=>ju({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Pu=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.unknown).call(),Fu=({plugin:e,schema:t,state:n})=>{let r=e.referenceSymbol({category:`external`,resource:`zod.z`}),i=I(r).attr(G.array),a,o=!1;if(!t.items)a=i.call(Pu({plugin:e,schema:{type:`unknown`},state:n}));else{t=S({schema:t});let s=t.items.map((t,r)=>{let i=ud({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`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).attr(G.intersection).call(...s);else{n=s[0];for(let e=1;e<s.length;e++)n=n.attr(G.and).call(s[e])}a=i.call(n)}else a=I(r).attr(G.array).call(I(r).attr(G.union).call(I.array(...s)))}return t.minItems===t.maxItems&&t.minItems!==void 0?a=a.attr(G.length).call(I.fromValue(t.minItems)):(t.minItems!==void 0&&(a=a.attr(G.min).call(I.fromValue(t.minItems))),t.maxItems!==void 0&&(a=a.attr(G.max).call(I.fromValue(t.maxItems)))),{expression:a,hasLazyExpression:o}},Iu=({plugin:e,schema:t})=>{let n,r=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(n=I(r).attr(G.literal).call(I.literal(t.const)),n):(n=I(r).attr(G.boolean).call(),n)},Lu=({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).attr(G.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).attr(G.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){s=!1;let t=I.literal(e.const);a.push(I(r).attr(G.literal).call(t))}else (e.type===`null`||e.const===null)&&(o=!0);if(!a.length)return Pu({plugin:e,schema:{type:`unknown`},state:n});let c;return c=s&&i.length>0?I(r).attr(G.enum).call(I.array(...i)):a.length===1?a[0]:I(r).attr(G.union).call(I.array(...a)),o&&(c=c.attr(G.nullable).call()),c},Ru=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.never).call(),zu=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.null).call();function Bu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return I(r).attr(G.coerce).attr(G.bigint).call();let i=I(r).attr(G.number).call();return t.type===`integer`&&(i=i.attr(G.int).call()),i}function Vu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.const!==void 0)return I(r).attr(G.literal).call(e.utils.maybeBigInt(t.const,t.format))}function Hu(e){let{chain:t,schema:n}=e;if(n.exclusiveMaximum!==void 0)return t.current.attr(G.lt).call(e.utils.maybeBigInt(n.exclusiveMaximum,n.format));if(n.maximum!==void 0)return t.current.attr(G.lte).call(e.utils.maybeBigInt(n.maximum,n.format));let r=e.utils.getIntegerLimit(n.format);if(r)return t.current.attr(G.max).call(e.utils.maybeBigInt(r.maxValue,n.format),I.object().prop(`message`,I.literal(r.maxError)))}function Uu(e){let{chain:t,schema:n}=e;if(n.exclusiveMinimum!==void 0)return t.current.attr(G.gt).call(e.utils.maybeBigInt(n.exclusiveMinimum,n.format));if(n.minimum!==void 0)return t.current.attr(G.gte).call(e.utils.maybeBigInt(n.minimum,n.format));let r=e.utils.getIntegerLimit(n.format);if(r)return t.current.attr(G.min).call(e.utils.maybeBigInt(r.minValue,n.format),I.object().prop(`message`,I.literal(r.minError)))}function Wu(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=e.nodes.min(e);r&&(e.chain.current=r);let i=e.nodes.max(e);return i&&(e.chain.current=i),e.chain.current}const Gu=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{base:Bu,const:Vu,max:Hu,min:Uu},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,getIntegerLimit:ul,maybeBigInt:Qc,shouldCoerceToBigInt:Zc,state:n}},o=e.config[`~resolvers`]?.number;return o?.(a)??Wu(a)};function Ku(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||n.properties&&Object.keys(n.properties).length>0)return;let r=ud({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`additionalProperties`])}});return r.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),r.expression}function qu(e){let{nodes:t,symbols:n}=e,{z:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i?I(r).attr(G.record).call(i):I(r).attr(G.object).call(a)}function Ju(e){return e.nodes.base(e)}function Yu(e){let{plugin:t,schema:n}=e,r=I.object().pretty();for(let i in n.properties){let a=n.properties[i],o=ud({optional:!n.required?.includes(i),plugin:t,schema:a,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`properties`,i])}});o.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),r.prop(i,o.expression)}return r}const Xu=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{additionalProperties:Ku,base:qu,shape:Yu},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,state:n}},o=e.config[`~resolvers`]?.object;return r.expression=o?.(a)??Ju(a),{...r,anyType:`AnyZodObject`}};function Zu(e){let{z:t}=e.symbols;return I(t).attr(G.string).call()}function Qu(e){let{schema:t,symbols:n}=e,{z:r}=n;if(typeof t.const==`string`)return I(r).attr(G.literal).call(I.literal(t.const))}function $u(e){let{chain:t,plugin:n,schema:r}=e;switch(r.format){case`date`:return t.current.attr(G.date).call();case`date-time`:{let e=I.object().$if(n.config.dates.offset,e=>e.prop(`offset`,I.literal(!0))).$if(n.config.dates.local,e=>e.prop(`local`,I.literal(!0)));return t.current.attr(G.datetime).call(e.hasProps()?e:void 0)}case`email`:return t.current.attr(G.email).call();case`ipv4`:case`ipv6`:return t.current.attr(G.ip).call();case`time`:return t.current.attr(G.time).call();case`uri`:return t.current.attr(G.url).call();case`uuid`:return t.current.attr(G.uuid).call()}}function ed(e){let{chain:t,schema:n}=e;if(!(n.minLength===void 0||n.minLength!==n.maxLength))return t.current.attr(G.length).call(I.literal(n.minLength))}function td(e){let{chain:t,schema:n}=e;if(n.maxLength!==void 0)return t.current.attr(G.max).call(I.literal(n.maxLength))}function nd(e){let{chain:t,schema:n}=e;if(n.minLength!==void 0)return t.current.attr(G.min).call(I.literal(n.minLength))}function rd(e){let{chain:t,schema:n}=e;if(n.pattern)return t.current.attr(G.regex).call(I.regexp(n.pattern))}function id(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=e.nodes.format(e);r&&(e.chain.current=r);let i=e.nodes.length(e);if(i)e.chain.current=i;else{let t=e.nodes.minLength(e);t&&(e.chain.current=t);let n=e.nodes.maxLength(e);n&&(e.chain.current=n)}let a=e.nodes.pattern(e);return a&&(e.chain.current=a),e.chain.current}const ad=({plugin:e,schema:t})=>{let n=e.external(`zod.z`),r={$:I,chain:{current:I(n)},nodes:{base:Zu,const:Qu,format:$u,length:ed,maxLength:td,minLength:nd,pattern:rd},plugin:e,schema:t,symbols:{z:n}},i=e.config[`~resolvers`]?.string;return i?.(r)??id(r)},od=({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).attr(G.literal).call(I.fromValue(e)));return{expression:I(r).attr(G.tuple).call(I.array(...e)),hasLazyExpression:i}}let a=[];return t.items&&t.items.forEach((t,r)=>{let o=ud({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,r])}});a.push(o.expression),o.hasLazyExpression&&(i=!0)}),{expression:I(r).attr(G.tuple).call(I.array(...a)),hasLazyExpression:i}},sd=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.undefined).call(),cd=({plugin:e})=>I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.void).call(),ld=({schema:e,...t})=>{switch(e.type){case`array`:return Fu({...t,schema:e});case`boolean`:return{expression:Iu({...t,schema:e})};case`enum`:return{expression:Lu({...t,schema:e})};case`integer`:case`number`:return{expression:Gu({...t,schema:e})};case`never`:return{expression:Ru({...t,schema:e})};case`null`:return{expression:zu({...t,schema:e})};case`object`:return Xu({...t,schema:e});case`string`:return{expression:Zc(e.format)?Gu({...t,schema:{...e,type:`number`}}):ad({...t,schema:e})};case`tuple`:return od({...t,schema:e});case`undefined`:return{expression:sd({...t,schema:e})};case`unknown`:return{expression:Pu({...t,schema:e})};case`void`:return{expression:cd({...t,schema:e})}}},ud=({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):(i.expression=I(a).attr(G.lazy).call(I.func().do(I(o).return())),i.hasLazyExpression=!0,r.hasLazyExpression[`~ref`]=!0)}else if(n.type){let e=ld({plugin:t,schema:n,state:r});i.expression=e.expression,i.typeName=e.anyType,t.config.metadata&&n.description&&(i.expression=i.expression.attr(G.describe).call(I.literal(n.description)))}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>ud({plugin:t,schema:e,state:{...r,path:(0,l.ref)([...(0,l.fromRef)(r.path),`items`,n])}}).expression);if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I(a).attr(G.intersection).call(...e):(i.expression=e[0],e.slice(1).forEach(e=>{i.expression=i.expression.attr(G.and).call(e)}))}else i.expression=I(a).attr(G.union).call(I.array().pretty().elements(...e))}else i=ud({plugin:t,schema:n,state:r});else{let e=ld({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression,i.typeName=e.anyType}return i.expression&&(n.accessScope===`read`&&(i.expression=i.expression.attr(G.readonly).call()),e&&(i.expression=i.expression.attr(G.optional).call()),n.default!==void 0&&(i.expression=i.expression.attr(G.default).call(n.type===`integer`||n.type===`number`?Qc(n.default,n.format):I.fromValue(n.default)))),r.hasLazyExpression[`~ref`]?i.typeName||=`ZodTypeAny`:i.typeName&&=void 0,i},dd=({plugin:e,schema:t,state:n})=>{let r=ra((0,l.fromRef)(n.path)),i=ud({plugin:e,schema:t,state:n}),a=z(r);Zl({ast:i,plugin:e,schema:t,symbol:e.symbol(R(a,e.config.definitions),{meta:{category:`schema`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(R(a,e.config.definitions.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`,variant:`infer`}}):void 0})},fd=({plugin:e})=>{e.symbol(`z`,{external:Ql({plugin:e}),meta:{category:`external`,resource:`zod.z`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=(0,l.refs)({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:$l({getAst:(n,r)=>ud({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:dd({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:dd({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:dd({plugin:e,schema:t.schema,state:n});break;case`webhook`:eu({getAst:(n,r)=>ud({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},pd=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.unknown).call(),t},md=({plugin:e,schema:t,state:n})=>{let r={},i=e.referenceSymbol({category:`external`,resource:`zod.z`}),a=I(i).attr(G.array);if(!t.items)r.expression=a.call(pd({plugin:e,schema:{type:`unknown`},state:n}).expression);else{t=S({schema:t});let o=t.items.map((t,i)=>{let a=Ud({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`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).attr(G.intersection).call(...o);else{n=o[0];for(let e=1;e<o.length;e++)n=n.attr(G.and).call(o[e])}r.expression=a.call(n)}else r.expression=I(i).attr(G.array).call(I(i).attr(G.union).call(I.array(...o)))}return t.minItems===t.maxItems&&t.minItems!==void 0?r.expression=r.expression.attr(G.length).call(I.fromValue(t.minItems)):(t.minItems!==void 0&&(r.expression=r.expression.attr(G.min).call(I.fromValue(t.minItems))),t.maxItems!==void 0&&(r.expression=r.expression.attr(G.max).call(I.fromValue(t.maxItems)))),r},hd=({plugin:e,schema:t})=>{let n={},r,i=e.referenceSymbol({category:`external`,resource:`zod.z`});return typeof t.const==`boolean`?(r=I(i).attr(G.literal).call(I.literal(t.const)),n.expression=r,n):(r=I(i).attr(G.boolean).call(),n.expression=r,n)},gd=({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).attr(G.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).attr(G.literal).call(t))}else if(e.type===`boolean`&&typeof e.const==`boolean`){c=!1;let t=I.literal(e.const);o.push(I(i).attr(G.literal).call(t))}else (e.type===`null`||e.const===null)&&(s=!0);return o.length?(c&&a.length>0?r.expression=I(i).attr(G.enum).call(I.array(...a)):o.length===1?r.expression=o[0]:r.expression=I(i).attr(G.union).call(I.array(...o)),s&&(r.expression=I(i).attr(G.nullable).call(r.expression)),r):pd({plugin:e,schema:{type:`unknown`},state:n})},_d=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.never).call(),t},vd=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.null).call(),t};function yd(e){let{schema:t,symbols:n}=e,{z:r}=n;if(e.utils.shouldCoerceToBigInt(t.format))return I(r).attr(G.coerce).attr(G.bigint).call();let i=I(r).attr(G.number).call();return t.type===`integer`&&(i=I(r).attr(G.int).call()),i}function bd(e){let{schema:t,symbols:n}=e,{z:r}=n;if(t.const!==void 0)return I(r).attr(G.literal).call(e.utils.maybeBigInt(t.const,t.format))}function xd(e){let{chain:t,schema:n}=e;if(n.exclusiveMaximum!==void 0)return t.current.attr(G.lt).call(e.utils.maybeBigInt(n.exclusiveMaximum,n.format));if(n.maximum!==void 0)return t.current.attr(G.lte).call(e.utils.maybeBigInt(n.maximum,n.format));let r=e.utils.getIntegerLimit(n.format);if(r)return t.current.attr(G.max).call(e.utils.maybeBigInt(r.maxValue,n.format),I.object().prop(`error`,I.literal(r.maxError)))}function Sd(e){let{chain:t,schema:n}=e;if(n.exclusiveMinimum!==void 0)return t.current.attr(G.gt).call(e.utils.maybeBigInt(n.exclusiveMinimum,n.format));if(n.minimum!==void 0)return t.current.attr(G.gte).call(e.utils.maybeBigInt(n.minimum,n.format));let r=e.utils.getIntegerLimit(n.format);if(r)return t.current.attr(G.min).call(e.utils.maybeBigInt(r.minValue,n.format),I.object().prop(`error`,I.literal(r.minError)))}function Cd(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=e.nodes.min(e);r&&(e.chain.current=r);let i=e.nodes.max(e);return i&&(e.chain.current=i),e.chain.current}const wd=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{base:yd,const:bd,max:xd,min:Sd},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,getIntegerLimit:ul,maybeBigInt:Qc,shouldCoerceToBigInt:Zc,state:n}},o=e.config[`~resolvers`]?.number;return r.expression=o?.(a)??Cd(a),r};function Td(e){let{plugin:t,schema:n}=e;if(!n.additionalProperties||n.properties&&Object.keys(n.properties).length>0)return;let r=Ud({plugin:t,schema:n.additionalProperties,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`additionalProperties`])}});return r.hasLazyExpression&&(e.utils.ast.hasLazyExpression=!0),r.expression}function Ed(e){let{nodes:t,symbols:n}=e,{z:r}=n,i=t.additionalProperties(e),a=t.shape(e);return i?I(r).attr(G.record).call(I(r).attr(G.string).call(),i):I(r).attr(G.object).call(a)}function Dd(e){return e.nodes.base(e)}function Od(e){let{plugin:t,schema:n}=e,r=I.object().pretty();for(let i in n.properties){let a=n.properties[i],o=Ud({optional:!n.required?.includes(i),plugin:t,schema:a,state:{...e.utils.state,path:(0,l.ref)([...(0,l.fromRef)(e.utils.state.path),`properties`,i])}});o.hasLazyExpression?(e.utils.ast.hasLazyExpression=!0,r.getter(i,o.expression.return())):r.prop(i,o.expression)}return r}const kd=({plugin:e,schema:t,state:n})=>{let r={},i=e.external(`zod.z`),a={$:I,chain:{current:I(i)},nodes:{additionalProperties:Td,base:Ed,shape:Od},plugin:e,schema:t,symbols:{z:i},utils:{ast:r,state:n}},o=e.config[`~resolvers`]?.object;return r.expression=o?.(a)??Dd(a),r};function Ad(e){let{z:t}=e.symbols;return I(t).attr(G.string).call()}function jd(e){let{schema:t,symbols:n}=e,{z:r}=n;if(typeof t.const==`string`)return I(r).attr(G.literal).call(I.literal(t.const))}function Md(e){let{plugin:t,schema:n,symbols:r}=e,{z:i}=r;switch(n.format){case`date`:return I(i).attr(G.iso).attr(G.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(i).attr(G.iso).attr(G.datetime).call(e.hasProps()?e:void 0)}case`email`:return I(i).attr(G.email).call();case`ipv4`:return I(i).attr(G.ipv4).call();case`ipv6`:return I(i).attr(G.ipv6).call();case`time`:return I(i).attr(G.iso).attr(G.time).call();case`uri`:return I(i).attr(G.url).call();case`uuid`:return I(i).attr(G.uuid).call()}}function Nd(e){let{chain:t,schema:n}=e;if(!(n.minLength===void 0||n.minLength!==n.maxLength))return t.current.attr(G.length).call(I.literal(n.minLength))}function Pd(e){let{chain:t,schema:n}=e;if(n.maxLength!==void 0)return t.current.attr(G.max).call(I.literal(n.maxLength))}function Fd(e){let{chain:t,schema:n}=e;if(n.minLength!==void 0)return t.current.attr(G.min).call(I.literal(n.minLength))}function Id(e){let{chain:t,schema:n}=e;if(n.pattern)return t.current.attr(G.regex).call(I.regexp(n.pattern))}function Ld(e){let t=e.nodes.const(e);if(t)return e.chain.current=t,e.chain.current;let n=e.nodes.base(e);n&&(e.chain.current=n);let r=e.nodes.format(e);r&&(e.chain.current=r);let i=e.nodes.length(e);if(i)e.chain.current=i;else{let t=e.nodes.minLength(e);t&&(e.chain.current=t);let n=e.nodes.maxLength(e);n&&(e.chain.current=n)}let a=e.nodes.pattern(e);return a&&(e.chain.current=a),e.chain.current}const Rd=({plugin:e,schema:t})=>{let n=e.external(`zod.z`),r={$:I,chain:{current:I(n)},nodes:{base:Ad,const:jd,format:Md,length:Nd,maxLength:Pd,minLength:Fd,pattern:Id},plugin:e,schema:t,symbols:{z:n}},i=e.config[`~resolvers`]?.string;return{expression:i?.(r)??Ld(r)}},zd=({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).attr(G.literal).call(I.fromValue(e)));return r.expression=I(i).attr(G.tuple).call(I.array(...e)),r}let a=[];return t.items&&t.items.forEach((t,i)=>{let o=Ud({plugin:e,schema:t,state:{...n,path:(0,l.ref)([...(0,l.fromRef)(n.path),`items`,i])}});a.push(o.expression),o.hasLazyExpression&&(r.hasLazyExpression=!0)}),r.expression=I(i).attr(G.tuple).call(I.array(...a)),r},Bd=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.undefined).call(),t},Vd=({plugin:e})=>{let t={};return t.expression=I(e.referenceSymbol({category:`external`,resource:`zod.z`})).attr(G.void).call(),t},Hd=({schema:e,...t})=>{switch(e.type){case`array`:return md({...t,schema:e});case`boolean`:return hd({...t,schema:e});case`enum`:return gd({...t,schema:e});case`integer`:case`number`:return wd({...t,schema:e});case`never`:return _d({...t,schema:e});case`null`:return vd({...t,schema:e});case`object`:return kd({...t,schema:e});case`string`:return Zc(e.format)?wd({...t,schema:{...e,type:`number`}}):Rd({...t,schema:e});case`tuple`:return zd({...t,schema:e});case`undefined`:return Bd({...t,schema:e});case`unknown`:return pd({...t,schema:e});case`void`:return Vd({...t,schema:e})}},Ud=({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):(i.expression=I(a).attr(G.lazy).call(I.func().returns(`any`).do(I(o).return())),i.hasLazyExpression=!0,r.hasLazyExpression[`~ref`]=!0)}else if(n.type){let e=Hd({plugin:t,schema:n,state:r});i.expression=e.expression,i.hasLazyExpression=e.hasLazyExpression,t.config.metadata&&n.description&&(i.expression=i.expression.attr(G.register).call(I(a).attr(G.globalRegistry),I.object().pretty().prop(`description`,I.literal(n.description))))}else if(n.items)if(n=S({schema:n}),n.items){let e=n.items.map((e,n)=>Ud({plugin:t,schema:e,state:{...r,path:(0,l.ref)([...(0,l.fromRef)(r.path),`items`,n])}}));if(n.logicalOperator===`and`){let t=n.items[0];t.logicalOperator===`or`||t.type&&t.type!==`object`?i.expression=I(a).attr(G.intersection).call(...e.map(e=>e.expression)):(i.expression=e[0].expression,e.slice(1).forEach(e=>{i.expression=i.expression.attr(G.and).call(e.hasLazyExpression?I(a).attr(G.lazy).call(I.func().do(e.expression.return())):e.expression)}))}else i.expression=I(a).attr(G.union).call(I.array().pretty().elements(...e.map(e=>e.expression)))}else i=Ud({plugin:t,schema:n,state:r});else{let e=Hd({plugin:t,schema:{type:`unknown`},state:r});i.expression=e.expression}return i.expression&&(n.accessScope===`read`&&(i.expression=i.expression.attr(G.readonly).call()),e&&(i.expression=I(a).attr(G.optional).call(i.expression),i.typeName=G.ZodOptional),n.default!==void 0&&(i.expression=i.expression.attr(G.default).call(n.type===`integer`||n.type===`number`?Qc(n.default,n.format):I.fromValue(n.default)))),i},Wd=({plugin:e,schema:t,state:n})=>{let r=ra((0,l.fromRef)(n.path)),i=Ud({plugin:e,schema:t,state:n}),a=z(r);Zl({ast:i,plugin:e,schema:t,symbol:e.symbol(R(a,e.config.definitions),{meta:{category:`schema`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`}}),typeInferSymbol:e.config.definitions.types.infer.enabled?e.symbol(R(a,e.config.definitions.types.infer),{meta:{category:`type`,path:(0,l.fromRef)(n.path),resource:`definition`,resourceId:r,tags:(0,l.fromRef)(n.tags),tool:`zod`,variant:`infer`}}):void 0})},Gd=({plugin:e})=>{e.symbol(`z`,{external:Ql({plugin:e}),meta:{category:`external`,resource:`zod.z`}}),e.forEach(`operation`,`parameter`,`requestBody`,`schema`,`webhook`,t=>{let n=(0,l.refs)({hasLazyExpression:!1,path:t._path,tags:t.tags});switch(t.type){case`operation`:$l({getAst:(n,r)=>Ud({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break;case`parameter`:Wd({plugin:e,schema:t.parameter.schema,state:n});break;case`requestBody`:Wd({plugin:e,schema:t.requestBody.schema,state:n});break;case`schema`:Wd({plugin:e,schema:t.schema,state:n});break;case`webhook`:eu({getAst:(n,r)=>Ud({plugin:e,schema:n,state:(0,l.refs)({hasLazyExpression:!1,path:r,tags:t.tags})}),operation:t.operation,plugin:e,state:n});break}})},Kd=e=>{let{plugin:t}=e;switch(t.config.compatibilityVersion){case 3:return fd(e);case`mini`:return Nu(e);case 4:default:return Gd(e)}},qd={api:new Xl,config:{case:`camelCase`,comments:!0,exportFromIndex:!1,metadata:!1},handler:Kd,name:`zod`,resolveConfig:(e,t)=>{let n=t.package.getVersion(`zod`),r=()=>n&&(n.major===4||n.major===3)?n.major:4,i=e=>{if(!e)return r();if(!n)return e;if((e===4||e===3||e===`mini`)&&!t.package.satisfies(n,`>=3.25.0 <5.0.0`)){let t=r();return console.warn(`🔌 ${u.default.yellow(`Warning:`)} Installed ${u.default.cyan(`zod`)} ${u.default.cyan(`v${n.version}`)} does not support compatibility version ${u.default.yellow(String(e))}, using ${u.default.yellow(String(t))}.`),t}return e};e.config.compatibilityVersion=i(e.config.compatibilityVersion),e.config.dates=t.valueToObject({defaultValue:{local:!1,offset:!1},value:e.config.dates}),e.config.types=t.valueToObject({defaultValue:{infer:{case:`PascalCase`,enabled:!1}},mappers:{object:(e,n)=>({...e,infer:t.valueToObject({defaultValue:{...n.infer,enabled:e.infer===void 0?n.infer.enabled:!!e.infer},mappers: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`]},Jd=_(qd),Yd={"@angular/common":Wa,"@hey-api/client-angular":so,"@hey-api/client-axios":lo,"@hey-api/client-fetch":fo,"@hey-api/client-ky":mo,"@hey-api/client-next":go,"@hey-api/client-nuxt":vo,"@hey-api/client-ofetch":bo,"@hey-api/schemas":No,"@hey-api/sdk":Wo,"@hey-api/transformers":es,"@hey-api/typescript":Os,"@pinia/colada":Ks,"@tanstack/angular-query-experimental":fc,"@tanstack/react-query":mc,"@tanstack/solid-query":gc,"@tanstack/svelte-query":vc,"@tanstack/vue-query":bc,arktype:Pc,fastify:Rc,swr:Uc,valibot:zl,zod:qd},Xd=[`@hey-api/typescript`,`@hey-api/sdk`],Zd=({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=Yd[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:Co(e),pluginByTag:(e,r={})=>{let{defaultPlugin:i,errorMessage:a}=r;for(let r of t){let t=Yd[r]||n[r];if(t&&t.tags?.includes(e)&&r!==s)return r}if(i){let t=Yd[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:g};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}},Qd=e=>typeof e==`string`?e.startsWith(`@hey-api/client`):e.name.startsWith(`@hey-api/client`)||e.tags&&e.tags.includes(`client`),$d=({dependencies:e,userConfig:t})=>{let n={},r=Xd;return t.plugins&&(t.plugins=t.plugins.filter(e=>typeof e==`string`&&e||typeof e!=`string`&&e.name),r=t.plugins.length===1&&Qd(t.plugins[0])?[...Xd,...t.plugins]:t.plugins),Zd({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})},ef=()=>!!(process.stdin.isTTY&&process.stdout.isTTY&&!process.env.CI&&!process.env.NO_INTERACTIVE&&!process.env.NO_INTERACTION),tf=async({logger:e,userConfigs:t})=>{let n=[],r={},i=e.timeEvent(`load`);for(let i of t){let t;if(i?.configFile){let e=i.configFile.split(`.`);t=e.slice(0,e.length-1).join(`.`)}let a=e.timeEvent(`c12`),{loadConfig:o}=await import(`c12`),{config:s,configFile:c}=await o({configFile:t,name:`openapi-ts`});a.timeEnd(),Object.keys(r).length||(r=ot(Object.keys(s).length?c:void 0));let l=s instanceof Array?s.map(e=>Re(e,i)):[Re(s,i)];for(let e of l){let t=Fe(e);if(e.output instanceof Array){let r=t.length,i=e.output.length;if(i>1)if(r!==i){console.warn(`⚙️ ${u.default.yellow(`Warning:`)} You provided ${u.default.cyan(String(r))} ${u.default.cyan(r===1?`input`:`inputs`)} and ${u.default.yellow(String(i))} ${u.default.yellow(`outputs`)}. This is probably not what you want as it will produce identical output in multiple locations. You most likely want to provide a single output or the same number of outputs as inputs.`);for(let r of e.output)n.push({...e,input:t,output:r})}else e.output.forEach((r,i)=>{n.push({...e,input:t[i],output:r})});else n.push({...e,input:t,output:e.output[0]??``})}else n.push({...e,input:t})}}i.timeEnd();let a=[],o=e.timeEvent(`build`);for(let e of n){let t=Ie(e),n=Fe(e),i=He(e),o=ct(e),s=[];n.length||s.push(new le(`missing input - which OpenAPI specification should we use to generate your output?`)),i.path||s.push(new le(`missing output - where should we generate your output?`)),i.path=f.default.resolve(process.cwd(),i.path);let c;try{c=$d({dependencies:r,userConfig:e})}catch(e){s.push(e),c={pluginOrder:[],plugins:{}}}let l={configFile:e.configFile??``,dryRun:e.dryRun??!1,input:n,interactive:e.interactive??ef(),logs:t,output:i,parser:o,pluginOrder:c.pluginOrder,plugins:c.plugins},d=a.length;if(t.level===`debug`){let e=u.default.gray(`[Job ${d+1}] `);console.warn(`${e}${u.default.cyan(`config:`)}`,l)}a.push({config:l,errors:s,jobIndex:d})}return o.timeEnd(),{dependencies:r,results:a}},nf=Object.entries({$body_:`body`,$headers_:`headers`,$path_:`path`,$query_:`query`}),rf=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},af=e=>{switch(e){case`form`:return`,`;case`pipeDelimited`:return`|`;case`spaceDelimited`:return`%20`;default:return`,`}},of=e=>{switch(e){case`label`:return`.`;case`matrix`:return`;`;case`simple`:return`,`;default:return`&`}},sf=({allowReserved:e,explode:t,name:n,style:r,value:i})=>{if(!t){let t=(e?i:i.map(e=>encodeURIComponent(e))).join(af(r));switch(r){case`label`:return`.${t}`;case`matrix`:return`;${n}=${t}`;case`simple`:return t;default:return`${n}=${t}`}}let a=rf(r),o=i.map(t=>r===`label`||r===`simple`?e?t:encodeURIComponent(t):cf({allowReserved:e,name:n,value:t})).join(a);return r===`label`||r===`matrix`?a+o:o},cf=({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)}`},lf=({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=of(r),s=Object.entries(i).map(([t,i])=>cf({allowReserved:e,name:r===`deepObject`?`${n}[${t}]`:t,value:i})).join(o);return r===`label`||r===`matrix`?o+s:s},uf=({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=sf({allowReserved:o.allowReserved,explode:!0,name:i,style:`form`,value:a,...o.array});e&&r.push(e)}else if(typeof a==`object`){let e=lf({allowReserved:o.allowReserved,explode:!0,name:i,style:`deepObject`,value:a,...o.object});e&&r.push(e)}else{let e=cf({allowReserved:o.allowReserved,name:i,value:a});e&&r.push(e)}}return r.join(`&`)},df=e=>{let t=[];return e.forEach((e,n)=>{t.push([n,e])}),t},ff=(...e)=>{let t=new Headers;for(let n of e){if(!n)continue;let e=n instanceof Headers?df(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},pf=uf({allowReserved:!1,array:{explode:!0,style:`form`},object:{explode:!0,style:`deepObject`}}),mf=async({fetchOptions:e,inputPath:t,timeout:n,watch:r})=>{let i=(0,te.getResolvedInput)({pathOrUrlOrSchema:t}),a,o,s;if(i.type===`url`){if(r.lastValue&&r.isHeadMethodSupported!==!1){try{let t=await(0,te.sendRequest)({fetchOptions:{method:`HEAD`,...e,headers:ff(e?.headers,r.headers)},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok&&r.isHeadMethodSupported)return{error:`not-ok`,response:s};if(r.isHeadMethodSupported===void 0&&(r.isHeadMethodSupported=s.ok),s.status===304)return{error:`not-modified`,response:s};if(o===void 0){let e=s.headers.get(`ETag`);e&&(o=e!==r.headers.get(`If-None-Match`),o&&r.headers.set(`If-None-Match`,e))}if(o===void 0){let e=s.headers.get(`Last-Modified`);e&&(o=e!==r.headers.get(`If-Modified-Since`),o&&r.headers.set(`If-Modified-Since`,e))}if(o===!1)return{error:`not-modified`,response:s}}try{let t=await(0,te.sendRequest)({fetchOptions:{method:`GET`,...e},timeout:n,url:i.path});if(t.response.status>=300)return{error:`not-ok`,response:t.response};s=t.response}catch(e){return{error:`not-ok`,response:new Response(e.message)}}if(!s.ok)return{error:`not-ok`,response:s};if(a=s.body?await s.arrayBuffer():new ArrayBuffer(0),o===void 0){let e=new TextDecoder().decode(a);o=e!==r.lastValue,r.lastValue=e}}else r.lastValue?o=!1:r.lastValue=i.type;return o===!1?{error:`not-modified`,response:s}:{arrayBuffer:a,resolvedInput:i}};var hf=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 gf=(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))},_f=(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 hf(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))},vf=(e,t,n)=>n?.order===`topological`?_f(e,t,n):gf(e,t,n),yf=[`operation`,`parameter`,`requestBody`,`schema`,`server`,`webhook`],bf=(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}},xf=[`server`,`schema`,`parameter`,`requestBody`,`operation`,`webhook`],Sf=(()=>{let e={};for(let t=0;t<xf.length;t++){let n=xf[t];n&&(e[n]=t)}for(let t of yf)e[t]===void 0&&(e[t]=xf.length);return e})(),Cf=10,wf=e=>{let t=bf(e);return t.matched?Sf[t.kind]??10:10},Tf=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},Ef=e=>{switch(e.method){case`delete`:case`patch`:case`post`:case`put`:return[`mutation`];case`get`:return[`query`];default:return}};var Df=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}external(e,t){return this.gen.symbols.reference({...t,category:`external`,resource:e})}forEach(...e){if(!this.context.graph)throw Error(`No graph available in context`);let t,n,r={getPointerPriority:wf,matchPointerToGroup:bf,order:`topological`,preferGroups:xf};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:yf);vf(this.context.graph,(e,n)=>{let r=bf(e);if(!r.matched||!i.has(r.kind))return;let a,o={_path:ta(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`)}};intent(e){this.context.intents.push(e)}isSymbolRegistered(e){return this.gen.symbols.isRegistered(e)}node(e,t){for(let t of this.eventHooks[`node:set:before`])t({node:e,plugin:this});let n=t===void 0?this.gen.nodes.add(e):this.gen.nodes.update(t,e);for(let t of this.eventHooks[`node:set:after`])t({node:e,plugin:this});return n}querySymbol(e){return this.gen.symbols.query(e)[0]}referenceSymbol(e){return this.gen.symbols.reference(e)}registerSymbol(e){return this.symbol(e.name,e)}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})}symbol(e,t){let n={...t,exportFrom:t?.exportFrom??(!t?.external&&this.context.config.output.indexFile&&this.config.exportFromIndex?[`index`]:void 0),getFilePath:t?.getFilePath??this.getSymbolFilePath.bind(this),meta:{pluginName:f.default.isAbsolute(this.name)?`custom`:this.name,...t?.meta},name:e};for(let e of this.eventHooks[`symbol:register:before`])e({plugin:this,symbol:n});let r=this.gen.symbols.register(n);for(let e of this.eventHooks[`symbol:register:after`])e({plugin:this,symbol:r});return r}symbolOnce(e,t){let n={...t?.meta};return t?.external&&(n.category=`external`,n.resource=t.external),this.querySymbol(n)||this.symbol(e,{...t,meta:n})}buildEventHooks(){let e={"node:set:after":[],"node:set:before":[],"plugin:handler:after":[],"plugin:handler:before":[],"symbol:register:after":[],"symbol:register: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 fe({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 Tf(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,Ef];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}},Of=class{config;gen;graph;intents=[];ir={};logger;package;plugins={};spec;constructor({config:e,dependencies:t,logger:n,spec:r}){this.config=e,this.gen=new l.Project({defaultFileName:`index`,fileName:t=>{let n=R(t,e.output.fileName),{suffix:r}=e.output.fileName;return r?n===`index`||n.endsWith(r)?n:`${n}${r}`:n},nameConflictResolvers:e.output.nameConflictResolver?{typescript:e.output.nameConflictResolver}:void 0,renderers:[new Fi({header:e.output.header,preferExportAll:e.output.preferExportAll,preferFileExtension:e.output.importFileExtension||void 0,resolveModuleName:e.output.resolveModuleName})],root:e.output.path}),this.logger=n,this.package=Co(t),this.spec=r}dereference(e){let t=this.resolveRef(e.$ref),n={...e,...t};return delete n.$ref,n}registerPlugin(e){let t=this.config.plugins[e],n=new Df({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 ia({$ref:e,spec:this.ir})}resolveRef(e){return ia({$ref:e,spec:this.spec})}};const kf=[`delete`,`get`,`head`,`options`,`patch`,`post`,`put`,`trace`],Af=e=>e.replace(/^[^\p{ID_Start}]+/u,``).replace(/[^$\u200c\u200d\p{ID_Continue}]/gu,`-`).replace(/[$+]/g,`-`),jf=({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.operations&&typeof e.config.plugins[`@hey-api/sdk`].config.operations!=`function`&&typeof e.config.plugins[`@hey-api/sdk`].config.operations==`object`&&e.config.plugins[`@hey-api/sdk`].config.operations.nesting===`operationId`)?L(Af(n),c):L(`${r}-${i.replace(/{(.*?)}/g,`by-$1`).replace(/[/:+]/g,`-`)}`,c),t>1&&(o=`${o}${t}`),a.ids.has(o)?jf({context:e,count:t+1,id:n,method:r,path:i,state:a}):(a.ids.set(o,w({method:r,path:i})),o)},Mf=`/`,K=(e,t=``)=>`${e}/${t}`,q=e=>{let t=e.indexOf(`/`);return{name:e.slice(t+1),namespace:e.slice(0,t)}},Nf=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)}},Pf=({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 kf){if(!i[t])continue;let a=w({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))},Ff=({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 kf){if(!r[t])continue;let i=w({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))}},If=({spec:e,...t})=>{`swagger`in e?Pf({...t,spec:e}):Ff({...t,spec:e})},Lf=(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);If({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},Rf=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,zf=({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}},Bf=({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}},Vf=({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}},Hf=({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}},Uf=({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}},Wf=({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}}}},Gf=({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}}}},Kf=({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}}}},qf=({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}}}},Jf=({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)},Yf=({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}},Xf=({filters:e,logger:t,resourceMetadata:n})=>{let r=t.timeEvent(`create-filtered-dependencies`),{schemas:i}=Uf({filters:e,resourceMetadata:n}),{parameters:a}=Bf({filters:e,resourceMetadata:n,schemas:i}),{requestBodies:o}=Vf({filters:e,resourceMetadata:n,schemas:i}),{responses:s}=Hf({filters:e,resourceMetadata:n,schemas:i});qf({filters:e,resourceMetadata:n,schemas:i}),Wf({filters:e,parameters:a,resourceMetadata:n}),Gf({filters:e,requestBodies:o,resourceMetadata:n}),Kf({filters:e,resourceMetadata:n,responses:s});let{operations:c}=zf({filters:e,parameters:a,requestBodies:o,resourceMetadata:n,responses:s,schemas:i});if(!e.orphans&&c.size){let{operationDependencies:e}=Yf({operations:c,resourceMetadata:n});Jf({operationDependencies:e,parameters:a,requestBodies:o,responses:s,schemas:i})}return r.timeEnd(),{operations:c,parameters:a,requestBodies:o,responses:s,schemas:i}},Zf=(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=ta(e),r=t[t.length-2],i=t[t.length-1];if(r&&i){let e=Nf(r);e===`unknown`&&console.warn(`unsupported type: ${r}`),n.add(K(e,i))}}return n};for(let[t,n]of e.nodes){let e=ta(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&&kf.includes(e[2])){let a=e[e.length-1],o=w({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}},Qf=e=>JSON.parse(JSON.stringify(e)),$f=[[`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`]],ep=e=>{if(tp(e))return e.components.schemas;if(np(e))return e.definitions},tp=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,np=e=>typeof e==`object`&&!!e&&`definitions`in e&&typeof e.definitions==`object`&&e.definitions!==null,rp=(e,t)=>e instanceof Set?e.has(t):e instanceof Array?e.includes(t):t in e,ip=({base:e,components:t,extraComponents:n})=>{let r=2,i=e;for(;rp(t,i)||n&&rp(n,i);)i=`${e}${r}`,r+=1;return i},ap=e=>e.length===3&&e[0]===`components`&&e[1]===`schemas`||e.length===2&&e[0]===`definitions`,op=e=>{if(e&&typeof e==`object`){if(`swagger`in e)return`#/definitions/`;if(`openapi`in e)return`#/components/schemas/`}return``},sp=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})},cp=({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||$f.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)=>cp({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):cp({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},lp=({spec:e})=>{let t=ep(e);if(!t)return;let n=op(e),r={};for(let[e,i]of Object.entries(t))sp(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,Qf(r[n])),delete e.$ref):i(n)};i(e);for(let e of Object.keys(r)){let n=ta(e),r=n[n.length-1];r&&delete t[r]}},up=({config:e,spec:t})=>{let n=ep(t);if(!n)return;let r={};for(let[e,t]of Object.entries(n)){let n=sp(t);n&&(r[n]=e)}let i=[];cp({key:null,node:t,parent:null,path:[],visitor:e=>{if(!ap(e.path)){let t=sp(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]=ip({base:R(typeof s==`object`&&s&&`title`in s&&typeof s.title==`string`?s.title:String(t),e),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=op(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}`})}},dp=({config:e,spec:t})=>{if(e.mode===`inline`){lp({spec:t});return}if(e.mode===`root`){up({config:e,spec:t});return}},fp=({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||$f.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)=>fp({key:a,node:t,parent:n,path:[...r,e,a],visitor:i})):fp({key:e,node:n,parent:t,path:[...r,e],visitor:i}))},pp=({spec:e})=>{fp({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)}}})},mp=(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(!mp(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(!mp(r[e],i[e]))return!1;return!0};var hp=mp;const gp=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))}},_p=({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=_p({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=_p({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}},vp=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&&yp(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 $f){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&&yp(r,a)&&n(i,a)}if(a.parentPointer){let t=e.nodes.get(a.parentPointer);t&&yp(a,t)&&n(a.parentPointer,t)}}},yp=(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},bp=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`])))}},xp=(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=ra(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=na(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);bp(r.nodes),vp(r),gp(r.nodes);for(let e of r.nodes.keys()){let t=_p({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}},Sp=new Set([`additionalProperties`,`allOf`,`anyOf`,`items`,`not`,`oneOf`,`patternProperties`,`properties`,`schema`]),Cp=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`}},wp=(e,t)=>{let n=t.timeEvent(`capture-original-schemas`),r={};if(tp(e))for(let[t,n]of Object.entries(e.components.schemas))r[`#/components/schemas/${t}`]=n;else if(np(e))for(let[t,n]of Object.entries(e.definitions))r[`#/definitions/${t}`]=n;return n.timeEnd(),r},Tp=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`insert-split-schemas-into-spec`);tp(t)?Object.assign(t.components.schemas,n.schemas):np(t)&&Object.assign(t.definitions,n.schemas),r.timeEnd()},Ep=(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,!$f.some(([e])=>e in t)))return!0}for(let[r,i]of $f){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||Ep(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||Ep(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||Ep(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||Ep(e,r,n))&&a.splice(t,1)}a.length||delete t[r]}else typeof a==`object`&&a&&(a[n]===!0||Ep(e,a,n))&&delete t[r]}if(t.type===`object`&&!$f.some(([e])=>e in t))return!0}return!1},Dp=({logger:e,originalSchemas:t,spec:n,split:r})=>{let i=e.timeEvent(`remove-original-split-schemas`),a=ep(n);for(let e of Object.keys(r.mapping)){let n=ta(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()},Op=({config:e,graph:t,logger:n,spec:r})=>{let i=n.timeEvent(`split-schemas`),a=new Set,o={mapping:{},reverseMapping:{},schemas:{}},s=op(r),c=s.split(`/`).length-1,l=e=>{if(e.startsWith(s)){let t=ta(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=Qf(r.node);Ep(t,c,`writeOnly`);let u=R(i,e.responses),d=u===i?u:ip({base:u,components:a});a.add(d),o.schemas[d]=c;let f=`${s}${d}`,p=Qf(r.node);Ep(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`))})&&hp(c,p)&&hp(c,r.node))continue;let ee=R(i,e.requests),h=ee===i&&ee!==d?ee:ip({base:ee,components:a});a.add(h),o.schemas[h]=p;let te=`${s}${h}`;o.mapping[n]={read:f,write:te},o.reverseMapping[f]=n,o.reverseMapping[te]=n}return i.timeEnd(),o},kp=({logger:e,spec:t,split:n})=>{let r=e.timeEvent(`update-refs-in-spec`),i=op(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(ap(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=Cp(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(Sp.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()},Ap=({config:e,logger:t,spec:n})=>{let{graph:r}=xp(n,t),i=wp(n,t),a=Op({config:e,graph:r,logger:t,spec:n});Tp({logger:t,spec:n,split:a}),kp({logger:t,spec:n,split:a}),Dp({logger:t,originalSchemas:i,spec:n,split:a})},jp=({context:e})=>{let{logger:t}=e,n=t.timeEvent(`transform-openapi-spec`);e.config.parser.transforms.enums.enabled&&dp({config:e.config.parser.transforms.enums,spec:e.spec}),e.config.parser.transforms.propertiesRequiredByDefault&&pp({spec:e.spec}),e.config.parser.transforms.readWrite.enabled&&Ap({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},Mp=e=>/^[A-Za-z_$][A-Za-z0-9_$]*$/.test(e),Np=e=>e.map((e,t)=>typeof e==`number`?`[${e}]`:t===0?e:Mp(e)?`.${e}`:`['${e.replace(/"/g,`\\'`)}']`).join(``),Pp=e=>{let t=Np(e.path),n=e.severity===`error`?u.default.bold.red:u.default.bold.yellow,r=e.message.replace(/`([^`]+)`/g,(e,t)=>u.default.yellow(`\`${t}\``));return`${n(`[${e.severity.toUpperCase()}]`)} ${u.default.cyan(t)}: ${r}`},Fp=({context:e,issue:t})=>e.config.logs.level===`silent`?!1:t.severity===`error`?e.config.logs.level!==`warn`:!0,Ip=({context:e,result:t})=>{for(let n of t.issues)Fp({context:e,issue:n})&&console.log(Pp(n));t.valid||process.exit(1)},Lp=({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 kf){if(!r[e])continue;let i=K(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete i.paths[n]}a.timeEnd()},Rp=/^(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,zp=/^application\/(.*\+)?json(;.*)?$/i,Bp=/^multipart\/form-data(;.*)?$/i,Vp=/^text\/[a-z0-9.+-]+(;.*)?$/i,Hp=/^application\/x-www-form-urlencoded(;.*)?$/i,Up=/^application\/octet-stream(;.*)?$/i,Wp=({mediaType:e})=>(Rp.lastIndex=0,Rp.test(e)),Gp=({mediaType:e})=>{if(zp.lastIndex=0,zp.test(e))return`json`;if(Bp.lastIndex=0,Bp.test(e))return`form-data`;if(Vp.lastIndex=0,Vp.test(e))return`text`;if(Hp.lastIndex=0,Hp.test(e))return`url-search-params`;if(Up.lastIndex=0,Up.test(e))return`octet-stream`},Kp=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Wp({mediaType:t})?{...n,format:`binary`}:n:Wp({mediaType:t})?{format:`binary`,type:`string`}:void 0},qp=({mimeTypes:e,response:t})=>{let n=[];for(let r of e??[])n.push({mediaType:r,schema:t.schema,type:Gp({mediaType:r})});return n};function Jp(e){let t=`^(${e.keywords.join(`|`)})$`;return new RegExp(t)}const Yp=(e,t,n)=>{let r=[];for(let n in t)t[n]===e&&r.push(n);return!r.length&&(!n||n())?[z(e)]:r},Xp=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},Zp=({irSchema:e,schema:t})=>{t.example&&(e.example=t.example),t.description&&(e.description=t.description),t.title&&(e.title=t.title)},Qp=({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`)},$p=({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=C({items:i,schema:t}),t},em=({irSchema:e={}})=>(e.type=`boolean`,e),tm=({irSchema:e={},schema:t})=>(e.type=t.type,e),nm=({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},rm=({irSchema:e={}})=>(e.type=`string`,e),im=({source:e,target:t})=>{for(let n in e)n.startsWith(`x-`)&&(t[n]=e[n])},am=({schema:e})=>{let t={};return Zp({irSchema:t,schema:e}),im({source:e,target:t}),t},om=({context:e,schema:t,state:n})=>{let r=am({schema:t}),i=[],a=Xp({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=Yp(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=dm({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(Xp({schema:a})===`object`){let i=dm({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),t[`x-nullable`]){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`},e[0].deprecated&&(r.deprecated=e[0].deprecated),e[0].description&&(r.description=e[0].description)}return r},sm=({context:e,schema:t,state:n})=>{let r=am({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=dm({context:e,schema:{description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:s===`null`?`string`:s},state:n});c.const=a,s===`null`&&(c.type=s),c.type===`array`&&(c.type=`tuple`),i.push(c)}return r=C({items:i,schema:r}),r},cm=({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},lm=({context:e,irSchema:t,schema:n,state:r})=>{t||=am({schema:n});let i={};return Qp({irSchema:i,schema:n}),i.default===null&&delete i.default,t=C({items:[dm({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},um=({context:e,schema:t,state:n})=>{let r=am({schema:t});Qp({irSchema:r,schema:t});let i=Xp({schema:t});return i?t[`x-nullable`]?lm({context:e,irSchema:r,schema:{...t,type:i},state:n}):dm({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},dm=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=am({schema:n}),Qp({irSchema:t,schema:n})),n.type){case`array`:return $p({context:e,irSchema:t,schema:n,state:r});case`boolean`:return em({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return tm({context:e,irSchema:t,schema:n,state:r});case`object`:return nm({context:e,irSchema:t,schema:n,state:r});case`string`:return rm({context:e,irSchema:t,schema:n,state:r});default:return fm({context:e,irSchema:t,schema:n})}},fm=({irSchema:e,schema:t})=>(e||=am({schema:t}),e.type=`unknown`,Qp({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?cm({context:e,schema:t,state:n}):t.enum?sm({context:e,schema:t,state:n}):t.allOf?om({context:e,schema:t,state:n}):t.type||t.properties?um({context:e,schema:t,state:n}):fm({context:e,schema:t})),pm=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[z(e)]=X({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},mm=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,hm=({context:e,name:t,schema:n})=>{if(Jp(e.config.parser.pagination).test(t))return!0;if(`$ref`in n){let r=e.resolveRef(n.$ref??``);return`in`in r&&r.in?hm({context:e,name:t,schema:`schema`in r?r.schema:{...r,in:void 0}}):hm({context:e,name:t,schema:r})}if(`in`in n)return n.in?hm({context:e,name:t,schema:`schema`in n?n.schema:{...n,in:void 0}}):!1;for(let t in n.properties)if(Jp(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&mm(Xp({schema:e})))return t}for(let r of n.allOf??[]){let n=hm({context:e,name:t,schema:r});if(n)return n}return!1},gm=({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)},_m=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:jf({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),gm({irOperation:a,operation:n}),im({source:n,target:a}),a},vm=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=_m({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=qp({mimeTypes:a,response:{schema:i}}),d=o.find(e=>e.type===`json`)||o[0];if(d){let t=hm({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=qp({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,...Kp({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},ym=({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]=vm({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},bm=e=>{switch(e){case`multi`:return!0;case`csv`:case`pipes`:case`ssv`:case`tsv`:default:return!1}},xm=e=>{switch(e){case`header`:case`path`:return`simple`;case`query`:default:return`form`}},Sm=({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()]=Cm({$ref:`#/todo/real/path/to/parameter/${n.name}`,context:e,parameter:n})}return r},Cm=({$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=hm({context:t,name:n.name,schema:i}),o=xm(n.in),s={allowReserved:!1,explode:bm(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),im({source:n,target:s}),s},wm=({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=no(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})))},Tm=(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 kf){if(t===`trace`)continue;let a=n[t];if(!a)continue;let o=w({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},Em=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Ip({context:e,result:Tm(e.spec,e.logger)}),Rf(e.config.parser.filters)){let t=Lf(e.config.parser.filters,e.spec,e.logger),{graph:n}=xp(e.spec,e.logger),{resourceMetadata:r}=Zf(n,e.logger);Lp({...Xf({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}jp({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];pm({$ref:n,context:e,schema:r})}for(let r in wm({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:Sm({context:e,operation:o,parameters:a.parameters})},path:r,securitySchemesMap:n,state:t};if(a.delete){let t=Y({source:Sm({context:e,operation:a.delete,parameters:a.delete.parameters}),target:s.operation.parameters});ym({...s,method:`delete`,operation:{...s.operation,...a.delete,parameters:t}})}if(a.get){let t=Y({source:Sm({context:e,operation:a.get,parameters:a.get.parameters}),target:s.operation.parameters});ym({...s,method:`get`,operation:{...s.operation,...a.get,parameters:t}})}if(a.head){let t=Y({source:Sm({context:e,operation:a.head,parameters:a.head.parameters}),target:s.operation.parameters});ym({...s,method:`head`,operation:{...s.operation,...a.head,parameters:t}})}if(a.options){let t=Y({source:Sm({context:e,operation:a.options,parameters:a.options.parameters}),target:s.operation.parameters});ym({...s,method:`options`,operation:{...s.operation,...a.options,parameters:t}})}if(a.patch){let t=Y({source:Sm({context:e,operation:a.patch,parameters:a.patch.parameters}),target:s.operation.parameters});ym({...s,method:`patch`,operation:{...s.operation,...a.patch,parameters:t}})}if(a.post){let t=Y({source:Sm({context:e,operation:a.post,parameters:a.post.parameters}),target:s.operation.parameters});ym({...s,method:`post`,operation:{...s.operation,...a.post,parameters:t}})}if(a.put){let t=Y({source:Sm({context:e,operation:a.put,parameters:a.put.parameters}),target:s.operation.parameters});ym({...s,method:`put`,operation:{...s.operation,...a.put,parameters:t}})}}},Dm=({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 kf){if(!r[e])continue;let i=K(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},Om=({content:e})=>{let{mediaType:t,schema:n}=e;return n&&`$ref`in n?{allOf:[{...n}]}:n?n.type===`string`&&!n.format&&Wp({mediaType:t})?{...n,format:`binary`}:n:Wp({mediaType:t})?{format:`binary`,type:`string`}:void 0},km=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:Gp({mediaType:n})});return t},Am=({schema:e})=>{if(e.type)return e.type;if(e.properties)return`object`},jm=({context:e,discriminators:t=[],schema:n})=>{if(n.discriminator&&t.push({discriminator:n.discriminator,oneOf:n.oneOf}),n.allOf)for(let r of n.allOf){let n;n=`$ref`in r?e.resolveRef(r.$ref):r,jm({context:e,discriminators:t,schema:n})}return t},Mm=({discriminator:e,schemaRef:t})=>{let n=[];for(let[r,i]of Object.entries(e.mapping||{}))i===t&&n.push(r);return n},Nm=({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)},Pm=({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`)},Fm=({context:e,irSchema:t={},schema:n,state:r})=>{n.maxItems&&n.maxItems===n.minItems?t.type=`tuple`:t.type=`array`;let i=[];if(n.items){let a=Z({context:e,schema:n.items,state:r});if(!i.length&&n.maxItems&&n.maxItems===n.minItems)i=Array(n.maxItems).fill(a);else if(`$ref`in n.items)i.push(a);else{let e=n.items.allOf||n.items.anyOf||n.items.oneOf;e&&e.length>1&&!n.items.nullable?t={...t,...a}:i.push(a)}}return t=C({items:i,schema:t}),t},Im=({irSchema:e={}})=>(e.type=`boolean`,e),Lm=({irSchema:e={},schema:t})=>(e.type=t.type,e),Rm=({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},zm=({irSchema:e={}})=>(e.type=`string`,e),Bm=({source:e,target:t})=>{for(let n in e)n.startsWith(`x-`)&&(t[n]=e[n])},Vm=({schema:e})=>{let t={};return Nm({irSchema:t,schema:e}),Bm({source:e,target:t}),t},Hm=({context:e,schema:t,state:n})=>{let r=Vm({schema:t}),i=[],a=Am({schema:t}),o=t.allOf,s=[],c=new Set;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(n.$ref){let r=jm({context:e,schema:t});for(let{discriminator:i,oneOf:a}of r){if(c.has(i.propertyName))continue;let o=Yp(n.$ref,i.mapping,a?()=>a.some(e=>`$ref`in e&&e.$ref===n.$ref):void 0);if(o.length>0){let n=r.some(n=>n.discriminator.propertyName===i.propertyName&&(t.required?.includes(n.discriminator.propertyName)||t.allOf&&t.allOf.some(t=>(`$ref`in t?e.resolveRef(t.$ref):t).required?.includes(n.discriminator.propertyName))));s.push({discriminator:i,isRequired:n,values:o}),c.add(i.propertyName)}}}}}for(let{discriminator:t,isRequired:r,values:a}of s){let o=Mm({discriminator:t,schemaRef:n.$ref}),s=(o.length>0?o:a).map(e=>({const:e,type:`string`})),c=s.length>1?{items:s,logicalOperator:`or`}:s[0];for(let n of i)(n.$ref||n.symbolRef)&&(()=>{if(!n.$ref)return!1;try{let r=e.resolveRef(n.$ref);return r.properties?.[t.propertyName]!==void 0||r.allOf&&r.allOf.some(n=>(`$ref`in n?e.resolveRef(n.$ref):n).properties?.[t.propertyName]!==void 0)}catch{return!1}})()&&(n.omit?n.omit.includes(t.propertyName)||(n.omit=[...n.omit,t.propertyName]):n.omit=[t.propertyName]);let l;for(let e=i.length-1;e>=0;e--){let t=i[e];if(t.type===`object`||t.properties){l=t;break}}if(l)l.properties||={},l.properties[t.propertyName]=c,r&&(l.required||=[],l.required.includes(t.propertyName)||(l.required=[...l.required,t.propertyName]));else{let e={properties:{[t.propertyName]:c},type:`object`};r&&(e.required=[t.propertyName]),i.push(e)}}if(a===`object`){let r=Ym({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(Am({schema:a})===`object`){let i=Ym({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),t.nullable){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`},e[0].deprecated&&(r.deprecated=e[0].deprecated),e[0].description&&(r.description=e[0].description)}return r},Um=({context:e,schema:t,state:n})=>{let r=Vm({schema:t}),i=[],a=Am({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=Yp(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`},a],logicalOperator:`and`}}i.push(a)}if(t.nullable&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=Ym({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Wm=({context:e,schema:t,state:n})=>{let r=Vm({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=Ym({context:e,schema:{description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:s===`null`?`string`:s},state:n});c.const=a,s===`null`&&(c.type=s),c.type===`array`&&(c.type=`tuple`),i.push(c)}return r=C({items:i,schema:r}),r},Gm=({context:e,schema:t,state:n})=>{let r=Vm({schema:t}),i=[],a=Am({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=Yp(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},required:[t.discriminator.propertyName],type:`object`},a],logicalOperator:`and`}}a.logicalOperator===`or`&&a.type!==`array`&&a.items?i=i.concat(a.items):i.push(a)}if(t.nullable&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a===`object`){let i=Ym({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Km=({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},qm=({context:e,irSchema:t,schema:n,state:r})=>{t||=Vm({schema:n});let i={};return Pm({irSchema:i,schema:n}),i.default===null&&delete i.default,t=C({items:[Ym({context:e,irSchema:i,schema:n,state:r}),{type:`null`}],schema:t}),t},Jm=({context:e,schema:t,state:n})=>{let r=Vm({schema:t});Pm({irSchema:r,schema:t});let i=Am({schema:t});return i?t.nullable?qm({context:e,irSchema:r,schema:{...t,type:i},state:n}):Ym({context:e,irSchema:r,schema:{...t,type:i},state:n}):r},Ym=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Vm({schema:n}),Pm({irSchema:t,schema:n})),n.type){case`array`:return Fm({context:e,irSchema:t,schema:n,state:r});case`boolean`:return Im({context:e,irSchema:t,schema:n,state:r});case`integer`:case`number`:return Lm({context:e,irSchema:t,schema:n,state:r});case`object`:return Rm({context:e,irSchema:t,schema:n,state:r});case`string`:return zm({context:e,irSchema:t,schema:n,state:r});default:return Xm({context:e,irSchema:t,schema:n})}},Xm=({irSchema:e,schema:t})=>(e||=Vm({schema:t}),e.type=`unknown`,Pm({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?Km({context:e,schema:t,state:n}):t.enum?Wm({context:e,schema:t,state:n}):t.allOf?Hm({context:e,schema:t,state:n}):t.anyOf?Um({context:e,schema:t,state:n}):t.oneOf?Gm({context:e,schema:t,state:n}):t.type||t.properties?Jm({context:e,schema:t,state:n}):Xm({context:e,schema:t})),Zm=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[z(e)]=Z({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Qm=e=>e===`boolean`||e===`integer`||e===`number`||e===`string`,$m=({context:e,name:t,schema:n})=>{if(Jp(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=km({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?$m({context:e,name:t,schema:n}):!1}return $m({context:e,name:t,schema:r})}for(let t in n.properties)if(Jp(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`&&!(`$ref`in e)&&Qm(Am({schema:e})))return t}for(let r of n.allOf??[]){let n=$m({context:e,name:t,schema:r});if(n)return n}return!1},eh=({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)},th=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:jf({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),eh({irOperation:a,operation:n}),Bm({source:n,target:a}),a},nh=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=th({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=km({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=$m({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){if(t.startsWith(`x-`))continue;o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=km({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,...Om({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},rh=({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]=nh({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})},ih=e=>{switch(e){case`query`:return!1;default:return}},ah=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},oh=e=>{switch(e){case`header`:case`path`:return`simple`;case`cookie`:case`query`:return`form`}},sh=({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()]=ch({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},ch=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=km({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=$m({context:t,name:n.name,schema:i}),o=n.style||oh(n.in),s=n.explode===void 0?ah(o):n.explode,c={allowReserved:n.allowReserved===void 0?ih(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),Bm({source:n,target:c}),c},lh=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[z(e)]=ch({$ref:e,context:t,parameter:n})},uh=({$ref:e,context:t,requestBody:n})=>{let r=km({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},dh=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[z(e)]=uh({$ref:e,context:t,requestBody:n})},fh=({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=no(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},ph=(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 kf){let a=n[t];if(!a)continue;let o=w({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}if(e.servers){(typeof e.servers!=`object`||!Array.isArray(e.servers))&&r.push({code:`invalid_type`,message:"`servers` must be an array.",path:[],severity:`error`});for(let t=0;t<e.servers.length;t++){let n=e.servers[t];!n||typeof n!=`object`?r.push({code:`invalid_type`,context:{actual:typeof n,expected:`object`},message:"Each entry in `servers` must be an object.",path:[`servers`,t],severity:`error`}):n.url||r.push({code:`missing_required_field`,context:{field:`url`},message:"Missing required field `url` in server object.",path:[`servers`,t],severity:`error`})}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},mh=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Ip({context:e,result:ph(e.spec,e.logger)}),Rf(e.config.parser.filters)){let t=Lf(e.config.parser.filters,e.spec,e.logger),{graph:n}=xp(e.spec,e.logger),{resourceMetadata:r}=Zf(n,e.logger);Dm({...Xf({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}jp({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];lh({$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];dh({$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];Zm({$ref:n,context:e,schema:r})}}for(let r in fh({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={context:e,operation:{description:a.description,parameters:sh({context:e,parameters:a.parameters}),security:e.spec.security,servers:a.servers,summary:a.summary},path:r,securitySchemesMap:n,state:t};a.delete&&rh({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:sh({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&rh({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:sh({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&rh({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:sh({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&rh({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:sh({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&rh({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:sh({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&rh({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:sh({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&rh({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:sh({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&rh({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:sh({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},hh=({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 kf){if(!r[e])continue;let i=K(`operation`,w({method:e,path:n}));t.has(i)||delete r[e]}Object.keys(r).length||delete s.paths[n]}c.timeEnd()},gh=({content:e})=>{let{mediaType:t,schema:n}=e;return n?n.type===`string`&&!n.format&&Wp({mediaType:t})?{...n,format:`binary`}:n:Wp({mediaType:t})?{format:`binary`,type:`string`}:void 0},_h=({content:e})=>{let t=[];for(let n in e)t.push({mediaType:n,schema:e[n].schema,type:Gp({mediaType:n})});return t},vh=({schema:e})=>typeof e.type==`string`?[e.type]:e.type?e.type:e.properties?[`object`]:[],yh=({context:e,discriminators:t=[],schema:n})=>{if(n.discriminator&&t.push({discriminator:n.discriminator,oneOf:n.oneOf}),n.allOf)for(let r of n.allOf){let n;n=r.$ref?e.resolveRef(r.$ref):r,yh({context:e,discriminators:t,schema:n})}return t},bh=({discriminator:e,schemaRef:t})=>{let n=[];for(let[r,i]of Object.entries(e.mapping||{}))i===t&&n.push(r);return n},xh=({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)},Sh=({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`)},Ch=({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&&!vh({schema:n.items}).includes(`null`)?t={...t,...a}:i.push(a)}}return t=C({items:i,schema:t}),t},wh=({irSchema:e={}})=>(e.type=`boolean`,e),Th=({irSchema:e={}})=>(e.type=`null`,e),Eh=({irSchema:e={},schema:t})=>(e.type=t.type,e),Dh=({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},Oh=({irSchema:e={}})=>(e.type=`string`,e),kh=({source:e,target:t})=>{for(let n in e)n.startsWith(`x-`)&&(t[n]=e[n])},Ah=({schema:e})=>{let t={};return xh({irSchema:t,schema:e}),kh({source:e,target:t}),t},jh=({context:e,schema:t,state:n})=>{let r=Ah({schema:t});Sh({irSchema:r,schema:t});let i=[],a=vh({schema:t}),o=t.allOf,s=[],c=new Set;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(n.$ref){let r=yh({context:e,schema:t});for(let{discriminator:i,oneOf:a}of r){if(c.has(i.propertyName))continue;let o=Yp(n.$ref,i.mapping,a?()=>a.some(e=>`$ref`in e&&e.$ref===n.$ref):void 0);if(o.length>0){let n=r.some(n=>n.discriminator.propertyName===i.propertyName&&(t.required?.includes(n.discriminator.propertyName)||t.allOf&&t.allOf.some(t=>(t.$ref?e.resolveRef(t.$ref):t).required?.includes(n.discriminator.propertyName))));s.push({discriminator:i,isRequired:n,values:o}),c.add(i.propertyName)}}}}}for(let{discriminator:t,isRequired:r,values:a}of s){let o=bh({discriminator:t,schemaRef:n.$ref}),s=(o.length>0?o:a).map(e=>({const:e,type:`string`})),c=s.length>1?{items:s,logicalOperator:`or`}:s[0];for(let n of i)(n.$ref||n.symbolRef)&&(()=>{if(!n.$ref)return!1;try{let r=e.resolveRef(n.$ref);return r.properties?.[t.propertyName]!==void 0||r.allOf&&r.allOf.some(n=>(n.$ref?e.resolveRef(n.$ref):n).properties?.[t.propertyName]!==void 0)}catch{return!1}})()&&(n.omit?n.omit.includes(t.propertyName)||(n.omit=[...n.omit,t.propertyName]):n.omit=[t.propertyName]);let l;for(let e=i.length-1;e>=0;e--){let t=i[e];if(t.type===`object`||t.properties){l=t;break}}if(l)l.properties||={},l.properties[t.propertyName]=c,r&&(l.required||=[],l.required.includes(t.propertyName)||(l.required=[...l.required,t.propertyName]));else{let e={properties:{[t.propertyName]:c},type:`object`};r&&(e.required=[t.propertyName]),i.push(e)}}if(a.includes(`object`)){let r=Ih({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(vh({schema:a}).includes(`object`)){let i=Ih({context:e,schema:{...a,type:`object`},state:n});if(i.properties?.[t]){r.properties[t]=i.properties[t];break}}}i.push(r)}}if(r=C({items:i,logicalOperator:`and`,mutateSchemaOneItem:!0,schema:r}),a.includes(`null`)){let e=[{type:`null`}];i.length&&e.unshift(r),r={items:e,logicalOperator:`or`}}return r},Mh=({context:e,schema:t,state:n})=>{let r=Ah({schema:t});Sh({irSchema:r,schema:t});let i=[],a=vh({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=Yp(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},type:`object`},a],logicalOperator:`and`}}i.push(a)}if(a.includes(`null`)&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=Ih({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Nh=({context:e,schema:t,state:n})=>{let r=Ah({schema:t});r.type=`enum`;let i=[],a=vh({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=Ih({context:e,schema:{const:o,description:t[`x-enum-descriptions`]?.[r],title:t[`x-enum-varnames`]?.[r]??t[`x-enumNames`]?.[r],type:c},state:n});i.push(l)}return r=C({items:i,schema:r}),r},Ph=({context:e,schema:t,state:n})=>{let r=Ah({schema:t});Sh({irSchema:r,schema:t});let i=[],a=vh({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=Yp(a.$ref,t.discriminator.mapping).map(e=>({const:e,type:`string`}));a={items:[{properties:{[t.discriminator.propertyName]:e.length>1?{items:e,logicalOperator:`or`}:e[0]},required:[t.discriminator.propertyName],type:`object`},a],logicalOperator:`and`}}a.logicalOperator===`or`&&a.type!==`array`&&a.items?i=i.concat(a.items):i.push(a)}if(a.includes(`null`)&&i.push({type:`null`}),r=C({items:i,mutateSchemaOneItem:!0,schema:r}),a.includes(`object`)){let i=Ih({context:e,schema:{...t,type:`object`},state:n});i.properties&&(r={items:[r,i],logicalOperator:`and`})}return r},Fh=({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=Ah({schema:t});Sh({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=C({items:a,mutateSchemaOneItem:!0,schema:r}),r},Ih=({context:e,irSchema:t,schema:n,state:r})=>{switch(t||(t=Ah({schema:n}),Sh({irSchema:t,schema:n})),n.type){case`array`:return Ch({context:e,irSchema:t,schema:n,state:r});case`boolean`:return wh({context:e,irSchema:t,schema:n});case`integer`:case`number`:return Eh({context:e,irSchema:t,schema:n});case`null`:return Th({context:e,irSchema:t,schema:n});case`object`:return Dh({context:e,irSchema:t,schema:n,state:r});case`string`:return Oh({context:e,irSchema:t,schema:n});default:return zh({context:e,irSchema:t,schema:n})}},Lh=({context:e,irSchema:t,schema:n,state:r})=>{t||=Ah({schema:n});let i={};Sh({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=Ih({context:e,irSchema:{...i},schema:{...n,type:t},state:r});a.push(o)}return t=C({items:a,schema:t}),t},Rh=({context:e,schema:t,state:n})=>{let r=Ah({schema:t});Sh({irSchema:r,schema:t});let i=vh({schema:t});return i.length===1?Ih({context:e,irSchema:r,schema:{...t,type:i[0]},state:n}):Lh({context:e,irSchema:r,schema:{...t,type:i},state:n})},zh=({irSchema:e,schema:t})=>(e||=Ah({schema:t}),e.type=`unknown`,Sh({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?Fh({context:e,schema:t,state:n}):t.enum?Nh({context:e,schema:t,state:n}):t.allOf?jh({context:e,schema:t,state:n}):t.anyOf?Mh({context:e,schema:t,state:n}):t.oneOf?Ph({context:e,schema:t,state:n}):t.type||t.properties?Rh({context:e,schema:t,state:n}):zh({context:e,schema:t})),Bh=({$ref:e,context:t,schema:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.schemas||(t.ir.components.schemas={}),t.ir.components.schemas[z(e)]=Q({context:t,schema:n,state:{$ref:e,circularReferenceTracker:new Set}})},Vh=e=>e.includes(`boolean`)||e.includes(`integer`)||e.includes(`number`)||e.includes(`string`),Hh=({context:e,name:t,schema:n})=>{if(Jp(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=_h({content:r.content}),t=e.find(e=>e.type===`json`)||e[0];t?.schema&&(n=t.schema)}return n?Hh({context:e,name:t,schema:n}):!1}return Hh({context:e,name:t,schema:r})}for(let t in n.properties)if(Jp(e.config.parser.pagination).test(t)){let e=n.properties[t];if(typeof e!=`boolean`){let n=vh({schema:e});if(!n.length){let n=(e.anyOf??e.oneOf??[]).filter(e=>e.type!==`null`);if(n.length===1&&Vh(vh({schema:n[0]})))return t}if(Vh(n))return t}}for(let r of n.allOf??[]){let n=Hh({context:e,name:t,schema:r});if(n)return n}return!1},Uh=({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)},Wh=({context:e,method:t,operation:n,path:r,state:i})=>{let a={id:jf({context:e,id:n.operationId,method:t,path:r,state:i}),method:t,path:r};return n.operationId&&(a.operationId=n.operationId),Uh({irOperation:a,operation:n}),kh({source:n,target:a}),a},Gh=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>{let o=Wh({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=_h({content:t.content}),i=r.find(e=>e.type===`json`)||r[0];if(i){let r=Hh({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){if(t.startsWith(`x-`))continue;o.responses||={};let r=n.responses[t],i=`$ref`in r?e.resolveRef(r.$ref):r,a=_h({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,...gh({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},Kh=({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})=>(n.servers&&(e.ir.servers=[...e.ir.servers??[],...n.servers]),{parsed:Gh({context:e,method:t,operation:n,path:r,securitySchemesMap:i,state:a})}),qh=({context:e,method:t,path:n,...r})=>{e.ir.paths||(e.ir.paths={}),e.ir.paths[n]||(e.ir.paths[n]={});let{parsed:i}=Kh({context:e,method:t,path:n,...r});e.ir.paths[n][t]=i},Jh=({context:e,key:t,method:n,...r})=>{e.ir.webhooks||(e.ir.webhooks={}),e.ir.webhooks[t]||(e.ir.webhooks[t]={});let{parsed:i}=Kh({context:e,method:n,path:t,...r});e.ir.webhooks[t][n]=i},Yh=e=>{switch(e){case`query`:return!1;default:return}},Xh=e=>{switch(e){case`deepObject`:case`form`:return!0;default:return!1}},Zh=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()]=Qh({$ref:`#/todo/real/path/to/parameter/${t.name}`,context:e,parameter:t})}return n},Qh=({$ref:e,context:t,parameter:n})=>{let r=n.schema;if(!r){let e=_h({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=Hh({context:t,name:n.name,schema:i}),o=n.style||Zh(n.in),s=n.explode===void 0?Xh(o):n.explode,c={allowReserved:n.allowReserved===void 0?Yh(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),kh({source:n,target:c}),c},$h=({$ref:e,context:t,parameter:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.parameters||(t.ir.components.parameters={}),t.ir.components.parameters[z(e)]=Qh({$ref:e,context:t,parameter:n})},eg=({$ref:e,context:t,requestBody:n})=>{let r=_h({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},tg=({$ref:e,context:t,requestBody:n})=>{t.ir.components||(t.ir.components={}),t.ir.components.requestBodies||(t.ir.components.requestBodies={}),t.ir.components.requestBodies[z(e)]=eg({$ref:e,context:t,requestBody:n})},ng=({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=no(t.path);e.ir.servers=[{url:`${n.protocol?`${n.protocol}://`:``}${n.host}${n.port?`:${n.port}`:``}`}]}e.ir.servers||(e.ir.servers=[{url:`/`}])},rg=(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 kf){let a=n[t];if(!a)continue;let o=w({method:t,path:e});a.operationId&&(i.has(a.operationId)?r.push({code:`duplicate_key`,context:{key:`operationId`,value:a.operationId},message:"Duplicate `operationId` found. Each `operationId` must be unique.",path:[`paths`,e,t,`operationId`],severity:`error`}):i.set(a.operationId,o))}}if(e.servers){(typeof e.servers!=`object`||!Array.isArray(e.servers))&&r.push({code:`invalid_type`,message:"`servers` must be an array.",path:[],severity:`error`});for(let t=0;t<e.servers.length;t++){let n=e.servers[t];!n||typeof n!=`object`?r.push({code:`invalid_type`,context:{actual:typeof n,expected:`object`},message:"Each entry in `servers` must be an object.",path:[`servers`,t],severity:`error`}):n.url||r.push({code:`missing_required_field`,context:{field:`url`},message:"Missing required field `url` in server object.",path:[`servers`,t],severity:`error`})}}return n.timeEnd(),{issues:r,valid:!r.some(e=>e.severity===`error`)}},ig=({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&&Jh({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&Jh({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&Jh({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&Jh({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&Jh({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&Jh({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&Jh({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&Jh({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}},ag=e=>{if(e.config.parser.validate_EXPERIMENTAL&&Ip({context:e,result:rg(e.spec,e.logger)}),Rf(e.config.parser.filters)){let t=Lf(e.config.parser.filters,e.spec,e.logger),{graph:n}=xp(e.spec,e.logger),{resourceMetadata:r}=Zf(n,e.logger);hh({...Xf({filters:t,logger:e.logger,resourceMetadata:r}),logger:e.logger,preserveOrder:t.preserveOrder,spec:e.spec})}jp({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];$h({$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];tg({$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];Bh({$ref:n,context:e,schema:r})}}for(let r in ng({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={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&&qh({...o,method:`delete`,operation:{...o.operation,...a.delete,parameters:Y({source:$({context:e,parameters:a.delete.parameters}),target:o.operation.parameters})}}),a.get&&qh({...o,method:`get`,operation:{...o.operation,...a.get,parameters:Y({source:$({context:e,parameters:a.get.parameters}),target:o.operation.parameters})}}),a.head&&qh({...o,method:`head`,operation:{...o.operation,...a.head,parameters:Y({source:$({context:e,parameters:a.head.parameters}),target:o.operation.parameters})}}),a.options&&qh({...o,method:`options`,operation:{...o.operation,...a.options,parameters:Y({source:$({context:e,parameters:a.options.parameters}),target:o.operation.parameters})}}),a.patch&&qh({...o,method:`patch`,operation:{...o.operation,...a.patch,parameters:Y({source:$({context:e,parameters:a.patch.parameters}),target:o.operation.parameters})}}),a.post&&qh({...o,method:`post`,operation:{...o.operation,...a.post,parameters:Y({source:$({context:e,parameters:a.post.parameters}),target:o.operation.parameters})}}),a.put&&qh({...o,method:`put`,operation:{...o.operation,...a.put,parameters:Y({source:$({context:e,parameters:a.put.parameters}),target:o.operation.parameters})}}),a.trace&&qh({...o,method:`trace`,operation:{...o.operation,...a.trace,parameters:Y({source:$({context:e,parameters:a.trace.parameters}),target:o.operation.parameters})}})}ig({context:e,securitySchemesMap:n})},og=({config:e,dependencies:t,logger:n,spec:r})=>{let i=new Of({config:e,dependencies:t,logger:n,spec:r});if(`swagger`in i.spec)return Em(i),i;if(So(i.spec.openapi,`>=3.0.0 <3.1.0`))return mh(i),i;if(So(i.spec.openapi,`>=3.1.0`))return ag(i),i;throw Error(`Unsupported OpenAPI specification`)};Object.defineProperty(exports,`A`,{enumerable:!0,get:function(){return me}}),Object.defineProperty(exports,`C`,{enumerable:!0,get:function(){return st}}),Object.defineProperty(exports,`D`,{enumerable:!0,get:function(){return ue}}),Object.defineProperty(exports,`E`,{enumerable:!0,get:function(){return le}}),Object.defineProperty(exports,`M`,{enumerable:!0,get:function(){return ge}}),Object.defineProperty(exports,`N`,{enumerable:!0,get:function(){return ae}}),Object.defineProperty(exports,`O`,{enumerable:!0,get:function(){return de}}),Object.defineProperty(exports,`P`,{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,`S`,{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,`T`,{enumerable:!0,get:function(){return Ie}}),Object.defineProperty(exports,`_`,{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,`a`,{enumerable:!0,get:function(){return Xd}}),Object.defineProperty(exports,`b`,{enumerable:!0,get:function(){return b}}),Object.defineProperty(exports,`c`,{enumerable:!0,get:function(){return Ka}}),Object.defineProperty(exports,`d`,{enumerable:!0,get:function(){return I}}),Object.defineProperty(exports,`f`,{enumerable:!0,get:function(){return Fi}}),Object.defineProperty(exports,`g`,{enumerable:!0,get:function(){return Bt}}),Object.defineProperty(exports,`h`,{enumerable:!0,get:function(){return Wt}}),Object.defineProperty(exports,`i`,{enumerable:!0,get:function(){return tf}}),Object.defineProperty(exports,`j`,{enumerable:!0,get:function(){return he}}),Object.defineProperty(exports,`k`,{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,`l`,{enumerable:!0,get:function(){return qa}}),Object.defineProperty(exports,`m`,{enumerable:!0,get:function(){return un}}),Object.defineProperty(exports,`n`,{enumerable:!0,get:function(){return xp}}),Object.defineProperty(exports,`o`,{enumerable:!0,get:function(){return oo}}),Object.defineProperty(exports,`p`,{enumerable:!0,get:function(){return ln}}),Object.defineProperty(exports,`r`,{enumerable:!0,get:function(){return mf}}),Object.defineProperty(exports,`s`,{enumerable:!0,get:function(){return eo}}),Object.defineProperty(exports,`t`,{enumerable:!0,get:function(){return og}}),Object.defineProperty(exports,`u`,{enumerable:!0,get:function(){return L}}),Object.defineProperty(exports,`v`,{enumerable:!0,get:function(){return T}}),Object.defineProperty(exports,`w`,{enumerable:!0,get:function(){return at}}),Object.defineProperty(exports,`x`,{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,`y`,{enumerable:!0,get:function(){return x}});
14
- //# sourceMappingURL=openApi-VRTfi3V4.cjs.map