UNPKG

@hey-api/openapi-ts

Version:

🌀 OpenAPI to TypeScript codegen. Production-ready SDKs, Zod schemas, TanStack Query hooks, and 20+ plugins. Used by Vercel, OpenCode, and PayPal.

3 lines (2 loc) 359 kB
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(` `))}};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.createEnumDec